This file contains hidden or 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 python | |
| #-*-coding:utf-8-*- | |
| d = { | |
| 1: ['a', 'b'], | |
| 2: ['b', 'c', 'd'], | |
| 3: ['b', 'c', 'e'] | |
| } | |
| print reduce(lambda r, k: reduce(lambda s, i: r.__setitem__(i, r.get(i, 0) + 1), set(d[k]), False) or r, d, {}) |
This file contains hidden or 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
| .saaanYYTYnaaac. | |
| _a/??+....:.....-.. -??<a/ | |
| _a)?=--......:.--:-:.:::::-:..?!a, | |
| a?(... . . . ...:.:..--...-.-.:-:..)?a, | |
| .u?:. .. . . . ...:.:.:.:.::--:.:.-.:-.:.?s, | |
| _a?:... . . ....-:.:.:.:.:.:..--.:.:.:.-:.:..?\, | |
| a7.. . ....:.-.:.--.:.:.-.:.:.:.:.-.:.:.--.:;:.4a | |
| .a!.... ...--.----.-----.:.:.:..:.:.:.:.:.:.:.:.==:)a | |
| J^- . ..-.:-.=aaaaaa.:.:.-:.aaaaaa.: :.:.-.:.:.::;=:+L | |
| d(:.. :.:.:.a?' "5/-:a7" ?\/::.:.:.:.-.::;=:/$ |
This file contains hidden or 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 python | |
| from tornado.web import Application, RequestHandler | |
| from tornado.ioloop import IOLoop | |
| from PIL import Image, ImageDraw, ImageFont, ImageColor | |
| import cStringIO | |
| import re | |
| fontPath = '/Library/Fonts/Arial.ttf' | |
| port = 8080 |
This file contains hidden or 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 iAny(seq): | |
| for item in seq: | |
| if item: | |
| return True | |
| return False |
This file contains hidden or 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
| allNum = range(1000*1000) | |
| random.shuffle(allNum) | |
| for promoCodeNeverRepeat in allNum: | |
| doSomethingWith(promoCodeNeverRepeat) | |
| def getCode(): | |
| result = allNum[getCode.usedNum] | |
| getCode.usedNum += 1 | |
| return result | |
| getCode.usedNum = 0 |
This file contains hidden or 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 Fruit(object): | |
| Apple = 0 | |
| Pear = 1 | |
| Banana = 2 | |
| #________________________________ | |
| #/ 其它的一些定義, \ | |
| #\ 使Fruit類可以下標訪問. / | |
| # -------------------------------- | |
| # \ ^__^ | |
| # \ (oo)\_______ |
This file contains hidden or 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 python | |
| import os | |
| import shutil | |
| count = 0 | |
| for filename in os.listdir('.'): | |
| if filename.endswith('.txt') and os.path.isfile(filename): | |
| destDir = 'AAA%d' % (count / 500 + 1) |
This file contains hidden or 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
| #!/bin/sh | |
| count=0 | |
| IFS=$'\n' | |
| for filename in `find *.txt` | |
| do | |
| destDir="AAA$((count / 500 + 1))" | |
| if (($count % 500 == 0 )) | |
| then | |
| echo mkdir $destDir |
This file contains hidden or 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 python | |
| from flask import Flask | |
| from time import sleep | |
| application = Flask(__name__) | |
| application.debug = True | |
| @application.route('/a') | |
| @application.route('/b') |