Skip to content

Instantly share code, notes, and snippets.

@alissone
alissone / colored-note-blocks.css
Created February 4, 2023 22:15
Obsidian multicolored note blocks (pastel-like colors)
.app-container pre[class*="language-"] {
border: 1px solid;
}
*[class*="language-note"]::first-line {
font-weight: bold;
}
.app-container pre[class*="language-"] code[class*="language-"] {
color: black;
@alissone
alissone / discord_clipboard_webhook.py
Created May 14, 2021 15:08
Send clipboard content to a Discord server via webhook
import requests
import pandas as pd
# To install the dependencies, run "pip install pandas requests" on a terminal
# Tested and working with Python 3.6 on Windows 10, Mac OS Catalina and Manjaro 20.2
content = "\n".join(pd.read_clipboard().columns)
url = "YOR WEBHOOK URL HERE" # Webhook url, from server settings here: https://i.imgur.com/f9XnAew.png
@alissone
alissone / discord_voice.py
Last active March 15, 2021 02:06
Basic boilerplate to join and exit a channel using discord.py (rewrite version)
import discord
from discord.ext import commands
from discord.ext.commands import CommandNotFound
from discord_config import CMD_PREFIX, DESCRIPTION, TOKEN
# You need to have a discord_config.py
# TOKEN = "" # The token you got when you created a new bot
# CMD_PREFIX = "$" # The command prefix (e.g. so you can call $command_name)
# DESCRIPTION = "" # The description (optional)
@alissone
alissone / code_to_carbon.py
Last active March 7, 2021 01:34
Code string to carbon.now.sh url
import json
import urllib.parse
from collections import OrderedDict
"""
This function will programatically generate a URL for carbon.now.sh to create
pretty code images, you can customize any of the props in code here, instead of
having to load the site, then load a json file, then paste the code.
"""
@alissone
alissone / whatsapp_send_message.py
Created March 4, 2021 20:36
Send message via whatsapp web via selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
# Paths may change over time. Last time tested, 2020-03-04
def login():
options = webdriver.ChromeOptions()
@alissone
alissone / copy_path.sh
Created March 3, 2021 12:23
Copy full path to clipboard Thunar custom action
# Requires xclip installed. Simply copy the following line to "Command" field and check any filetype in "Appearance Conditions"
echo -n %f | xclip -selection clipboard
@alissone
alissone / convert_video_to_whatsapp.sh
Created March 3, 2021 12:20
Convert video to WhatsApp Thunar custom action
# Requires ffmpeg installed. Place this into "Command" field, choose an icon and filetype and voilà!
bash -c 'ffmpeg -i "$0" -c:v libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p "${0%%.*}_whatsapp".mp4' %f
@alissone
alissone / ocr_from_clipboard.sh
Last active March 3, 2021 11:54
OCR text from clipboard image
#!/bin/bash
# OCR image copied to clipboard into terminal
# Requires tesseract, xclip and imagemagick installed
clipboard_img_path="/tmp/out.png"
output_img_path="/tmp/gray_out.png"
temp_txt_path="/tmp/ocr"
xclip -se c -t image/png -o > $clipboard_img_path
convert -colorspace gray -fill white -resize 300% -sharpen 0x1 $clipboard_img_path $output_img_path
@alissone
alissone / sum_timestamps_from_file.py
Created January 9, 2021 01:53
Sum timestamps list from text file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This script will read a list of timestamps and return the sum of them.
Example file:
```
01:00
@alissone
alissone / gist:a1541733663b06847e001ad054a032fa
Created September 14, 2020 14:56
Thunar custom action to convert video to WhatsApp compatible format
bash -c 'ffmpeg -i "$0" -c:v libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p "${0%%.*}".mp4' %f