Skip to content

Instantly share code, notes, and snippets.

View BaksiLi's full-sized avatar
✍️
Wired-in ∨ Studying

Baksi BaksiLi

✍️
Wired-in ∨ Studying
View GitHub Profile
@BaksiLi
BaksiLi / decryptpdf.sh
Created June 27, 2020 14:24
Decrypt PDF by password stored in the Spotlight comment
#!/bin/bash
# Decrypt PDF by password stored in the Spotlight comment.
read -d '' Script << EOF
tell application "Finder"
set Comm to comment of (POSIX file "$1" as alias)
end tell
return Comm
EOF
@BaksiLi
BaksiLi / Revolut.list
Created February 11, 2022 10:52
Revolut domains used for DNS filtering (primarily on Surge)
# Revolut
DOMAIN-SUFFIX,revolut.com
DOMAIN-SUFFIX,revolutlabs.com
# assets.bwbx.io
# IP-CIDR,185.76.151.0/24,no-resolve
# IP-CIDR6,2001:b28:f23d::/48,no-resolve
@BaksiLi
BaksiLi / Barclays.list
Created February 16, 2022 08:59
Barclays domains used for DNS filtering (primarily on Surge)
# Barclays Mobile Banking
DOMAIN-SUFFIX,barclays.com
DOMAIN-SUFFIX,barclays.mobi
DOMAIN-SUFFIX,barclays.co.uk
DOMAIN-SUFFIX,barclays
DOMAIN-KEYWORD,barc.ly
DOMAIN-KEYWORD,bclays-ads
DOMAIN-KEYWORD,barclaysuk
# Other domains
@BaksiLi
BaksiLi / proxy.zsh
Last active May 21, 2022 11:06
zsh function for proxy and undo proxy
function check_install {
output="$($1 --version)"
output_size=${#output}
if [ $output_size -eq 0 ]; then
echo '0'
else
echo '1'
fi
}
@BaksiLi
BaksiLi / gist:c6a371bf770e8dd8a2c703ae5087d31e
Created February 17, 2023 02:53
Anki Python debug script to move "[sound:xxx]" between fields
note_type = 'Basic'
regex = r'\[sound:.*\]'
field_from = 'Back'
field_to = 'Pronunciation'
model = mw.col.models.by_name(note_type)
notes = mw.col.models.nids(model)
for nid in notes:
note = mw.col.get_note(nid)
@BaksiLi
BaksiLi / undock.sh
Last active August 10, 2023 06:45
Docker command to kill and remove a container with its image
alias undock='f() {
if sudo docker kill $1; then
echo "[+] Successfully killed: $1"
else
echo "[-] Failed to kill: $1"
fi
if sudo docker rm $1; then
echo "[+] Successfully removed: $1"
else
@BaksiLi
BaksiLi / git_user_switcher.zsh
Created July 7, 2023 05:39
zsh function for switching git users (for team, multiple accounts etc.)
function git_user_switcher() {
# Define an associative array to store the user settings
typeset -A -g git_users
# Add the users to the dictionary
# Format: username "name email gpg_key"
git_users=(
adam "adam [email protected]"
)
@BaksiLi
BaksiLi / install_zellij.sh
Created August 9, 2023 10:48
Install Zellij (latest release) on Linux (incl. Ubuntu) and Darwin
#!/bin/bash
# Get the architecture of the machine
arch=$(uname -m)
os=$(uname -s)
# Download the Zellij binary
if [ "$os" == "Darwin" ]; then
filename="zellij-${arch}-apple-darwin.tar.gz"
url="https://github.com/zellij-org/zellij/releases/latest/download/$filename"
@BaksiLi
BaksiLi / load_func.sh
Last active August 12, 2023 06:58
Add import (`load_func`) online scripts to zsh/bash
load_func() {
local CMD_NAME="$1"
local SCRIPT_URL="$2"
local SAFETY_CHECK="${3:-true}"
local script=$(curl -fsSL $SCRIPT_URL)
if [[ "$SAFETY_CHECK" == "true" && $script =~ "rm " ]]; then
echo "Failed to load command $CMD_NAME: Harmful command detected in script."
return 1
else
function ipinfo() {
ip_address=${1:-$(curl -s ipinfo.io/ip)}
while (( "$#" )); do
case $1 in
-h|--help)
echo "Command: ip-info IP_ADDRESS\n"
echo "Default: your ip address"
echo "Option -s or --simple"
echo "==>Print only Your address"