start new:
tmux
start new with session name:
tmux new -s myname
| from math import log, floor, pow | |
| class MinMaxHeap(object): | |
| """an implementation of min-max heap using an array, | |
| which starts at 1 (ignores 0th element) | |
| """ | |
| def __init__(self, array=[]): | |
| super(MinMaxHeap, self).__init__() |
| # Chained comparisons in Ruby | |
| # inspired by http://coffeescript.org/#comparisons | |
| # as well as http://refactormycode.com/codes/1284 | |
| [:<, :>, :<=, :>=].each do |operator| | |
| [Float, Fixnum, Rational, Comparable].each do |klass| | |
| klass.class_eval do | |
| alias_method "_#{operator}", operator | |
| define_method operator do |rhs| | |
| send("_#{operator}", rhs) && rhs |