Skip to content

Instantly share code, notes, and snippets.

View tmitchell's full-sized avatar

Taylor Mitchell tmitchell

  • BrainGu
  • Austin, TX
View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@tmitchell
tmitchell / binner.py
Created October 1, 2012 21:16
Django Binner
class Binner(object):
"""Bin a numeric value according to some set bins"""
def __init__(self, model, bins):
"""Set up the Binner
:Parameters:
- `model`: The BasicModel derived class that we'll be populating and pulling from
- `bins`: Iterable containing tuples for (min_val, max_val) for each bin, where None implies +/-Inf
"""
@tmitchell
tmitchell / gist:3784765
Created September 25, 2012 22:06 — forked from joho/gist:3735740
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. brew update
3. brew upgrade postgresql
4. initdb /usr/local/var/postgres/9.2 -E utf8 -U postgres
5. pg_upgrade -u postgres -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres/9.1 -D /usr/local/var/postgres/9.2
6. cp /usr/local/Cellar/postgresql/9.2.1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
7. pg_ctl -D /usr/local/var/postgres/9.2 -l /usr/local/var/postgres/server.log start
@tmitchell
tmitchell / load_related_m2m.py
Created November 18, 2010 08:34
Django 1.2 helper for approximating select_related on a M2M relation
-- Tweet.scpt
-- Applescript for Quicksilver to post to Twitter using Twitterrific credentials stored in the keychain
-- Copy to ~/Library/Application Support/Quicksilver/Actions and restart Quicksilver
-- Modified from http://blog.codahale.com/2007/01/15/tweet-twitter-quicksilver/
using terms from application "Quicksilver"
on process text tweet
tell application "Keychain Scripting"
set twitter_key to first key of current keychain whose name is "Twitterrific"
set twitter_login to quoted form of (account of twitter_key & ":" & password of twitter_key)