Skip to content

Instantly share code, notes, and snippets.

View mheadd's full-sized avatar

Mark Headd (He/Him) 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 / bike-share-top-100.sh
Created April 22, 2014 19:20
Get the top 100 NYC bike share riders from July, 2013.
curl -s "http://www.civicdata.com/api/action/datastore_search_sql?sql=SELECT%20*%20from%20%229dd48bd2-fa77-43bb-a433-1227b3a17623%22%20ORDER%20BY%20tripduration%20DESC%20LIMIT%20100" \
| sed 's/birth year/birth_year/g;s/start station name/start_station_name/g;s/end station name/end_station_name/g' \
| jq .result.records[] \
| jq '[.tripduration, .birth_year, .gender, .start_station_name, .end_station_name]' \
| jq @csv \
| sed 's/\\//g;s/""/"/g'
@mheadd
mheadd / Samples.md
Last active August 29, 2015 14:01
Some URLs that can be used to query NYPD Vehicle Crash Data on CivicData.io

Accidents with the greatest number of persons injured in Manhattan (top 10 in descending order).

http://www.civicdata.io/api/action/datastore_search_sql?sql=SELECT%20*%20from%20%22036fcc27-5b0a-401c-aca5-3de5b90143dc%22%20ORDER%20BY%20%22PersonsInjured%22%20DESC%20LIMIT%2010

Total number of accidents in Queens where a cyclist was injured.

http://www.civicdata.io/api/action/datastore_search_sql?sql=SELECT%20COUNT(*)%20from%20%227d6dd1e8-0f86-48c9-80c4-fd0c88a58b3b%22%20WHERE%20%22CyclistsInjured%22%20%3E%200

Total number of pedestrians killed in accidents in Brooklyn.

@mheadd
mheadd / links.md
Last active August 29, 2015 14:01
Summer of Open Source: Intro to Git/GitHub Links
{
"page": {
"hasmore": true,
"limit": 25,
"offset": 0
},
"status": 200,
"result": [
{
"value": "14CAP-00000-00082",
@mheadd
mheadd / awesome-civic-reading.md
Last active August 29, 2015 14:05
Some great recent articles / blog posts on civic technology

The Three Levers of Civic Engagement

by Anthea Watson Strong

Over time, I have come to believe that our inability to attract mass usage for our products is, in part, due to a willful ignorance of how users are motivated to civic action. To build the technologies that will transform government and governance, we need to do a better job of designing and building tools for real world users.

Read more.

Let’s build the road network of civic tech.

by Eric Hysen

...let’s stop focusing on the next killer app, but instead on building healthy ecosystems.

@mheadd
mheadd / civic-id-example.html
Last active August 29, 2015 14:05
An example showing the Civic ID process using jQuery.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../assets/ico/favicon.ico">
@mheadd
mheadd / data.sh
Created August 29, 2014 18:48
jq recipe to fetch Healthy Corner Store Locations in Philadelphia
echo 'x_coord,y_coord,name' > my-file.csv
curl -s "http://gis.phila.gov/arcgis/rest/services/PhilaGov/Healthy_Corner_Stores/MapServer/0/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson" \
| jq .features[] \
| jq '[.geometry.x, .geometry.y, .attributes.OFFICIAL_S]' \
| jq @csv \
| sed 's/\\//g;s/""/"/g' \
>> my-file.csv
@mheadd
mheadd / ETags.md
Last active August 29, 2015 14:06
@mheadd
mheadd / rivercast.php
Created September 11, 2014 17:25
A phone application to get the current Rivercast status on the Schuylkill River
<?php
answer();
$rivercast = json_decode(file_get_contents("http://apify.heroku.com/api/rivercast.json"));
say("Hello.");
say("The current river cast on the Skew kill river is, " . $rivercast[0]->status . ".");
say("Happy recreating!");
say("Goodbye.");
hangup();