This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_stupid_password(password): | |
'''look here http://coolshell.cn/articles/6193.html .''' | |
stupid_password_list = [ | |
'123456789', | |
'12345678', | |
'dearbook', | |
'123123123', | |
'1234567890', | |
'147258369', | |
'987654321', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro field(field, cls='') -%} | |
<p>{{field.label()}}</p> | |
<p>{{field(class_ = cls)}}</p> | |
{%if field.errors%} | |
<ul class='errors'> | |
{%for error in field.errors%} | |
<li class='error'>{{error}}</li> | |
{%endfor%} | |
</ul> | |
{%endif%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PageNotFound(tornado.web.RequestHandler): | |
def get(self): | |
raise tornado.web.HTTPError(404) | |
routes = [ | |
# This is url route rule | |
(r'.*', PageNotFound), # Place to end. | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#将callback添加到一个类里面 | |
class MessageMixin(object): | |
waiters = set() | |
MessageMixin.waiters.add(callback) | |
#在有新的消息的时候遍历waiters返回 | |
for callback in waiters: | |
callbask(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Base(object): | |
def foo(): | |
pass | |
class Mixin(object): | |
def bar(): | |
return foo() # 这样子可以吗? | |
# 还是说 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def main(): | |
#read data file. | |
try: | |
f = open("piaodata.txt", "r") | |
except IOError: | |
f = open("piaodata.txt", "w") | |
f.close() | |
f = open("piaodata.txt", "r") | |
body = f.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import 输入输出 "fmt" | |
func main() { | |
输入输出.Printf("你好世界\n") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: utf8 | |
count = 6 | |
elems = [1, 2, 3, 4] # 代表四种颜色 | |
def way(elem, index, head): | |
if index == count - 2: | |
# 到了倒数第二个花台的时候,根据自己是否和第一个花台一样来算出方法数 | |
if elem == head: | |
return 3 # 倒数第二个颜色和第一个相同,所以最后一个花台有3种方法 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
#coding=utf8 | |
import gtk | |
import webkit | |
url = "http://translate.google.com/" | |
class Main(gtk.Window): | |
max_size = (780, 400) | |
min_size = (140, 50) | |
browser_size = (760, 340) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(display "hello, world") |
OlderNewer