Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
stage { "pre": before => Stage["main"] } | |
class python { | |
package { | |
"build-essential": ensure => latest; | |
"python": ensure => "2.6.6-2ubuntu1"; | |
"python-dev": ensure => "2.6.6-2ubuntu1"; | |
"python-setuptools": ensure => "latest"; | |
} | |
exec { "easy_install pip": | |
path => "/usr/local/bin:/usr/bin:/bin", |
#!/usr/bin/env python | |
"""html2text: Turn HTML into equivalent Markdown-structured text.""" | |
__version__ = "2.35" | |
__author__ = "Aaron Swartz ([email protected])" | |
__copyright__ = "(C) 2004-2008 Aaron Swartz. GNU GPL 3." | |
__contributors__ = ["Martin 'Joey' Schulze", "Ricardo Reyes"] | |
# TODO: | |
# Support decoded entities with unifiable. | |
# Relative URL resolution |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Jed Schmidt <http://jed.is> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
from django.db.models.fields import Field | |
import types | |
def patch_model(model_to_patch, class_to_patch_with): | |
""" | |
Adapted from http://www.ravelsoft.com/blog/2010/patchmodel-hacky-solution-extending-authuser-class | |
Monkey patch a django model with additional or replacement fields and methods. | |
All fields and methods that didn't exist previously are added. |
# can be used to hide email addresses in the html source of Web sites from spiders | |
def html_encode(email): | |
''' | |
Takes a unicode string as only parameter and returns | |
a sequence of html encoded chars. | |
>>> html_encode(u"[email protected]") | |
'test@website.org' | |
''' |
# -*- coding: utf-8 -*- | |
""" | |
This scripts reqire a third party module 'requests'. | |
You can get it from PyPI, i.e. you can install it using | |
easy_install or pip. | |
http://docs.python-requests.org/en/v0.10.4/ | |
Original source code is written by shin1ogawa, which is in Java. |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
This article is now published on my website: Prefer Subshells for Context.
sudo apt-get install build-essential libsqlite3-dev zlib1g-dev libncurses5-dev libgdbm-dev libbz2-dev libreadline5-dev libssl-dev libdb-dev | |
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz | |
tar -xzf Python-2.7.3.tgz | |
cd Python-2.7.3 | |
./configure --prefix=/usr --enable-shared | |
make | |
sudo make install | |
cd .. |
Copyright the authors of Honcho and/or Ben Lopatin | |
Licensed for reuse, modification, and distribution under the terms of the MIT license |