Skip to content

Instantly share code, notes, and snippets.

@assafmo
assafmo / fstab
Last active December 13, 2018 19:07
Mount /tmp as tmpfs
# https://blog.ubuntu.com/2016/01/20/data-driven-analysis-tmp-on-tmpfs
# In /etc/fstab:
tmpfs /tmp tmpfs rw,size=128m,noexec,nosuid 0 0
@assafmo
assafmo / rescan_hd.sh
Created December 12, 2018 11:09
Rescan hard drives without rebooting
#!/bin/bash
echo "- - -" > sudo tee /sys/class/scsi_host/*/scan
@assafmo
assafmo / sysctl.conf
Created December 12, 2018 08:40
set BBR for TCP
# put in /etc/sysctl.conf
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
@assafmo
assafmo / Golang_Flame_Graphs.md
Last active April 18, 2020 11:50
Golang Flame Graphs
package main

import "runtime/pprof"

func main() {
	pprof.StartCPUProfile(os.Stderr)
	defer pprof.StopCPUProfile()

 // ...
@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}'
@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 / 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 / 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 / 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 / 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