Skip to content

Instantly share code, notes, and snippets.

@afharo
afharo / git-delete-merged-branches.sh
Last active August 21, 2020 14:48
Delete all merged branches
git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d
# When having more than 1 remote
(git remote | xargs -I % git fetch % -p) && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D
@afharo
afharo / _etc_cron.d_ensure-wifi
Created February 25, 2019 22:48
Keep WiFi up in Raspberry PI
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
* * * * * root /home/pi/ensure-wifi.sh
@afharo
afharo / connections_per_port.sh
Created November 4, 2015 11:16
Get Number of open connections in total && per port
watch "(netstat | wc -l) && (netstat -ant | awk '{split(\$4,res,\":\");print(res[2])}' | sort | uniq -c | sort -nr)"
@afharo
afharo / git-single-brach.sh
Created September 11, 2015 01:13
How to clone 1 single branch in git
git clone <url> --branch <branch> --single-branch [<folder>]
@afharo
afharo / udev-info.sh
Last active August 29, 2015 14:24
Device properties info from udev
#!/bin/bash
# Device properties info from udev
udevadm info -a -p $(udevadm info -q path -n /dev/sdb)