Skip to content

Instantly share code, notes, and snippets.

View meoow's full-sized avatar

Ang Li meoow

  • Beijing University
  • homeless
View GitHub Profile
@meoow
meoow / colfilter.py
Created August 9, 2014 11:48
Filtering One File by Another File
#!/usr/bin/env python2.7
from argparse import ArgumentParser
import sys
def parseArg():
'''parse command line arguments'''
parser = ArgumentParser()
parser.add_argument('-i', '--input', dest='input', metavar='INPUT',\
type=file, default=sys.stdin, help='Full input file')
@meoow
meoow / zimbuild.sh
Created August 9, 2014 11:49
zimwriterfs shell wrapper
#!/bin/bash
# index icon dir file.zim
abspath(){ #{{{
local thePath
if [[ ! "$1" =~ ^/ ]];then
thePath="$PWD/$1"
else
thePath="$1"
fi
@meoow
meoow / extractflash.sh
Created August 9, 2014 11:51
Install Flash Broswer Plugin without Running the Installer (Spares Other Craps Being Foreced to be Installed)
#!/bin/bash
[[ ! -f "$1" ]] && exit 1
dmgfile="$1"
while read a b c;do
eval mp='$c'
done < <(hdiutil mount -noautofsck -noverify -noautoopen "$dmgfile"||exit 1)
echo Step 1
@meoow
meoow / bashrc
Last active August 29, 2015 14:05
return absolute path in pure bash
#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 / updatecookie.py
Created August 14, 2014 03:28
Update cookie for xunlei-lixian
#!/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 August 14, 2014 03:26
Add disabled into plist file of iOS apps
#!/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 / xunlei-lixian-gui.py
Created August 14, 2014 03:32
Simple GUI for xunlei-lixian
#!/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 / screenshot.py
Created August 14, 2014 03:35
Take screenshot
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 / cpv.sh
Last active August 29, 2015 14:05
Simple alternative for **cp** but shows progress
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 / ffcover.py
Created October 24, 2014 06:40
Embed ablum cover into MP3 file using FFmpeg
#!/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