This file contains 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 | |
from __future__ import unicode_literals, absolute_import, print_function | |
k1 = 'v1' | |
k2 = 'v2' | |
module_items = locals() | |
module_keys = ['k1', 'k2'] | |
# print({k: locals()[k] for k in module_keys}) |
This file contains 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
[Unit] | |
Description=Shadowsocks Server | |
After=network.target | |
[Service] | |
ExecStart=/usr/local/bin/ssserver -c /etc/shadowsocks/ss-config.json | |
Restart=on-abort | |
[Install] | |
WantedBy=multi-user.target |
This file contains 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
if has('vim_starting') | |
set runtimepath+=~/.config/nvim/bundle/neobundle.vim/ | |
endif | |
call neobundle#begin(expand('~/.config/nvim/bundle')) | |
NeoBundleFetch 'Shougo/neobundle.vim' | |
NeoBundle 'altercation/vim-colors-solarized' | |
NeoBundle 'scrooloose/nerdtree' | |
NeoBundle 'tpope/vim-fugitive' | |
NeoBundle 'mattn/emmet-vim' |
This file contains 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 handle_default_optional_desc(some_validater): | |
def wrapped_validater(*args, **kwargs): | |
default = kwargs.pop("default", None) | |
optional = kwargs.pop("optional", False) | |
desc = kwargs.pop("desc", None) | |
origin_validater = some_validater(*args, **kwargs) | |
def validater(value): | |
if value is None: | |
if default is not None: |
This file contains 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
import os | |
SQL = "INSERT INTO table (`value1`,`value2`,) VALUES ('%s','%s');\n" | |
def main(): | |
for fname in os.listdir("."): | |
# step1 | |
name, ext = os.path.splitext(fname) | |
if ext != ".txt": |
This file contains 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
import flask | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def index(): | |
return "hello" |
This file contains 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 | |
import platform | |
def pkginfo(): | |
for pkg in ['setuptools', 'pip', 'wheel', | |
'virtualenv', 'distutils', 'cython']: | |
try: | |
version = getattr(__import__(pkg), '__version__', 'Unknown') | |
print('{} = {}'.format(pkg, version)) |
This file contains 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 | |
from inspect import getclasstree | |
def classtree(cls, indent=0, fillchar='-'): | |
""" | |
Print class tree | |
Args: | |
cls: base class |
This file contains 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
# https://pythonhosted.org/pyparsing/ | |
from pyparsing import * | |
# https://pyparsing.wikispaces.com/file/view/jsonParser.py | |
def make_keyword(kwd_str, kwd_value): | |
return Keyword(kwd_str).setParseAction(replaceWith(kwd_value)) | |
TRUE = make_keyword("true", True) | |
FALSE = make_keyword("false", False) | |
NULL = make_keyword("null", None) |
This file contains 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
""" | |
Requires: | |
pip install click sqlparse | |
""" | |
import re | |
from textwrap import indent, dedent | |
import click | |
import sqlparse |
OlderNewer