Skip to content

Instantly share code, notes, and snippets.

View mheadd's full-sized avatar

Mark Headd mheadd

View GitHub Profile
@mheadd
mheadd / sql-search-example.md
Last active August 29, 2015 14:25
Example of how to use SQL Search API to rename columns

HTTP GET on this:

http://www.civicdata.com/api/action/datastore_search_sql?sql=SELECT "PermitNum", 
"Description", "AppliedDate", "IssuedDate", "CompletedDate", 
"OriginalAddress1", "OriginalCity", "OriginalState", "OriginalZip", "PermitClass",
"PermitClassMapped","StatusCurrent","StatusCurrentMapped","WorkClass","WorkClassMapped",
"PermitType","PermitTypeMapped","PermitTypeDesc", "StatusDate","TotalSqFt","Link",
"EstProjectCost","HousingUnits","PIN","ContractorCompanyName","ContractorTrade",
"ContractorTradeMapped","ContractorLicNum","ContractorStateLic","ContractorFullName",
@mheadd
mheadd / philly-open-data-policy.md
Last active January 26, 2016 23:56
Excerpt from the City of Philadelphia Open Records Policy & Open Data Policy

Open Data & Government Transparency

WHEREAS, the City of Philadelphia is committed to creating a high level of openness and transparency in government; and

WHEREAS, the three principles of transparency, participation, and collaboration form the cornerstone of an open government; and

WHEREAS, the City's participation as a founding and vital partner in the open data consortium has provided a model for transparency on which the City should continue to build; and

WHEREAS, more City data sets should be published and made available via an Open Data Portal which will provide access to information and a mechanism for public feedback and participation; and

@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