Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kjordahl
kjordahl / citibike.py
Created July 9, 2013 14:00
Get number of available bikes in Manhattan and Brooklyn with GeoPandas
from urllib2 import urlopen
from cStringIO import StringIO
import json
from pyproj import Proj
from shapely.geometry import Point
from geopandas import GeoSeries, GeoDataFrame
# http://www.nyc.gov/html/dcp/download/bytes/nybb_13a.zip
boros = GeoDataFrame.from_file('/nybb_13a/nybb.shp', vfs='zip://nybb_13a.zip')
url = 'http://citibikenyc.com/stations/json'
@kjordahl
kjordahl / gist:5306093
Created April 3, 2013 22:36
find the connection file for a running ipython process.
from IPython.kernel.zmq.kernelapp import IPKernelApp
app = IPKernelApp.instance()
print app.connection_file
@kjordahl
kjordahl / bootstrap.ipynb
Created October 24, 2012 18:20
Gaussian process bootstrap plots in iPython notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kjordahl
kjordahl / cat311.json
Created September 29, 2012 16:01
NYC 311 map using D3 and Leaflet
{"1024000": {"taxi": 18, "squeegee": 0, "noise": 112, "radioactive": 0, "street_condition": 7, "snow": 0, "sewer": 0, "graffiti": 0, "food_poisoning": 3, "streetlight": 0, "total": 210, "hpd": 0}, "3072000": {"taxi": 1, "squeegee": 0, "noise": 22, "radioactive": 0, "street_condition": 93, "snow": 17, "sewer": 12, "graffiti": 2, "food_poisoning": 4, "streetlight": 25, "total": 963, "hpd": 309}, "3080200": {"taxi": 9, "squeegee": 0, "noise": 120, "radioactive": 0, "street_condition": 82, "snow": 8, "sewer": 12, "graffiti": 21, "food_poisoning": 1, "streetlight": 83, "total": 3300, "hpd": 2392}, "4029100": {"taxi": 12, "squeegee": 0, "noise": 74, "radioactive": 0, "street_condition": 65, "snow": 36, "sewer": 14, "graffiti": 14, "food_poisoning": 18, "streetlight": 50, "total": 1993, "hpd": 655}, "4005900": {"taxi": 55, "squeegee": 0, "noise": 282, "radioactive": 0, "street_condition": 111, "snow": 14, "sewer": 10, "graffiti": 22, "food_poisoning": 2, "streetlight": 123, "total": 2752, "hpd": 688}, "3088400": {"t
@kjordahl
kjordahl / cat311.json
Created September 29, 2012 14:27
NYC 311 map using D3 and Leaflet
{"1024000": {"taxi": 18, "squeegee": 0, "noise": 112, "radioactive": 0, "street_condition": 7, "snow": 0, "sewer": 0, "graffiti": 0, "food_poisoning": 3, "streetlight": 0, "total": 210, "hpd": 0}, "3072000": {"taxi": 1, "squeegee": 0, "noise": 22, "radioactive": 0, "street_condition": 93, "snow": 17, "sewer": 12, "graffiti": 2, "food_poisoning": 4, "streetlight": 25, "total": 963, "hpd": 309}, "3080200": {"taxi": 9, "squeegee": 0, "noise": 120, "radioactive": 0, "street_condition": 82, "snow": 8, "sewer": 12, "graffiti": 21, "food_poisoning": 1, "streetlight": 83, "total": 3300, "hpd": 2392}, "4029100": {"taxi": 12, "squeegee": 0, "noise": 74, "radioactive": 0, "street_condition": 65, "snow": 36, "sewer": 14, "graffiti": 14, "food_poisoning": 18, "streetlight": 50, "total": 1993, "hpd": 655}, "4005900": {"taxi": 55, "squeegee": 0, "noise": 282, "radioactive": 0, "street_condition": 111, "snow": 14, "sewer": 10, "graffiti": 22, "food_poisoning": 2, "streetlight": 123, "total": 2752, "hpd": 688}, "3088400": {"t
@kjordahl
kjordahl / garradd.py
Created February 26, 2012 17:31
Calculate position of Comet Garradd
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
"""Calculate position for comet Garradd
Author: Kelsey Jordahl
Time-stamp: <Sun Feb 26 12:28:17 EST 2012>
License: GPLv3
"""
import ephem
@kjordahl
kjordahl / multi_detector.py
Created February 17, 2012 15:19
multiprocessing test
#!/usr/bin/env python
'''
based on gil_detector.py
http://codepad.org/CeI6gJLk
Swapped out multiprocessing for threading
Effective use of multiple processors is done by checking how fast multiprocess code
is executed in relation to single-threaded code.
'''
@kjordahl
kjordahl / pudb-add-breakpoint
Created January 25, 2012 19:31
Emacs lisp code to add pudb breakpoint to a python file (add to .emacs)
;; this location is "~/.pudb-bp" in older versions of pudb
(setq pudb-bp-file (expand-file-name "~/.config/pudb/saved-breakpoints"))
(defun pudb-add-breakpoint ()
(interactive)
(append-to-file
(concat "b " buffer-file-name ":"
(nth 1 (split-string (what-line))) "\n")
nil pudb-bp-file))
(define-key py-mode-map (kbd "C-c C-t") 'pudb-add-breakpoint)