Skip to content

Instantly share code, notes, and snippets.

View scturtle's full-sized avatar
🐢

scturtle

🐢
View GitHub Profile
@scturtle
scturtle / doubanfav.py
Created April 22, 2011 10:02
show all doubanFM favorite songs
# coding: utf-8
import cookielib,urllib2
from cStringIO import StringIO
from pysqlite2 import dbapi2 as sqlite
from BeautifulSoup import BeautifulSoup
# a useful function from others
def sqlite2cookie(filename,host):
con = sqlite.connect(filename)
@scturtle
scturtle / myTimer.py
Created April 22, 2011 10:11
a timer using Tkinter
# coding: utf-8
from Tkinter import *
from threading import Thread
from tkMessageBox import showinfo
import time,tkMessageBox
class Timer(Thread):
over=False
pause=False
def __init__(self,func):
@scturtle
scturtle / firstpinyin.py
Created April 22, 2011 10:13
return first pinyin letter of chinese word
# coding: utf-8
a=[ i.decode('utf8').encode('gbk') for i in
['澳', '怖', '错', '堕', '贰', '咐', '过',
'祸', '祸', '骏', '阔', '络', '穆', '诺',
'沤', '瀑', '群', '弱', '所', '唾',
'唾', '唾', '误', '褕', '孕', '座',] ]
def firstpy(s,code='utf8'):
s=s.decode(code).encode('gbk')
@scturtle
scturtle / ptcheater.py
Created April 22, 2011 10:14
a proxy cheating the upload of BT/PT
# -*- coding: utf-8 -*-
import re, time, sys
import socket
import threading
from time import time
from random import random
PORT = 8080
mbps=10
@scturtle
scturtle / zipcomic.py
Created April 22, 2011 10:16
zip downloaded comics
# coding: utf-8
import os,sys,zipfile
def walkdir(d):
l=os.listdir(d)
nodir=True
for t in l:
p=os.path.join(d,t)
if os.path.isdir(p):
nodir=False
@scturtle
scturtle / gist:959240
Last active September 25, 2015 17:38
vimperatorrc
" vim: set ft=vim:
" Vimperator 3.5
source! /Users/scturtle/.vimperatorrc.local
source ~/.vimperator/plugin/pinyin-hints.js
let mapleader=","
" quick jump
noremap <leader>1 :b 1<cr>
@scturtle
scturtle / getsong.py
Created May 17, 2011 03:39
get song urls from baidu
# coding: utf-8
import sys,os,urllib2,xml
from xml.dom import minidom
lc = sys.getfilesystemencoding()
baseurl0="http://box.zhangmen.baidu.com/x?op=7&mode=1&count=1&listid=&title=%s"
baseurl1="http://box.zhangmen.baidu.com/x?op=12&count=1&mtype=4&title=%s"
@scturtle
scturtle / ftpserver.py
Created June 20, 2011 16:03
simple ftp server by python
#!/usr/bin/env python2
# coding: utf-8
import os,socket,threading,time
#import traceback
allow_delete = False
local_ip = socket.gethostbyname(socket.gethostname())
local_port = 8888
currdir=os.path.abspath('.')
@scturtle
scturtle / .screenrc
Created July 19, 2011 03:24
screen configuration
altscreen on
#se the startup message
startup_message off
term linux
##use ` as the Global Key
## escape ``
##set a biger buffer
defscrollback 4096
#
hardstatus alwayslastline
@scturtle
scturtle / txt2epub.py
Created September 10, 2011 07:17
txt to epub
# coding: utf-8
import os
#书籍信息
title='test book'
creator='scturtle'
description='blablablabla'
#章节文件
txtlist=['1.txt','2.txt']