This gist holds a few images used in the chroma.js wiki.
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
""" | |
computes the center of a multi-polygon | |
""" | |
def shape_center(shape): | |
""" | |
computes the center of gravity of a shapefile multi-polygon | |
shape must be an instance of shapefile._Shape of the Python Shapefile Library | |
http://packages.python.org/Python%20Shapefile%20Library/ | |
Polygon class comes from here | |
http://pypi.python.org/pypi/Polygon/1.17 |
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 3 columns, instead of 1. in line 1.
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
indic_na,unit,geo\time 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 | |
AT11 11523.9 11771.1 12318.3 13027.5 13923.5 13937.3 14402.1 15052.7 16057.0 16840.4 17825.5 18470.1 | |
AT12 12871.0 13021.4 13665.6 14525.4 15537.4 15403.4 15765.8 16322.2 16928.0 17831.3 18813.9 19544.9 | |
AT13 14683.3 14857.3 15374.7 16069.4 17056.0 16630.1 16928.8 17261.8 17699.9 18279.5 18977.4 19485.4 | |
AT21 11795.8 11922.2 12421.4 13006.9 14042.2 13967.3 14393.7 14954.2 15521.1 16523.0 17420.1 18127.9 | |
AT22 12031.6 12222.0 12755.1 13429.9 14425.1 14242.8 14685.7 15180.8 15686.9 16638.9 17560.7 18347.0 | |
AT31 12460.4 12643.3 13179.3 13796.6 14869.5 14654.6 15008.0 15522.6 16281.2 17261.5 18266.9 18949.4 | |
AT32 12879.1 12985.2 13544.3 14257.6 15264.9 15007.9 15416.9 15921.1 16505.8 17563.2 18509.2 19289.0 | |
AT33 12029.3 12018.6 12697.8 13400.2 14507.7 14402.3 15030.8 15632.8 16203.9 17043.9 17868.1 18588.3 | |
AT34 12591.4 12620.3 13488.1 14107.7 15568.7 15154.4 15641.8 16167.9 16716.1 17793.2 18803.9 19367.5 |
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
# coding=utf-8 | |
from wikitools import wiki | |
from wikitools import api | |
site = wiki.Wiki('http://de.wikipedia.org/w/api.php') | |
# | |
# returns a list of categories | |
# | |
def getPageCategories(pages): |
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
/** | |
* This is the light version of Danial Wachsstock's jQuery based CSS parser | |
* http://bililite.com/blog/2009/01/16/jquery-css-parser/#parserdetails | |
* | |
* Everything is removed but the core css2object parsing | |
* | |
* Usage is straight forward: | |
* | |
* $.parseCSS('body { background: red; font-weight: 300 }'); | |
* // returns { 'body': { 'background': 'red', 'font-weight': 300 } } |
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::bind ?= (scope) -> | |
_function = this | |
() -> | |
_function.apply scope, arguments | |
$.ender | |
loadAssets: (opt) -> | |
data = {} | |
cnt = 0 | |
for id of opt.assets |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 twitter import Twitter, OAuth | |
import json | |
auth_token = 'xxxxxxxxxxxxxx' | |
auth_token_secret = 'xxxxxxxxxxxxxxxx' | |
consumer_key = 'xxxxxxxxxxxxxxxx' | |
consumer_secret = 'xxxxxxxxxxxxxxxx' | |
user = "driven_by_data" |
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
{ | |
"proj": { | |
"id": "satellite", | |
"up": 23, | |
"dist": 1.15 | |
}, | |
"layers": [{ | |
"id": "regions", | |
"src": "italy-nuts2.shp", | |
"attributes": [{ "src": "NUTS_ID", "tgt": "nuts2" }] |
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 csv, codecs, cStringIO | |
class UTF8Recoder: | |
""" | |
Iterator that reads an encoded stream and reencodes the input to UTF-8 | |
""" | |
def __init__(self, f, encoding): | |
self.reader = codecs.getreader(encoding)(f) | |
def __iter__(self): |