Skip to content

Instantly share code, notes, and snippets.

View JulieGoldberg's full-sized avatar

Julie Goldberg JulieGoldberg

View GitHub Profile
@JulieGoldberg
JulieGoldberg / censusreporter_acs_tables_to_user_friendly_tables.sql
Created May 27, 2020 23:50
Approach for pulling ACS data from CensusReporter database into user-friendly tables in our own schema. By using the ACS documentation, this approach can be used to pull a lot of other sorts of data in useful ways.
--DROP SCHEMA IF EXISTS acs2018_5yr_extraction CASCADE;
CREATE SCHEMA acs2018_5yr_extraction;
CREATE TABLE acs2018_5yr_extraction.population__bg_tract_county AS (
SELECT gh.sumlevel, CONCAT(state, county, tract, blkgrp) AS geoid, b01003001 AS population, stusab
FROM acs2018_5yr.geoheader gh
JOIN acs2018_5yr.b01003 b
ON gh.geoid = b.geoid
WHERE gh.sumlevel = 150
@JulieGoldberg
JulieGoldberg / GroupedModelChoiceField
Created April 9, 2015 00:25
Display OptGroup options from a Django ModelChoiceField
from django import forms
class GroupedModelChoiceField(forms.ModelChoiceField):
def optgroup_from_instance(self, obj):
return ""
def __choice_from_instance__(self, obj):
return (obj.id, self.label_from_instance(obj))
@JulieGoldberg
JulieGoldberg / DynamicLayersTileServer
Last active December 25, 2015 05:39
A decorator around the WSGITileServer that allows for custom tilestache configuration.
from TileStache import WSGITileServer, splitPathInfo
import re
#
# Decorator for the WSGITileServer that allows for custom tilestache configuration.
#
# Takes in a tilestache config file and a series of parameter names. Any that are present will be sent to the
# provider and the cache classes on each call.