Skip to content

Instantly share code, notes, and snippets.

Ang Li meoow

View GitHub Profile
@meoow
meoow / bdcurl.sh
Last active Feb 19, 2020
百度云命令行(bash)上传下载脚本
View bdcurl.sh
#!/bin/bash
# Baidu Yun Command Line Interface
# Depends: bash, curl, grep, awk, sed, od
# (They are basicly builtin tools of any *nix system.)
# Additionally, fastupload depends: head, wc, md5sum or md5, cksum
# (Which are also builtin tools)
#### Variables ####
@meoow
meoow / delpkg.py
Created Aug 4, 2014
Remove pkg packages on Mac OS X
View delpkg.py
#!/usr/bin/env python2.7
import subprocess as subp
import shutil
import sys, os
import pdb
class Delpkg(object):
pkgInfoCommand = 'pkgutil --pkg-info "{pkgname}"'
pkgFilesCommand = 'pkgutil --files "{pkgname}" --only-files'
@meoow
meoow / embedhtml.py
Created Aug 4, 2014
Embed JS/CSS/IMG into HTML page
View embedhtml.py
#!/usr/bin/env python2.7
from bs4 import BeautifulSoup as bs
import base64 as b64
import urllib
import os
import re
import unicodedata
import inspect
@meoow
meoow / cln.py
Created Aug 4, 2014
Clean retina resources and multi-language files (keeping English and Chinese-Simplified)
View cln.py
#!/usr/bin/env python2.7
import os, re, sys
from itertools import chain
import shutil as sh
def main(walkingPath=None, cleanPic=True, cleanLang=True, dryrun=False):
matchPatternlang = re.compile(r'^(?!(?:english|base|en(?=\.)|chinese|zh(?=\.)|zh[-_](?!tw))).+\.lproj$', flags=re.I)
matchPattern2xp = re.compile(r'^(.+)(@2x)(\.(?:png|bmp|tiff|tif|icns|gif))$', flags=re.I)
for path, dirs, files in os.walk(walkingPath):
@meoow
meoow / cleanFTypeAssoc.py
Created Aug 4, 2014
Clean all associated file types of a app bundle
View cleanFTypeAssoc.py
#!/usr/bin/env python2.7
import plistlib
import os
import sys
import shutil
import subprocess
SUBDIR_PATH=os.path.sep.join(('Contents', 'Info.plist'))
@meoow
meoow / updateHost.py
Created Aug 4, 2014
Update/delete entries in system hosts file by a hosts file or URL
View updateHost.py
#!/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 / dmg2iso.sh
Created Aug 4, 2014
Convert DMG to ISO format (using expect and mkisofs)
View dmg2iso.sh
#!/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 / ports.sh
Created Aug 4, 2014
Show current listening ports and established connections of system
View ports.sh
#!/bin/bash
if [[ $1 =~ (tcp|udp) ]] || [ -z "$1" ];then
pass
else
echo Wrong option!
exit 1
fi
trap 'tput clear;exit 0' 2
col=$(tput cols)
while true; do
@meoow
meoow / vdmounter.sh
Created Aug 4, 2014
Mount VDI/VHD/VMDK images without virtual machine installed (need vdfuse)
View vdmounter.sh
#!/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 / bashrc
Last active Aug 29, 2015
Custom PS1 prompt
View bashrc
if ((psi==1));then
PS1='$(
exitstatus=$?
if ((exitstatus==0));then
exitstatus=''
fi
predots=""
postdots=""
extrachars=6
if [[ "$PWD" =~ ^$HOME ]];then
You can’t perform that action at this time.