Skip to content

Instantly share code, notes, and snippets.

View PeterDing's full-sized avatar
🪐
Working

Peter Ding PeterDing

🪐
Working
View GitHub Profile
@PeterDing
PeterDing / trans.py
Created June 12, 2011 14:32
rearranging the record that stardict saved to readable lines.
#!/usr/bin/env python
#########################################################
# I wrote the little script depended on following dictionaries:
# stardict-cced-2.4.2.tar.bz2, stardict-langdao-ec-gb-2.4.2.tar.bz2,
# stardict-ncce-ec-2.4.2.tar.bz2, stardict-xiangya-medical-2.4.2.tar.bz2
#
# If you want to use other dictionary you will add or remove parts of the code.
#
# Default is designed to remove the record of <Collins Cobuild English Dictionary>
@PeterDing
PeterDing / baidu_mp3_album_downloader.py
Last active February 22, 2017 05:12
baidu mp3 专辑下载 python 脚本-------------用法:python baidu_mp3_album_downloader.py url## url 是 http://music.baidu.com/song/23473715http://music.baidu.com/album/783596 -- # 移到仓库 https://github.com/PeterDing/iScript
#!/usr/bin/env python2
# vim: set fileencoding=utf8
import re, sys, os, random, time, json, urllib2, logging, argparse
from mutagen.id3 import ID3,TRCK,TIT2,TALB,TPE1,APIC,TDRC,COMM,TCOM,TCON,TSST,WXXX,TSRC
from HTMLParser import HTMLParser
parser = HTMLParser()
s = u'\x1b[1;%dm%s\x1b[0m' # terminual color template
ua = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36'
@PeterDing
PeterDing / xiami_vip_linux.py
Last active April 9, 2017 18:34
在linux上,下载 xiami.com 320Kbps mp3 -- # 移到仓库 https://github.com/PeterDing/iScript
#!/usr/bin/env python2
# vim: set fileencoding=utf8
import re, sys, os, random, time, json, logging, argparse, requests, urllib
from mutagen.id3 import ID3,TRCK,TIT2,TALB,TPE1,APIC,TDRC,COMM,TPOS,USLT
from HTMLParser import HTMLParser
parser = HTMLParser()
s = u'\x1b[1;%dm%s\x1b[0m' # terminual color template
@PeterDing
PeterDing / xiami.py
Created August 14, 2013 23:51 — forked from lepture/xiami.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011, lepture.com
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import os
import sys
import zipfile
print "Processing File " + sys.argv[1]
file=zipfile.ZipFile(sys.argv[1],"r");
@PeterDing
PeterDing / flvxz.py
Last active December 24, 2015 23:48
反解析 flvxz.com
#!/usr/bin/env python2
# vim: set fileencoding=utf8
import base64, requests, time, os, sys, argparse, random, subprocess
s = '\x1b[1;%dm%s\x1b[0m' # terminual color template
############################################################
# wget exit status
wget_es = {
#!/usr/bin/env python2
# vim: set fileencoding=utf8
import re, os
s = u'\x1b[1;%dm%s\x1b[0m' # terminual color template
r = re.compile(r'[^ -~\n]+')
a = []
print ' --> runing', s % (93, 'http://www.xunlei6.com/2.htm')
f = os.popen("curl -s http://www.xunlei6.com/2.htm | iconv -f gbk -t utf8 | html2text -ascii | grep -E '(迅雷会|白|企)' | sort -u").read()
@PeterDing
PeterDing / cmp.py
Last active December 26, 2015 18:39
#!/usr/bin/env python2
# vim: set fileencoding=utf8
import os, sys, json, datetime
s = u'\x1b[1;%dm%s\x1b[0m' # terminual color template
types = ('.MKV', '.FLV', '.AVI', '.RMVB', '.MPG', '.WMV', '.RM', '.mkv', '.flv', '.avi', '.rmvb', '.mpg', '.wmv', '.rm')
class compare(object):
def __init__(self, dir_):
self.dir_ = dir_
@PeterDing
PeterDing / xiami_player.py
Last active December 29, 2015 13:29
虾米(xiami.com)终端播放器,支持song, album, showcollect, artist(top 20), user。 输入账号后,可以将播放的歌曲记录到 http://www.xiami.com/space/charts-recent/u/{id}。 Usage: xiami_player.py url -----------播放时,一下enter,进入下一曲。两下enter,退出。 -- # 移到仓库 https://github.com/PeterDing/iScript
#!/usr/bin/env python2
# vim: set fileencoding=utf8
import re, StringIO, sys, os, time, json, gzip, urllib2, argparse, select
from HTMLParser import HTMLParser
parser = HTMLParser()
s = u'\x1b[1;%dm%s\x1b[0m' # terminual color template
email = '' # 输入账号后,可以将播放的歌曲记录到 http://www.xiami.com/space/charts-recent/u/{id}
@PeterDing
PeterDing / cs_skills.md
Last active August 29, 2015 13:57
linux skills

sed with re

sed -r '' file      # -r, --regexp-extended

match newline with grep

grep '^$' file.txt

split file to files

split -l [number] --numeric-suffixes=[from number] --additional-suffix=[suffix] file [prefix]
-l, --lines=NUMBER

-d, --numeric-suffixes[=from number]