Skip to content

Instantly share code, notes, and snippets.

Avatar
😊

Andrew McGill arm5077

😊
View GitHub Profile
@arm5077
arm5077 / ngram.php
Last active Jan 3, 2016
Snippet from Tomlin ngram project.
View ngram.php
<?PHP
// For this example, $ngram = 1, meaning we're only looking at one word at a time and not phrases
$textArray = explode( " ", $formatted ); // $formatted is the text sample with most punctuation removed
for ( $i = 0; $i < count( $textArray ) - $ngram; $i++ ) {
$chunk = "";
for ( $j = 0; $j < $ngram; $j++ ) {
@arm5077
arm5077 / peduto_scraper.php
Last active Jan 3, 2016
Segment of PHP script that scrapes Pittsburgh Mayor Bill Peduto's daily schedule.
View peduto_scraper.php
<?PHP
$scheduleArray = explode( "<p><strong>", $schedule );
for( $j = 0; $j < count( $scheduleArray ); $j++ ) {
$scheduleArray[$j] = strip_tags( $scheduleArray[$j] );
$scheduleArray[$j] = trim( str_replace( "&nbsp;", "", $scheduleArray[$j] ) );
//parse split press release into export array
$start = 0;
if( $scheduleArray[$j] != "" ) {
$tempArray = "";
@arm5077
arm5077 / potholes.r
Created Mar 10, 2014
Potholes in Pittsburgh
View potholes.r
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,]
View bill-peduto-bot-tweet.py
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 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,
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 Aug 29, 2015
Pennsylvania counties treemap by population
View README.md

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
2014 Pa. Democratic gubernatorial primary scraper
View index.php
<?PHP
function getURL($url)
{
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $url);
@arm5077
arm5077 / index.html
Last active Aug 29, 2015
National Journal swatch tool
View index.html
<!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 Feb 23, 2015
Converts a copy-and-pasted table of emails into readable text.
View index.html
<!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 Aug 29, 2015
nstein js changes
View scripts.js
$(window).load(function(){
$(".magWYSIWYG h1").css("font-size", "20pt");
});