Skip to content

Instantly share code, notes, and snippets.

View kpq's full-sized avatar

Kevin Quealy kpq

View GitHub Profile
@kpq
kpq / gist:4752291
Created February 11, 2013 03:31
KQ Test
<h1>Test tktktk</h1>
@kpq
kpq / nba-draft-scrape
Created June 24, 2013 00:13
Scrape every player ever in the NBA draft in R
library(XML)
years <- 1950:2012
data <- NULL
for (i in years) {
print(i)
url <- paste("http://www.basketball-reference.com/draft/NBA_", i, ".html", sep="")
page <- htmlTreeParse(readLines(url), useInternalNodes=T)
table <- readHTMLTable(page)$stats
@kpq
kpq / nyc-pharms.R
Last active December 18, 2015 23:49
How to plot points and shapes in R, bc I always forget the reprojecting stuff
library(rgdal)
# a clean data frame called d2
maptest <- d2
coordinates(maptest) <- c("lng", "lat")
proj4string(maptest) <- CRS("+proj=longlat")
ogrInfo(dsn = "shapes", "County")
@kpq
kpq / nyt-albera-usa
Created June 27, 2013 19:41
NYT Albers USA Projection
function nytAlbersUsa() {
var lower48 = d3.geo.albers().rotate([96, 0]).center([0, 38]).parallels([29.5, 45.5]),
alaska = d3.geo.albers().rotate([160, 0, -35]).center([45, 44]).parallels([55, 65]),
hawaii = d3.geo.albers().rotate([160, 0]).center([0, 20]).parallels([8, 18]);
function nytAlbersUsa(coordinates) {
return projection(coordinates)(coordinates);
}
function projection(point) {
@kpq
kpq / index.html
Created June 29, 2013 03:11
refactoring a little for will
<!DOCTYPE html>
<meta charset="utf-8">
<style>
/*whole page*/
body {
width:900px;
margin:20px auto;
font-family:georgia, sans-serif;
@kpq
kpq / base.css
Created June 29, 2013 13:37
suggestions for michael
body {
width: 800px;
margin: 20px auto;
font-family: georgia;
}
h1 {
font-family: arial;
font-weight: bold;
@kpq
kpq / mapStyles.js
Created July 8, 2013 18:07
generic + unofficial map styles for NYT google maps
var mapStyles = [ { "elementType" : "all",
"featureType" : "all",
"stylers" : [ { "lightness" : 53 },
{ "gamma" : 0.80000000000000004 },
{ "saturation" : -61 }
]
},
{ "elementType" : "geometry",
"featureType" : "road.local",
"stylers" : [ { "saturation" : -73 },
@kpq
kpq / encode_mp4
Last active December 19, 2015 19:58
video encoding messes
ASPECTRATIO=1.777777777777 # 16x9
WIDTH=970
ffmpeg -i jackalope.mov -vcodec libx264 -acodec libfaac -pix_fmt yuv420p -b:v 1000k -b:a 128k -threads 0 -vf scale=$WIDTH':trunc('$WIDTH'/'$ASPECTRATIO'/2)*2' promo.mp4
@kpq
kpq / test.html
Created July 16, 2013 18:31
responsive videos with mediaelement
<div class="wrapper">
<video width="640" height="360" style="width: 100%; height: 100%;" id="player1">
<!-- Pseudo HTML5 -->
<source type="video/youtube" src="http://www.youtube.com/watch?v=nOEw9iiopwI" />
</video>
</div>
@kpq
kpq / README.md
Last active December 23, 2015 15:09
Dancing line chart in D3