Skip to content

Instantly share code, notes, and snippets.

Ang Li meoow

View GitHub Profile
@meoow
meoow / ffmediainfo.py
Created Oct 24, 2014
Get basic information of media file from FFmpeg's command line output.
View ffmediainfo.py
#!/usr/bin/env python2.7
import subprocess as subp
import sys
import re
bitratePtn = re.compile(r'^\s*Duration:.+, (bitrate: (\d+) kb/s).*$')
videoPtn = re.compile(r'^\s*Stream #\d+:\d+.*?: Video: ([^,]+).*$')
audioPtn = re.compile(r'^\s*Stream #\d+:\d+.*?: Audio: ([^,]+).*$')
@meoow
meoow / ffcover.py
Created Oct 24, 2014
Embed ablum cover into MP3 file using FFmpeg
View ffcover.py
#!/usr/bin/env python2.7
from optparse import OptionParser
from subprocess import call
import os.path
import os
import tempfile
img_max_width_or_height = 256
@meoow
meoow / cpv.sh
Last active Aug 29, 2015
Simple alternative for **cp** but shows progress
View cpv.sh
cpv() {
if ! type -P pv >/dev/null;then
echo need pv >&2
return 1
fi
case $# in
0|1)
echo invalid arguments >&2
return 1
;;
@meoow
meoow / screenshot.py
Created Aug 14, 2014
Take screenshot
View screenshot.py
import sys
from PyQt4.QtGui import QPixmap, QApplication
import os
namebase='screenshit_'
num=1
outdir= os.path.abspath(os.path.join(os.environ['HOMEPATH'],'Documents'))
while os.path.exists(os.path.join(outdir,namebase+str(num)+'.png')):
num+=1
fulloutname = os.path.join(outdir, namebase + str(num) + '.png')
@meoow
meoow / xunlei-lixian-gui.py
Created Aug 14, 2014
Simple GUI for xunlei-lixian
View xunlei-lixian-gui.py
#!/usr/bin/env python2.7
from PyQt4.QtCore import SIGNAL, pyqtSignal, QObject, QString
from PyQt4.QtGui import (QApplication, QDialog,
QTextBrowser, QPushButton, QVBoxLayout,
QLineEdit, QGridLayout, QTextCursor,
QLabel, QHBoxLayout, QFileDialog,
QCheckBox , QSizePolicy , QSpacerItem,
QGroupBox, QComboBox, QSpinBox)
import sys,os,re
import subprocess as subp
@meoow
meoow / updatecookie.py
Created Aug 14, 2014
Update cookie for xunlei-lixian
View updatecookie.py
#!/usr/bin/env python2.7
import os, sys
import ConfigParser as cfgp
import sqlite3 as sql
import cookielib
import pdb
def getDefaultProfile(profilesIniFile):
profilesCfg = cfgp.ConfigParser()
profilesCfg.read(profilesIniFile)
@meoow
meoow / add_disabled.py
Created Aug 14, 2014
Add disabled into plist file of iOS apps
View add_disabled.py
#!/usr/bin/env python2.7
import plistlib as plib
import subprocess as subp
from contextlib import closing
import os, tempfile, shutil, re
from NameAppend import nameAppend
def parsePlistToString(plistFile=None):
'''parsePlistToString(plistFile)
@meoow
meoow / bashrc
Last active Aug 29, 2015
return absolute path in pure bash
View bashrc
#get absolute path(shell)
abspath(){ #{{{
local thePath
if [[ ! "$1" =~ ^/ ]];then
thePath="$PWD/$1"
else
thePath="$1"
fi
IFS=/ parr=($thePath)
declare -a outp
@meoow
meoow / bashrc
Last active Aug 29, 2015
append / prepend / remove path from PATH
View bashrc
addpath() { #{{{
local method path
if (($#==0));then
cat <<_EOF_
addpath [+|_|-] path [... pathN]
+ append path (default)
- remove path
_ prepend path
_EOF_
@meoow
meoow / aria2rpc.py
Created Aug 9, 2014
Aria2 RPC interface
View aria2rpc.py
#!/usr/bin/env python
import json, urllib2, sys, os
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('-c', '--cookie', help='use cookies', type=str,
default='', metavar='COOKIES', dest='cookies')
parser.add_argument('-o', '--output', help='output name', type=str,
default='', metavar='NAME', dest='output')
You can’t perform that action at this time.