Skip to content

Instantly share code, notes, and snippets.

View tioover's full-sized avatar

ACCOUNT MOVED tioover

View GitHub Profile
@tioover
tioover / stupid_password.py
Created January 14, 2012 09:24
判断傻密码的函数
def is_stupid_password(password):
'''look here http://coolshell.cn/articles/6193.html .'''
stupid_password_list = [
'123456789',
'12345678',
'dearbook',
'123123123',
'1234567890',
'147258369',
'987654321',
@tioover
tioover / gist:2437140
Created April 21, 2012 13:46
wtform field maker for jinja2 macro
{% 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%}
@tioover
tioover / gist:2602795
Created May 5, 2012 14:17
tornado 404
class PageNotFound(tornado.web.RequestHandler):
def get(self):
raise tornado.web.HTTPError(404)
routes = [
# This is url route rule
(r'.*', PageNotFound), # Place to end.
]
@tioover
tioover / gist:2603165
Created May 5, 2012 15:11
tornado chat Learning
#将callback添加到一个类里面
class MessageMixin(object):
waiters = set()
MessageMixin.waiters.add(callback)
#在有新的消息的时候遍历waiters返回
for callback in waiters:
callbask(message)
class Base(object):
def foo():
pass
class Mixin(object):
def bar():
return foo() # 这样子可以吗?
# 还是说
@tioover
tioover / piao.py
Created September 14, 2012 14:19
纪念
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()
@tioover
tioover / gist:3953321
Created October 25, 2012 15:24
nihao
package main
import 输入输出 "fmt"
func main() {
输入输出.Printf("你好世界\n")
}
@tioover
tioover / huatai.py
Last active December 10, 2015 01:28
在一个正六边形的六个区域栽种观赏植物,要求同一块中种同一种植物,相邻的两块种不同的植物.现有4种不同的植物可供选择,则有?种栽种方案
#coding: utf8
count = 6
elems = [1, 2, 3, 4] # 代表四种颜色
def way(elem, index, head):
if index == count - 2:
# 到了倒数第二个花台的时候,根据自己是否和第一个花台一样来算出方法数
if elem == head:
return 3 # 倒数第二个颜色和第一个相同,所以最后一个花台有3种方法
@tioover
tioover / gtran.py
Last active December 10, 2015 08:28
#!/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)
@tioover
tioover / hw.scm
Last active December 18, 2015 22:08
Scheme Hello world
(display "hello, world")