Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 = []
#! /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
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