Skip to content

Instantly share code, notes, and snippets.

View davclark's full-sized avatar

Dav Clark davclark

View GitHub Profile
@davclark
davclark / vega.json
Created December 24, 2013 21:41
Example vega.json file that doesn't work
{
"axes": [],
"data": [
{
"format": {
"feature": "world-countries",
"type": "topojson"
},
"name": "countries",
"transform": [
@davclark
davclark / ftrain_treeify.py
Created November 11, 2012 21:04
An apology to Paul
def ftrain(l):
'''Convert an iterable to a nested list based on ordered comparison'''
i = iter(l)
tree, seen = ftrain_helper(i, i.next())
# This might not be the desired behavior, but it's not terrible
# You could also emit a warning or an exception here
while(not seen is None):
rest_tree, seen = ftrain_helper(i, seen)
tree = [tree] + rest_tree
return tree