Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| #!/bin/bash | |
| LINES=$(tput lines) | |
| COLUMNS=$(tput cols) | |
| declare -A snowflakes | |
| declare -A lastflakes | |
| clear |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import urllib2 | |
| gh_url = 'https://api.github.com' | |
| req = urllib2.Request(gh_url) | |
| password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm() |
| import struct | |
| import SocketServer | |
| from base64 import b64encode | |
| from hashlib import sha1 | |
| from mimetools import Message | |
| from StringIO import StringIO | |
| class WebSocketsHandler(SocketServer.StreamRequestHandler): | |
| magic = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11' |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| function JSON_stringify(s, emit_unicode) | |
| { | |
| var json = JSON.stringify(s); | |
| return emit_unicode ? json : json.replace(/[\u007f-\uffff]/g, | |
| function(c) { | |
| return '\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4); | |
| } | |
| ); | |
| } |
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 python | |
| # -*- coding: utf-8 -*- | |
| """Simple async crawler/callback queue based on gevent.""" | |
| import traceback | |
| import logging | |
| import httplib2 | |
| import gevent |
| from gcrawler import GCrawler, Downloader | |
| import unittest | |
| import urllib2 | |
| import logging | |
| import traceback | |
| from datetime import datetime | |
| import re | |
| logging.basicConfig(level=logging.DEBUG) |
| import gevent | |
| from gevent import monkey, queue | |
| monkey.patch_all() | |
| import urllib2 | |
| from time import sleep | |
| import traceback | |
| import logging |
| import gevent | |
| from gevent import monkey, queue | |
| monkey.patch_all() | |
| import urllib2 | |
| from time import sleep | |
| import traceback | |
| import logging |