Skip to content

Instantly share code, notes, and snippets.

View ryanpitts's full-sized avatar

Ryan Pitts ryanpitts

View GitHub Profile
@app.route("/1.0/data/geographies")
@qwarg_validate({
'geo_ids': {'valid': StringList(), 'required': True},
})
@crossdomain(origin='*')
def get_geo_polys():
geo_ids = []
for geoid_str in request.qwargs.geo_ids:
geoid_split = geoid_str.split('|')
if len(geoid_split) == 2 and len(geoid_split[0]) == 3:
@ryanpitts
ryanpitts / new.js
Created January 16, 2014 20:04
yay underscore
// hit the /parents API endpoint
$.getJSON(parentGeoAPI)
.done(function(results) {
var parents = results['parents'];
// list of unique parent sumlev types, maintaining order
var parentRelations = _.uniq(_.pluck(parents, 'sumlevel'));
// collect parents into individual sumlev groups
var parentGroups = _.groupBy(parents, function(d) {
return d.sumlevel;
});
"geography": {
"census_release": "ACS 2012 1-year",
"parents": {
"county": {
"total_population": 475735,
"short_name": "Spokane County",
"land_area": 4568197852,
"sumlevel": "050",
"full_name": "Spokane County, WA",
"full_geoid": "05000US53063"
RowID Distillery Body Sweetness Smoky Medicinal Tobacco Honey Spicy Winey Nutty Malty Fruity Floral Postcode Latitude Longitude
01 Aberfeldy 2 2 2 0 0 2 1 2 2 2 2 2 PH15 2EB 286580 749680
02 Aberlour 3 3 1 0 0 4 3 2 2 3 3 2 AB38 9PJ 326340 842570
03 AnCnoc 1 3 2 0 0 2 0 0 2 2 3 2 AB5 5LI 352960 839320
04 Ardbeg 4 1 4 4 0 0 2 0 1 2 1 0 PA42 7EB 141560 646220
05 Ardmore 2 2 2 0 0 1 1 1 2 3 1 1 AB54 4NH 355350 829140
06 ArranIsleOf 2 3 1 1 0 1 1 1 0 1 1 2 KA27 8HJ 194050 649950
07 Auchentoshan 0 2 0 0 0 1 1 0 2 2 3 3 G81 4SJ 247670 672610
08 Auchroisk 2 3 1 0 0 2 1 2 2 2 2 1 AB55 3XS 340754 848623
09 Aultmore 2 2 1 0 0 1 0 0 2 2 2 2 AB55 3QY 340754 848623
@ryanpitts
ryanpitts / gist:7937646
Created December 12, 2013 23:44
Mike Bostock tip on moving elements in front of siblings. https://groups.google.com/forum/#!msg/d3-js/eUEJWSSWDRY/EMmufH2KP8MJ
d3.selection.prototype.moveToFront = function() {
return this.each(function() {
this.parentNode.appendChild(this);
});
};
Then you can say:
d3.select("p").moveToFront().style("color", "red");
@ryanpitts
ryanpitts / .bash_prompt
Last active October 13, 2021 12:24
This is a SUPER handy bash_prompt update. Source this at the end of your .bash_profile, and your command line while in git repo directories adds some awesome information. Example: http://cl.ly/image/1A0c1D3R2H1R Adapted from https://github.com/necolas/dotfiles/blob/master/shell/bash_prompt
#!/bin/bash
# bash_prompt
# Example:
# nicolas@host: ~/.dotfiles on master[+!?$]
# $
# Screenshot: http://i.imgur.com/DSJ1G.png
# iTerm2 prefs: import Solarized theme (disable bright colors for bold text)
#!/usr/bin/env bash
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
###############################################################################
# General UI/UX #
@ryanpitts
ryanpitts / gist:7685318
Created November 28, 2013 00:19
an experiment in Markov'd restaurant reviews from @SpoCool
"Diner will lure the thin stuff.. mean, but it's not, the door after work of average. really only lacked a bit far as Rockwood cement its glory you certainly won't find ten faceless places, but not sure was close to be back, the only assume some flavor to give the place a better. found No Li's take the dish on the spot, but it was more so much better the most disgusting cup of the Back to expect what it would I mean, the overpowering sweetness was sweet.. chicken wrap, it did give it just caught them well known for half of the al pastor didn't., though not to yet another Elk, maybe we would suggest it a surprise was homemade or Veraci or Veraci or Veraci or not to do we can be left with the baked goods felt fresh tuna tasted like it was, I mean, if you're looking for many things are still were nicely seasoned. everyone to be OK. stuff. way of Canada since Northern Lights changed? An improvement is under new to say"
{
"geography": {
"total_population": 209504,
"census_release": "ACS 2011 5-year",
"short_name": "Spokane",
"land_area": 178021482,
"sumlevel": "160",
"full_name": "Spokane, WA"
},
"demographics": {