Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
"""
Reconstitue an ELF file based on the ELF header in the *.b00
file and the data in each of the other files.
"""
import sys, struct, glob, os
def readfmt(f, fmt) :
d = f.read(struct.calcsize(fmt))
@lizhiwei
lizhiwei / panda.pac
Created December 15, 2013 06:32
熊猫翻滚
https://www.pandafan.org/pac/index.html 自动生成
function suffix(s1,s2) {
return s1.indexOf(s2,s1.length-s2.length)!==-1
};
function FindProxyForURL(url, host) {
var PROXY = "SOCKS 127.0.0.1:9625; SOCKS5 127.0.0.1:9625";
var DEFAULT = "DIRECT";
@lizhiwei
lizhiwei / xiegongji.pac
Created December 15, 2013 05:19
谢公屐脚著谢公屐,身登青云梯 PAC代理自动配置脚本
var ipmask=[2130706456,2851995664,167772184,2885681173,3232235536,16777480,16777737,16779275,16785421,16842760,16843273,16843786,16844811,16846860,16850957,16908297,16908808,16909320,16909576,16909833,16910344,16910600,16910857,16911370,16912396,16916493,16924686,16973840,17039624,17039881,17040392,17040648,17040905,17041419,17043468,17047565,17055758,17301520,17432587,17434633,17435400,17435658,17436684,17440781,17448974,17563666,18350099,19726352,19922961,20054032,20119568,20447251,21233682,22020115,22544402,22806545,22937617,24379410,28573714,28835857,29098002,29360147,30015505,30146578,234881035,234884106,234946570,235929620,241598474,241605642,241631248,241696787,242221076,243400721,243662865,244318228,247479306,247483402,247726097,248250385,248512532,453509139,454033428,455272459,455344146,455606291,456271883,456294415,456542219,456562699,456572942,459460620,459464717,459505679,459735056,459964430,459983882,460136461,460324878,460345356,460423182,460521487,460598282,460933131,460945419,461373457,46162
@lizhiwei
lizhiwei / partial_web.py
Created December 10, 2013 04:27
Implementing HTTP 206 Partial Content support for web.py
###https://code.google.com/p/rctk/source/browse/core/trunk/rctk/webpy.py?r=447#57
## experimental partial content support
## perhaps this shouldn't be enabled by default
range = web.ctx.env.get('HTTP_RANGE')
if range is None:
return result
total = len(result)
_, r = range.split("=")
@lizhiwei
lizhiwei / send_file_partial.py
Created December 10, 2013 04:20
HTTP 206 (Partial Content) For Flask
import mimetypes
import os
import re
from flask import request, send_file, Response
@app.after_request
def after_request(response):
response.headers.add('Accept-Ranges', 'bytes')
return response
@lizhiwei
lizhiwei / sendfile.py
Created December 10, 2013 03:01
response to a range request with python Flask framework
from flask import Response, request
from werkzeug.datastructures import Headers
from time import time
from re import findall
def send_file(musicFile , cachetimout, stream=True):
headers = Headers()
headers.add('Content-Disposition', 'attachment', filename=musicFile.filename)