Skip to content

Instantly share code, notes, and snippets.

View jmichalicek's full-sized avatar

Justin Michalicek jmichalicek

View GitHub Profile
@jmichalicek
jmichalicek / inlinetogglemixin.py
Created October 26, 2012 19:34
Togglable inline details for Tastypie resources
class InlineToggleMixIn(object):
"""
Allows details=<resource> querystring param to toggle whether to return resource uri or full details
"""
# based on handy dehydrate_related from
# http://chrismeyers.org/2012/06/25/tastypie-inline-aka-nested-fulltrue-embedded-relationship-dynamically-via-get-parameter/
# Be careful not to create an infinite loop from having multiple resources that reference each other using this
# and requesting details on both of them
def dehydrate_related(self, bundle, related_resource):
@jmichalicek
jmichalicek / phone_number_map.py
Created May 6, 2012 13:45
Selected Programming Pearls Excercises
from optparse import OptionParser
import re
# The book Programming Pearls has an excercise to code
# a simple algorithm for taking numbers pressed on a
# phone keypad and returning the names from a directory
# that the caller may have been looking for. The book
# is really aimed at C and C++, but I'm doing some of these
# in Python since that's what I mostly work in these days
# and am building my skills in.