Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| # Raw transaction API example work-through | |
| # Send coins to a 2-of-3 multisig, then spend them. | |
| # | |
| # For this example, I'm using these three keypairs (public/private) | |
| # 0491bba2510912a5bd37da1fb5b1673010e43d2c6d812c514e91bfa9f2eb129e1c183329db55bd868e209aac2fbc02cb33d98fe74bf23f0c235d6126b1d8334f86 / 5JaTXbAUmfPYZFRwrYaALK48fN6sFJp4rHqq2QSXs8ucfpE4yQU | |
| # 04865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac09ef122b1a986818a7cb624532f062c1d1f8722084861c5c3291ccffef4ec6874 / 5Jb7fCeh1Wtm4yBBg3q3XbT6B525i17kVhy3vMC9AqfR6FH2qGk | |
| # 048d2455d2403e08708fc1f556002f1b6cd83f992d085097f9974ab08a28838f07896fbab08f39495e15fa6fad6edbfb1e754e35fa1c7844c41f322a1863d46213 / 5JFjmGo5Fww9p8gvx48qBYDJNAzR9pmH5S389axMtDyPT8ddqmw | |
| # First: combine the three keys into a multisig address: | |
| ./bitcoind createmultisig 2 '["0491bba2510912a5bd37da1fb5b1673010e43d2c6d812c514e91bfa9f2eb129e1c183329db55bd868e209aac2fbc02cb33d98fe74bf23f0c235d6126b1d8334f86","04865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac09ef122b1a9 |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
| class Backend(object): | |
| def __init__(self): | |
| engine = create_engine("mysql://{0}:{1}@{2}/{3}".format(options.mysql_user, options.mysql_pass, options.mysql_host, options.mysql_db) | |
| , pool_size = options.mysql_poolsize | |
| , pool_recycle = 3600 | |
| , echo=options.debug | |
| , echo_pool=options.debug) | |
| self._session = sessionmaker(bind=engine) | |
| @classmethod |
| import tornado.ioloop | |
| import tornado.web | |
| import tornado.httpserver | |
| import tornado.httputil | |
| import json | |
| class MainHandler(tornado.web.RequestHandler): | |
| def post(self): | |
| # do something useful | |
| name = self.get_argument('foo') |
| import tornado.ioloop | |
| import tornado.web | |
| import tornado.httpserver | |
| import tornado.httputil | |
| import json | |
| class MainHandler(tornado.web.RequestHandler): | |
| def post(self): | |
| # do something useful | |
| name = self.get_argument('foo') |
| worker_processes 2; | |
| error_log /var/log/nginx/error.log; | |
| pid /var/run/nginx.pid; | |
| events { | |
| worker_connections 1024; | |
| use epoll; | |
| } |
| from tornado import ioloop | |
| from tornado import iostream | |
| import socket | |
| class Envelope(object): | |
| def __init__(self, sender, rcpt, body, callback): | |
| self.sender = sender | |
| self.rcpt = rcpt[:] | |
| self.body = body | |
| self.callback = callback |
| class Application(tornado.web.Application): | |
| def __init__(self): | |
| tornado.web.Application.__init__(self, handlers, **settings) | |
| self.db_session = db_session | |
| self.redis = redis.StrictRedis() | |
| self.session_store = RedisSessionStore(self.redis) | |
| class BaseHandler(tornado.web.RequestHandler): |
| worker_processes 2; | |
| error_log /var/log/nginx/error.log; | |
| pid /var/run/nginx.pid; | |
| events { | |
| worker_connections 1024; | |
| use epoll; | |
| } |