Skip to content

Instantly share code, notes, and snippets.

@mccutchen
mccutchen / config.xml
Last active August 29, 2015 14:02
Cordova config.xml for iOS
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.foo" version="0.0.28" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>Foo</name>
<description>bla bla bla</description>
<author email="support@phonegap.com" href="http://phonegap.com">Foo</author>
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="DisallowOverscroll" value="true" />
<preference name="EnableViewportScale" value="false" />

Keybase proof

I hereby claim:

  • I am mccutchen on github.
  • I am mccutchen (https://keybase.io/mccutchen) on keybase.
  • I have a public key whose fingerprint is C280 17A1 5056 9A15 5E8D 1016 B0C1 944A 52EF E3B6

To claim this, I am signing this object:

  1. Decide you want to make n delicious burgers

  2. Go to a butcher, buy n/2 lbs of ribeye steak, ask them to grind it for you

  3. Make that beautiful ground ribeye into 1/2 lb patties

  4. Sprinkle sea salt and ground black pepper on both sides of the patties

  5. Heat cast iron skillet to 400 degrees in an oven (leave the oven at 400)

@mccutchen
mccutchen / README.md
Last active August 29, 2015 14:05
Java is the worst.

Java is the Worst

All I want to do is sort an array of ints by some arbitrary function, criteria(). This is the the only way I've figured out how to do it in Java.

There's a Python implementation of the same thing, for comparison's sake.

*** glibc detected *** python2.7: free(): invalid pointer: 0x000000000e41a8a0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7e626)[0x7f5ab00f1626]
python2.7[0x559b31]
python2.7[0x426577]
/usr/local/lib/python2.7/dist-packages/sqlalchemy/cresultproxy.so(+0x1813)[0x7f5aadefd813]
python2.7[0x5020b8]
python2.7[0x425e5c]
python2.7[0x425d02]
python2.7[0x5754ad]
@mccutchen
mccutchen / gen_batches.py
Last active August 29, 2015 14:07
flexible batching of sequences in Python
def gen_batches(xs, size):
"""
Given a sequence xs and a batch size, yield batches from the sequence as
lists of length size, where the last batch might be smaller than the
rest.
>>> list(gen_batches(range(9), 3))
[[0, 1, 2], [3, 4, 5], [6, 7, 8]]
>>> list(gen_batches(range(11), 3))
>>> import urllib
>>> url = 'http://www.newyorker.com/magazine/2014/10/13/cooka%C2%80%C2%99s-tale'
>>> urllib.unquote(url)
'http://www.newyorker.com/magazine/2014/10/13/cooka\xc2\x80\xc2\x99s-tale'
>>> print _
http://www.newyorker.com/magazine/2014/10/13/cooka€™s-tale
>>> urllib.unquote(url).decode('utf8')
u'http://www.newyorker.com/magazine/2014/10/13/cooka\x80\x99s-tale'
>>> print _
http://www.newyorker.com/magazine/2014/10/13/cooka€™s-tale
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: `basename $0` BRANCHNAME"
exit 1
fi
git fetch origin
git checkout -b "$1" origin/master --no-track
def weighted_choice(choices):
# http://stackoverflow.com/a/3679747/151221
total = sum(w for c, w in choices)
r = random.uniform(0, total)
for c, w in choices:
r -= w
if r <= 0:
return c
@mccutchen
mccutchen / .gitconfig
Created June 4, 2015 15:58
Basic ~/.gitconfig
[user]
name = YOUR NAME HERE
email = YOUR EMAIL ADDRESS HERE
[alias]
br = branch
ci = commit
co = checkout
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%an, %cr)%Creset' --abbrev-commit --date=relative --topo-order
st = status -sb
up = fetch --all --prune