Skip to content

Instantly share code, notes, and snippets.

View tlds.js
// run this in the console or something
document.body.innerHTML = Array.from(document.querySelectorAll('table.wikitable td:first-child')).map(x => x.textContent.replace(/\[[^\]]*\]/, '').trim()).sort().join("<br>")
@rolandcrosby
rolandcrosby / sort-streams.js
Last active Mar 24, 2020
Script that adds "sort by" options to Zulip's "add streams" widget
View sort-streams.js
window.sortBy = function(key, ascending) {
const streams = Array.from(document.querySelectorAll(".stream-row")).map(
r => ({
row: r,
name: r.querySelector(".stream-name").innerText,
description: r.querySelector(".description").innerText,
messagesPerWeek: parseInt(
r.querySelector(".stream-message-count-text").innerText
),
subscribers: parseInt(
@rolandcrosby
rolandcrosby / rupauls-oil-wells.csv
Last active Mar 17, 2020
data about oil and gas production on the lebar property in wyoming
View rupauls-oil-wells.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 23 columns, instead of 14. in line 3.
Well Name,API No.,Well Direction,Operator,Well Status,Well Type,Township Range Section,Kelly Bushing Elevation,Drillers Total Depth,County,Closest City,Latitude,Longitude,Spud Date,Completion Date,Sep 2019 Oil Prod,Sep 2019 Gas Prod,Total Oil Prod,Total Gas Prod,First Production Date on File,Most Recent Production Date on File,Ground Elevation,Permit Date
Le Bar Et Al B 3 3,49-009-21137,V,BLACK BEAR OIL CORPORATION,Producing Oil Well,Oil Well,35N 70W 2,4770 KB,7444,"Converse County, WY",Douglas,43.030730,-105.228700,1976-10-02,1976-12-02,50 BBLs,120 MCF,"116,346 BBLs","140,695 MCF",January 1978,December 2020,,
Lebar 1-24,49-009-21402,V,MATRIX PRODUCTION COMPANY,Producing Oil Well,Oil Well,36N 70W 24,4926,7410,"Converse County, WY",Douglas,43.076050,-105.207030,1978-06-13,1978-07-19,188 BBLs,0 MCF,"265,994 BBLs","501,793 MCF",January 1978,December 2019,,
Lebar Fee 1-4,49-009-21550,V,CHACO ENERGY COMPANY,Producing Oil Well,Oil Well,35N 70W 4,4830 KB,7557,"Converse County, WY",Douglas,43.037640,-105.268560,1979-
@rolandcrosby
rolandcrosby / fecview.py
Created Jan 26, 2020
Generate a BigQuery query that joins together all the FEC individual contributor data
View fecview.py
out = []
for i in range(2020, 1978, -2):
yr = "%02d" % (i % 100)
out.append("""(
SELECT
`bigquery-public-data.fec.indiv{0}`.cmte_id,
cmte_nm,
amndt_ind,
rpt_tp,
transaction_pgi,
View artcc.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rolandcrosby
rolandcrosby / countypres_2000-2016.tab
Created Dec 8, 2019
MIT Election Data and Science Lab, 2018, "County Presidential Election Returns 2000-2016", https://doi.org/10.7910/DVN/VOQCHQ, Harvard Dataverse, V6, UNF:6:ZZe1xuZ5H2l4NUiSRcRf8Q== [fileUNF]
View countypres_2000-2016.tab
This file has been truncated, but you can view the full file.
year state state_po county FIPS office candidate party candidatevotes totalvotes version
2000 "Alabama" "AL" "Autauga" 1001 "President" "Al Gore" "democrat" 4942 17208 20191203
2000 "Alabama" "AL" "Autauga" 1001 "President" "George W. Bush" "republican" 11993 17208 20191203
2000 "Alabama" "AL" "Autauga" 1001 "President" "Ralph Nader" "green" 160 17208 20191203
2000 "Alabama" "AL" "Autauga" 1001 "President" "Other" "NA" 113 17208 20191203
2000 "Alabama" "AL" "Baldwin" 1003 "President" "Al Gore" "democrat" 13997 56480 20191203
2000 "Alabama" "AL" "Baldwin" 1003 "President" "George W. Bush" "republican" 40872 56480 20191203
2000 "Alabama" "AL" "Baldwin" 1003 "President" "Ralph Nader" "green" 1033 56480 20191203
2000 "Alabama" "AL" "Baldwin" 1003 "President" "Other" "NA" 578 56480 20191203
View cities.csv
city population area_sqmi
San Francisco 884363 46.873
Brooklyn 2622000 96.92
Queens 2322000 178.2
Manhattan 1636000 33.59
Staten Island 474248 102
Bronx 1438000 57.48
Chicago 2716000 227.6
Paris 2206000 40.5
View diff-word-list.js
const childProcess = require("child_process");
function gitCmd(args) {
const cmd = childProcess.spawnSync("/usr/local/bin/git", args);
return cmd.stdout.toString().split("\n");
}
function commitsForPath(path) {
return gitCmd(["rev-list", "--format=oneline", "--all", path])
.map(x => [x.substr(0, 40), x.substr(41)])
View airway-beacons.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 16 columns, instead of 7. in line 8.
PID,Designation,State,County,Latitude,Longitude,USGS Quad,First City,Second City,Beacon #,Airport?,Arrow?,Airway,Status,Report,
TT6703,LADD FIELD AIRWAY BEACON,AK, ,64.8393467,-147.6422778,FAIRBANKS D-2, , , ,N,N, ,Undetermined NGS beacon/arrow,,
UV1481,MENDENHALL PENPOLE OBS LT,AK, ,58.36027612,-134.6373542,JUNEAU B-2, , , , , , ,Undetermined NGS beacon/arrow,,
UV1482,MENDENHALL PEN TWR OBS LT,AK, ,58.36558586,-134.6345829,JUNEAU B-2, , , , , , ,Undetermined NGS beacon/arrow,,
UV1489,MENDENHALL PENINSULA AWY BCN,AK, ,58.35891469,-134.6378411,JUNEAU B-2, , , ,N,N, ,Undetermined NGS beacon/arrow,,
UV8118,BETHEL CAA AIRFIELD AIRWAY BCN,AK, ,60.77455235,-161.7225519,BETHEL D-8, , , ,Y,N, ,Undetermined NGS beacon/arrow,,
UV8494,ANIAK AIRWAY BEACON,AK, ,61.5781849,-159.5386466,RUSSIAN MISSION C-2, , , ,N,N, ,Undetermined NGS beacon/arrow,,
UW5259,AIR BCN,AK, ,71.32724161,-156.6789262,BARROW B-4, , , ,N,N, ,Undetermined NGS beacon/arrow,,
BG4136,ATLANTA MOBILE AWY BCN 15,AL,BALDWIN,30.96132667,-87.70389309,DYAS (19
@rolandcrosby
rolandcrosby / gtfs.sql
Last active Aug 19, 2019
CockroachDB 19.2 IMPORT INTO with GTFS data
View gtfs.sql
-- IMPORT INTO for GTFS data (e.g. http://transitfeeds.com/p/mta/87)
create table agencies (
agency_id int primary key,
agency_name string,
agency_url string,
agency_timezone string,
agency_phone string,
agency_lang string
);
You can’t perform that action at this time.