Skip to content

Instantly share code, notes, and snippets.

View arm5077's full-sized avatar
😊

Andrew McGill arm5077

😊
View GitHub Profile
@arm5077
arm5077 / ngram.php
Last active January 3, 2016 01:59
Snippet from Tomlin ngram project.
<?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 January 3, 2016 23:28
Segment of PHP script that scrapes Pittsburgh Mayor Bill Peduto's daily schedule.
<?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 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");
});