This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git remote prune origin | |
# or delete branches: | |
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HASH= | |
FILE= | |
vimdiff <(git show $HASH~:$FILE) <(git show $HASH:$FILE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
branch=$1 | |
commitfile=$2 | |
ticketno=$(echo $branch | sed -r 's/[^0-9]+([0-9]+)[^0-9].*/\1/') | |
if [ -z "$branch" ]; then | |
echo | |
echo "Usage: $(basename $0) branch [ commitfile ]" | |
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load_ssh_key() { | |
key=~/.ssh/id_ed25519 | |
force=0 | |
if [ -n "$1" ]; then | |
if [ -e "$1" ]; then | |
key=$(readlink -f $1) | |
elif [ "$1" == "reset-all" ]; then | |
echo "resetting" | |
pkill --signal 9 -f ssh-agent | |
force=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/a/1162345/971529 | |
load_display() { | |
if [ -z "$1" ]; then | |
PID=$(pgrep -n -u $USER 'gnome-session|xfdesktop|xterm|kodi|lxsession|mate-session') | |
else | |
PID=$(pgrep -n -u $USER -f "$1") | |
fi | |
FALLBACK=$(pgrep -n 'unity-greeter') | |
if [ -n "$PID" ]; then | |
export DISPLAY=$(cat /proc/$PID/environ | strings | awk 'BEGIN{FS="=";} $1=="DISPLAY" {print $2; exit}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo -n "Do you want to run '$*'? [N/y] " | |
read -N 1 REPLY | |
echo | |
if test "$REPLY" = "y" -o "$REPLY" = "Y"; then | |
"$@" | |
else | |
echo "Cancelled by user" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This was to create a quick snapshot of the database, make the changes I | |
# wanted, and then revert the database to exactly the way it was before I | |
# snapshotted it. | |
LV=pg_ot | |
VG=$(/sbin/vgdisplay -s | sed -e 's/ "\([^"]*\)" .*/\1/') | |
MTPT=/var/lib/postgresql/11/main | |
PROC=postgres | |
VERSION=11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo lvs --segments -o +pe_ranges |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first list devices that are connected: | |
ls /dev/sd* | |
# then list devices listed in /sys/block: | |
ls /sys/block/sd* # I expect they agree, but unsure atm | |
# find the 'hostid' of the existing devices | |
for i in $(ls /dev/); do if [[ "$i" =~ "sd" ]]; then (echo -n "$i => "; readlink /sys/block/$i | cut -d '/' -f 5; echo "") | grep "host"; fi; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dev1=$1 | |
remote=$(echo $2 | cut -d ':' -f 1) | |
dev2=$(echo $2 | cut -d ':' -f 2) | |
ssh -i ~/.ssh/id_rsa $remote " | |
perl -'MDigest::MD5 md5' -ne 'BEGIN{\$/=\1024};print md5(\$_)' $dev2 | lzop -c" | | |
lzop -dc | perl -'MDigest::MD5 md5' -ne 'BEGIN{$/=\1024};$b=md5($_); | |
read STDIN,$a,16;if ($a eq $b) {print "s"} else {print "c" . $_}' $dev1 | lzop -c | | |
ssh -i ~/.ssh/id_rsa $remote "lzop -dc | |