Skip to content

Instantly share code, notes, and snippets.

View jkeefe's full-sized avatar

John Keefe jkeefe

View GitHub Profile
@jkeefe
jkeefe / election-urls.txt
Created January 29, 2012 05:04
Urls I used for Fusion Tables Election Data
# Results by county:
https://www.google.com/fusiontables/api/query?sql=SELECT+'DistrictName-en'%2C+NumVoters%2C+NumBallotBoxes%2C+NumCountedBallotBoxes%2C+'VoteCount-Paul'%2C+'VoteCount-Bachmann'%2C+'VoteCount-Johnson'%2C+'VoteCount-Gingrich'%2C+'VoteCount-Santorum'%2C+'VoteCount-Huntsman'%2C+'VoteCount-Other'%2C+'VoteCount-Roemer'%2C+'VoteCount-Romney'%2C+'VoteCount-Perry'%2C+'VoteCount-Cain'+FROM+2475414+ORDER+BY+'DistrictName-en'
# Candidate totals for the entire state:
https://www.google.com/fusiontables/api/query?sql=SELECT+SUM('NumVoters')%2C+SUM('NumBallotBoxes')%2C+SUM('NumCountedBallotBoxes')%2C+SUM('VoteCount-Paul')%2C+SUM('VoteCount-Bachmann')%2C+SUM('VoteCount-Johnson')%2C+SUM('VoteCount-Gingrich')%2C+SUM('VoteCount-Santorum')%2C+SUM('VoteCount-Huntsman')%2C+SUM('VoteCount-Other')%2C+SUM('VoteCount-Roemer')%2C+SUM('VoteCount-Romney')%2C+SUM('VoteCount-Perry')%2C+SUM('VoteCount-Cain')+FROM+2475414
# Sorted by Patchwork Nation Community type (from a merged table I made with the Iowa results):
@jkeefe
jkeefe / gist:1697449
Created January 29, 2012 05:42
URL for South Carolina Counties request to my table
Note: Table number goes in place of TTTTTTT:
https://www.google.com/fusiontables/api/query?sql=SELECT+'PN-Community-Type'%2C+'PN-Community-Type'%2C+'Precincts_Total'%2C+'Precincts_Reporting'%2C+'VoteCount-Bachmann'%2C+'VoteCount-Cain'%2C+'VoteCount-Gingrich'%2C+'VoteCount-Huntsman'%2C+'VoteCount-Johnson'%2C+'VoteCount-Paul'%2C+'VoteCount-Perry'%2C+'VoteCount-Romney'%2C+'VoteCount-Santorum'%2C+'UnitName'%2C+'FIPSCode'+FROM+TTTTTTT+WHERE+'FIPSCode'+>+0+ORDER+BY+FIPSCode+ASC&jsonCallback=?
@jkeefe
jkeefe / datacall.js
Created January 30, 2012 02:56
John's Iowa Data Call Code
var overview;
var overview_query_url = "https://www.google.com/fusiontables/api/query?sql=SELECT+PNCommunityType%2C+SUM('NumVoters')%2C+SUM('NumBallotBoxes')%2C+SUM('NumCountedBallotBoxes')%2C+SUM('VoteCount-Paul')%2C+SUM('VoteCount-Bachmann')%2C+SUM('VoteCount-Johnson')%2C+SUM('VoteCount-Gingrich')%2C+SUM('VoteCount-Santorum')%2C+SUM('VoteCount-Huntsman')%2C+SUM('VoteCount-Other')%2C+SUM('VoteCount-Roemer')%2C+SUM('VoteCount-Romney')%2C+SUM('VoteCount-Perry')%2C+SUM('VoteCount-Cain')+FROM+2486515&jsonCallback=?";
function refreshData() {
// Hit the Google Fusion Table
$.getJSON(overview_query_url, function(data) {
overview = data;
@jkeefe
jkeefe / gist:1702551
Created January 30, 2012 04:32
URL for Iowa Statewide Totals
https://www.google.com/fusiontables/api/query?sql=SELECT+PNCommunityType%2C+SUM('NumVoters')%2C+SUM('NumBallotBoxes')%2C+SUM('NumCountedBallotBoxes')%2C+SUM('VoteCount-Paul')%2C+SUM('VoteCount-Bachmann')%2C+SUM('VoteCount-Johnson')%2C+SUM('VoteCount-Gingrich')%2C+SUM('VoteCount-Santorum')%2C+SUM('VoteCount-Huntsman')%2C+SUM('VoteCount-Other')%2C+SUM('VoteCount-Roemer')%2C+SUM('VoteCount-Romney')%2C+SUM('VoteCount-Perry')%2C+SUM('VoteCount-Cain')+FROM+2486515&jsonCallback=foo
@jkeefe
jkeefe / 3d-nevada-embed.html
Created February 4, 2012 21:05
embed code for 3-d nevada map
<iframe frameborder="0" height="500" scrolling="no" src="http://dl.dropbox.com/u/466610/nevada_map/index.html" width="460"></iframe>
@jkeefe
jkeefe / gist:3012308
Created June 28, 2012 16:27
document embed
<div id="DV-viewer-392162-national-federation-of-independent-business-et" class="DV-container"></div>
<script src="http://s3.documentcloud.org/viewer/loader.js"></script>
<script>
DV.load("http://www.documentcloud.org/documents/392162-national-federation-of-independent-business-et.js", {
width: 600,
height: 800,
sidebar: false,
container: "#DV-viewer-392162-national-federation-of-independent-business-et"
});
</script>
@jkeefe
jkeefe / gist:3827607
Created October 3, 2012 15:33
Pres. Debate Video Embed Code / 10-3-2012
From Google:
<iframe width="640" height="480" src="http://www.youtube.com/embed/Z4Nkw4nqigU" frameborder="0" allowfullscreen></iframe>
@jkeefe
jkeefe / gist:3965614
Created October 27, 2012 18:37
Mini Version of Evac Zone Map
<iframe src="http://project.wnyc.org/news-maps/hurricane-zones/hurricane-zones-mini.html" height="700" width="560" scrolling="no" frameborder="0"></iframe>
@jkeefe
jkeefe / gist:4391583
Last active December 10, 2015 05:58
Quick description on how I layered streets above the data, and used the water areas to obscure the offshore data(!) on maps for: http://project.wnyc.org/nyc-districting-revised/#. Note that this is just for one layer, not the two I use to toggle on the finished project.
// 'jkeefe.nyc-district-revised' is the mapbox.js name for the data I made in TileMill which
// resides here: https://tiles.mapbox.com/jkeefe/map/nyc-district-revised#12.00/40.7223/-73.9112
// 'jkeefe.map-bz4e2who' is the mapbox.js name for a map I made at mapbox.com. It's just a
// Mapbox Streets layer I tinkered with to make the streets have opacity (alpha) of 53.
// It lives here: https://tiles.mapbox.com/jkeefe/map/map-bz4e2who#14.00/40.7227/-73.9904
// The rest of this code I learned from the mapbox.js documentation: http://mapbox.com/mapbox.js/api/v0.6.7/
// Code:
@jkeefe
jkeefe / stop-frisk-process.r
Created April 23, 2013 16:15
R Stats script used to process NYPD Stop & Frisk Data for map at http://project.wnyc.org/stop-frisk-delta/embed.html
# load foreign package
library("foreign", lib.loc="/Library/Frameworks/R.framework/Versions/2.15/Resources/library")
# set working directory
setwd("/Volumes/JK-Spinner/Dropbox/Coding/r/stop-frisk-delta")
## To get the .por file into R, I turned on the "foreign" package
data2011<-read.spss("2011.por")
#check to see field names