Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
import sys, os.path, logging | |
try: | |
import sysconfig | |
except ImportError: | |
sysconfig = None | |
def warn_on_path_overlap(): | |
""" |
Copyright (c) 2012, Miguel Araujo | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright notice, this | |
list of conditions and the following disclaimer. | |
* Redistributions in binary form must reproduce the above copyright notice, |
$less-column-width: 68px; | |
$less-gutter-width: 24px; | |
@function column-width($columns) { | |
@return ($less-column-width * $columns) + ($less-gutter-width * ($columns - 1)); | |
} | |
@function grid-padding-px($columns) { | |
@if $columns == 10 { | |
@return 48px; |
#!/bin/sh | |
# | |
# Copyright (c) 2011, Jonas Obrist | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are met: | |
# * Redistributions of source code must retain the above copyright | |
# notice, this list of conditions and the following disclaimer. | |
# * Redistributions in binary form must reproduce the above copyright |
import datetime | |
import simplejson | |
from pymongo.dbref import DBRef | |
from pymongo.objectid import ObjectId | |
class MongoEngineEncoder(simplejson.JSONEncoder): | |
"""Handles Encoding of ObjectId's""" |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Spiral</title> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script> | |
<style type="text/css"> | |
body { | |
font: 10px sans-serif; | |
} |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
# python file | |
import ConfigParser | |
config = ConfigParser.ConfigParser() | |
config.read('settings.cfg') | |
API_KEY = config.get('Params', 'api_key') | |
BASE_URL = config.get("Params", 'base_url') | |
# settings.cfg | |
[Params] |
This article is now published on my website: Prefer Subshells for Context.
# Setup dir and repo | |
mkdir underscore-string | |
cd underscore-string | |
git init | |
# Make some files we'll need | |
touch README.md package.js smart.json | |
# Add the submodule and checkout the desired branch | |
git submodule add git://github.com/epeli/underscore.string.git lib/underscore.string |