Skip to content

Instantly share code, notes, and snippets.

View anbnyc's full-sized avatar

Alec Barrett anbnyc

View GitHub Profile
@anbnyc
anbnyc / star.js
Created March 3, 2018 12:22
SVG polygon points for a five-pointed star
const star = radius =>
[0, .4, .8, .2, .6, 0].map(d =>
Math.round(1000* radius*Math.cos(2*Math.PI*d - .5*Math.PI) )/1000
+","+
Math.round(1000* radius*Math.sin(2*Math.PI*d - .5*Math.PI) )/1000
).join(' ')
star(7.5)
@anbnyc
anbnyc / counties.dsv
Last active May 31, 2018 21:48
County presidential election results change in Dem advantage from 2008 and 2012 to 2016
per_point_diff_2016|per_point_diff_2012|per_point_diff_2008|state_abbr|county_name|per_point_diff_12_16|per_point_diff_08_16
-0.4947893435|-0.460579698|-0.4784061588|AL|Autauga County|-0.03420964548|-0.01638318471
-0.5778616219|-0.5582317504|-0.5144755752|AL|Baldwin County|-0.01962987149|-0.0633860467
-0.05611164581|0.02914739506|-0.01453138435|AL|Barbour County|-0.08525904087|-0.04158026146
-0.5554412437|-0.4684781313|-0.4584683017|AL|Bibb County|-0.08696311238|-0.096972942
-0.813819729|-0.7414512093|-0.6950591338|AL|Blount County|-0.07236851962|-0.1187605952
0.5086151883|0.5280180519|0.4838411819|AL|Bullock County|-0.01940286364|0.02477400636
-0.1352907311|-0.07529262891|-0.1335873931|AL|Butler County|-0.05999810223|-0.001703338005
-0.4138382303|-0.3194636678|-0.3252101864|AL|Calhoun County|-0.09437456251|-0.0886280439
-0.148062128|-0.0510232111|-0.08478202728|AL|Chambers County|-0.09703891693|-0.06328010075
@anbnyc
anbnyc / districts.dsv
Created May 31, 2018 18:20
House districts presidential election results 2016 and incumbent status in 2018
CD;Incumbent;Party;Pres;Open;Not running
AK-AL;Young, Don;(R);Trump;FALSE;
AL-01;Byrne, Bradley;(R);Trump;FALSE;
AL-02;Roby, Martha;(R);Trump;FALSE;
AL-03;Rogers, Mike;(R);Trump;FALSE;
AL-04;Aderholt, Rob;(R);Trump;FALSE;
AL-05;Brooks, Mo;(R);Trump;FALSE;
AL-06;Palmer, Gary;(R);Trump;FALSE;
AL-07;Sewell, Terri;(D);Clinton;FALSE;
AR-01;Crawford, Rick;(R);Trump;FALSE;
@anbnyc
anbnyc / readme.md
Created May 31, 2018 19:29
Statewide election results over years, 2012-2017

Compiled from publicly available news sources including NY Times, CNN, NPR, and Wikipedia.

Pct_point_diff is calculated as (Dem vote percentage - GOP vote percentage).

@anbnyc
anbnyc / .block
Last active July 31, 2018 20:02
Composition
license: mit
height: 500
border: no
@anbnyc
anbnyc / .block
Last active August 2, 2018 19:34
Senate Scenarios
license: mit
height: 500
border: no
@anbnyc
anbnyc / compare.js
Created February 25, 2019 20:28
Async JavaScript examples
function asyncWithCallbacks(callback){
getApiUrl(apiName, function(err1, url){
if(err1) throw new Error(err1);
callApi(url, function(err2, data){
if(err2) throw new Error(err2);
writeDataToServer(data, function(err3, response){
if(err3) throw new Error(err3);
console.log('welcome to the third circle of callback hell.')
callback(response);
})
@anbnyc
anbnyc / Amy-Klobuchar.png
Last active April 16, 2019 17:13
2020headshots
Amy-Klobuchar.png
@anbnyc
anbnyc / StationInfo.tsv
Created April 22, 2019 19:02
Ocean plastic data files
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 22 columns, instead of 10 in line 5.
# Sampling event ID Sampling type Platform name Start day (UTC) Start month (UTC) Start year (UTC) Start UTC time (hours) End UTC time (hours) Sampling duration (hours) Start latitude (degrees) Start longitude (degrees) End latitude (degrees) End longitude (degrees) Sampling distance (km) Sampling width (km) Sampling area (km2) Sampling depth (km) Wind speed (Knots) Sea state (Beaufort) Vessel speed (knots) Observations
1 0.0 Manta trawl RV Ocean Starr 25 7 2015 22.30 22.73 0.43 33.1932 -128.7879 33.1795 -128.8071 2.36 0.0009 0.0021195 0.00015 10 3 3
2 0.1 Mega trawl RV Ocean Starr 25 7 2015 21.50 23.05 1.55 33.2135 -128.75 33.1656333333333 -128.83 9.156 0.006 0.054936 0.001 10 3 3
3 1.1 Manta trawl RV Ocean Starr 27 7 2015 15.72 18.48 2.77 29.0751 -133.9640 29.0695 -134.1250 15.66 0.0009 0.01409337 0.00015 14 4 3
4 1.2 Manta trawl RV Ocean Starr 27 7 2015 15.80 18.38 2.58 29.0748 -133.9680 29.0693 -134.1180 14.59 0.0009 0.01313172 0.00015 14 4 3
5 1.3 Mega trawl RV Ocean Starr 27 7 2015 15.57 19.22 3.65