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
sudo strace -e trace=network -p `pgrep -x sogou-qimpanel` -s 100000 -f -ff -o sogou
@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
#!/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 / 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>..
@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 / ubuntu-ksru-timeline.js
Created October 28, 2025 13:41
Timeline chart on Ubuntu Kernel SRU tracking bug
// ==UserScript==
// @name Timeline chart on Ubuntu Kernel SRU tracking bug
// @namespace http://anthonywong.net/
// @version 3.0
// @description Display a timeline chart on Ubuntu Kernel SRU tracking bug
// @match https://bugs.launchpad.net/kernel-sru-workflow/+bug/*
// @grant none
// @require https://cdn.plot.ly/plotly-2.20.0.min.js
// @license GPLv2
// ==/UserScript==