Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Michele Venturi dardo82

🏠
Working from home
View GitHub Profile
@dardo82
dardo82 / RTV38-dl.sh
Last active Aug 18, 2020
Auto Video Edit
View RTV38-dl.sh
#! /bin/sh
# Save $1 secs of RTV38 stream
EPOCH=$(date +%s); [ -d Movies ] && cd Movies/; mkdir -v RTV38/; cd RTV38/; pwd;
PLURL="{https://open.http.mp.streamamg.com/p/3001301/sp/300130100/playManifest/entryId/0_seco7tg8/format/applehttp/protocol/https/uiConfId/30026353/a.m3u8}";
VURLS=$(curl $PLURL | awk -F '[/t_]' -v n=$(($1/10)) '/^[^#]/ {sub($12, "["$12"-"$12+n"]", $0); print; exit}'); CARGS="--disable --limit-rate 128k -O $VURLS"
curl $CARGS; cat segment*_1_av-p.ts* > ../rtv38-$EPOCH.ts; cd ../; rm -frv RTV38
View com.zerowidth.launched.icdc.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.zerowidth.launched.icdc</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
@dardo82
dardo82 / sort-macport-size.sh
Last active Nov 16, 2019
Sort PIP pkgs by size
View sort-macport-size.sh
#!/bin/sh
for port in $(port info --line --name installed); do
port contents $port | grep / | xargs du -cks \
| grep "\ttotal" | sed s/total/$port/; done | sort -n
@dardo82
dardo82 / opencv-samples.sh
Last active Jun 22, 2019
Install OCV samples
View opencv-samples.sh
#!/bin/zsh
PMS="macports"; PKG="opencv"; DIR="samples/cpp"; BIN="$1"
sudo port install $PKG; sudo port fetch $PKG; sudo port extract $PKG
MPP=$(man -w $PMS.conf); prefix=$(zegrep -m1 '^/' $MPP)
cd ${$(eval grep 'cache$' ${$(zegrep -m1 $PMS'\\&.conf$' $MPP)/\\&/} | cut -f2)%/*}/*$PKG*/*$PKG*/*/*$PKG*/$DIR
sudo g++ $(pkg-config --cflags --libs $PKG) $BIN.cpp -o $BIN
@dardo82
dardo82 / mac-askpass.sh
Last active Nov 27, 2021
OSX sudo helper
View mac-askpass.sh
#!/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 Jun 2, 2019
OSX user PW to HC format
View mac-passwd2hashcat.sh
#!/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 / yt2videoindexer.sh
Last active May 26, 2019
YT to VideoIndexer
View yt2videoindexer.sh
#!/bin/sh
API="https://api.videoindexer.ai/auth/trial/Accounts/be4863e0-b5be-416d-9de2-91dbdd0afd11"
TOKEN=$(curl -s -H "Ocp-Apim-Subscription-Key:5ebebe8abada42c4a04065544942edf5" "$API/AccessToken?allowEdit=true" | tr -d \")
NAME=$(youtube-dl --get-title $1 | tr \ _); URL=$(curl -s "https://tinyurl.com/api-create.php?url=$(youtube-dl -g -f mp4 $1)")
curl -s -X POST -H "Content-Length:0" "${API//\/auth/}/Videos?language=auto&name=$NAME&videoUrl=$URL&accessToken=$TOKEN"
@dardo82
dardo82 / rename-hash.sh
Last active May 27, 2019
Hash-Based ReName
View rename-hash.sh
#!/bin/sh
# Rename files appending hash.
find $1 -type f -name "?*.?*" -exec md5 -r {} \; \
| sed -E "s^(.*)/^\1"\\$'\x7F'"^" \
| sort -t\\$'\x7F' -k2,2 \
| sed -E "s^"\\$'\x7F'"^/^" \
| awk -F'[/.]' '{if(NAME==$(NF-1)&&HASH!=$1)\
{PREV=LINE; sub($NF,substr(PREV,1,32)"."$NF,LINE)\
;print "mv -v \""substr(PREV,34)"\" \""substr(LINE,34)"\""\
;NEXT=$0; sub($NF,substr($0,1,32)"."$NF,NEXT)\
@dardo82
dardo82 / youtube-subs-dl.sh
Created Mar 22, 2019
DL YouTube SubTitles
View youtube-subs-dl.sh
#!/bin/sh
URL="$1";LANG=it;ID="${URL##*=}.$LANG";VTT="$ID.vtt";SRT="$ID.srt";TXT="$ID.txt"
youtube-dl --verbose --skip-download --write-auto-sub --sub-lang $LANG --id $URL
ffmpeg -y -i $VTT $SRT; egrep -v "^[^a-z]*$|\\r" $SRT > $TXT; rm -f -v $VTT $SRT
@dardo82
dardo82 / GDrive-Trash -Mount.sh
Last active May 27, 2019
Google Drive Trash Mount
View GDrive-Trash -Mount.sh
#!/bin/zsh
GDOF="google-drive-ocamlfuse";GDMP="$HOME/${(C)${GDOF%-*}/-/ }";mkdir -v "$GDMP"
opam install -qvy $GDOF;$GDOF -browser open;$GDOF "$GDMP";open -R "$GDMP/.Trash"