Skip to content

Instantly share code, notes, and snippets.

@mccutchen
mccutchen / crazy-test-case.py
Created September 24, 2010 21:01
Worst comment ever?
def test_recipe_ref_creation(self):
# There are 7 recipes in the fixtures plus 3 cookbooks containing 3, 2
# and 1 recipes, respectively, which adds up to 15 initial
# RecipeReferences (because two those cookbook recipes belong to
# another user'saccount, which leads to one RecipeReference under that
# cookbook and one under the AccountRef for that account, plus one
# more reference for a recipe duplicated in two cookbooks).
refs = cookbook_models.RecipeReference.all().fetch(1000)
self.failUnlessEqual(len(refs), 15)
"""
Code for solving the Greplin Challenge
http://challenge.greplin.com/
"""
from itertools import chain, combinations
# Level one
def palindrome(s):
"""Find the largest palindrome in the given string."""
;;; fic-mode.el --- Show FIXME/TODO/BUG/KLUDGE in special face only in
;;; comments and strings
;;--------------------------------------------------------------------
;;
;; Copyright (C) 2010, Trey Jackson <bigfaceworm(at)gmail(dot)com>
;; Original source: http://www.emacswiki.org/emacs/fic-mode.el
;;
;; Minor modifications by Will McCutchen <[email protected]>
;;
;; This file is NOT part of Emacs.
@with_appcfg
def prep_local_shell():
"""Prepares a local shell by adjusting the datastore paths according to
the settings and setting up the appropriate stubs."""
import settings
args = dev_appserver_main.DEFAULT_ARGS.copy()
# If a custom datastore directory is requested, modify the args for each
# of the datastore paths
if hasattr(settings, 'DATASTORE_DIR'):
ddir = settings.DATASTORE_DIR
@mccutchen
mccutchen / gist:722389
Created November 30, 2010 20:59
Plain text vs. HTML emails
Wilbur -
It's 2010 now. People are twatting left and right. We have telephones that
can plot traffic in real time. So HTML email, while not thematically true to
the to it's DARPANET precursor, is now the defacto standard. I don't plan to
be quitting it any more than I'm planning on cutting off my fingers with a
butcher knife.
W
@mccutchen
mccutchen / dropcap.py
Created December 23, 2010 00:11
Uses pictogrid to generate a giant Daily Drop Cap poster.
"""Generates a giant Daily Drop Cap poster. Get the images into the dropcap/
subdir with something like:
curl -O http://jhische.com/dailydropcap/[A-Z]-[1-12].jpg
Depends on pictogrid and PIL.
"""
import glob
import re
@mccutchen
mccutchen / gae.sh
Created March 30, 2011 14:51
the relevant part of my .profile
GAE=~/lib/google-app-engine
DJANGO=~/lib/django
WEBTEST=~/lib/WebTest
export PYTHONPATH=$GAE:$GAE/lib/antlr3:$GAE/lib/yaml/lib:$GAE/lib/webob:$GAE/lib/ipaddr:$GAE/lib/fancy_urllib:$DJANGO:$WEBTEST:~/workspace:$PYTHONPATH
@mccutchen
mccutchen / gist:904277
Created April 5, 2011 19:03
Best spam email ever?
From: "James Barker" <[email protected]>
To: <[email protected]>
Subject: Free heroin shipping!
Date: Tue, 5 Apr 2011 10:00:42 -0800
FREE HEROIN SHIPPING!
1. Heroin, in liquid and crystal form.
2. Rocket fuel and Tomohawk rockets (serious enquiries only).
4. New shipment of cocaine has arrived, buy 9 grams and get 10th for free.
@mccutchen
mccutchen / bitchy email of the week
Created April 14, 2011 14:12
Bitchy email of the week
Subject: Re: Message from Tax Data Systems Web Service Contact Page
From: Will McCutchen <[email protected]>
To: Tax Data Systems Support <[email protected]>
I'm sorry to bug you, but are there any other avenues of support for
your products? So far, the "send an email and wait" method of suport
leaves something to be desired, especially for a product on which we
will be spending thousands of dollars.
Thanks,
@mccutchen
mccutchen / fixkey.py
Created April 14, 2011 17:07
How to migrate App Engine datastore keys from one application to another
import os
from google.appengine.ext import db
def fixkey(key):
"""Takes a db.Key (or its string form) and checks to see if it is tied to
the current application. If not, the key is recreated for the current
application and returned as a string.
"""
app_id = os.environ.get('APPLICATION_ID')
if isinstance(key, basestring):