Skip to content

Instantly share code, notes, and snippets.

View schwanksta's full-sized avatar
💭
(┛ಠ_ಠ)┛彡┻━┻

Ken Schwencke schwanksta

💭
(┛ಠ_ಠ)┛彡┻━┻
View GitHub Profile
@schwanksta
schwanksta / models.py
Last active August 13, 2019 20:41
Simple Django FOIA CCing code
from django.db import models
from django.db.models import Q
from django.conf import settings
from django.utils.functional import cached_property
from django.contrib.postgres.fields import HStoreField, ArrayField
from datetime import date, datetime, time, timedelta
from foiaminder.schedule import SCHEDULES
from business_calendar import Calendar
import requests

Keybase proof

I hereby claim:

  • I am schwanksta on github.
  • I am schwanksta (https://keybase.io/schwanksta) on keybase.
  • I have a public key ASBcdo7HTW0HfyikZ8M0_Adaaf4V4Yq8wnUqja3WkJEZkwo

To claim this, I am signing this object:

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@schwanksta
schwanksta / parallelcopy.py
Created February 25, 2016 20:57
parallelized COPY in postgres
import multiprocessing
import subprocess
from glob import glob
import os
fields = ["field1", "field2", "field3"]
def work(fname):
print "starting %s" % fname
fname = os.path.abspath(fname)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Smoke, mirrors and madlibs: How to break news while you sleep

Around 6:25 a.m. I was awakened by a jolt from slipping tectonic plates. The tremor didn't last very long, and as soon as my window stopped rattling my first thought was to check for an email.

Here it was:

L.A. Now: Ready for copyedit: Earthquake: 4.7 quake strikes near Westwood, California

This is a robopost from your friendly earthquake robot. Please copyedit & publish the

@schwanksta
schwanksta / index.html
Last active December 27, 2015 10:39
high homicide tracts
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" />
<![endif]-->
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<script type="text/javascript">
geojson = {"type":"FeatureCollection","features":[{"type":"Feature","id":651,"properties":{"GEOID10":"06037600304","CT10":"600304","LABEL":"6003.04","X_Center":6472482.0,"Y_Center":1798989.0,"Shape_area":4798305.86046,"Shape_len":9662.240288860000874,"PNTCNT":15.0,"SumLev":"140","AreaName":"CensusTract6003.04","State":"06","AreaLand":"445759","AreaWatr":"0","TotPop":"3424","Wht":"50","Blk":"1330","Asn":"7","Hisp":"1986","Oth":"51","NAMELSAD10":"CensusTract6003.04","per_capita":0.0043808411,"PopInt":3424},"geometry":{"type":"Polygon","coordinates":[[[-118.291637000512452,33.939880999892225],[-118.291639000350102,33.939056000142166],
@schwanksta
schwanksta / parse_inspections.py
Last active December 25, 2015 16:08
Parse LA County restaurant inspection data
import mechanize
from BeautifulSoup import BeautifulSoup
def parse_table(html):
"""
Returns a list of lists. Each list is a row in the table.
"""
soup = BeautifulSoup(html)
# The 9th table down the page is the one with all the info.
table = soup.findAll('table')[9]
@schwanksta
schwanksta / index.html
Created August 15, 2013 18:40
Quick dump of downtown into OSMBuildings
This file has been truncated, but you can view the full file.
<link rel="stylesheet" href="http://osmbuildings.org/js/leaflet-0.5.1/leaflet.css">
<script src="http://osmbuildings.org/js/leaflet-0.5.1/leaflet.js"></script>
<script src="http://osmbuildings.org/js/OSMBuildings-Leaflet.js"></script>
<div id="map" style="width:100%; height:100%"></div>
<script type="text/javascript">