Skip to content

Instantly share code, notes, and snippets.

@timwis
timwis / index.js
Last active May 28, 2016 22:16
requirebin sketch
const choo = require('choo')
const app = choo()
app.model({
state: {
name: 'Foo'
},
reducers: {
receive: (action, state, send) => {
@timwis
timwis / index.js
Created May 28, 2016 19:49
requirebin sketch
const yo = require('yo-yo')
const onload = require('on-load')
const a = yo`<div>a</div>`
const b = yo`<div>b</div>`
onload(a, () => console.log('a loaded'))
onload(b, () => console.log('b loaded'))
document.body.appendChild(a)
@timwis
timwis / vehicle-pedestrian-investigations.json
Created April 21, 2016 22:50
VizWit - Vehicle & Pedestrian Investigations
{
"version": "2",
"header": {
"title": "Vehicle & Pedestrian Investigations",
"description": "Business licenses issued by the Department of Business Affairs and Consumer Protection in the City of Chicago from 2002 to the present. January 1, 2006 to present. Data is updated daily.",
"navigation": [
{
"label": "Download",
"url": "https://data.cityofchicago.org/api/views/r5kz-chrr/rows.csv?accessType=DOWNLOAD&bom=true"
}
load data
infile '/Users/tim/Sites/property-assessments-pipeline/output/merged_properties.csv'
into table GIS_OPA.PROPERTIES
fields terminated by ',' optionally enclosed by '"'
(location,owner_1,owner_2,census_tract,zip_code,geographic_ward,house_number,suffix,unit,house_extension,recording_date,sale_date,sale_price,unfinished,assessment_date,market_value_date,market_value,taxable_land,taxable_building,exempt_land,exempt_building,category_code,zoning,site_type,frontage,depth,parcel_shape,total_area,topography,garage_type,garage_spaces,off_street_open,view,other_building,number_stories,general_construction,type_dwelling,date_exterior_condition,exterior_condition,quality_grade,year_built,year_built_estimate,number_of_rooms,number_of_bedrooms,number_of_bathrooms,basements,fireplaces,type_heater,fuel,central_air,interior_condition,utility,sewer,separate_utilities,total_livable_area,book_and_page,registry_number,cross_reference,category_code_description,building_code,building_code_description,state_code,st
1. PARCEL
<type 'unicode'>
Nulls: False
Unique values: 579912
Max length: 9
2. LOC
<type 'unicode'>
Nulls: False
Unique values: 547180
5 most frequent values:
import sys
import csv
from collections import defaultdict
reader = csv.reader(iter(sys.stdin.readline, ''), delimiter=';')
# Skip header row
reader.next()
grouped_dict = defaultdict(lambda: ['', '', '', 0.0, 0.0, 0.0, 0.0, 0.0])
- Art Museum
- Atwater Kent Museum
- Auditing:
- Auditing (City Controller)
- Aviation
- Board of Ethics
- Board of Pensions # See #5
- Board of Revision of Taxes
- City Commissioners
- City Council
valid_depts = []
with open(DEPT_FILE_PATH, 'rb') as file:
depts = list(load(file))
for dept in depts:
if isinstance(dept, dict):
for key, matches in dept.iteritems(): # only one of these
valid_depts = valid_depts + [{match: key} for match in matches]
else:
var filteredDatasets = _.filter(datasets, function (dataset) {
return (!params.organization || (dataset.organization && slugify(dataset.organization) === params.organization)) &&
(!params.category || (dataset.category && slugify(dataset.category).indexOf(params.category) !== -1))
})
@timwis
timwis / where.rb
Created February 25, 2016 15:08
Jekyll where filter for strings and arrays
def where(input, property, value)
return input unless input.is_a?(Enumerable)
input = input.values if input.is_a?(Hash)
input.select do |object|
input_property = item_property(object, property)
input_property.to_s == value.to_s || Array(input_property).include?(value.to_s)
end
end