Skip to content

Instantly share code, notes, and snippets.

View tonyseek's full-sized avatar

Jiangge Zhang tonyseek

View GitHub Profile
@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 / 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 / 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 / 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 / ext.py
Last active April 6, 2019 12:54
Fixes the nonstandard OAuth interface of Tencent WeChat with Flask-OAuthlib.
from .weixin_compat import fixup_weixin_oauth
oauth = OAuth()
weixin = oauth.remote_app(
'weixin',
app_key='WEIXIN',
request_token_params={'scope': 'snsapi_base'},
base_url='https://api.weixin.qq.com',
authorize_url='https://open.weixin.qq.com/connect/oauth2/authorize',
access_token_url='https://api.weixin.qq.com/sns/oauth2/access_token',
from operator import itemgetter
class Step(tuple):
location = property(itemgetter(0))
milestone = property(itemgetter(1))
step = Step(['nowhere', 'nothing'])
assert step.location == 'nowhere'
@tonyseek
tonyseek / captcha.py
Created November 26, 2014 02:51
A example of wheezy.captcha
import random
from wheezy.captcha.image import captcha
from wheezy.captcha.image import background
from wheezy.captcha.image import curve
from wheezy.captcha.image import noise
from wheezy.captcha.image import smooth
from wheezy.captcha.image import text
from wheezy.captcha.image import offset
from wheezy.captcha.image import rotate
@tonyseek
tonyseek / blog.tonyseek.com.conf
Created November 30, 2014 11:00
partial nginx config of my blog
server {
listen 80;
server_name blog.tonyseek.com;
root /srv/blog.tonyseek.com/;
# digg has a broken https support while sni extension has been enabled.
if ($http_user_agent !~ Digg ) {
rewrite ^ https://$server_name$request_uri? permanent; # enforce to use https
}
@tonyseek
tonyseek / formula.py
Last active June 28, 2022 09:13
render latex formula with matplotlib and pillow.
try:
from StringIO import StringIO as BytesIO
except ImportError:
from io import BytesIO
import matplotlib.pyplot as plt
def render_latex(formula, fontsize=12, dpi=300, format_='svg'):
"""Renders LaTeX formula into image."""
@tonyseek
tonyseek / gulpfile.coffee
Created January 18, 2015 05:59
Flask + Browserify + Gulp + Stylus
gulp = require 'gulp'
uglify = require 'gulp-uglify'
sourcemaps = require 'gulp-sourcemaps'
stylus = require 'gulp-stylus'
rename = require 'gulp-rename'
source = require 'vinyl-source-stream'
buffer = require 'vinyl-buffer'
browserify = require 'browserify'
del = require 'del'
pkginfo = require './package.json'