Skip to content

Instantly share code, notes, and snippets.

Ang Li meoow

View GitHub Profile
@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 / 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 / external_drives_no_index.plist
Created Aug 7, 2014
automatically prevents spotlight indexing on usb drives
View external_drives_no_index.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnableGlobbing</key>
<false/>
<key>Label</key>
<string>external_drives_no_index</string>
<key>ProgramArguments</key>
<array>
@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
@meoow
meoow / list.txt
Created Aug 9, 2014
Blocking Dopus Online Validation
View list.txt
ver2.gpsoft.com.au
ver0.gpsoft.com.au
blog.dopus.com
www.gpsoft.com.au
dns.msftncsi.com
@meoow
meoow / text2pic.py
Created Aug 9, 2014
Convert Text to Image
View text2pic.py
#!/usr/bin/env python2.7
# coding:utf-8
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
import sys
import re
fontSize = 18
@meoow
meoow / utoa.pl
Created Aug 9, 2014
Convert Unicode Characters to ASCIIs
View utoa.pl
#!/usr/bin/env perl -i -n
use warnings;
use strict;
use Encode;
my $l=decode_utf8($_);
$l=~s/([^[:ascii:]])/"&#".ord($1).";"/ge;
print $l;
You can’t perform that action at this time.