Skip to content

Instantly share code, notes, and snippets.

View gabrielgrant's full-sized avatar

Gabriel Grant gabrielgrant

View GitHub Profile
@gabrielgrant
gabrielgrant / README.md
Last active October 22, 2015 10:35
US Census Two-Digit State Codes
@gabrielgrant
gabrielgrant / munge.py
Last active August 29, 2015 14:19 — forked from anonymous/munge.py
IMDB Ratings Data Munging
""" Loads IMDB's Ratings data into Pandas
Assumes you've already downloaded the raw data by running:
wget -O - ftp://ftp.funet.fi/pub/mirrors/ftp.imdb.com/pub/ratings.list.gz | gunzip > ratings.list
See: http://www.imdb.com/interfaces
"""
import pandas as pd
@gabrielgrant
gabrielgrant / north_america_area_code_locations.txt
Created November 9, 2013 02:50
Locations of North American area codes (from http://www.allareacodes.com/)
201 - Jersey City, NJ
202 - Washington, DC
203 - New Haven, CT
204 - Minto, MB
205 - Birmingham, AL
206 - Seattle, WA
207 - Portland, ME
208 - Boise, ID
209 - Modesto, CA
210 - San Antonio, TX
@gabrielgrant
gabrielgrant / choice-output.json
Created September 4, 2013 01:28
Arrrg, shouldn't django-rest-framework `viewsets.ModelViewSet` use `serializers.ModelSerializer` by default? It seems to be using `HyperlinkedModelSerializer` instead. Do I really need to create and specify a custom serializer just to get an ID output rather than a hyperlink?
{
"url": "http://localhost:8000/api/v1/choices/1/",
"poll": "http://localhost:8000/api/v1/polls/1/",
"choice_text": "Pretty confusing",
"votes": 0
}
@gabrielgrant
gabrielgrant / ember-data-0.14.js
Created September 3, 2013 23:04
Couldn't find built versions of ember-data-0.14, so they are
// Version: v0.14
// Last commit: d9cd270 (2013-08-31 17:12:14 -0700)
(function() {
var define, requireModule;
(function() {
var registry = {}, seen = {};
hidden_bin_string = '01011001001100110101011001110111011000100011' \
'001000110100011001110101100100110010001110010110101101011010' \
'010101000110111101100111010100110101010100110001010101000101' \
'010000110000011110000100011001010010010101100101000101100111' \
'01001111011110010110101100111101'
from itertools import groupby
from base64 import b64decode
bit_counts = [0]
@gabrielgrant
gabrielgrant / ember-precompile.js
Created September 15, 2012 04:11 — forked from zilkey/ember-precompile.js
Precompile .handlebars templates with node js
var fs = require('fs');
var path = require('path');
var vm = require('vm');
var argv = require('optimist').argv;
function compileHandlebarsTemplate(file, onComplete) {
//dummy jQuery
var jQuery = function () { return jQuery }
jQuery.ready = function () { return jQuery }
jQuery.inArray = function () { return jQuery }
@gabrielgrant
gabrielgrant / postinstall
Created July 29, 2012 19:38
Postinstall script to put dotCloud DB settings into Rails' database.yml
#! /usr/bin/env ruby
require 'yaml'
environment = YAML.load_file('../environment.yml')
database = YAML.load_file('config/database.yml')
prod_db = database['production']
prod_db['username'] = environment['DOTCLOUD_DB_SQL_LOGIN']
prod_db['password'] = environment['DOTCLOUD_DB_SQL_PASSWORD']
prod_db['host'] = environment['DOTCLOUD_DB_SQL_HOST']
prod_db['port'] = Integer(environment['DOTCLOUD_DB_SQL_PORT'])
@gabrielgrant
gabrielgrant / gist:2986503
Created June 25, 2012 04:21
Install dependencies to preview Ember.js docs (Ubuntu 11.04)
sudo apt-get install ruby1.9.1 ruby1.9.1-dev
gem1.9.1 install --user rake
gem1.9.1 install --user bundler
# nokogiri requirements
# see http://nokogiri.org/tutorials/installing_nokogiri.html
sudo apt-get install libxslt-dev libxml2-dev
~/.gem/ruby/1.9.1/bin/bundle install --path ~/.gem/ruby/1.9.1
@gabrielgrant
gabrielgrant / testapp.py
Created February 9, 2012 01:43
Simple wsgi streaming response
pip install gunicorn
gunicorn testapp:app