Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am michaelhood on github.
  • I am mh (https://keybase.io/mh) on keybase.
  • I have the public key with fingerprint A60F 1C10 7E4B 4306 CE35  51E2 B3DF 3143 19DC B2E0

To claim this, I am signing this object:

user www-data;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
sendfile on;
'''pass_socket.py
Written September 14, 2012
Released into the public domain.
Works on Python 2.6, 2.7, and may need minor changes for 3+.
'''
import multiprocessing
@michaelhood
michaelhood / ec2-ssh-instance.sh
Created September 22, 2012 04:05
EC2 SSH-by-Instance-ID
# ssh $(ec2ip i-a1b2c3d)
function ec2ip() { if [ "$#" -gt 0 ]; then ip=$(ec2din --show-empty-fields -H $1 | grep "^INST" | cut -f17); echo $ip; fi }
function ec2pip() { if [ "$#" -gt 0 ]; then ip=$(ec2din --show-empty-fields -H $1 | grep "^INST" | cut -f18); echo $ip; fi }
function ec2host() { if [ "$#" -gt 0 ]; then ip=$(ec2din --show-empty-fields -H $1 | grep "^INST" | cut -f4); echo $ip; fi }
# ec2ssh i-a1b2c3d
function ec2ssh() { if [ "$#" -gt 0 ]; then ip=$(ec2din --show-empty-fields -H $1 | grep "^INST" | cut -f4); echo $ip; ssh $ip; fi }
@michaelhood
michaelhood / gist:3892179
Created October 15, 2012 12:21
dtruss "drop" privileges
mh@mbp:~% sudo dtruss -f sudo -u\#$UID whoami 2>/dev/null
mh
mh@mbp:~% sudo dtruss -f -t fakesyscall sudo -u\#$UID touch /
PID/THRD SYSCALL(args) = return
28082/0xad253: fork() = 0 0
touch: setting times of ‘/’: Permission denied
mh@mbp:~% # note that i only used these methods to hide output
mh@mbp:~% # to keep the demo short. dtruss is functional.
@michaelhood
michaelhood / gist:4412203
Created December 30, 2012 11:01
git patches for a pull request
for c in $(curl -su michaelhood:$ppp https://api.github.com/repos/github/developer.github.com/pulls/183/commits | fgrep "git/commits" | sed "s/\/git\//\//g" | awk '{print $NF;}' | tr -d \",); do echo "\n### START: $c ###\n\n"; curl -u michaelhood:$ppp -H "Accept: application/vnd.github.beta.diff" $c; done
@michaelhood
michaelhood / onload-network-graph-fix.js
Last active December 10, 2015 15:08
fix github network graph for chrome retina
/*
MIT: https://raw.github.com/github/hubot/1455b62e5b6daffeacb7472db83ccf6502396bea/LICENSE.md
refs:
http://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html
http://www.html5rocks.com/en/tutorials/canvas/hidpi/
https://code.google.com/p/chromium/issues/detail?id=127852 (WONTFIX)
*/
(function(doc) {
@michaelhood
michaelhood / repro.md
Last active December 11, 2015 01:19
GFM has undocumented difference in hN parsing

GFM requires space between # and string to create an hN.

% curl -d '{"text": "#asdf", "mode": "gfm"}' https://api.github.com/markdown
<p>#asdf</p>

% curl -d '{"text": "# asdf", "mode": "gfm"}' https://api.github.com/markdown
<h1>asdf</h1>

markdown doesn't.

@michaelhood
michaelhood / mdbrowser.sh
Last active December 11, 2015 01:58
markdown to browser demo (via github api)
#!/usr/bin/env bash
echo "# sup markdown" > sup.md
cat sup.md | { _t=$(mktemp --suffix=\.html); curl -s -H "Content-type: text/plain" -d @/dev/stdin https://api.github.com/markdown/raw > $_t ; open $_t ; rm -f $_t; }
@michaelhood
michaelhood / clone-in-mac-git-not-https.js
Last active December 11, 2015 08:58
make 'clone in mac' links on github use git:// not https://
(function(doc) {
$("#repo_details div.url-box ul.native-clones li a span.mini-icon-apple").
parent().
attr('href', function(i,v) { return v.replace(/https:\/\//, "git://"); });
}(document));