This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Explore the relationship between Key Miss Rate and time. | |
i.e. if you are doing a lot of dictionary lookups, how few misses | |
do you need to get in order to use try/except vs methods without exceptions | |
run via $ ipython dict_timing.ipy | |
""" | |
def a(d, i): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install bokeh # Fail | |
# gevent requires libevent, although you'd never know it from the error message | |
brew install libevent | |
# configure: error: C compiler cannot create executables ??? | |
# Update Command Line tools for XCode | |
# No love | |
# find this: http://stackoverflow.com/questions/13041525/osx-10-8-xcrun-no-such-file-or-directory | |
sudo mv /usr/bin/xcrun /usr/bin/xcrun.bak | |
sudo vim /usr/bin/xcrun # Replace contents with #!/bin/bash $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.wired.com/design/2013/08/how-segregated-is-your-city-this-eye-opening-map-shows-you/ | |
http://www.coopercenter.org/demographics/Racial-Dot-Map | |
https://github.com/unorthodox123/RacialDotMap | |
https://www.mapbox.com/blog/mapping-millions-of-dots/ | |
https://github.com/ericfischer/datamaps | |
https://www.mapbox.com/blog/visualizing-3-billion-tweets/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import dateutil.parser | |
import itertools | |
import json | |
import os | |
import pytz | |
import re | |
# For use with data generated from: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Wrapper(object): | |
"""Communicate with a program via stdin/stdout. | |
Wrap the communication in python so it "feels" like native code. | |
See use by Runner, below. | |
""" | |
def __init__(self, script): | |
self.scriptname = os.path.basename(script) | |
self.p = Popen([script], stdin=PIPE, stdout=PIPE, bufsize=1) | |
print("%s initialized" % self.scriptname) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:fa014ff7b33faeb7067a121aa857dd54b41b9c8f17d6299ea5b8df7f93e98601" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto | |
import gzip | |
import os | |
import shutil | |
import subprocess | |
from subprocess import Popen, PIPE | |
import sys | |
import tempfile | |
import json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Problem -- you have a bounded space defined by the cardinality of each dimension. | |
You want to: | |
a) Go from coordinates inside that space to an index of inside that space (map_point) | |
b) Reverse that (go from an index to a set of coordinates) (unmap_point) | |
""" | |
import operator | |
def get_multipliers(cardinalities): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int step(int curr, int steps, const int n) | |
{ | |
curr += steps; | |
if (curr < n) | |
return step(curr, 1, n) + step(curr, 2, n); | |
if (curr == n) | |
return 1; | |
return 0; | |
} |
OlderNewer