Skip to content

Instantly share code, notes, and snippets.

@dawn110110
dawn110110 / easyprint.py
Created September 8, 2017 08:39
easyprint lib py3 ver
#!/usr/bin/env python3
# coding: utf-8
# source code from https://github.com/dainan13/py-aluminium/blob/master/src/easyprint.py
# modified by zhangtianxiao@sensorsdata.cn for python3.X support.
from __future__ import print_function
import types
import unicodedata
import re
@dawn110110
dawn110110 / safeunicode.py
Last active August 29, 2015 14:01
Safe unicode function(modified from web.py)
def safeunicode(obj, encoding='utf-8'):
r"""s
Converts any given object to unicode string.
>>> safeunicode('hello')
u'hello'
>>> safeunicode(2)
u'2'
>>> safeunicode('\xe1\x88\xb4')
u'\u1234'
@dawn110110
dawn110110 / pyftp.py
Created December 30, 2013 16:12
pyftpdlib. server in one file.
#!/usr/bin/env python
# ftpserver.py
#
# pyftpdlib is released under the MIT license, reproduced below:
# ======================================================================
# Copyright (C) 2007 Giampaolo Rodola' <g.rodola@gmail.com>
#
# All Rights Reserved
#
# Permission to use, copy, modify, and distribute this software and
@dawn110110
dawn110110 / tornado_log_fmt.py
Created March 2, 2013 13:55
Use tonado's LogFormatter out of tornado. just use it as an ordinary LogFormatter, of cource tornado has to be installed.
# use tornado's formatter out of tornado
try:
from tornado.options import _LogFormatter as Fmt # tornado 2.2
except:
from tornado.log import LogFormatter as Fmt # toando 2.4
class TornadoFormatter(Fmt):
''' require toanado installed
usuage:
use it as an ordinary LogFormatter