Skip to content

Instantly share code, notes, and snippets.

View vvoody's full-sized avatar

vvoody vvoody

  • Shanghai, China
View GitHub Profile
--- getCover.py 2010-01-25 21:44:58.000000000 +0800
+++ getCover/getCover.py 2010-01-25 15:30:40.000000000 +0800
@@ -3,10 +3,14 @@
# @author mingcheng<i.feelinglucky@gmail.com>
# @site http://www.gracecode.com/
# @date 2010-01-22
import eyeD3, re, os, sys, time, urllib
urlread = lambda url: urllib.urlopen(url).read()
; Right click the link, then surf the https page instead of the http one.
; menu.ini of Opera
; [Link Popup Menu]
Item, https=New page & Go to page, "javascript:location.href='%l'.replace(/^http/, 'https');"
; 我不要全局代理,只需要通过PAC。开启某个代理软件后能在Opera里方便的切换对应的pac文件
; pac文件没法判断当前使用的是那个代理软件,所以只能根据不同的代理软件写多个pac文件
; vvoodysToolbar.ini
Button0, "PAC"="Enable proxy servers, , , "PAC", "New folder" | Disable proxy servers + Show popup menu, "PAC menu""
; vvoodysMenu.ini
[PAC Menu]
Item, 使用GAP=show preferences & show proxy servers & Focus previous widget & Focus previous widget & Focus previous widget & Focus previous widget & Check item & Focus next widget & Insert, "file:///C:/Users/vvoody/AppData/Roaming/Opera/Opera/proxy-gap.pac" & OK & Delay, 10 & Cancel
Item, 使用IndiaWebProxy=show preferences & show proxy servers & Focus previous widget & Focus previous widget & Focus previous widget & Focus previous widget & Check item & Focus next widget & Insert, "file:///C:/Users/vvoody/AppData/Roaming/Opera/Opera/proxy-indiawebproxy.pac" & OK & Delay, 10 & Cancel
Item, 关闭PAC=show preferences & show proxy servers & Focus previous widget & Focus previous widget & Focus previous widget & Focus previous widget & Focus previous widget & Unc
#!/bin/bash
# TEST
# sh find_substring_position.sh "find substring position" "g p" => 13
# sh find_substring_position.sh foodforthought.jpg fo => 0
function find_substring_position()
{
longstr=$1
substr=$2
import random
a = []
def bingo(n):
b = []
while len(b) < n:
s = random.randint(0,120)
if s in a:
continue
b.append(s)
# 返回中通速递订单的跟踪记录
# Return trace records of order of ZTO Express.
curl -d "ID=1234567890" http://zto.cn/bill.aspx | grep '<td width="82">' | iconv -f GB2312 -t UTF-8 | sed 's/^[\t ]*//' | sed 's/<[^>]*>/|/g'
import datetime
# I wanna create some thing in advance monthly, so I need to know the next month(and next year as well).
# Calculating previos month is pretty simple, send 'days=-1' to timedelta.
def nextmo(d, days=31):
"""Return today's next month. If want previous month, set 'days' to '-1'."""
mo = d.month
yr = d.year
nm = datetime.date(yr,mo,1)+datetime.timedelta(days=days)
@vvoody
vvoody / srv.py
Created November 28, 2010 12:19
recording the http request(GET/POST)
#!/usr/bin/python
# -*- coding: utf-8 -*-
from BaseHTTPServer import HTTPServer,BaseHTTPRequestHandler
class MyHttpHandler(BaseHTTPRequestHandler):
def do_GET(self):
print self.headers
print self.path
self.send_response(200)
@vvoody
vvoody / table_dependencies.py
Created January 17, 2011 09:40
generate raw table relations and sort by 'tsort' later
#!/usr/bin/python
# use PostgreSQL for example
import pgdb
def get_namespace_oid(db, name):
cx = db.cursor()
cx.execute('SELECT oid FROM pg_namespace WHERE nspname=%s', (name,))
row = cx.fetchone()
cx.close()
@vvoody
vvoody / gist:929925
Created April 19, 2011 22:59
rewrite my old wordpress blog urls to new
# part of /etc/nginx/nginx.conf
server {
listen 80;
server_name vvoody.org;
location ~ /blog[/]?$ {
if ($query_string ~ p=([0-9]+)) {
rewrite ^(.*) http://blog.vvoody.org/article/$arg_p? permanent;
#set $article_id $1;