Skip to content

Instantly share code, notes, and snippets.

Michael Blume MichaelBlume

Block or report user

Report or block MichaelBlume

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@MichaelBlume
MichaelBlume / abkiller.user.js
Created Apr 9, 2011
kills the action bar on okcupid profiles
View abkiller.user.js
// ==UserScript==
// @name ABKiller
// @namespace http://www.github.com/MichaelBlume/
// @description Kill the action bar on OKCupid profiles
// @include http://www.okcupid.com/profile/*
// @include http://okcupid.com/profile/*
// ==/UserScript==
var action_bar = document.getElementById('action_bar');
action_bar.parentNode.removeChild(action_bar);
@MichaelBlume
MichaelBlume / Orphan a Commit
Created Apr 10, 2011
Script for orphaning a single commit. Useful in conjunction with .git/info/grafts
View Orphan a Commit
git filter-branch -f --parent-filter '
if [ "$GIT_COMMIT" = "SHA_GOES_HERE" ];
then
echo ''
else
read parents;
echo $parents;
fi' -- --all
@MichaelBlume
MichaelBlume / comitter rename
Created Apr 10, 2011
rename a comitter (works with AUTHOR in place of COMITTER, of course)
View comitter rename
git filter-branch -f --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "name" ];
then
GIT_COMMITTER_NAME="New Name";
GIT_COMMITTER_EMAIL="new@email.com.com";
git commit-tree "$@";
else
git commit-tree "$@";
fi' -- --all
@MichaelBlume
MichaelBlume / Lose SVN IDs
Created Apr 10, 2011
Strip off the SVN IDs appended by the git-svn-clone command
View Lose SVN IDs
git filter-branch --msg-filter 'sed -e "/^git-svn-id:/d" ' -- --all
@MichaelBlume
MichaelBlume / git-aliases.bash
Created Apr 11, 2011
Some git-svn workflow stuff from my .bash_aliases, before our office switched to git and I switched to .gitconfig
View git-aliases.bash
alias g="git"
alias com="g commit"
alias add="g add"
alias dif="g diff"
alias res="g reset"
alias co="g checkout"
alias branch="g branch"
alias merge="g merge"
alias st="g status"
@MichaelBlume
MichaelBlume / gitconfig
Created Apr 12, 2011
my git config file
View gitconfig
[advice]
# I know this stuff by now
pushNonFastForward = false
statusHints = false
[alias]
a = add
ai = add --interactive
ap = add --patch
b = branch
bl = blame
@MichaelBlume
MichaelBlume / deepdict.py
Created May 6, 2011
deepdict: quickly create highly nested dictionary structures without lots of initialization steps.
View deepdict.py
'''deepdict: quickly create highly nested dictionary structures without lots
of initialization steps.'''
from collections import defaultdict
class deepdict(defaultdict):
def __init__(self, *a, **kw):
defaultdict.__init__(self, deepdict, *a, **kw)
def __add__(self, num):
return num
@MichaelBlume
MichaelBlume / localdict.py
Created May 6, 2011
Localdict -- reduce your typing by half when constructing a dictionary literal from objects in the local context.
View localdict.py
'''Localdict -- reduce your typing by half when constructing a dictionary
literal from objects in the local context.
params = {'foo': foo, 'bar': bar, 'baz': baz}
can be replaced ith
params = localdict('foo', 'bar', 'baz')
'''
@MichaelBlume
MichaelBlume / compose_defaults
Created May 23, 2012
The dumps param in simplejson.dumps is often helpful, but sometimes you want to quickly pass in multiple default actions. This should help.
View compose_defaults
def compose_defaults(*defaults):
'''I got annoyed that simplejson.dumps doesn't let you pass multiple
defaults. So here's this.'''
def new_default(obj):
for default in defaults:
try:
return default(obj)
except:
pass
raise TypeError("no default functions succeeded")
View qualia.py
qualia = ("red", "blue", "cold", "pleasure")
memory_associations = { "red": ("anger", "hot")
, "blue": ("cold", "calm")
, "pleasure": ("hot", "good")
, "cold": ("blue", "calm")
}
def experience_qualia(in_qual):
for q in qualia:
if in_qual == q:
You can’t perform that action at this time.