Skip to content

Instantly share code, notes, and snippets.

View onyxfish's full-sized avatar

Christopher Groskopf onyxfish

View GitHub Profile
@onyxfish
onyxfish / map.py
Created March 25, 2011 19:33
Django management command to construct a KML map from the Boundary Service
from colorsys import hsv_to_rgb
import json
import logging
log = logging.getLogger('electioncenter.lib.kml')
import struct
from django.contrib.gis.geos import GEOSGeometry
def hsv_to_kml_hex(h, s, v):
"""
@onyxfish
onyxfish / csvkit_tutorial.sh
Created April 17, 2011 23:23
Full script for the csvkit tutorial (proof of process repeatability)
#!/bin/bash
###################
# Getting started #
###################
# Setup a workspace
mkdir va_benefits
cd va_benefits
@onyxfish
onyxfish / render.sh
Created June 10, 2011 14:45
How to generate tiles from TileMill config (ie. bypass mbtiles)
/TileMill/bin/carto map.mml > map.xml
python render_tiles.py map.xml .tiles/ 42.05 -88 41.6 -87.5 11 16 2
@onyxfish
onyxfish / test_cache.py
Created June 28, 2011 21:30
Python unittest-based cache testing rig for Varnish + Wordperss
#!/usr/bin/env python
import cookielib
import json
import re
import random
import unittest
import requests
from wordpress_xmlrpc import Client, WordPressComment, WordPressPost
@onyxfish
onyxfish / newsapps-varnish-admin.php
Created June 28, 2011 21:32
Newsapps Varnish plugin for Wordpress (handles targeted invalidation)
<?php
if($_POST['varnish_hidden'] == 'Y') {
//Process form data
$varnish_server1 = (!isset($_POST['varnish_server1'])? '': $_POST['varnish_server1']);
update_site_option('varnish_server1', $varnish_server1);
$varnish_server2 = (!isset($_POST['varnish_server2'])? '': $_POST['varnish_server2']);
update_site_option('varnish_server2', $varnish_server2);
$varnish_server3 = (!isset($_POST['varnish_server3'])? '': $_POST['varnish_server3']);
@onyxfish
onyxfish / wordpress.vcl
Created June 28, 2011 21:34
ChicagoNow Varnish configuration (development version)
backend app1 {
.host = "127.0.0.1";
.port = "8000";
}
acl purge {
"127.0.0.1";
"::1";
}
@onyxfish
onyxfish / fabfile.py
Created August 12, 2011 19:09
Fabric configuration for advanced mapping w/ TileMill and invar
import os
import re
from fabric.api import *
import yaml
"""
Base configuration
"""
# Ubuntu
@onyxfish
onyxfish / enb_schema.csv
Created August 23, 2011 13:46
An in2csv (csvkit) schema for parsing the Bureau of Labor Statistics Quarterly Census of Employment and Wages flat-files (ftp://ftp.bls.gov/pub/special.requests/cew/)
column start length
survey_prefix 0 3
area_code 3 5
datatype_code 8 1
size_code 9 1
ownership_code 10 1
naics_industry_code 11 6
year 17 4
aggregation_level 21 2
first_quarter_status_code 23 1
@onyxfish
onyxfish / 10periodic
Created November 18, 2011 03:15
Configuration files for hacktyler_project
APT::Periodic::Enable "1";
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "5";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::RandomSleep "1800";
@onyxfish
onyxfish / results.txt
Created February 7, 2012 16:48
Stupid Komen graphic
First order approximation of this image's actual slice size using pixel counts:
https://motherjones.com/files/images/komen_expenses_300px.jpg
Graphic had numbers painted out and text cropped before processing with stupid.py.
Pixel counts, l to r:
(255, 162, 194, 255) 1602
(177, 178, 180, 255) 392