Skip to content

Instantly share code, notes, and snippets.

View shawnbot's full-sized avatar
🎹

Shawn Allen shawnbot

🎹
View GitHub Profile
import sys, csv, simplejson
from optparse import OptionParser
parser = OptionParser(usage='usage: %prog [options] csv_file json_file\n' """
Merges data from a comma- (or tab-, pipe-, etc.) separated file into the
properties of GeoJSON features by joining on a foreign key, and prints the
resulting GeoJSON feature collection to stdout.""")
parser.add_option('-f', '--fk', dest='fk', default='id',
help='The CSV column and GeoJSON feature property name on '
'which to join. This may either be a single string, or '
#!/bin/sh
FILE=`mktemp -t webview`
pbpaste >> $FILE
mv "$FILE" "$FILE.html"
open -a Safari "$FILE.html"
@shawnbot
shawnbot / index.html
Created November 3, 2011 00:24
Polymaps bad projection example
<html>
<head>
<title>Polymaps don't like these dots</title>
<script type="text/javascript" src="https://github.com/simplegeo/polymaps/raw/master/polymaps.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<style type="text/css">
html, body, #map {
position: absolute;
width: 100%;
height: 100%;
@shawnbot
shawnbot / modestmaps.js.diff
Created November 11, 2011 03:45
modestmaps.js diff
diff --git a/modestmaps.js b/modestmaps.js
index 869c650..dd50831 100644
--- a/modestmaps.js
+++ b/modestmaps.js
@@ -134,7 +134,7 @@ if (!com) {
toKey: function() {
/* there used to be a clever hash function here but there were collisions.
TODO: optimize, but test for collisions properly :) */
- return [ Math.floor(this.zoom), Math.floor(this.column), Math.floor(this.row) ].join(',');
+ return [ 'c', Math.floor(this.zoom), Math.floor(this.column), Math.floor(this.row) ].join('_');
@shawnbot
shawnbot / index.html
Created February 3, 2012 00:44
U.S. Unemployment
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>U.S. Unemployment</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.min.js"></script>
<style type="text/css">
body {
margin: 0;
padding: 2em;
@shawnbot
shawnbot / google.js
Created March 6, 2012 01:00
Stamen tiles in popular map engines
// replace "toner" here with "terrain" or "watercolor"
var layer = "toner";
var map = new google.maps.Map(document.getElementById("element_id"), {
center: new google.maps.LatLng(37.7, -122.4),
zoom: 12,
mapTypeId: layer,
mapTypeControlOptions: {
mapTypeIds: [layer]
}
});
@shawnbot
shawnbot / index.html
Created March 21, 2012 19:36
modestmaps-js zoom drift
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="https://raw.github.com/stamen/modestmaps-js/master/modestmaps.js"></script>
<style type="text/css">
html, body, #map {
position: absolute;
width: 100%;
height: 100%;
@shawnbot
shawnbot / queue.py
Created June 20, 2012 23:09
SQS Queue pusher
#!/usr/bin/env python
import optparse
parser = optparse.OptionParser(usage="%prog -k KEY -s SECRET -q QUEUE msg msg msg")
parser.add_option("--key", "-k", dest="key")
parser.add_option("--secret", "-s", dest="secret")
parser.add_option("--queue", "-q", dest="queue")
options, args = parser.parse_args()
from boto.sqs.connection import SQSConnection
@shawnbot
shawnbot / xterm-256color.md
Last active March 22, 2024 16:26
Make OS X Terminal respect 256 colors in screen

1. Ensure that Terminal declares itself as "xterm-256color"

Under Terminal > Preferences... > (Profile) > Advanced, "Declare terminal as:" should be set to xterm-256color.

2. Build a version of screen that supports 256 colors

This is easy with homebrew:

brew install screen
@shawnbot
shawnbot / request.js
Created October 31, 2012 20:52
A lame little JSONP implementation
var request = function(options) {
var aborted = false,
abort = function() {
aborted = true;
};
switch (options.type) {
case "jsonp":
// a very simplistic JSON-P implementation
var script = document.createElement("script"),