Skip to content

Instantly share code, notes, and snippets.

View arm5077's full-sized avatar
😊

Andrew McGill arm5077

😊
View GitHub Profile
@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,
@arm5077
arm5077 / index.html
Last active December 2, 2015 23:11
Color palette for Poseidon
<!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 / app.js
Last active December 10, 2015 21:30
Candidate tracker
// thenBy.js, sorting library
/*** Copyright 2013 Teun Duynstee Licensed under the Apache License, Version 2.0 ***/
var firstBy=function(){function n(n,t){if("function"!=typeof n){var r=n;n=function(n){return n[r]}}if(1===n.length){var u=n;n=function(n,t){return u(n)<u(t)?-1:u(n)>u(t)?1:0}}return-1===t?function(t,r){return-n(t,r)}:n}function t(t,u){return t=n(t,u),t.thenBy=r,t}function r(r,u){var f=this;return r=n(r,u),t(function(n,t){return f(n,t)||r(n,t)})}return t}();
var limit = 3; // Number of places to display
// Get data from endpoint
d3.json("http://traveltracker.nationaljournal.com/api/widget", function(err, data){
// Sort by date and number of trips
@arm5077
arm5077 / candidate_example.json
Created January 15, 2016 16:58
Example of delegate tracker JSON
[
{
"name": "Hillary Clinton",
"party": "D",
"bound": 954,
"unbound": 122,
"states": [
{
"state": "PA",
"bound": 40,
@arm5077
arm5077 / data.csv
Created March 24, 2016 02:34
De-industrialization-based model for Donald Trump in Ohio and Michigan
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 52 columns, instead of 31. in line 1.
area_fips,state,name,clinton_raw,sanders_raw,clinton_percent,sanders_percent,bush_raw,carson_raw,christie_raw,cruz_raw,fiorina_raw,huckabee_raw,kasich_raw,rubio_raw,santorum_raw,trump_raw,bush_percentage,carson_percentage,christie_percentage,cruz_percentage,fiorina_percentage,huckabee_percentage,kasich_percentage,rubio_percentage,santorum_percentage,trump_percentage,1975_raw_manufacturing,1975_percent_manufacturing,1975_raw_total,1993_raw_manufacturing,1993_percent_manufacturing,1993_raw_total,2007_raw_manufacturing,2007_percent_manufacturing,2007_raw_total,2014_raw_manufacturing,2014_percent_manufacturing,2014_raw_total,1975_to_1993_manufacturing,1975_to_1993_total,1993_to_2007_manufacturing,1993_to_2007_total,2007_to_2014_manufacturing,2007_to_2014_total,1975_to_2014_manufacturing,1975_to_2014_total,gini,gini_adjusted,college_or_higher,poverty_level,percent_white_alone
26001,Michigan,ALCONA,463,455,48.74,47.89,13,27,5,460,4,2,340,138,4,1111,0.61,1.26,0.23,21.47,0.19,0.09,15.87,6.44,0.19,51.84,94,17.06,551,2
@arm5077
arm5077 / readme.md
Last active January 10, 2022 02:08
A roster of staff stationed on the (fictional) First Order’s Starkiller battle station, as seen on Star Wars VII: The Force Awakens.

This is a randomly generated dataset that simluates a crew roster for the First Order's Starkiller base, as seen in Star Wars VII: The Force awakens.

name: The crew member's name

division: The crew member's assignement (security, droid maintainence, etc.)

salary: The individual's salary, in Galactic Credits

@arm5077
arm5077 / index.js
Created July 5, 2016 12:21
A Slack doorbell run through Amazon's Lambda service and activated by its IoT button.
exports.handler = function(event, context){
var request = require('request');
var quotes = [
{
quote: "Good manners will open doors that the best education cannot.",
author: "Clarence Thomas"
},
{
quote: "I think there are influences that you open the door to, and influences that come under the door.",
author: "Harrison Birtwistle"
@arm5077
arm5077 / app.js
Created August 31, 2016 18:43
Template for resizable D3 v4 map
d3.json("topojson/states.topojson", function(states){
// Make SVG container
var map = d3.select("#map");
var svg = map.append("svg");
var country = svg.append("g");
// Grab width of containing element
var width = d3.select("#map").node().offsetWidth;
// Size container to correct dimensions
@arm5077
arm5077 / index.js
Created November 22, 2016 13:50
A script for the Raspberry Pi that turns on a Powerswitch when the user says "Lumos!"
const record = require('node-record-lpcm16');
const {Detector, Models} = require('./node_modules/snowboy/');
const Gpio = require('onoff').Gpio;
// Set up control of the pin that toggles the Powerswitch
power = new Gpio(14, 'out');
var on = false;
// Turn the power off by default
power.writeSync(0);