Skip to content

Instantly share code, notes, and snippets.

View caged's full-sized avatar
🎸

Justin Palmer caged

🎸
View GitHub Profile
@caged
caged / toteamscsv.coffee
Created February 9, 2014 08:47
Convert raw NBA JSON to CSV.
#!/usr/bin/env coffee
fs = require 'fs'
csv = require 'csv'
extend = (object, properties) ->
for key, val of properties
object[key] = val
object
@caged
caged / point-diff.rb
Last active August 29, 2015 13:56
Get above/below .500 point differential for NBA teams.
#!/usr/bin/env ruby
require 'pg'
require 'pp'
require 'terminal-table'
require 'csv'
conn = PGconn.open(:dbname => 'nba')
seasons = conn.exec 'select distinct(season) from teams'
@caged
caged / point-diff.py
Created February 9, 2014 08:58
Generate graphs from NBA data
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import glob
import os.path
font = {'family' : 'sans-serif',
'size' : 8}

Hi,

I'm looking through the City Council agenda items and noticed there is a great deal of information in each one. However, all of the documents are in the proprietary PDF format which makes them hard for machines (computers) to parse. If I were looking to extract some meaningful data (say expense, revenue, and affected city areas), I would need to comb through each one of these files manually.

It would be great if the city were to release these documents as HTML or XML documents. Even plain text is better than PDF for parsing!

With the above in mind, I have two questions:

  • Can the city provide additional open formats for agenda item documents going forward?

Data directory for my bl.ocks.

  • us.json - US states, counties and land boundaries
<!doctype html>
<meta charset="UTF-8">
<style type="text/css" media="screen">
.path {
stroke: #c00;
stroke-width: 1;
fill: none;
}
</style>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
@caged
caged / score-buildings.sql
Last active August 29, 2015 14:01
Scoring buildings based on proximity to neighborhood features
drop table if exists target_homes;
with
supermarket_zones as (select st_expand(geom, 0.0045) as zone, 5 as score from osm_polygons where osm_polygons.shop='supermarket'),
rail_stop_zones as (select st_expand(geom, 0.0045) as zone, 5 as score from trimet_rail_stops),
park_zones as (select st_expand(geom, 0.0045) as zone, 2 as score from osm_polygons where osm_polygons.leisure='park'),
target_buildings as (
select * from supermarket_zones inner join buildings on st_intersects(supermarket_zones.zone, buildings.geom) where buildings.subarea='City of Portland'
union select * from rail_stop_zones inner join buildings on st_intersects(rail_stop_zones.zone, buildings.geom) where buildings.subarea='City of Portland'
)
function long2tile(lon,zoom) {
return (Math.floor((lon+180)/360*Math.pow(2,zoom)));
}
function lat2tile(lat,zoom) {
return (Math.floor((1-Math.log(Math.tan(lat*Math.PI/180) + 1/Math.cos(lat*Math.PI/180))/Math.PI)/2 *Math.pow(2,zoom)));
}
function tile2long(x,z) {
return (x/Math.pow(2,z)*360-180);
osm-building-import┋ master⚡ ᴥ osmosis --read-xml osm/features.osm --truncate-pgsql database=osm_test port=15432 --wp database=osm_test port=15432
Oct 10, 2014 11:56:59 AM org.openstreetmap.osmosis.core.Osmosis run
INFO: Osmosis Version 0.42-6-gf39a160-dirty
Oct 10, 2014 11:56:59 AM org.openstreetmap.osmosis.core.Osmosis run
INFO: Preparing pipeline.
Oct 10, 2014 11:56:59 AM org.openstreetmap.osmosis.core.Osmosis main
SEVERE: Execution aborted.
org.openstreetmap.osmosis.core.OsmosisRuntimeException: Argument port for task 2-truncate-pgsql was not recognised.
at org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory.createTaskManager(TaskManagerFactory.java:64)
at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.buildTasks(Pipeline.java:50)