Skip to content

Instantly share code, notes, and snippets.

View cjwinchester's full-sized avatar
💭
🤌

Cody Winchester cjwinchester

💭
🤌
View GitHub Profile
@cjwinchester
cjwinchester / il-sor-scraper.py
Created July 6, 2021 18:18
Download a CSV of the Illinois SOR.
from datetime import date
from playwright.sync_api import sync_playwright
today = date.today().isoformat()
filename = f'il-sex-offenders-{today}.csv'
with sync_playwright() as p:
browser = p.chromium.launch(headless=False)
API_KEY = os.environ.get('FEC_API')
DONOR_URL = 'https://api.open.fec.gov/v1/schedules/schedule_a'
# for brevity, will skip the read-in-the-csv step
# `names` is a list of first initial/last name strings
# e.g. `J DOE`
# list of records to write out
data_out = []
CHAPTER I. Professor Persikov's Curriculum Vitae
On the evening of 16 April, 1928, the Zoology Professor of the Fourth State University and Director of the Moscow Zoological Institute, Persikov, went into his laboratory at the Zoological Institute in Herzen Street. The Professor switched on the frosted ceiling light and looked around him.
This ill-fated evening must be regarded as marking the beginning of the appalling catastrophe, just as Professor Vladimir Ipatievich Persikov must be seen as the prime cause of the said catastrophe.
He was fifty-eight years old. With a splendid bald head, like a pestle, and tufts of yellowish hair sticking out at the sides. His face was clean-shaven, with a slightly protruding lower lip which gave it a slightly cantankerous expression. Tall and round-shouldered, he had small bright eyes and tiny old-fashioned spectacles in silver frames on a red nose. He spoke in a grating, high, croaking voice and one of his many idiosyncrasies was to crook the index finger of his right
@cjwinchester
cjwinchester / good-bois.sh
Created April 6, 2019 05:38
Extract trading card pics of members of the USDA Beagle Brigade
# first install curl and poppler-utils, if you don't have already
curl https://www.cbp.gov/sites/default/files/documents/Agriculture%20Canine%20Cards.pdf > dogs.pdf
pdfimages -png dogs.pdf goodboi
@cjwinchester
cjwinchester / house-gift-travel.csv
Last active January 12, 2019 04:15
CSV of Congressional gift travel, 2007-2018
We can't make this file beautiful and searchable because it's too large.
DocID,FilerName,MemberName,State,District,Year,Destination,FilingType,DepartureDate,ReturnDate,TravelSponsor,pdf_link
500003590,Mark Bayer,"Markey, Edward J.",MA,5.0,2010,"Las Vegas, NV",Original,2010-01-07,2010-01-09,Consumer Electronics Association,http://clerk.house.gov/GTImages/ST/2010/500003590.pdf
500003602,Joshua Finestone,"Rogers, Mike",AL,3.0,2010,"Las Vegas, NV",Original,2010-01-06,2010-01-08,Consumer Electronic Association,http://clerk.house.gov/GTImages/ST/2010/500003602.pdf
500003603,Jeff Choudhry,"Franks, Trent",AZ,8.0,2010,"Las Vegas, NV",Original,2010-01-07,2010-01-09,Consumer Electronics Association,http://clerk.house.gov/GTImages/ST/2010/500003603.pdf
500003616,Solomon Ortiz,"Ortiz, Solomon P.",TX,27.0,2010,"Beijing, China",Original,2010-01-02,2010-01-10,Robstown Improvement Development Board,http://clerk.house.gov/GTImages/ST/2010/500003616.pdf
500003616,Solomon Ortiz,"Ortiz, Solomon P.",TX,27.0,2010,"Quingdao, China",Original,2010-01-02,2010-01-10,Robstown Improvement Development Board,htt
@cjwinchester
cjwinchester / geocoder.sh
Created September 17, 2018 22:55
Quick CLI duder to geocode a place and return coordinates
####################################################
# quick bash script to geocode a place name and #
# load tab-separated coordinates to clipboard #
# (n.b. uses osx `pbcopy`, so swap in whatever #
# works for your os in the last line) #
# #
# you'll need jq and an opencage geocode API key, #
# which i stored in an environment variable called #
# $OPENCAGE_GEOCODE_API #
# #
from random import sample
from itertools import chain
FAMILIES = {
'Joel and Amanda Sletten': ['Blaine', 'Bruce', 'Titus', 'Olivia'],
'Micah and Leslie Winchester': ['Jack', 'Alex'],
'Cody and Laurel Winchester': ['Julian', 'Lucy'],
'Barry and April Winchester': ['Brook', 'Blake']
}
@cjwinchester
cjwinchester / craigslist-alerter.py
Created September 5, 2018 00:06
Get alerted, via Slack, to items of interest on free craigslist
import os
import json
import requests
from bs4 import BeautifulSoup
target_keywords = ['bookshelf', 'book shelf', 'desk']
url = 'https://cosprings.craigslist.org/search/zip'
r = requests.get(url)
@cjwinchester
cjwinchester / co-cora-for-data.txt
Last active November 9, 2019 01:34
Sample requests for public records.
Dear {RECORDS CUSTODIAN},
Pursuant to the Colorado Open Records Act § 24-72-201 et seq., I request {DESCRIBE THE RECORDS YOU SEEK IN SOME DETAIL HERE}.
If you are not the custodian of the records being requested, please redirect this to the appropriate person's attention and apprise me of the change.
In keeping with Colo. Rev. Stat. § 24-72-203(3.5)(a), which states that a governmental entity must provide digital records in a searchable or sortable format if the records exist in that format, I request that these data be provided in a machine-readable electronic format that can be imported into standard database software. Examples include an Excel .xls or .xlsx file, an Access .mdb or .accdb file, a text-based delimited file (.csv, .txt., .tsv., etc.), a .dbf file or an SQL dump. This would NOT include PDFs, which are not readable by database software.
I am a member of the news media requesting this information for newsgathering purposes. I request a waiver of fees for searching or copying these records be
@cjwinchester
cjwinchester / spongebobber.py
Created July 17, 2018 15:51
Spongebob-ify some text.
from itertools import zip_longest
def spongebobify(text):
up = text[::2].upper()
low = text[1::2].lower()
return ''.join([''.join(x) for x in list(zip_longest(up,low,fillvalue=''))])