Skip to content

Instantly share code, notes, and snippets.

View cjwinchester's full-sized avatar
💭
🤌

Cody Winchester cjwinchester

💭
🤌
View GitHub Profile
@cjwinchester
cjwinchester / index.html
Created April 10, 2018 22:09
pulsing dots on an old d3 map ftw
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div id="map"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.1/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3-queue/3.0.7/d3-queue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/3.0.2/topojson.min.js"></script>
@cjwinchester
cjwinchester / -son.sh
Created March 27, 2018 22:50
Get a sorted list of surnames that occur more than 100 times in the 2010 Census that end in "-son".
curl -O https://www2.census.gov/topics/genealogy/2010surnames/names.zip; unzip names.zip; awk -F "," '{print $1}' < Names_2010Census.csv | grep -i 'son$' | sort
curl -LJO https://www2.census.gov/geo/docs/reference/codes/files/national_places.txt; grep -i "lucy" national_places.txt > lucy.txt; grep -i "julian" national_places.txt > julian.txt; grep -i "cody" national_places.txt > cody.txt; grep -i "laurel" national_places.txt > laurel.txt; curl -LJO https://www2.census.gov/geo/tiger/TIGER2017/PRIMARYROADS/tl_2017_us_primaryroads.zip; unzip tl_2017_us_primaryroads.zip; ogr2ogr -f 'CSV' tl_2017_us_primaryroads.csv tl_2017_us_primaryroads.dbf; grep -i "lucy" national_places.txt >> lucy.txt; grep -i "julian" national_places.txt >> julian.txt; grep -i "cody" national_places.txt >> cody.txt; grep -i "laurel" national_places.txt >> laurel.txt
@cjwinchester
cjwinchester / alphadict.py
Created December 17, 2017 05:18
python: get a dict of letters and (1-indexed) index
from string import ascii_lowercase as alph
from pprint import pprint
alphabet = {v: k+1 for (k, v) in enumerate(alph)}
pprint(alphabet)
"""
=>
{'a': 1,
@cjwinchester
cjwinchester / bday_reminder.gs
Created December 13, 2017 05:04
a google apps script that runs against a spreadsheet every week and emails me if peeps got a bday coming up
/*
a script that runs every sunday to let me know of birthdays coming up that week
most of the math happens in the spreadsheet
--> example: https://docs.google.com/spreadsheets/d/1iXcg0THKuQwosKiD5syktAmGA390Gu8OSFs5iKM1EwQ/edit?usp=sharing
*/
function birthdayNotifier() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
@cjwinchester
cjwinchester / tx-death-row-witnesses.py
Created October 9, 2017 22:07
Quick and dirty "rank Texas death row media witnesses by frequency" script.
from collections import Counter
import requests
from bs4 import BeautifulSoup
def j_formatter(reporter):
name, affil = [x.strip() for x in reporter.split(',', 1)]
# if this were a real thing, would obv want more rigorous cleaning
@cjwinchester
cjwinchester / holla.sh
Last active April 20, 2017 04:55
yeah! we doin' this!
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
-u|--url)
URL="$2"
shift
;;
-s|--starttime)
@cjwinchester
cjwinchester / whois.js
Created April 5, 2017 02:52
whois bookmarklet
javascript:(function() {window.open("http://whoiz.herokuapp.com/lookup?url=" + window.location.host.toString().replace(/\//g,"").replace("http:","").replace("www.",""), '_blank');})();
@cjwinchester
cjwinchester / array_consecutive_collapser.js
Last active November 8, 2016 23:49
Collapse an array of arrays of numeric pairs by consecutiveness, or whatever
// given an array of arrays of paired numbers (say, years)
// collapse consecutive into an aggregate human-readable string
// so like
// [[2001, 2002], [2002, 2003], [2003, 2004], [2015, 2016]]
// becomes "2001-2004, 2015-2016"
function makeHumanReadableYears(arr) {
var out = [];
var breakpoints = [];
@cjwinchester
cjwinchester / gorillas_in_the_gist.txt
Last active October 20, 2016 04:11
gorillas in the gist
$$$. $$$$$$$$&@@@@@@@BBB$@@##E gj @@`L@@El&&@$$&@,#@@$@@@E .$$#, |L$E
@l$B,'B$$$$@g@@@@$$@@$$$$$@@'E $$@ $lgg$@$$#@$@@@$3@p#@@@@FsO@$gL#,'$E
|@E@ @@@@@@@@$@@@B$&$$$$$$$@- E=w$@@$$@@@$I'l#E$$r$B}$@@E,}@@B@IL`;#E
$ $= $$$$$$$@@@@@$$$$$$$$$@$ $@@$$F="``"""-: 3#L$@ $$B @g3@Q@&L |L`
E #@L j$$$$@@$@B$$$$$$$$$$$E $@$$$8FLLL., -|,A$F &$$@@@I||||$
@j@$E #$@$g$@@@$$$$IlL|l&$@ gE$$F||I4&$@$&QL F,-,$$$B$&$&L|LQ$B
@$,$@ $$@&@$$$$$LlI$$$$IA` #$@BF' "A&$$@8$LL |-@$$$$L|Ll1$$I$$F
B4@@,-L$$ggggE1#EI$$F"^ ||@#@L zgppz, | '@$$L|||TL|LTl|$$F
#$@@5 $@$$#@$$@g'1`.;z$@@g;'T$@E,g$@@@B@@@@@@@@@@ , }l$LlLlIL@g$P! $#L
@@@@@ $$$$$@$$$E$Q$&@@@$$$, .-lg$$$$@$@B#B$@BB@@b ^?$L$II4$$$,! $#L