Skip to content

Instantly share code, notes, and snippets.

View catroll's full-sized avatar

胡昂 catroll

View GitHub Profile
@catroll
catroll / sqlalchemy_reflect.py
Created January 31, 2021 03:21 — forked from csabatini/sqlalchemy_reflect.py
Auto-create models from an existing db with SQLAlchemy
from __future__ import print_function
from sqlalchemy import *
from sqlalchemy.orm import create_session
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
engine = \
create_engine("postgresql://...")
metadata = MetaData(bind=engine)
@catroll
catroll / raw_unicode_escape.py
Created November 26, 2018 03:02
Python 2,raw_unicode_escape
a = u'中国'
print repr(a) # u'\u4e2d\u56fd'
b = '\u4e2d\u56fd'
print b.decode('raw_unicode_escape') # 中国
@catroll
catroll / generateOrderID.php
Created October 31, 2018 09:27
PHP 生成订单 ID
<?php
define('CHARS_D', '0123456789');
define('CHARS_LL', 'abcdefghijklmnopqrstuvwxyz');
define('CHARS_LU', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
define('CHARS_L', CHARS_LL . CHARS_LU);
define('CHARS_COMMON', CHARS_D . CHARS_L);
function gen_random_str($length = 3, $chars = null)
{
from __future__ import print_function
import logging
import time
import types
from tornado import ioloop
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(levelname)s] %(message)s')
DEFAULT_TIMEOUT = 5
@catroll
catroll / twisted_debug.py
Created June 5, 2018 07:27
twisted debug
import txaio
txaio.start_logging(level='debug')
from twisted.python import log
observer = log.PythonLoggingObserver(loggerName=__name__)
observer.start()
@catroll
catroll / debug.py
Created June 5, 2018 06:49
Python Debug
import logging
logging.basicConfig(level=logging.INFO,
format='%(asctime)s [%(levelname)s] %(message)s, %(module)s:%(lineno)d',
datefmt='%Y/%m/%d %H:%M:%S')
LOG = logging.getLogger(__name__)
@catroll
catroll / system-management-20170719-01.md
Last active July 19, 2017 06:32
系统管理日志(20170719-01)

停止部分服务

sudo systemctl disable vsftpd.service
sudo systemctl disable redis-server.service
sudo systemctl disable privoxy.service
sudo systemctl disable mysql.service
sudo systemctl disable mongodb.service
sudo systemctl disable memcached.service
sudo systemctl disable docker.service
@catroll
catroll / forWife.js
Created December 25, 2015 11:12
获取/设置《Fatkun图片批量下载》的设置
/**
* 获取/设置《Fatkun图片批量下载》的设置
* 作者:胡昂
*/
(function(){
var keys = [
'savePathType', 'fixedName',
'min_height', 'min_width',
@catroll
catroll / 0_reuse_code.js
Created October 26, 2015 01:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@catroll
catroll / foo.md
Last active August 29, 2015 14:03

Github Todo

  • hello
  • world

hello world