看美劇,提供迅雷下載連結 http://kanmeiju.net/
迅雷離線,代抓檔案 http://lixian.vip.xunlei.com/task.html
# Orignal version taken from http://www.djangosnippets.org/snippets/186/ | |
# Original author: udfalkso | |
# Modified by: Shwagroo Team and Gun.io | |
import sys | |
import os | |
import re | |
import hotshot, hotshot.stats | |
import tempfile | |
import StringIO |
看美劇,提供迅雷下載連結 http://kanmeiju.net/
迅雷離線,代抓檔案 http://lixian.vip.xunlei.com/task.html
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
import json | |
import os | |
import time | |
import requests | |
from PIL import Image | |
from StringIO import StringIO | |
from requests.exceptions import ConnectionError | |
def go(query, path): | |
"""Download full size images from Google image search. |
class LoggingMixin(object): | |
def dispatch(self, request_type, request, **kwargs): | |
logger.debug( | |
'%s %s %s' % | |
(request.method, request.get_full_path(), request.raw_post_data)) | |
try: | |
response = super(LoggingMixin, self).dispatch( | |
request_type, request, **kwargs) | |
except (BadRequest, fields.ApiFieldError), e: |
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import chardet | |
BROTHER_ENCODINGS = [ | |
('GB2312', 'GBK', 'GB18030'), | |
] |
class CachedModelResource(ModelResource): | |
def create_response(self, *args, **kwargs): | |
resp = super(CachedModelResource, self).create_response(*args, **kwargs) | |
resp['Cache-Control'] = "max-age=600" | |
return resp |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
As configured in my dotfiles.
start new:
tmux
start new with session name: