Skip to content

Instantly share code, notes, and snippets.

View tonyseek's full-sized avatar

Jiangge Zhang tonyseek

View GitHub Profile
@tonyseek
tonyseek / requirements.txt
Last active August 29, 2015 14:05 — forked from iwinux/sumup.py
pip-tools==0.3.5
xlrd==0.9.3
@tonyseek
tonyseek / demo
Created August 15, 2014 07:00
The progress precent in Shell.
#!/usr/bin/env bash
for i in {1..100}
do
echo -ne "\t$i"'%\r'
sleep 0.05
done
echo -e '\n'"success."
@tonyseek
tonyseek / supervisord.service
Created August 8, 2014 07:11
Running supervisord with systemd.
[Unit]
Description=supervisord - Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
ExecReload=/usr/bin/supervisorctl reload
ExecStop=/usr/bin/supervisorctl shutdown
@tonyseek
tonyseek / taggable.java
Created July 23, 2014 14:23
"Mixin" is a kind of composite pattern implementation.
import java.util.List;
import java.util.ArrayList;
interface Entity {
public int getId();
public int getKind();
}
interface Taggable {
public void addTag(int tagId);
@tonyseek
tonyseek / Makefile
Last active August 29, 2015 13:57
Patch the Monaco font for vim-powerline/vim-airline in OS X.
PATCHED_FILENAME = "Monaco for Powerline.ttf"
$(PATCHED_FILENAME): Monaco.ttf fontpatcher.py fontpatcher-symbols.sfd
fontforge -script fontpatcher.py Monaco.ttf
@echo "(´・_・`) You can install the $(PATCHED_FILENAME) now."
Monaco.ttf: Monaco.dfont
fondu Monaco.dfont
rm *.bdf
@tonyseek
tonyseek / wxpython.sh
Created February 28, 2014 07:30
The wrapper for running wxPython in virtualenv.
#!/usr/bin/env sh
PYTHON_VERSION=2.7
WXPYTHON_ROOT="$(brew --prefix wxwidgets)/lib/python${PYTHON_VERSION}/site-packages"
WXPYTHON_SITE_ROOT="${WXPYTHON_ROOT}/$(cat ${WXPYTHON_ROOT}/wx.pth)"
SYSTEM_PYTHON=/usr/bin/python
# find the root of the virtualenv, it should be the parent of the dir this script is in
ENV=`${SYSTEM_PYTHON} -c "import os; print os.path.abspath(os.path.join(os.path.dirname(\"$0\"), '..'))"`
@tonyseek
tonyseek / zshrc
Last active August 29, 2015 13:56
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="seeker"
# Set to this to use case-sensitive completion
@tonyseek
tonyseek / README.rst
Last active August 16, 2025 15:57
Build Python binding of C++ library with cffi (PyPy/Py3K compatible)

Run with Python:

pip-2.7 install cffi
PYTHON=python2.7 sh go.sh

Run with PyPy:

pip-pypy install cffi
PYTHON=pypy sh go.sh
@tonyseek
tonyseek / convert_string_template.py
Last active July 11, 2019 17:01
Convert the old style string formatting of Python into the new style one.
import re
def convert_string_template(string):
index = -1
def repl(matched):
nonlocal index
keyword = matched.group(1)
if keyword:
return "{%s}" % keyword.strip('()')
@tonyseek
tonyseek / manage.py
Last active December 29, 2015 06:09
Flask App Management Script
#!/usr/bin/env python
from flask_script import Manager
from myapp.app import create_app
from myapp.ext import db, oauth
app = create_app()
manager = Manager(app)