Skip to content

Instantly share code, notes, and snippets.

View cpdean's full-sized avatar

Conrad cpdean

View GitHub Profile
@cpdean
cpdean / map_reduce_subquery_breaks.js
Last active August 29, 2015 13:56
q.js demo for having an arbitrary number of sub-promises generated from an initial promise
// @cpdean
// demonstrates how to have one promise kick off
// an additional arbitrary number of promises, and
// then merge their results down again after
// all the promises are complete.
var Q = require('q'); // "q": "~1.0.0"
// initial query that generates seed data for more work to be done
function fakeQuery(){
import contextlib
def a_bad():
print "doing work"
raise IOError
def retry(n, f, e):
times = 0
@cpdean
cpdean / README.md
Last active August 29, 2015 14:05 — forked from mbostock/.block

This is a fork of mike bostock's vector tiles example.

I've just re-centered it around Minneapolis to see how it looks.

Looking for an easy way to do map visualizations, geo data is too fickle to learn without leveraging tons of examples

Adapting d3.geo.tile to show OpenStreetMap vector tiles. See also the static example.

@cpdean
cpdean / README.md
Last active August 29, 2015 14:05
plot bike stations

still work in progress...

Trying to get points from a CSV plotted on a map.

TODO:

  1. map flickers when you move it
  2. click-drag to pan moves slower than the mouse location
  3. I don't have any geo features to provide context (OSM streets?)
@cpdean
cpdean / README.md
Last active August 29, 2015 14:05
trying to show station inbalances

given the end-of-year data about which stations are feeding which, there're significant imbalances that require a manual rebalance by a given bikeshare program.

click and drag to pan, scroll to zoom.

trying to find the best way to visualize the imbalances for a single station before I extrapolate to every inter-station relationship.

@cpdean
cpdean / README.md
Last active August 29, 2015 14:06
understanding zoom behavior bindings

Zoom and pan by scrolling and clicking and dragging.

view on bl.ocks.org

The difference between these two maps is how the zoom behavior is bound to them. I had been using the one on the right and unhappy with how the ability to pan was compromised the further you zoomed in. Also it had seemed jittery. After closely studying the examples from Mike Bostock I finally figured out that you have to bind the zoom behavior to the parent SVG element but have all the juicy map details as a child element, and have the zoom function manipulate that child directly. The way I had set it up originally, the zoom function was manipulating the child, but the zoom behavior was also bound directly to the child. At least that's how I understand that I did it.

What's the difference between these two ways to use the zoom behavior? Why does the one on the right act so buggy?

@cpdean
cpdean / test.py
Last active August 29, 2015 14:10
default vim python indentation example
# if you just start typing
def really_long_func_def(
a,
b,
c):
really_long_func_def(
a, # "continuation line over-indented for hanging indent"
b,
c
@cpdean
cpdean / examples.sh
Created December 3, 2014 22:08
parallel demo
#!/bin/bash
# pull out census data per city file and put it into its own file
for i in $(ls raw_city_data/);
do
echo "parsing $i"
grep -i "census:population" raw_city_data/$i > census_populations/$i
done
# do the exact same thing, but takes a third the time (and makes your computer very very warm)
@cpdean
cpdean / gist:f842ec19b485e76e7228
Created January 24, 2015 21:46
look at that ipython magic
In [8]: !ls
README.tmpenv bin include lib share
In [9]: [i.upper() for i in _]
Out[9]: ['README.TMPENV', 'BIN', 'INCLUDE', 'LIB', 'SHARE']