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 / dc-blds.sh
Created April 29, 2015 16:46
Shell script to convert DC building permit data to BLDS format
# Field names from BLDS spec
echo "IssuedDate,PermitNum,PermitType,PermitTypeDesc,StatusCurrent,OriginalAddress1,Description,ContractorCompanyName,StatusDate,OriginalCity,OriginalState,OriginalZip" > dc-permits-2014.csv
# Get permit data from ESRI endpoint and convert to CSV
curl -s "http://maps2.dcgis.dc.gov/dcgis/rest/services/FEEDS/CDW_Feeds/MapServer/5/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 .attributes \
| jq '[.ISSUE_DATE, .PERMIT_ID, .PERMIT_TYPE_NAME, .PERMIT_SUBTYPE_NAME, .APPLICATION_STATUS_NAME, .FULL_ADDRESS, .DESC_OF_WORK, .PERMIT_APPLICANT, .LASTMODIFIEDDATE, .CITY, .STATE, .LATITUDE, .LONGITUDE]' \
| jq @csv \
| sed 's
@mheadd
mheadd / petitions.md
Created March 17, 2015 18:09
Get the title of all current We The People Petitions
curl -s https://api.whitehouse.gov/v1/petitions.json | jq .results[] | jq .title
"Petition to arrest and have charges against the person in this video for racist hate; assault; & assault of a minor."
"Grant Clemency to my 80yr old father Antonio Bascaro. In jail 35+years for a non-violent, marijuana-only, 1st offense."
"Change the official name of ISIL to Daesh."
"47 seditious Senators. Take the next step!"
"Full pardon for Kent Hovind and Paul Hansen"
@mheadd
mheadd / violations.sql
Created February 3, 2015 16:05
SQL script to import traffic ticket data into MySQL database.
DROP DATABASE IF EXISTS violations;
CREATE DATABASE violations;
USE violations;
DROP TABLE IF EXISTS _2011;
CREATE table _2011 (
Violation_Charged_Code VARCHAR(30),
Violation_Description VARCHAR(80),
Violation_Month VARCHAR(5),
Violation_Time VARCHAR(12),
{
"addressLine1": {
"type": "string"
},
"addressLine2": {
"type": "string"
},
"city": {
"type": "string"
},
@mheadd
mheadd / openlims.md
Last active August 29, 2015 14:13
How many resolutions were disapproved by DC council in 2014?
curl -s "https://openlims.herokuapp.com/search?measure_type=2&status=120&start_date=1/1/2014&end_date=12/31/2014" 
{
    "data": [
        {
            "Phase": 3,
            "IntroductionDate": "2014/07/11 00:00:00",
(void)amRequest: (AMRequest *)request didLoad: (id)result
{
NSLog(@"result = %@",result);
[data removeAllObjects];
if (result && [result isKindOfClass:[NSDictionary class]])
{
NSArray *temp = [result objectForKey:@"records"];
@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();
@mheadd
mheadd / ETags.md
Last active August 29, 2015 14:06
@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 / 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">