Skip to content

Instantly share code, notes, and snippets.

@abortz
abortz / git-find-cut
Created January 31, 2016 23:32
Find the "branching off" point between two commits, irrespective of how many times they've been merged into each other.
#!/bin/bash -e
BRANCH_A="$1"
BRANCH_B="$2"
# Filter out early commits that are not common ancestors
# Also helpfully throws an error if there are *no* common ancestors.
FRONTIER=$(git rev-list --boundary "$BRANCH_A"..."$BRANCH_B" | grep ^- | cut -d- -f2)
# Only happens if branch A == branch B exactly
@abortz
abortz / git-find-remote-revision
Created December 30, 2015 22:41
Probe a remote git repo for a particular commit in the history of a branch. Yes this is horrible.
#!/bin/sh
set -e
REMOTE=$1
BRANCH=$2
NEWREV=$3
OLDREV=$4
# TODO: Might want to cache these instead?
@abortz
abortz / git-update-descendants
Last active January 2, 2016 02:57
Automatically propagate changes in local branches to local dependent branches. For parallel development workflows.
#!/bin/bash
set -e
# FIXME: Use bash lists rather than strings
LOCAL_BRANCHES="$(git for-each-ref --format='%(refname)' refs/heads/*)"
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
#git fetch -q
@abortz
abortz / vpn-disable-force
Last active November 5, 2017 20:54
Safely and easily force all traffic through a VPN on OS X
#!/bin/sh
sudo pfctl -a com.apple/000.ForceVPN -F all 2>/dev/null

Keybase proof

I hereby claim:

  • I am abortz on github.
  • I am abortz (https://keybase.io/abortz) on keybase.
  • I have a public key whose fingerprint is 100D 73C7 A980 3D5E 9FB4 1ADA 46D0 5A76 19B9 7971

To claim this, I am signing this object:

@abortz
abortz / ssh-copy-id
Last active December 30, 2015 04:56
A much simpler variant of the common Linux ssh-copy-id script. A single SSH public keyfile is hardcoded in.
#!/bin/sh
ssh "$@" "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go-rwx ~/.ssh && cat >> ~/.ssh/authorized_keys" < ~/.ssh/id_rsa.pub