Skip to content

Instantly share code, notes, and snippets.

aleung /
Created December 7, 2022 16:02 — forked from phlinhng/
Clash as transparent proxy gateway via TPROXY


  1. If your local network use public IP ranges instead of private ones, make sure to add respecive RETURN rules to iptables to prevent looping issue
  2. Set clash as DHCP's only DNS server to allow domain-based filter (shunting) rules work
  3. Use lsof -i udp:53 to check if clash's DNS module work fine, otherwise you may have to kill systemd-resolved and any other processes occupying the UDP 53 port
  4. The given scripts will NOT hangle the traffic of gateway itself since it is not recommend to do so. If you want to redirect the egress traffic of the gateway, the following material may be useful


aleung /
Last active September 21, 2022 03:24
Install Docker CE on WSL2
set -eu
echo Install Docker on WSL2 Ubuntu
echo =============================
echo It will prompt to input password for sudo.
# Setup repo
aleung /
Created November 8, 2011 06:41
Dump beans information in a Springframework application context. Licensed under WTFPL v2. More detail in blog post:
package leoliang.springtest;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
aleung / gz-covid-19.geojson
Last active June 8, 2021 14:10
2021 Guangzhou COVID-19
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
* Header Counters in TOC
/* No link underlines in TOC */
.md-toc-inner {
text-decoration: none;
.md-toc-content {
aleung /
Last active September 1, 2020 05:36
Generate latest offline map for OsmAnd


Download OsmAndMapCreator and extract.

Install osmupdate and osmconvert into path.

cd ~/bin
wget -O - | cc -x c - -o osmupdate 
wget -O - | cc -x c - -lz -O3 -o osmconvert
aleung /
Last active June 15, 2020 11:15
Retrieve a file or a directory from git history at specific reversion
#!/usr/bin/env python3
# Usage:
# [-o <output_path>] <rev> [<path>]
# Retrieve a file or a directory from git history at specific reversion (tag or commit).
# The restored file(s) are saved into destination path.
# You must run it in a directory which is inside a git repository.
aleung /
Last active March 26, 2019 08:54 — forked from iest/
Moving from lodash/fp to ramda

Moving from lodash/fp to ramda


Good news is we're only using lodash/fp, which makes it easier to match function signatures.

  1. Find most-used lodash methods, we'll convert these first maybe?
  2. Go through each lodash method, find the ramda equivalent where possible
  3. Write a codemod to rewrite those usages
  4. Who the fuck thought function aliases were a good idea
aleung / example.ts
Last active March 15, 2019 10:40
TypeScript logic flow execution engine
async function operationOne(context: SharedContext, input: Readonly<Op1Input>): Promise<[Op1Output, RollbackFn]> {
const id =;
await saveDb(id, true);
const result = 'OK';
const rollback = async (context: SharedContext) => {
await saveDb(id, false);