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
# -*- coding: utf-8 -*- | |
# | |
# Copyright(c) 2015 http://feilong.me | |
# | |
# @author: Felinx Lee <[email protected]> | |
# | |
from tornado.httpclient import HTTPClient, HTTPRequest | |
from tornado import escape | |
import hashlib |
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
# -*- coding: utf-8 -*- | |
# | |
# Copyright (c) 2013 feilong.me All rights reserved. | |
# | |
# @author: Felinx Lee <[email protected]> | |
# Created on May 4, 2013 | |
# | |
""" | |
tornado.options.options don't parse default value automatically, sometimes, |
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
# based on http://uberblo.gs/2011/06/high-performance-url-shortening-with-redis-backed-nginx | |
# using code from http://stackoverflow.com/questions/3554315/lua-base-converter | |
# "database scheme" | |
# database 0: id ~> url | |
# database 1: id ~> hits | |
# database 2: id ~> [{referer|user_agent}] | |
# database 3: id ~> hits (when id is not found) | |
# database 4: id ~> [{referer|user_agent}] (when id is not found) | |
# database 5: key "count" storing the number of shortened urls; the id is generated by (this number + 1) converted to base 62 |
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 _thumbnail_image(self, body, size): | |
try: | |
im = Image.open(StringIO(body)) | |
# rotate image according rotation meta of this image | |
# for orientation in ExifTags.TAGS.keys(): | |
# if ExifTags.TAGS[orientation] == 'Orientation' : break | |
orientation = 274 # get 274 through upper loop | |
try: | |
exif = im._getexif() |
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 -*- | |
# | |
# zipdb.py | |
# Use a zipfile store a dict like k-v database. | |
# Known bug: duplicate key(filenames) allowed | |
# | |
# Copyright 2012 mayli <[email protected]> | |
# |
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
# To get remote_ip, it should set xheaders=True when initializing HTTPServer | |
http_server = HTTPServer(Application(), xheaders=True) |