Skip to content

Instantly share code, notes, and snippets.

View rolandcrosby's full-sized avatar

Roland Crosby rolandcrosby

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rolandcrosby
rolandcrosby / fecview.py
Created January 26, 2020 00:32
Generate a BigQuery query that joins together all the FEC individual contributor data
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,
@rolandcrosby
rolandcrosby / rupauls-oil-wells.csv
Last active March 17, 2020 03:36
data about oil and gas production on the lebar property in wyoming
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 / sort-streams.js
Last active March 24, 2020 16:37
Script that adds "sort by" options to Zulip's "add streams" widget
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(
// 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 / rot13-inline.js
Created April 8, 2020 19:24
rot13 the current selection in your browser
(function () {
function rot13(str) {
return str.replace(/([A-Ma-m])|([N-Zn-z])/g, function (m, p1, p2) {
return String.fromCharCode(m.charCodeAt(0) + (p1 ? 13 : -13));
});
}
if (document.getSelection().rangeCount == 0) {
return;
}
const range = window.getSelection().getRangeAt(0);

these are all pretty similar --

Scala:

val outer = List(List(1, 2, 3, 4, 5), List(4, 5, 6, 7, 8))
for {
  inner <- outer
  x <- inner
} yield x
@rolandcrosby
rolandcrosby / Palme d'Or.sparql
Last active July 24, 2020 13:05
Wikidata SPARQL query to retrieve films that have won the Palme d'Or at Cannes
SELECT
?film
?title
?directors
?year
WHERE
{
SELECT
?film
?title
SELECT ?ingredient ?ingredientLabel (GROUP_CONCAT(DISTINCT ?sandwichLabel; SEPARATOR = ", ") AS ?sandwiches) WHERE {
?sandwich ((wdt:P31?)/(wdt:P279*)) wd:Q28803;
wdt:P527 ?ingredient.
MINUS { ?ingredient (wdt:P279*) wd:Q7802. }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en", "fr".
?sandwich rdfs:label ?sandwichLabel.
?ingredient rdfs:label ?ingredientLabel.
}
}
@rolandcrosby
rolandcrosby / openterm.sh
Created April 25, 2020 02:14
switch to gnome-terminal if it's open, otherwise launch a new one
#!/bin/bash
read -r win_found <<<$(wmctrl -l -p | awk '{print $1,$3}' | while read -r wins; do ps -o command= -p "${wins/0x* /}" | grep -q gnome-terminal && echo "${wins/ */}" && break; done)
if [ -z "$win_found" ]; then
gnome-terminal
else
wmctrl -i -a $win_found
fi