Skip to content

Instantly share code, notes, and snippets.

View JamesSaxon's full-sized avatar

Jamie Saxon JamesSaxon

View GitHub Profile
@JamesSaxon
JamesSaxon / salaries.sh
Last active September 24, 2017 22:31
Top 10 Salaries
curl data.cityofchicago.org/api/views/xzkq-xp2w/rows.csv -s -o salaries.csv
cat salaries.csv | sed 's/\$//g' | sort -t , -k 8 -n -r | head -10 | column -s "," -t
@JamesSaxon
JamesSaxon / broken_conversion.py
Created September 28, 2016 04:19
A Broken Python Example
#!/usr/bin/env python
a = 26.2 # miles in a marathon
b = 5 # km in a 5k
km_per_mile = 1.61
print(a, "miles is", a * km_per_mile, "km.")
print(a, "km is", b * mile_per_km, "miles.")
#!/usr/bin/env python
import math
import turtle
joe = turtle.Turtle()
def polygon(joe, size, sides, color):
# Use a for loop with fd() and lt() or rt(),
@JamesSaxon
JamesSaxon / json_narcotics_example.py
Last active October 16, 2017 04:59
JSON Narcotics Examples for Oct 10
import json
with open("narcotics.json") as data: narcotics = json.load(data)
offenses = [x['description'] for x in narcotics['objects']]
for x in sorted((offenses.count(o), o) for o in set(offenses)): print(x)
@JamesSaxon
JamesSaxon / colombia_simple_map_geopandas.ipynb
Created January 24, 2017 16:33
Colombia simple map example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import requests
places = [570220, 491527, 570182]
req = "https://pleiades.stoa.org/places/{}/json"
with open("coords.csv", "w") as out:
for p in places:
j = requests.get(req.format(p)).json()
name = j["names"][0]["romanized"] if j["names"] else None
#!/bin/bash
createdb network -O jsaxon -D brobspace
sudo -u postgres psql network -c "CREATE EXTENSION postgis; CREATE EXTENSION pgrouting; CREATE EXTENSION postgis_topology;"
# Covering the LiveRamp area, all the way to Wisconsin.
wget 'http://overpass-api.de/api/interpreter?data=(way["highway"]["highway"!~"pedestrian|footway|steps|path"]["service"!~"parking_aisle|driveway"](41.57,-88.29,42.49,-87.30);>;);out;' -O chicago.osm
osm2pgrouting -U jsaxon -d network --f chicago.osm --password MYPASSWD
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
# mkdir -p tmp/dec/
cd tmp/dec/
# wget -r ftp://ftp2.census.gov/geo/tiger/PREVGENZ/tr/tr90shp/
# wget -r ftp://ftp2.census.gov/geo/tiger/PREVGENZ/tr/tr00shp/
# wget -r ftp://ftp2.census.gov/geo/tiger/GENZ2010/gz_2010_*_140_00_500k.zip
# mv ftp2.census.gov/geo/tiger/PREVGENZ/tr/tr90shp/*zip dec/
# mv ftp2.census.gov/geo/tiger/PREVGENZ/tr/tr00shp/*zip dec/
# mv ftp2.census.gov/geo/tiger/GENZ2010/*zip dec/
@JamesSaxon
JamesSaxon / alternate_segregation.ipynb
Last active August 28, 2018 23:33
Alternate views of segregation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.