Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
from gevent import monkey | |
monkey.patch_all() | |
import gevent.pool | |
import os | |
import random | |
import time | |
import datetime | |
from multiprocessing import Semaphore, Array |
! Hybrid Terminal Colours. Uses the palette from Tomorrow-Night: | |
! https://github.com/chriskempson/tomorrow-theme/blob/master/vim/colors/Tomorrow-Night.vim | |
! vim: ft=xdefaults | |
*background: #1D1F21 | |
*foreground: #C5C8C6 | |
! black | |
*color0: #282A2E | |
*color8: #373B41 | |
! red |
body { | |
font-family: Helvetica, arial, sans-serif; | |
font-size: 14px; | |
line-height: 1.6; | |
padding-top: 10px; | |
padding-bottom: 10px; | |
background-color: white; | |
padding: 30px; } | |
body > *:first-child { |
import urllib2 | |
def xiami_decode(s): | |
s = s.strip() | |
if not s: | |
return False | |
result = [] | |
line = int(s[0]) | |
rows = len(s[1:]) / line | |
extra = len(s[1:]) % line |
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
wget -q -O - https://raw.github.com/gist/2204072/install_tmux_1.6_on_ubuntu_10.04.sh | sudo bash |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#! -*- Coding: utf-8 -*- | |
from gevent import monkey | |
monkey.patch_all() | |
import gevent | |
import time | |
from envoy import run | |
from sys import exit, argv | |
import subprocess | |
import pip |
"""SSL client/server certificates verification for `urllib2`. | |
It works on Python 2.6, 2.7, 3.1, 3.2 | |
It also works on Python 2.4, 2.5 if `ssl` is installed (``pip install ssl``) | |
Example:: | |
>>> import urllib2, urllib2_ssl | |
>>> opener = urllib2.build_opener(urllib2_ssl.HTTPSHandler( | |
... key_file='clientkey.pem', |
# SEE: http://d.hatena.ne.jp/shim0mura/20110730/1312046133 | |
# SEE: https://gist.github.com/1031961 | |
# SEE: http://atrpms.net/documentation/install/ | |
# 1. prepare | |
$ cat /etc/yum.repos.d/atrpms.repo | |
[atrpms-stable] | |
name=ATrpms RHEL5 stable | |
baseurl=http://dl.atrpms.net/el5-$basearch/atrpms/stable/ | |
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms |