Skip to content

Instantly share code, notes, and snippets.


Andrew McGill arm5077

View GitHub Profile
arm5077 / potholes.r
Created Mar 10, 2014
Potholes in Pittsburgh
View potholes.r
potholes <- read.csv(file="potholes.csv", head=TRUE, sep=",", stringsAsFactors=T)
potholes$COMPOSEDATE <- as.POSIXlt(strptime(potholes$COMPOSEDATE, "%m/%d/%Y %H:%M"))
potholes$RESOLVEDDATE <- as.POSIXlt(strptime(potholes$RESOLVEDDATE, "%m/%d/%Y %H:%M"))
potholes$COMPLETED_DATE <- as.POSIXlt(strptime(potholes$COMPLETED_DATE, "%m/%d/%Y %H:%M"))
potholes$DAYS_UNTIL_COMPLETED <- difftime(potholes$COMPLETED_DATE,potholes$COMPOSEDATE, units="days")
# Make subset of dataset that excludes potholes that weren't filled
completedPotholes <- potholes[$DAYS_UNTIL_COMPLETED) != TRUE,]
import twitter
import json
import urllib2
from datetime import datetime
import re
from config import *
# Parser for tranforming Peduto schedule-speak into the lyric timbre of BillPedutoBot!
def writeTweet( event ):
keywords = {
arm5077 / doctors.sql
Created Apr 23, 2014
Medicare doctor charge database query
View doctors.sql
SELECT medicare.*,
peerAverage.average AS charge_average,
( medicare.average_submitted_chrg_amt - peerAverage.average ) /
peerAverage.average * 100 AS difference_from_average,
FROM medicare
JOIN (SELECT Avg(average_submitted_chrg_amt) AS average,
FROM medicare
arm5077 /
Last active Aug 29, 2015
Pennsylvania counties treemap by population

It's election season again, and I considered using a treemap to show vote totals for Pennsylvania's gubernatorial primary, which will pit four Democrats against each other. Using an abstract visualization like a treemap, which sizes each county by vote totals, cancels out the visual advantage enjoyed by large-but-unpeopled counties of Central Pennsylvania.

I decided to go with something else, but I thought this demo (sized by population, organized by region, colored by Obama/Romney vote in 2012) was still neat.

arm5077 / index.php
Created May 13, 2014
2014 Pa. Democratic gubernatorial primary scraper
View index.php
function getURL($url)
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $url);
arm5077 / index.html
Last active Aug 29, 2015
National Journal swatch tool
View index.html
<!doctype html>
<script src=""></script>
<script src="swatches.json"></script>
<script type="text/javascript">
angular.module("swatchApp", [])
.controller('swatchController', ['$scope', function($scope){
$scope.colors = swatches;
$scope.height = window.innerHeight / swatches.length;
arm5077 / index.html
Created Feb 23, 2015
Converts a copy-and-pasted table of emails into readable text.
View index.html
<!doctype html>
<html ng-app="formatApp">
<script src=""></script>
<style type="text/css">
body {
font-family: Helvetica, sans-serif;
arm5077 / scripts.js
Last active Aug 29, 2015
nstein js changes
View scripts.js
$(".magWYSIWYG h1").css("font-size", "20pt");
arm5077 / index.js
Last active Aug 29, 2015
Scrapes Clinton Benghazi emails from the State Department's open records website
View index.js
var fs = require("fs");
var http = require('http');
fs.readFile("data.json", 'utf8', function(err, data){
data = JSON.parse(data);
data.Results.forEach(function(email, i){
// use a timeout so State's server doesn't get mad
arm5077 / compare_candidates.sql
Last active Oct 19, 2015
Finds donors who have contributed to multiple 2016 campaigns.
View compare_candidates.sql
ALTER TABLE contributions_individual ADD COLUMN contbr_nm_short varchar(200);
UPDATE contributions_individual set contbr_nm_short = SUBSTRING_INDEX(contributions_individual.contbr_nm, ' ', 2);
SELECT contributions_individual.cand_nm,
SUM(contributions_individual.contb_receipt_amt) as total,