Skip to content

Instantly share code, notes, and snippets.

View duncanhall's full-sized avatar
💭
Computers

Duncan Hall duncanhall

💭
Computers
View GitHub Profile
@duncanhall
duncanhall / diff-search.sh
Created September 28, 2018 09:53
Search for a string across git diff changes with file path and line numbers
git diff --name-only --diff-filter=MA | xargs grep 'SEARCH TERM' -rn
@duncanhall
duncanhall / tunnel.sh
Created January 4, 2018 16:31
Create tunnel for Node inspector to AWS instance behind ELB
ssh -i ~/.ssh/key.pem -L 60101:127.0.0.1:60101 ubuntu@<INSTANCE IP> -N
@duncanhall
duncanhall / safe_load_uri.sh
Created January 3, 2018 13:02
Bash / cURL: Load URL contents or fail with HTTP Status code
safe_load_uri() {
local URL="$1"
local RESPONSE="$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X GET $URL)"
local BODY="$(echo $RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')"
local STATUS="$(echo $RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')"
if [ $STATUS -ge 400 ]; then
echo "$STATUS"
exit 1
else
echo "$BODY"