Skip to content

Instantly share code, notes, and snippets.

@assafmo
assafmo / aria2-inorder.conf
Last active December 21, 2017 20:11
aria2c conf files
# To download video/music files
# Put in ~/.aria2/aria2-inorder.conf
# Usage: aria2c --conf-path ~/.aria2/aria2-inorder.conf "$URL"
continue=true
split=8
max-connection-per-server=8
min-split-size=1M
stream-piece-selector=inorder
@assafmo
assafmo / mac.conf
Created December 4, 2017 18:11
Randomize MAC on each new network connection
# Put in /etc/NetworkManager/conf.d/mac.conf
[device]
wifi.scan-rand-mac-address=yes
[connection]
wifi.cloned-mac-address=random
ethernet.cloned-mac-address=random
@assafmo
assafmo / 0_scaling_governor_performance.sh
Last active May 15, 2019 10:22
Set scaling governor to performance, set noatime in root filesystem, install preload
#!/bin/sh
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
@assafmo
assafmo / ad7.js
Last active March 21, 2022 06:31
Donwload english subs from addic7ed
#!/usr/bin/env node
// Newest version is in https://github.com/assafmo/ad7
// Install: sudo npm install -g addic7ed-api
// Usage: node ad7.js "the flash" 4 8
// Usage 2: chmod +x ad7.js; ./ad7.js "the flash" 4 8
// Usage 3: chmod +x ad7.js; mv ad7.js /usr/local/bin/ad7; ad7 "the flash" 4 8
// Usage 4: seq 1 4 | xargs -n 1 ad7 "the flash" 4
@assafmo
assafmo / fix_firefox_double_icon.sh
Created December 18, 2017 20:05
Fix firefox nighlty double icon in gnome favorites
#!/bin/sh
grep StartupWMClass /usr/share/applications/firefox-trunk.desktop || sudo sed -i 's/\[Desktop Entry\]/[Desktop Entry]\nStartupWMClass=Nightly/' /usr/share/applications/firefox-trunk.desktop
@assafmo
assafmo / nba_com_gamerecaps_to_mp4.sh
Last active January 14, 2018 10:32
NBA.com gamerecaps page to highlights mp4
#!/bin/bash
nba_date=$( \
curl 'https://data.nba.net/10s/prod/v3/today.json' --compressed -s | \
jq .links.anchorDate \
)
num_of_games=$( \
curl 'https://data.nba.net/prod/v2/calendar.json' --compressed -s | \
jq ".[$nba_date]" \
@assafmo
assafmo / hi.sh
Last active March 9, 2018 19:03
Remove hearing impaired subtitles
#!/bin/bash
sed -ri 's/\[.+\]:?|\(.+\):?|[a-zA-Z ]+://g' *srt
@assafmo
assafmo / addic7ed.sh
Last active January 5, 2019 19:29
Download subtitles from addic7ed for an episode & delete hearing impaired help
#!/bin/bash
# sudo npm install -g ad7
file="$1"
(
cd $(dirname "${file}")
ad7 --show "$(basename "${file}" | grep -Pio '.+?S\d\dE\d\d' | sed -r 's/\.(s|S)[0-9]{2}(e|E)[0-9]{2}//')" \
--s "$(basename "${file}" | grep -Pio 'S\d\dE\d\d' | awk -F '(S|s)|(E|e)' '{print $2}')" \
@assafmo
assafmo / battery_low.sh
Created April 14, 2018 14:10
Notify on low battery
#!/bin/bash
# "low" = lower than 60 because my chinese battery dies at 51%
cat /sys/class/power_supply/BAT0/uevent |
awk -F = '/_FULL=/{full=$2} /_NOW=/{now=$2} END{if(now/full < 0.6){print "Bettery " 100*now/full "%"}}' |
xargs notify-send
@assafmo
assafmo / place_to_gps.sh
Created April 30, 2018 11:35
Place name -> GPS coordinates using Google Maps
#!/bin/bash
place="$1"
curl "https://www.google.com/maps/place/${place}" -L -s --compressed |
grep -Po 'cacheResponse.+?\]' |
tr '[],()' ' ' |
awk '{print $4","$3}'