Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!/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) |
# 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 |
# 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' |
>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 |
(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 |
# encoding: utf-8 | |
require 'rubygems' | |
require 'builder' | |
svg_doctype = [ | |
:DOCTYPE, | |
:svg, | |
:PUBLIC, | |
"-//W3C//DTD SVG 1.1//EN", |
# 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 | |
# |
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 |
# (c) 2012 Andreas Mueller amueller@ais.uni-bonn.de | |
# License: BSD 2-Clause | |
# | |
# See my blog for details: http://peekaboo-vision.blogspot.com | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.animation import FuncAnimation |