Skip to content

Instantly share code, notes, and snippets.

View arm5077's full-sized avatar
😊

Andrew McGill arm5077

😊
View GitHub Profile
@arm5077
arm5077 / potholes.r
Created March 10, 2014 21:08
Potholes in Pittsburgh
library(ggplot2)
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[is.na(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
arm5077 / doctors.sql
Created April 23, 2014 18:43
Medicare doctor charge database query
SELECT medicare.*,
peerAverage.average AS charge_average,
( medicare.average_submitted_chrg_amt - peerAverage.average ) /
peerAverage.average * 100 AS difference_from_average,
totalAverage.total_difference_average
FROM medicare
JOIN (SELECT Avg(average_submitted_chrg_amt) AS average,
hcpcs_code,
place_of_service
FROM medicare
@arm5077
arm5077 / README.md
Last active August 29, 2015 14:01
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
arm5077 / index.php
Created May 13, 2014 22:29
2014 Pa. Democratic gubernatorial primary scraper
<?PHP
function getURL($url)
{
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $url);
@arm5077
arm5077 / index.html
Last active August 29, 2015 14:12
National Journal swatch tool
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></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
arm5077 / index.html
Created February 23, 2015 17:20
Converts a copy-and-pasted table of emails into readable text.
<!doctype html>
<html ng-app="formatApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script>
<style type="text/css">
body {
font-family: Helvetica, sans-serif;
@arm5077
arm5077 / scripts.js
Last active August 29, 2015 14:21
nstein js changes
$(window).load(function(){
$(".magWYSIWYG h1").css("font-size", "20pt");
});
@arm5077
arm5077 / index.js
Last active August 29, 2015 14:22
Scrapes Clinton Benghazi emails from the State Department's open records website
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){
console.log("http://foia.state.gov/searchapp/"+email.pdfLink);
// use a timeout so State's server doesn't get mad
@arm5077
arm5077 / compare_candidates.sql
Last active October 19, 2015 22:56
Finds donors who have contributed to multiple 2016 campaigns.
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,
contributions_individual.contbr_nm_short,
contributions_individual.contbr_zip,
SUM(contributions_individual.contb_receipt_amt) as total,
b.cand_nm,
b.contbr_nm_short,