Skip to content

Instantly share code, notes, and snippets.

View mheadd's full-sized avatar

Mark Headd mheadd

View GitHub Profile
@mheadd
mheadd / lobby-data.sql
Last active August 29, 2015 13:57
SQL script to import lobbying registration data into MySQL instance.
-- Create database.
DROP DATABASE IF EXISTS lobbydata;
CREATE DATABASE lobbydata;
-- Create table.
USE lobbydata;
DROP TABLE IF EXISTS registrations;
CREATE TABLE registrations (
`RegistrationNumber` VARCHAR(12) NOT NULL,
`RegistrationName` VARCHAR(100) NOT NULL,
@mheadd
mheadd / incident_anomolies.csv
Created October 22, 2013 15:27
Crime incident records with bad coordinates.
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 14 columns, instead of 1 in line 7.
01,2,2011-11-01 17:56:00,2011-11-01,17:56:00,17,201101049843,2500 BLOCK PT BREEZE AV,600,145111,Thefts,145111,-84.69369121,39.1207947
01,2,2011-11-28 06:41:00,2011-11-28,06:41:00,6,201101053637,2800 BLOCK S 17TH S,600,172069,Theft from Vehicle,172069,-84.69369121,39.1207947
01,2,2011-12-01 01:29:00,2011-12-01,01:29:00,1,201101053953,23RD & OREGON AVE,700,149748,Recovered Stolen Motor Vehicle,149748,-84.69369121,39.1207947
01,2,2011-12-12 15:56:00,2011-12-12,15:56:00,15,201101055831,1700 BLOCK MOYAMENSING AVMENSING AV,700,160874,Recovered Stolen Motor Vehicle,160874,-84.69369121,39.1207947
01,1,2011-12-27 17:23:00,2011-12-27,17:23:00,17,201101058138,S 16TH ST/MIFFLIN,300,164145,Robbery No Firearm,164145,-84.69369121,39.1207947
02,2,2011-11-21 08:10:00,2011-11-21,08:10:00,8,201102076587,4600 BLOCK ROOSEVELT BLVD ADAMS AV,600,137403,Theft from Vehicle,137403,-84.69369121,39.1207947
02,3,2011-11-30 17:11:00,2011-11-30,17:11:00,17,201102078486,7400 BLOCK BUSELTON,600,153038,Thefts,153038,-84.69369121,39.1207947
02
@mheadd
mheadd / curl-li.sh
Last active December 23, 2015 22:49
Unix command-line magic for fetching list of L&I licensed entities and saving to a simple CSV file.
curl -s "http://services.phila.gov/PhillyApi/Data/v1.0/licenses?%24filter=substringof(%273381%27,license_type_code)%20eq%20true&%24expand=locations&%24format=json" \
| jq .d.results[] \
| jq '[.pri_contact_last_name, .pri_contact_first_name, .pri_contact_company_name, .pri_contact_address1, .pri_contact_city, .pri_contact_state, .pri_contact_zip, .license_number, .license_type_name, .license_type_code]' \
| jq @csv \
| sed 's/\\//g;s/""/"/g' \
> filename.csv
@mheadd
mheadd / odp-api-test.md
Last active December 23, 2015 22:09
Playing around with the OpenDataPhilly API.
@mheadd
mheadd / phlgate.php
Last active December 23, 2015 16:29
<?php
define("AIRPORT_API_ENDPOINT", "http://54.235.132.110/number/");
define("TTS_VOICE", "Veronica");
function getFlightInfo($flightNum) {
return json_decode(file_get_contents(AIRPORT_API_ENDPOINT . $flightNum));
}
[
{
"name": "NAME",
"type": "esriFieldTypeString",
"alias": "NAME",
"description": "Name of farmers’ markets",
"length": 33
},
{
"name": "ADDRESS",
@mheadd
mheadd / annyang.min.js
Last active December 22, 2015 18:39
JS-based speech recognition
//! annyang
//! version : 0.2.0
//! author : Tal Ater @TalAter
//! license : MIT
//! https://www.TalAter.com/annyang/
(function(){"use strict";var a,b,c=this,d="en-US",e={start:[],error:[],end:[],result:[],resultMatch:[],resultNoMatch:[]},f=!1,g="font-weight: bold; color: #00f;";if(!("webkitSpeechRecognition"in c))return c.annyang=null,null;var h=/\s*\((.*?)\)\s*/g,i=/(\(\?:[^)]+\))\?/g,j=/(\(\?)?:\w+/g,k=/\*\w+/g,l=/[\-{}\[\]+?.,\\\^$|#]/g,m=function(a){return a=a.replace(l,"\\$&").replace(h,"(?:$1)?").replace(j,function(a,b){return b?a:"([^\\s]+)"}).replace(k,"(.*?)").replace(i,"\\s*$1?\\s*"),new RegExp("^"+a+"$","i")},n=function(a){for(var b=0,c=a.length;c>b;b++)a[b].apply(this)};c.annyang={init:function(h){b&&b.abort&&b.abort(),b=new webkitSpeechRecognition,b.maxAlternatives=5,b.continuous=!0,b.lang=d,b.onstart=function(){n(e.start)},b.onerror=function(){n(e.error)},b.onend=function(){n(e.end)},b.onresult=function(b){n(e.result);for(var d,h=b.results[b.resultIndex],i=0;i<h.length;i++){d=h[i].transcript.t

Install MySQL:

~$ sudo apt-get install mysql-server

Ensure MySQL is running:

~$ pgrep mysql

Create a temporary location for the GTFS files:

@mheadd
mheadd / data-officer-position.md
Last active September 1, 2020 23:41
A brief description for the job of Municipal Chief Data Officer

Municipal Chief Data Officer

Description:

The Municipal Chief Data Officer (CDO) is a 'C' level executive in the city's technology leadership with primary responsibility for implementing the city's open data / open government plans. Open data is an important cornerstone to broader government transparency efforts, and the CDO is responsible for developing and expanding open data activities across city departments and agencies, and coordinating with other municipal leaders on broader transparency efforts.

The CDO is the face of the city's open data effort, and will be an evangelist for open data and innovation both inside and outside municipal government.

Responsibilities:

@mheadd
mheadd / app.js
Created July 3, 2013 19:32
Simple Node.js app to search for permits using the City of Philadelphia L&I API
var phli = require('phli')();
phli.getPermits({start_date: '2012-10-31', end_date: '2012-11-01'}, function (err, data) {
for(var i=0; i<data.d.results.length; i++) {
console.log(data.d.results[i].permit_number + ': ' + data.d.results[i].permit_type_code + ', ' + data.d.results[i].permit_type_name);
}
});