Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| brew install python | |
| easy_install pip | |
| #install scipy use temp branch | |
| pip install git+https://github.com/minrk/scipy-1.git@accelerate | |
| #ft2build.h not found ==> | |
| pip install git+git://github.com/matplotlib/matplotlib.git |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| # United States of America Python Dictionary to translate States, | |
| # Districts & Territories to Two-Letter codes and vice versa. | |
| # | |
| # Canonical URL: https://gist.github.com/rogerallen/1583593 | |
| # | |
| # Dedicated to the public domain. To the extent possible under law, | |
| # Roger Allen has waived all copyright and related or neighboring | |
| # rights to this code. Data originally from Wikipedia at the url: | |
| # https://en.wikipedia.org/wiki/ISO_3166-2:US | |
| # |
| # encoding: utf-8 | |
| require 'rubygems' | |
| require 'builder' | |
| svg_doctype = [ | |
| :DOCTYPE, | |
| :svg, | |
| :PUBLIC, | |
| "-//W3C//DTD SVG 1.1//EN", |
| (function(){ | |
| var button_id = "download" | |
| // include this code in your page | |
| // you must have jQuery installed | |
| // you must have a link element with an id of "download" | |
| // this is limited to only one chart on the page (the first) | |
| function encode_as_link(){ | |
| // Add some critical information |
| >sp|P16250|HIS4_STRCO Phosphoribosyl isomerase A OS=Streptomyces coelicolor GN=priA PE=1 SV=1 | |
| MSKLELLPAVDVRDGQAVRLVHGESGTETSYGSPLEAALAWQRSGAEWLHLVDLDAAFGT | |
| GDNRALIAEVAQAMDIKVELSGGIRDDDTLAAALATGCTRVNLGTAALETPEWVAKVIAE | |
| HGDKIAVGLDVRGTTLRGRGWTRDGGDLYETLDRLNKEGCARYVVTDIAKDGTLQGPNLE | |
| LLKNVCAATDRPVVASGGVSSLDDLRAIAGLVPAGVEGAIVGKALYAKAFTLEEALEATS | |
| >sp|Q9WYG7|PYRF_THEMA Orotidine 5'-phosphate decarboxylase OS=Thermotoga maritima GN=pyrF PE=1 SV=1 | |
| MTPVLSLDMEDPIRFIDENGSFEVVKVGHNLAIHGKKIFDELAKRNLKIILDLKFCDIPS | |
| TVERSIKSWDHPAIIGFTVHSCAGYESVERALSATDKHVFVVVKLTSMEGSLEDYMDRIE | |
| KLNKLGCDFVLPGPWAKALREKIKGKILVPGIRMEVKADDQKDVVTLEEMKGIANFAVLG | |
| REIYLSENPREKIKRIKEMRL |
| # sinatra twitter client with oauth | |
| require 'rubygems' | |
| require 'sinatra' | |
| # use http://github.com/moomerman/twitter_oauth gem | |
| # gem sources -a http://gems.github.com | |
| # gem install moomerman-twitter_oauth | |
| require 'twitter_oauth' |
| # This is a method I use when working with slow ruby scripts that | |
| # operate on huge datasets. | |
| # | |
| # It caches the return value of a block of extremely slow code | |
| # in a file so that subsequent runs are fast. | |
| # | |
| # It's indispensable to me when doing edit-debug-edit-debug-edit | |
| # cycles on giant datasets. | |
| # loads ruby object from a cache file or (if cache file doesn't exist) runs |
| #!/usr/bin/env ruby | |
| class Array | |
| def random; self[rand(self.length)]; end | |
| end | |
| # extended by actual player classes | |
| class Player | |
| attr_reader :name | |
| def initialize(name) |