Skip to content

Instantly share code, notes, and snippets.

View anthonywong's full-sized avatar
🏠
Working from home

Anthony Wong anthonywong

🏠
Working from home
View GitHub Profile
@anthonywong
anthonywong / cbbc.js
Created October 5, 2025 07:14
Retrieve latest CBBC price for Hong Kong market
/**
* Get (delayed) last price from AASTOCKS Whatshot table.
* Usage in Google Sheets: =AASTOCKS_PRICE("55288")
*
* @param {string|number} symbol HK code (e.g., 5, 00005, 700, 55288)
* @return {number} Last price
* @customfunction
*/
function AASTOCKS_PRICE(symbol) {
// symbol='55288';
@anthonywong
anthonywong / adv_git.sh
Last active August 7, 2025 05:10
Advanced Git commands
# Finds the merge commits that lie on the path between a specific commit to the head. Useful for knowing when a commit has been merged by maintainer:
git log --oneline --graph --merges --ancestry-path <commit-hash>..
#!/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 February 1, 2018 07:58
Calculate total number of commits from merges
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
sudo strace -e trace=network -p `pgrep -x sogou-qimpanel` -s 100000 -f -ff -o sogou
@anthonywong
anthonywong / Makefile
Created January 6, 2017 10:46
Makefile for compiling a single kernel module
obj-m := oops.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
SYM=$(PWD)
all:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
" 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 January 13, 2016 06:57
HKSAR and BN(O) passport visa-free country list
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 September 24, 2015 14:32
Output installed packages order by size
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
-o cache=yes
-o kernel_cache
-o compression=no
-o large_read
-o Cipher=arcfour