Skip to content

Instantly share code, notes, and snippets.

@csessig86
csessig86 / IA_poverty
Created December 14, 2011 02:59
Poverty rates across IA map - Uses Google's mouseover effect to change polygon colors
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>WCFCourier.com - Poverty in Iowa</title>
<style>
body { font-family: Arial, sans-serif; }
@csessig86
csessig86 / Iowa caucus location scraper
Created January 4, 2012 23:00
This Python code goes through the Iowa GOP's website (actually the info was pulled from the GOP site and posted on my personal site after I cleaned it up a bit), scrapes caucus locations and exports it into a TSV. Based on a tutorial from BuzzData
# Scraper based on this tutorial from BuzzData:
# http://blog.buzzdata.com/post/11871523667/how-to-scrape-toronto-data-a-basic-tutorial
import urllib2
from BeautifulSoup import BeautifulSoup
# Create a file called "ward_pop.tsv" where we'll save our data
f = open('caucus_locations02.tsv', 'w')
# Make a header row: locationname (tab) precinct (tab) address (tab) address2
@csessig86
csessig86 / GOP Caucus Results
Created January 6, 2012 20:55
Map of GOP caucus/primary dates and results
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Lee Enterprises - GOP Caucus/Primary Results</title>
<style>
body { height: 650px; width:610px;
font-family: Arial, sans-serif; }
@csessig86
csessig86 / us_heroin
Created January 21, 2012 22:17
Map of heroin usage rates in the U.S. Online at: http://wcfcourier.com/app/special/us_heroin/
# Uses Albert Sun's polygon library - https://github.com/albertsun/gmap-features
<!doctype html>
<head>
<title>WCFCourier.com - Heroin in the U.S.</title>
<style type="text/css">
body { font-family: Arial, sans-serif; }
#map_canvas {
height: 600px;
width: 620px;
@csessig86
csessig86 / national_register
Created February 6, 2012 19:57
Map of historic places in Eastern Iowa
## View online: http://wcfcourier.com/app/special/national_register/
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>WCFCourier.com - Historic places in Eastern Iowa</title>
<style>
@csessig86
csessig86 / gist:1754481
Created February 6, 2012 20:05
Function initialize - FT (For blog)
function initialize() {
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(42.5, -92.2),
zoom: 10,
minZoom: 8,
maxZoom: 15,
mapTypeId: google.maps.MapTypeId.TERRAIN
});
loadmap();
}
@csessig86
csessig86 / gist:1754509
Created February 6, 2012 20:10
Multiple Fusion Tables layers (For blog
function loadmap() {
layer2 = new google.maps.FusionTablesLayer({
query: {
select: 'geometry',
from: 2814002
}
});
layer2.setMap(map);
layer = new google.maps.FusionTablesLayer({
@csessig86
csessig86 / gist:1754598
Created February 6, 2012 20:25
Rollover effects for Fusion Tables (For blog)
layer.enableMapTips({
select: "'Number', 'Tract', 'County', 'Population for whom poverty status is determined - Total', 'Population for whom poverty status is determined - Below poverty level', 'Population for whom poverty status is determined - Percent below poverty level', 'One race - White', 'One race - Black', 'Other', 'Two or more races'", // list of columns to query, typially need only one column.
from: 2415095, // fusion table name
geometryColumn: 'geometry', // geometry column name
suppressMapTips: true, // optional, whether to show map tips. default false
delay: 1, // milliseconds mouse pause before send a server query. default 300.
tolerance: 6 // tolerance in pixel around mouse. default is 6.
});
//here's the pseudo-hover
@csessig86
csessig86 / gist:1755142
Created February 6, 2012 21:49
FusionTips (For blog)
FusionTipOverlay.prototype.onAdd = function() {
var div = document.createElement('DIV');
div.style.border = "1px solid #999999";
div.style.opacity = ".85";
div.style.position = "absolute";
div.style.whiteSpace = "nowrap";
div.style.backgroundColor = "#ffffff";
div.style.fontSize = '13px';
div.style.padding = '10px';
div.style.fontWeight = 'bold';
@csessig86
csessig86 / gist:1755522
Created February 6, 2012 22:36
Link to Fusiontips JS (For blog)
<script type="text/javascript" src="fusiontips.js"></script>