Skip to content

Instantly share code, notes, and snippets.

from multiprocessing import Pool,Process
def f(x):
return x*x
def f2(x):
return [i*i for i in x]
num = 10000000
'''
http://en.wikipedia.org/wiki/Base_36#Python%5FConversion%5FCode
'''
def base36encode(number):
if not isinstance(number, (int, long)):
raise TypeError('number must be an integer')
if number < 0:
raise ValueError('number must be positive')
alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
Opera Preferences version 2.1
; Do not edit this file while Opera is running
; This file is stored in UTF-8 encoding
[matches]
; One can disable xft or core fonts if necessary
;engine:xft=blacklist
engine:x11=blacklist
from scrapy import log
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.xpath.selector import HtmlXPathSelector
from scrapy.item import ScrapedItem
def safecn(i):
try:
return unichr(int(i))
except:
@qingfeng
qingfeng / gist:143728
Created July 9, 2009 15:06
处理&#开头的中文
s = u'&#22914;&#20309;&#38754;&#23545;&#20135;&#30171; '
print "".join( map(lambda x:unichr(int(x.replace("&#",""))),filter(lambda x:x!='',s.strip().split(";"))) )
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Test CSS Ani</title>
<style type="text/css" media="screen">
body { margin: 0; color: #fff; background: #000; overflow: hidden; }
#header h1, #apple div.icon { color: transparent; }
#apple, #header, #safari { position: absolute; top: 40%; left: 50%; }
#apple { width: 600px; height: 538px; margin: -290px 0 0 -290px; overflow: hidden; }
#apple div { position: absolute; width: 600px; height: 538px; opacity: 0; filter: alpha(opacity=0); }
@qingfeng
qingfeng / tokyotyrant-freebsd-Makefile.patch
Created May 26, 2009 08:24
让Tokyo Tyrant开启lua支持,以及修正了BUILD_DEPENDS的Makefile patch
*** Makefile Tue May 26 16:10:20 2009
--- Makefile.bak Tue May 26 11:07:05 2009
***************
*** 14,31 ****
MAINTAINER= [email protected]
COMMENT= Network interface of Tokyo Cabinet
! BUILD_DEPENDS= tokyocabinet>=1.4.20:${PORTSDIR}/databases/tokyocabinet
LIB_DEPENDS= tokyocabinet:${PORTSDIR}/databases/tokyocabinet
! RUN_DEPENDS= tokyocabinet>=1.4.20:${PORTSDIR}/databases/tokyocabinet
#
# controller.py
# sha1_pyobjc
#
# Created by yanxu on 09/05/18.
# Copyright (c) 2009 SINA. All rights reserved.
#
from objc import YES, NO, IBAction, IBOutlet
from Foundation import *
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "
# encoding: utf-8
import random
from pinyin import hanzi2pinyin
def addpinyin(text):
textcount=len(text)
replace_dict={}
pinyincount=5#最小添加拼音的字数,5个字
for i in range(pinyincount):
s = random.choice(text)#要替换的文字