Skip to content

Instantly share code, notes, and snippets.

View tonyseek's full-sized avatar

Jiangge Zhang tonyseek

View GitHub Profile
@tonyseek
tonyseek / charsets.py
Last active December 17, 2015 23:09
Declare charset of XHTML file.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from sys import argv, stderr
from lxml import etree
xhtml_namespace = "http://www.w3.org/1999/xhtml"
content_type_attrs = {
"http-equiv": "Content-Type",
@tonyseek
tonyseek / spd.py
Last active December 19, 2015 08:39
批量下载深圳大学毕业照
#-*- coding:utf-8 -*-
import gevent.monkey
import gevent.pool
gevent.monkey.patch_all()
import requests
from zipfile import ZipFile
@tonyseek
tonyseek / deliver-solidot.sh
Last active December 19, 2015 14:58
Solidot 日报
#!/usr/bin/env bash
deliver_target=(example1@kindle.cn example2@kindle.cn)
smtp_account="your-deliver@your-gmail.com"
smpt_password="******"
issue_archive_dir="/srv/ebook-deliver/archives"
issue_name="solidot-$(date +%Y%m%d)"
@tonyseek
tonyseek / contacts-notify.py
Created July 13, 2013 06:32
批量发短信通知同学更换号码
#-*- coding:utf-8 -*-
import time
import subprocess
"""
select last_name || "" || middle_name || "" || first_name as name, mobile_phone, other_phone from contacts where categories like "%通讯录%" and (mobile_phone <> '' or other_phone <> '')
"""
people = [
@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)
@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 / README.rst
Last active November 5, 2022 15:20
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 / 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 / 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 / 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