Skip to content

Instantly share code, notes, and snippets.

yangjuven yangjuven

Block or report user

Report or block yangjuven

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yangjuven
yangjuven / cgi_testing.py
Created Nov 8, 2012
test for python cgi.
View cgi_testing.py
#!/usr/bin/env python
# -*- coding: utf8 -*-
import os
import sys
import subprocess
environ = {
"QUERY_STRING": "name=juven",
"REQUEST_METHOD": "GET",
View absolutizeURL.js
function absolutizeURL(url){
var img = document.createElement("img");
img.src = url; // set string url
url = img.src; // get qualified url
img.src = null; // no server request
return url;
}
@yangjuven
yangjuven / webpy_queue.py
Created Mar 7, 2012
Test gevent.queue in web.py.
View webpy_queue.py
#!/usr/bin/env python
# -*- coding: utf8 -*-
import web
import gevent
from gevent import queue
from gevent.timeout import Timeout
from gevent.hub import Waiter
from gevent.pywsgi import WSGIServer
from gevent import monkey
@yangjuven
yangjuven / md5sum.py
Created Feb 14, 2012
Get md5 of file without getting all content. It's very pythonic
View md5sum.py
#!/usr/bin/env python
import sys, hashlib
m = hashlib.md5()
with open(sys.argv[1], "rb") as fp:
for chunk in iter(lambda :fp.read(128 * m.block_size), ""):
m.update(chunk)
@yangjuven
yangjuven / run.py
Created Feb 11, 2012
find bottleneck of wsgi service using python cProfile
View run.py
#!/usr/bin/env python
# -*- coding: gb2312 -*-
# $Id$
import os, sys, cProfile
from wsgi_handler import application
def wsgi():
environ = dict(os.environ.items())
environ.update({
You can’t perform that action at this time.