This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var clrs = [colorbrewer.Reds[7][3], colorbrewer.Reds[7][5], colorbrewer.Reds[7][7]]; | |
var color = d3.scale.quantize() | |
.domain(minmax) | |
.range(clrs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.management.base import BaseCommand, CommandError | |
from django.core.cache import cache | |
from django.test.client import Client | |
from django.test.client import RequestFactory | |
class Command(BaseCommand): | |
def handle(self, *args, **options): | |
cache.clear() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" charset="utf-8"> | |
var map = null; | |
var ft_id = 1964047; | |
var precinct_ft = 1979379; | |
var directionsService = new google.maps.DirectionsService(); | |
var directionsDisplay = new google.maps.DirectionsRenderer(); | |
var geocoder = new google.maps.Geocoder(); | |
var cur_marker = null; | |
var selected_address = ""; | |
var layer = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.gis.geos import Point | |
from django.contrib.gis.gdal import DataSource | |
import random | |
import csv | |
def dotdensity(shape_id_key=None, col_id_key=None,\ | |
shapefilepath=None, datafilepath=None, outputfilepath=None, filter_map=None): | |
reader = list(csv.reader(open(datafilepath, 'rb'))) | |
header = reader[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from BeautifulSoup import BeautifulSoup | |
from datetime import datetime | |
import pdb | |
''' | |
To use: | |
num_pages_to_follow = 85 | |
scraper = EmmaScraper('CAP APPREC') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
scraper_urls = [ | |
'http://foo.net/TESTDIR/TEST.pdf', | |
'http://foo.net/TESTDIR/TEST2.pdf' | |
] | |
p_session = requests.session() | |
for surl in scraper_urls: | |
content = p_session.get(surl).content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def key_str(term): | |
''' | |
remove as much from the string as possible while | |
preserving its meaning | |
''' | |
term = term.strip() | |
obv = term.split(' ') | |
obv = map(lambda x: x.strip(), obv) | |
term = ' '.join(obv) | |
term = term.lower() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MapLegendView(el, values, headerText, footerText){ | |
/* | |
Class to dynamically generate a legend for a given map | |
el: containing element | |
values: array of key, value objects | |
ex: var legendItems = [ | |
{text: 'text to display next to color', colorStr: 'color of legend item (hex preferred)'}, | |
] | |
you'll want your container element and map to be contained in the same parent element | |
and to position the containing element to float over the map like so: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find DIR_PATH -type f -mmin +4320 -delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type='text/javascript' src='http://media.baycitizen.org/js/jquery-1.4.2.min.js'></script> | |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> | |
<script type="text/javascript" charset="utf-8"> | |
var ft_id = INSERT_FUSION_TABLE_ID; | |
function Legend(controlDiv, name, title) { | |
// Set CSS for the control border | |
var controlUI = document.createElement('DIV'); | |
controlUI.style.cursor = 'default'; | |
controlUI.style.textAlign = 'left'; |