Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Anthony Wong anthonywong

🏠
Working from home
  • Canonical
  • Hong Kong
View GitHub Profile
View test_thermald.sh
#!/bin/bash
[ $UID != 0 ] && echo "Must run as root" && exit
i=1
RUNS=3
if [ -n "$1" ]; then
RUNS=$1
fi
while [ $i -le $RUNS ]; do
d=`date +%Y%m%d-%H%M`
@anthonywong
anthonywong / get_number_of_merged_commits.sh
Last active Feb 1, 2018
Calculate total number of commits from merges
View get_number_of_merged_commits.sh
n=0
PATTERN=ti-linux-4.14.y
while read line; do
hash=`echo "$line" | cut -f1 -d' '`
nn=`git show "$hash" | head -2 | tail -1 | awk '{ print $2".."$3 }' | xargs git log --pretty=oneline | wc -l`
echo "$nn": "$line"
n=$(($n + $nn))
done <<< "$(git log --grep 'Merge branch' --abbrev-commit --pretty=oneline | grep $PATTERN)"
echo "Total number of commits:" $n
View check_sogou_IME_network_traffic.sh
sudo strace -e trace=network -p `pgrep -x sogou-qimpanel` -s 100000 -f -ff -o sogou
@anthonywong
anthonywong / Makefile
Created Jan 6, 2017
Makefile for compiling a single kernel module
View Makefile
obj-m := oops.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
SYM=$(PWD)
all:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
View .vimrc
" Vim
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
"set fe=taiwan
"set gfs=-adobe-courier-bold-r-normal--14-140-75-75-m-90-iso8859-1,-eten-fixed-medium-r-normal--16-150-75-75-c-160-big5-0
@anthonywong
anthonywong / BN(O)
Last active Jan 13, 2016
HKSAR and BN(O) passport visa-free country list
View BN(O)
Adélie Land
Åland
Anguilla
Antigua and Barbuda
Arab Republic of Egypt
Argentine Republic
Aruba
Australian Antarctic Territory
Barbados
Belize
@anthonywong
anthonywong / installed_packages_order_by_size.sh
Created Sep 24, 2015
Output installed packages order by size
View installed_packages_order_by_size.sh
for package in $(dpkg -l | grep ^ii| awk '{ print $2 }'); do size=$(dpkg -s $package | grep Installed-Size | awk '{ print $2 }'); echo $package $size; done | sort -nr -k2
View sshfs essential options
-o cache=yes
-o kernel_cache
-o compression=no
-o large_read
-o Cipher=arcfour
View Canonical kernel contribution since 3.0
$ git log --pretty=format:"%an <%ae>" --abbrev-commit v3.0..HEAD --author=canonical|sort|uniq -c|sort -nr
212 David Henningsson <david.henningsson@canonical.com>
185 Ming Lei <ming.lei@canonical.com>
125 Maarten Lankhorst <maarten.lankhorst@canonical.com>
88 Seth Forshee <seth.forshee@canonical.com>
64 Tim Gardner <tim.gardner@canonical.com>
62 John Johansen <john.johansen@canonical.com>
58 Colin Ian King <colin.king@canonical.com>
50 Hui Wang <hui.wang@canonical.com>
View .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignorespace