Skip to content

Instantly share code, notes, and snippets.

View michaelsanford's full-sized avatar

Michael Sanford michaelsanford

View GitHub Profile
@michaelsanford
michaelsanford / clean-local-merged-branches.sh
Last active October 18, 2016 15:48
Interactively delete local branches which have been merged upstream. In my case, that's into `develop`.
#!/bin/bash
MERGED_INTO=${1:-"develop"}
statistics() {
echo
echo "Remaining local branches:"
git branch
echo
echo "These local branches are not merged into ${MERGED_INTO}:"
@michaelsanford
michaelsanford / notify-on-dns-propagated.sh
Created May 25, 2016 20:51
Email when a DNS change has propagated to a certain nameserver.
#!/usr/bin/env bash
# The IP to which you just updated your DNS
NEW_IP="127.0.0.1"
# The domain for which you're awaiting propagation
DOMAIN="EXAMPLE.COM"
# Polling interval in seconds
WAIT=30
import urllib2
import re
import sys
from collections import defaultdict
from random import random
"""
PLEASE DO NOT RUN THIS QUOTED CODE FOR THE SAKE OF daemonology's SERVER, IT IS
NOT MY SERVER AND I FEEL BAD FOR ABUSING IT. JUST GET THE RESULTS OF THE
CRAWL HERE: http://pastebin.com/raw.php?i=nqpsnTtW AND SAVE THEM TO "archive.txt"
@michaelsanford
michaelsanford / Apple_DOS_6Oct1978_retyped
Created November 13, 2013 20:27
’APPLE DOS’ circa 1978 in 8-bit assembler (C) COPYRIGHT 1978 APPLE COMPUTER, INC From: http://www.computerhistory.org/atchm/apple-ii-dos-source-code/
.TITLE SHEP,’APPLE DOS’
* 6.3 10-6-78
* 8 BIT ASSEMBLER
.M6502
*
**************************************************************************************
* (C) COPYRIGHT 1978 APPLE COMPUTER, INC
**************************************************************************************
ORG1 EQU $1B00
ORG2 EQU $3600
@michaelsanford
michaelsanford / nuke-mysql-conditional-comments
Last active August 29, 2015 14:18
Nuke mysql conditional comment markers in vim
Two vim editor commands to nuke mysql conditional comment markers in
MySQL dumps, but not the statement within them:
: %s/\/\*!\d\+\s//g
: %s/\*\///g
Or you can use sed:
sed -i 's/\/\*!\d\+\s//g' dump.sql
sed -i 's/\*\///g' dump.sql
@michaelsanford
michaelsanford / gcap.sh
Last active August 29, 2015 14:03
Android screenshot (Glass, Wear, mobile)
#!/usr/bin/env bash
##
# Screencaps, pulls, and deletes the png from a device.
#
# gcap [w | a | device identifier]
#
# For debugging over Bluetooth (i.e., Android Wear), see
# https://developer.android.com/training/wearables/apps/bt-debugging.html
#