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 / dmg2iso.sh
Created August 4, 2014 05:19
Convert DMG to ISO format (using expect and mkisofs)
#!/bin/bash
#export IFS=$'\n'
which -s mkisofs || {
echo can\'t not find mkisofs >&2
exit 1
}
path="$(dirname "$1")"
name="$(basename "$1")"
folder="${name%.[Dd][Mm][Gg]}"
cd "$path"
@meoow
meoow / g~f~w~list2pac.py
Last active August 1, 2016 16:20
After looking around for existed implementations for converting gfwlist to pac file, suprisingly few of them producing the results really statisfies me, so I eventually ended up writing an arguably better version for the task.
#!/usr/bin/env python2.7
# This script simply produces a working pac file,
# no fancy input arguments support yet.
# If someone is really interested in using this script,
# download the gfwlist.txt, decode it through base64, name it as "gfwlist_decoded.txt"
# and put it in the same direcotry with this script
# run the script in terminal.
import re
@meoow
meoow / updateHost.py
Created August 4, 2014 05:17
Update/delete entries in system hosts file by a hosts file or URL
#!/usr/bin/env python2.7
import re
import os, os.path
import sys
import urllib2
from contextlib import closing
USAGE = "{0} hosts".format(sys.argv[0])
@meoow
meoow / vdmounter.sh
Created August 4, 2014 05:25
Mount VDI/VHD/VMDK images without virtual machine installed (need vdfuse)
#!/bin/bash
if ! which vdfuse &>/dev/null;then
echo Can not find vdfuse >&2
exit 1
fi
if [[ ! -f "$1" ]];then
echo Disk file does not exist >&2
exit 1
@meoow
meoow / block.txt
Last active August 29, 2015 14:17
Personal element hide
[Adblock Plus 2.0]
www.cnbeta.com##.wrapper.global_head > .tiny_bar > .cb_rss
www.safaribooksonline.com###js-subscribe-nag.subscribe-nag.clearfix.trial-panel.collapsed.slideUp
hi.baidu.com##.mod-page-body > .mod-page-main.wordwrap.clearfix > .x-page-container > .mod-blogpage-wraper > .grid-80.mod-blogpage > .mod-text-content.mod-post-content.mod-cs-contentblock > .mod-post-info.clearfix > .op-box.mod-cs-opBox > .pv
www.mtime.com###carter > embed
qun.qzone.qq.com##.td_upload_counts
www.talkshowcn.com###wideRight.col-md-4.column
||cnzz.com/stat.php
||cpro.baidustatic.com
@meoow
meoow / .bashrc
Last active August 29, 2015 14:08
Wrappers for CUT and SORT treat consecutive whitespaces as field separator
cuttor() {
local cutopts files
declare -a cutopts
declare -a files
while [[ $# -gt 0 ]];do
case "$1" in
-f) shift; cutopts+=(-f "$1") ;;
-f?*) cutopts+=("$1") ;;
*) files+=("$1") ;;
esac
@meoow
meoow / ffaac.py
Created October 24, 2014 07:05
Convert all FFmpeg supported media file to high quality AAC file (need libfdk_aac encoder)
#!/usr/bin/env python2.7
from optparse import OptionParser
from subprocess import call
from os.path import splitext
import sys, os
def ffaac(filename, opts):
cmd = ['ffmpeg', '-hide_banner', '-y', '-i', filename,
'-c:a', 'libfdk_aac']
@meoow
meoow / ffposter.py
Created October 24, 2014 07:03
Take screenshot (poster) for video at specific seconds
#!/usr/bin/env python2
import sys
import os.path
import datetime
from subprocess import call
width = 1280
sec = str(datetime.timedelta(seconds=int(sys.argv[1])))
@meoow
meoow / ffmp3.py
Created October 24, 2014 06:48
A wrapper for FFmpeg to convert any support media file to high quality MP3 file.
#!/usr/bin/env python2.7
from optparse import OptionParser
from subprocess import call,Popen, PIPE
from os.path import splitext
import sys, os, re
def mediainfo(filename):
bitratePtn = re.compile(r'^\s*Duration:.+, (bitrate: (\d+) kb/s).*$')
@meoow
meoow / blockit.sh
Created October 24, 2014 07:24
A simple way for blocking apps to connect to internet.
#!/bin/bash
# Usage:
# navigate the MacOS folder inside the app bundle you want to block
# usually where it is "SomeApp.app/Contents/MacOS"
# open terminal at current location
# run "blockit.sh executable"
# note the name "executable varies per apps"
# then this app is no longer be able to connect to internet.
if [[ -z "$1" ]];then