Skip to content

Instantly share code, notes, and snippets.

View albertsun's full-sized avatar

Albert Sun albertsun

View GitHub Profile
# Make sure ctypes can find simple tiles
import ctypes
from ctypes import *
from ctypes.util import find_library
library = ctypes.CDLL(find_library("simple-tiles"))
simplet_map_new = library.simplet_map_new
simplet_map_new.restype = POINTER(c_void_p)
map_p = simplet_map_new()
print(type(map_p))
@albertsun
albertsun / gist:1820839
Created February 13, 2012 22:00
kind of fun
/* run on
http://www.nytimes.com/interactive/2012/02/13/us/politics/2013-budget-proposal-graphic.html
*/
setInterval(function(){ console.log("grav .3"); nytg.c.force.gravity(0.05).start();}, 3000);
setTimeout(function(){
setInterval(function() { console.log("grav 0"); nytg.c.force.gravity(0).start(); }, 3000)
}, 2000);
setInterval(function(){ console.log("grav .3"); nytg.c.force.gravity(0.05).start();}, 3000);
setTimeout(function(){
setInterval(function() { console.log("grav 0"); nytg.c.force.gravity(0).start(); }, 3000)
@albertsun
albertsun / .tmux.conf
Created February 13, 2012 19:27
tmux conf
unbind C-b
set -g prefix `
set -g default-terminal "screen-256color"
set -g status-bg black
set -g status-fg white
set -g status-interval 60
set -g status-left-length 30
set -g status-left '#[fg=green](#S) #(whoami)@#H#[default]'
set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=blue]%H:%M#[default]'
set-window-option -g window-status-current-bg red
@albertsun
albertsun / dostuff.py
Created February 12, 2012 21:33
management command
from django.core.management.base import NoArgsCommand, CommandError
from django.core import management
class Command(NoArgsCommand):
help="Run a command"
def get_version(self):
return "0.1"
def handle_noargs(self, **options):
@albertsun
albertsun / gist:1696891
Created January 29, 2012 02:45 — forked from brianboyer/gist:1696819
Lion dev environment notes
Homebrew (https://github.com/mxcl/homebrew/wiki/installation)
brew install postgres
brew install gdal --with-postgres (EDIT THE FORMULA FIRST, see https://github.com/mxcl/homebrew/issues/8301)
brew install postgis
edit /etc/paths to put /usr/local/bin on top, so that lion's psql doesnt win
PostGIS templates (based on https://wiki.archlinux.org/index.php/PostGIS)
createdb template_postgis -E UTF8
createlang plpgsql template_postgis
psql -d template_postgis -f /usr/local/share/postgis/postgis.sql
/*jslint white: false, debug: false, devel: true, onevar: false, plusplus: false, browser: true, bitwise: false */
/*global jQuery: false, $: false, Raphael: false, window: false, Box: false, tmpl: false */
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@albertsun
albertsun / models.py
Created November 1, 2011 21:10
census data models.py
from django.contrib.gis.db import models
# generated by running ogrinspect against shapefiles
# ./manage.py ogrinspect ../state_tabblock_shapefiles/tl_2010_01_tabblock10/tl_2010_01_tabblock10.shp CensusBlock --srid=4326 --mapping --multi
# ./manage.py ogrinspect ../state_tract_shapefiles/tl_2010_01_tract10/tl_2010_01_tract10.shp CensusTract --srid=4326 --mapping --multi
class CensusBlock(models.Model):
statefp10 = models.CharField(max_length=2)
countyfp10 = models.CharField(max_length=3)
@albertsun
albertsun / views.py
Created November 1, 2011 21:10
geojson tiles views.py
from redistricting.apps.features.models import CensusBlock, CensusTract, CensusCounty, DataBlock
from redistricting.utils import gmerc
from django.http import HttpResponse, Http404, HttpResponseForbidden
from django.contrib.gis.geos import GEOSGeometry
from django.shortcuts import render_to_response
from django.template.loader import render_to_string
from django.template import RequestContext
@albertsun
albertsun / query.js
Created November 1, 2011 21:09
LoadCensusBlockTiles
/* Author: Albert Sun
WSJ.com News Graphics
*/
/*jslint white: false, nomen: false, debug: false, devel: true, onevar: false, plusplus: false, browser: true, bitwise: false, es5: true, maxerr: 200 */
/*global jQuery: false, $: false, log: false, window: false, WSJNG: false, _: false, google: false, localStorage: false */
// Necessary functions
if (!window.typeOf) {
window.typeOf = function(b){var a=typeof b;if(a==="object")if(b){if(b instanceof Array)a="array"}else a="null";return a};