Skip to content

Instantly share code, notes, and snippets.

Justin Palmer caged

Block or report user

Report or block caged

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@caged
caged / toteamscsv.coffee
Created Feb 9, 2014
Convert raw NBA JSON to CSV.
View toteamscsv.coffee
#!/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 Aug 29, 2015
Get above/below .500 point differential for NBA teams.
View point-diff.rb
#!/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 Feb 9, 2014
Generate graphs from NBA data
View point-diff.py
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}
View message.md

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?
View README.md

Data directory for my bl.ocks.

  • us.json - US states, counties and land boundaries
View index.html
<!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 Aug 29, 2015
Scoring buildings based on proximity to neighborhood features
View score-buildings.sql
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'
)
View latlon.js
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);
View osmosis-port.log
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)
You can’t perform that action at this time.