Skip to content

Instantly share code, notes, and snippets.

View dardo82's full-sized avatar
🏠
Working from home

Michele Venturi dardo82

🏠
Working from home
View GitHub Profile
@dardo82
dardo82 / safari-favicons.sh
Last active February 16, 2024 02:40
Fix Safari FavIcons
#!/bin/zsh
# Fix Safari Favorites Icons
CS="cache_settings"; TIC="Touch Icons Cache"; DIR="$HOME/Library/Safari/$TIC/Images"
DB="$DIR/../${${TIC// }%%s*}${${(C)CS}//_}.db"; SQL=$(sqlite3 "$DB" "SELECT host FROM $CS")
sqlite3 "$DB" "UPDATE $CS SET ${${${(L)TIC// /_}#*_}//s/_is_in}=1, download_status_flags=1"
for png in "$1"/*.png; do URL="$(plutil -convert xml1 -o - "$DIR/../../Bookmarks.plist" | \
awk -F '[</>]' -v name="${${png##*/}%%.*}" '$3~name{getline;getline;getline;print $5}')"; \
cp -f -v "$png" "$DIR/${(U)$(md5 -q -s $URL)}.png"; done; chflags -v uappnd $DIR $DB*
@dardo82
dardo82 / .zshrc@SurfacePro7
Last active February 9, 2024 04:16
ZSH configs
#!/usr/bin/env zsh
# ZSH configuration
# Set shell options.
export CORRECT_IGNORE="_*"
setopt RC_EXPAND_PARAM
setopt CORRECT
@dardo82
dardo82 / mac-askpass.sh
Last active June 8, 2023 22:27
OSX sudo helper
#!/bin/sh
BIN="/usr/local/bin/askpass"; touch $BIN; chmod 755 $BIN
security add-generic-password -a $USER -s login -T "" -w
echo "#!/bin/sh\\nsecurity find-generic-password -a $USER -s login -w" > $BIN
echo "\\n# Set sudo helper.\\nexport SUDO_ASKPASS=$BIN" >> ~/.${SHELL##/*/}rc
@dardo82
dardo82 / mac-passwd2hashcat.sh
Created June 2, 2019 18:26
OSX user PW to HC format
#!/bin/sh
sudo dscl . read /Users/$USER ShadowHashData | tail -1 | xxd -p -r | plutil -convert xml1 - -o - | sed s/data/string/ | plutil -convert json - -o $USER.json
ITERATIONS=$(jq '."SALTED-SHA512-PBKDF2".iterations' $USER.json)
SALT=$(jq '."SALTED-SHA512-PBKDF2".salt' $USER.json | sed -E 's/"?\\n\\t\\t"?//g' | base64 -D | xxd -c 256 -p)
ENTROPY=$(jq '."SALTED-SHA512-PBKDF2".entropy' $USER.json | sed -E 's/"?\\n\\t\\t"?//g' | base64 -D | xxd -c 256 -p | cut -c -128)
echo "\$ml\$$ITERATIONS\$$SALT\$$ENTROPY" > $USER.hash
hashcat -m 7100 --example-hashes | awk '/HASH/{print $2}' > example.hash
hashcat -a 3 -m 7100 example.hash "?l?l?l?l?l?l?l"
@dardo82
dardo82 / mpv-yt-lw-st.sh
Last active November 28, 2022 12:33
Play last YouTube history video in MPV.
#!/bin/zsh
# Play the last video watched on YouTube in MPV with subtitles.
L="${2-${${LANG%.*}%_*}}"; SIZE="${3-48}"; EXT="${4-vtt}"; FMT="${5-135+140}" # Set variables.
ID=$(yt-dlp -v --get-id --playlist-items ${1-1} \
--cookies-from-browser chrome+gnomekeyring :ythistory) # Set the video's ID.
SUB=$(yt-dlp youtu.be/$ID --write-subs --sub-format vtt --sub-langs $L \
--print '%(requested_subtitles)j' | jq -M -r '.[]|.url') # Set the subtitles' URL.
@dardo82
dardo82 / RTV38-dl.sh
Last active October 16, 2022 14:59
Save $1 secs of RTV38 stream
#! /bin/zsh
# Saves '$1' secs of the RTV38 stream.
URL="webtools\
-845d8509d2cb4f249dd0b2ae5755b6c2\
.msvdn.net/embed/CXHH7K39hg9K/"
DATE="$(date +%F)"
NAME="RTV38_$DATE"
@dardo82
dardo82 / Kodi-Icon.sh
Last active October 11, 2022 07:43
FrontRow Kodi Icon
#!/bin/sh
BASE="FrontRow.png"; LOGO="Kodi.png"; PNG="${LOGO%.*}-$BASE"
ICNS=${PNG/.png/.icns}; SIZE=$(file "$BASE" | cut -d' ' -f5)
for n in {0..3}; do eval S$n="$[$SIZE/(2**$n)]"; done
DIM="${S2}x${S2}"; POS="+$[($S2+$S3)]+$[($S0/3)-$S3]"
convert $BASE \( $LOGO -geometry $DIM$POS \) \
-compose soft-light -composite $PNG
@dardo82
dardo82 / get-dirs-logos.sh
Created September 28, 2022 04:34
Copy logos from dirs
#!/bin/zsh
# Extract logos from folder icons
DL="Downloads"; G="Generic"
U="Utilities"; c="compare"
SB="Sidebar"; f="format"
I="Icon"; F="Folder"
mkdir -v Core
@dardo82
dardo82 / RBTC-dl.sh
Created September 16, 2022 02:01
Rogue Bunnies DownLoader
#!/bin/zsh
# Rogue Bunnies Trading Cards DownLoader
URL="https://tradingcards.roguebunnies.com"
API="https://api.gigantik.io\
/marketplace/tokens/[1738371-1775895]"
PT='function glpf4() {getline; print $4}; \
/"type/{glpf4(); glpf4()}'
@dardo82
dardo82 / auto-video-edit.sh
Last active September 16, 2022 01:53
Auto Video Edit
#!/bin/sh
SD="Foto/Persone/VIP/TeleVisione/RTV38/Carlotta_Comparini"
GDD="/Volumes/Misc Stuff/Google Drive/$USER/MultiMedia/Immagini"
ID=$(youtube-dl --get-id ytsearch:tadà_$(date -v-mon -v-0w +%d/%m))
VURL=$(curl -s "$(youtube-dl -g -f 135 youtu.be/$ID)" | gawk -v RS='<|>' '/"135"/{while($0!~/\/\//)getline; print}')
AURL=$(curl -s "$(youtube-dl -g -f 140 youtu.be/$ID)" | gawk -v RS='<|>' '/"140"/{while($0!~/\/\//)getline; print}')
cd $HOME/Pictures/$SD; youtube-dl --id --skip-download --write-auto-sub --sub-format=ttml --sub-lang=it youtu.be/$ID