Skip to content

Instantly share code, notes, and snippets.

func romanify(n: Int) -> String {
let pivotRomans = [
1: "I",
4: "IV",
5: "V",
9: "IX",
10: "X",
40: "XL",
50: "L",
90: "XC",
@avihut
avihut / hashtree.rb
Created April 21, 2013 19:52
Tree from Hash
class Tree
attr_accessor :children, :node_name
def initialize(name, children=[])
@node_name = name
@children = children
end
def visit_all(&block)
visit &block
@avihut
avihut / auto_optparse.py
Created June 27, 2012 14:31
optparse decorator
from optparse import OptionParser, Option
from functools import wraps
my_parser = OptionParser(usage = "Usage: %prog [options]")
approve_option = Option("-a", "--approve", default = False, action = "store_true", \
help = "Must be provided along with disruptive options.")
class optparse_option(object):
# Can also accept 'ask_for_approval' argument. By default it's False.