Skip to content

Instantly share code, notes, and snippets.

from threading import _Timer
class Timer(_Timer):
def __init__(self, interval, handler, repeats=0, args=[], kwargs={}):
_Timer.__init__(self, interval, self.__invoke, args, kwargs)
self.handler = handler
self.repeats = repeats
#! /bin/sh
### BEGIN INIT INFO
# Provides: FastCGI servers for Django
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Start FastCGI servers with Django.
# Description: Django, in order to operate with FastCGI, must be started
# in a very specific way with manage.py. This must be done
@harryxu
harryxu / quicksort.py
Created July 26, 2010 13:39
quicksort (Python)
#!/usr/bin/env python
def quicksort1(q):
"""
The basic version.
http://zh.wikipedia.org/wiki/%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F#.E6.BC.94.E7.AE.97.E6.B3.95
"""
less = []
pivotList = []
greater = []
@harryxu
harryxu / vcsup
Created August 13, 2010 06:17
vcsup. Update all vcs dirs in a specific path.
#!/usr/bin/env bash
# Update all vcs dirs in a specific path.
# Support git, hg and svn.
basePath=`pwd`
function vcsup()
{
echo "checing $1"
@harryxu
harryxu / views.py
Created December 13, 2010 02:34
gitweb in django
import os, sys, subprocess, httplib
from cStringIO import StringIO
from django.http import HttpResponse
def gitweb(request):
cigenv = {
'REQUEST_METHOD': request.method,
'QUERY_STRING': request.META['QUERY_STRING'],
}
os.environ.update(cigenv)
@harryxu
harryxu / awk.html
Created January 27, 2011 06:14
awk手册
<p>这个手册是我转载的,准备用markdown整理下格式,感觉原来的html太乱了。</p>
<p>TOC是通过python的markdown生成的,<a href="http://www.freewisdom.org/projects/python-markdown/">http://www.freewisdom.org/projects/python-markdown/</a></p>
<pre><code>markdown awk.md &gt; awk.html -x toc
</code></pre>
<p>以下全部内容是从 <a href="http://linuxfire.com.cn/~lily/awk.html">http://linuxfire.com.cn/~lily/awk.html</a> 转载的。</p>
<div id="awktoc">
<div class="toc">
<ul>
<li><a href="#awk">awk 手册</a><ul>
@harryxu
harryxu / change_prefix.sql
Created December 9, 2011 04:50
批量修改MySQL表前缀
-- http://blog.itmem.com/?p=1062
-- @author xueyu
-- @desc modify the prefix of table name in db
-- @example
--
-- use DBNAME;
-- show tables;
-- source ~/change_prefix.sql;
--
-- call change_prefix('old_', 'new_', 'DBNAME');
@harryxu
harryxu / gist:1470448
Last active November 20, 2017 18:21
Linux new user
# Create a new user.
adduser username
# Add a existing user to existing group.
# Add existing user tony to ftp supplementary/secondary group with usermod command using -a
# option ~ i.e. add the user to the supplemental group(s). Use only with -G option :
usermod -a -G ftp tony
# Create a new group.
@harryxu
harryxu / .vromerc
Created January 8, 2012 07:22
Vromerc
unmap <M-d>
unmap <C-f>
set disablesites=mail.google.com, reader.google.com, localhost, 127.0.0.1
" vim: set ft=vim:
@harryxu
harryxu / cnv.sh
Created September 19, 2012 11:13
#!/usr/bin/env bash
CURRENT_PATH=`pwd`
outdir="$CURRENT_PATH/out"
if [[ ! -d $outdir ]]; then
mkdir $outdir
fi
cd "$CURRENT_PATH/origin"
VIDEOS=`find . -name "*"`