Skip to content

Instantly share code, notes, and snippets.

@mccutchen
mccutchen / scrubber.py
Created April 14, 2011 21:33
Map-reduce task to clean up App Engine datastore entities whose models have changed
from mapreduce import operation as op
def scrubber(entity):
"""Deletes any data from the underlying datastore that are no longer
present in the entity's model definition.
"""
# What properties are still defined on the model?
valid_props = set(entity.properties().keys())
# What properties are attached in the datastore?
raw_props = set(entity._entity.keys())
@mccutchen
mccutchen / vulgarfractions.py
Created April 15, 2011 13:57
Code we use to replace "dumb" vulgar fractions with their Unicode counterparts
# Map ASCII fractions to fancy fractions
FRACTION_MAP = {
u'1/2' : u'\u00BD',
u'1/4' : u'\u00BC',
u'3/4' : u'\u00BE',
u'1/3' : u'\u2153',
u'2/3' : u'\u2154',
u'1/5' : u'\u2155',
u'2/5' : u'\u2156',
u'3/5' : u'\u2157',
@mccutchen
mccutchen / gist:967489
Created May 11, 2011 22:04
Generate a simple list of differences between two directories
diff -qr dirA/ dirB/
name = 'Will'
print 'Hello, %s' % name
name = raw_input('Name? ')
print 'Hello, %s' % name
From 5761a54ec9553c704c0782d5c581c2178f8e32b1 Mon Sep 17 00:00:00 2001
From: Will McCutchen <[email protected]>
Date: Mon, 4 Apr 2011 15:13:09 -0500
Subject: [PATCH] Stop caring about coverage omissions when running tests with code coverage. Let anyone creating coverage reports worry about them.
---
shared/fabric/utils.py | 30 +++---------------------------
1 files changed, 3 insertions(+), 27 deletions(-)
diff --git a/shared/fabric/utils.py b/shared/fabric/utils.py
@mccutchen
mccutchen / gist:1040802
Created June 22, 2011 18:48
Simple App Engine mapreduce counter example
from google.appengine.ext.mapreduce import operation as op
def count_impressions_by_month(entity):
key = entity.timestamp.strftime('%Y-%m')
yield op.counters.Increment(key)
@mccutchen
mccutchen / gist:1120177
Created August 2, 2011 13:26
jQuery JSONP request for KI API
$.ajax({
url: url,
dataType: 'jsonp',
jsonp: 'jsonp',
success: onSuccess,
error: onError
});
@mccutchen
mccutchen / example_row.json
Created January 6, 2012 22:51
Compression test
[{"privacy": "0", "created": "1325864138", "modified": "1325887899", "global_hash": "bGuRVV", "user_hash": "8rcCNv", "login": "5aQOloVyMze"}, {"privacy": "1", "created": "1325889382", "modified": "1325881184", "global_hash": "7eGqml", "user_hash": "VsrNOH", "login": "87YwHtJVoWthckEYLdum9akgmN4QzB"}, {"privacy": "1", "created": "1325918261", "modified": "1325983013", "global_hash": "a5rlvC", "user_hash": "OTHiE6", "login": "qvIKx3iw"}, {"privacy": "0", "created": "1325946981", "modified": "1325919728", "global_hash": "aZufjE", "user_hash": "7EwMRB", "login": "rpgOLjYkmzFyl2MIiTQAbAv"}, {"privacy": "0", "created": "1325892447", "modified": "1325893896", "global_hash": "rN4QdJ", "user_hash": "wlVmhv", "login": "HEN2KhU"}, {"privacy": "0", "created": "1325822276", "modified": "1325924205", "global_hash": "S2Vcmb", "user_hash": "F5nnD9", "login": "UBoEMP4giVjzo7SJmGG0ptyD"}, {"privacy": "1", "created": "1325890208", "modified": "1325986230", "global_hash": "GvdjO8", "user_hash": "j5qyky", "login": "MgYFhjgp63uo4C
@mccutchen
mccutchen / HOST-remote_app
Created January 17, 2012 20:06
Hacky remote TextMate setup for bitly VMs
#!/bin/sh
app=$1
shift;
open -a $app $@