Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| #!/bin/bash | |
| # virtualenv-auto-activate.sh | |
| # | |
| # Installation: | |
| # Add this line to your .bashrc or .bash-profile: | |
| # | |
| # source /path/to/virtualenv-auto-activate.sh | |
| # | |
| # Go to your project folder, run "virtualenv .venv", so your project folder | |
| # has a .venv folder at the top level, next to your version control directory. |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| abhi@Laptop:~/forticlientsslvpn$ ls -l | |
| total 2392 | |
| -rwxr-xr-x 1 abhi abhi 2442292 2009-03-10 09:35 forticlientsslvpn | |
| drwxr-xr-x 2 abhi abhi 4096 2012-04-25 16:57 helper | |
| abhi@Laptop:~/forticlientsslvpn$ cd helper/ | |
| abhi@Laptop:~/forticlientsslvpn/helper$ ls -l | |
| total 2140 | |
| -rwxr-xr-x 1 abhi abhi 902 2009-03-10 09:35 cleanup.linux.sh | |
| -rw-r--r-- 1 abhi abhi 11 2009-03-10 09:35 config |
| # based on the import script by icebreaker, which is based on mojombo's | |
| # https://github.com/mojombo/jekyll/blob/master/lib/jekyll/migrators/wordpress.rb | |
| # https://gist.github.com/303570 | |
| # edited to rewrite image URLs to use my CloudFront URL | |
| require 'rubygems' | |
| require 'sequel' | |
| require 'fileutils' | |
| require 'yaml' |
| # -*- coding: utf-8 -*- | |
| require 'fileutils' | |
| require 'date' | |
| require 'yaml' | |
| require 'uri' | |
| require 'rexml/document' | |
| include REXML | |
| doc = Document.new File.new(ARGV[0]) |
| 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", |
| """ | |
| do ... | |
| pip install boto, turbomail | |
| echo "just a test" > README.txt | |
| ... first | |
| """ | |
| import sys | |
| from boto import connect_ses | |
| FROM = "[email protected]" | |
| TO = "[email protected]" |
| # /etc/postfix/main.cf | |
| smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) | |
| biff = no | |
| append_dot_mydomain = no | |
| readme_directory = no | |
| # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns | |
| Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
| Read 1 MB sequentially from memory 250,000 ns 0.25 ms | |
| Round trip within same datacenter 500,000 ns 0.5 ms | |
| Read 1 MB sequentially from SSD 1,000,000 ns 1 ms 4X memory |
| import yaml | |
| import yaml.constructor | |
| try: | |
| # included in standard lib from Python 2.7 | |
| from collections import OrderedDict | |
| except ImportError: | |
| # try importing the backported drop-in replacement | |
| # it's available on PyPI | |
| from ordereddict import OrderedDict |