Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'colorize'
require 'optparse'
class LOLCat
def initialize options = {}
@tagspecs = options[:tagspecs] || []
@whitelist = options[:processes] || []
@processes = Hash.new
end
@bellcliff
bellcliff / gist:47effba1b9c4ab8d1b79
Created September 3, 2014 03:22
working on ios
sed need one more parameter
bash_profile will be loaded, not profile or bashrc
PS1 need export
function parse_git_branch() {
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [[ -z "$branch" ]]; then return; fi
if [[ -z "$(git status -s 2>/dev/null)" ]]; then
@bellcliff
bellcliff / list_subfolder_size.sh
Created June 19, 2015 03:32
list disk usage of subfolder
# suppose ls -l will show content like below
# drwxr-xr-x 8 yangb staff 272 Apr 17 16:21 output
# -rw-r--r-- 1 yangb staff 13925 Apr 17 15:15 post.py
ls -l | awk '{print $9}' | xargs du -sh
@bellcliff
bellcliff / android_device_id.md
Last active July 7, 2017 13:14
android device id

stack overflow discussion

device id solution

final TelephonyManager tm = (TelephonyManager)
  getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);

final String tmDevice, tmSerial, androidId;
tmDevice = "" + tm.getDeviceId();
@bellcliff
bellcliff / NumberAssingment.md
Last active September 9, 2015 03:44
Number Assignment

code

def calc(ns, g):
    ns.sort()  # sort list o(nlg(n))
    ds = []
    for i in range(len(ns)-1):  # o(n)
 ds.append(ns[i+1]-ns[i])