Skip to content

Instantly share code, notes, and snippets.

@aleung
aleung / montreal-fsa-polygons.geojson
Created December 30, 2024 03:19 — forked from sabatale/montreal-fsa-polygons.geojson
Geojson with postal codes FSA polygons for Montréal, QC, Canada.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aleung
aleung / export-at-last.ts
Created December 4, 2024 05:21
Fix errors reported by eslint rule import/exports-last
import { Project, Node } from 'ts-morph';
const args = process.argv.slice(2);
const sourceFilePath = args[0];
if (!sourceFilePath) {
console.log('Please specify the source file path.');
process.exit(1);
}
@aleung
aleung / a-clash-tproxy-gateway.md
Created December 7, 2022 16:02 — forked from phlinhng/a-clash-tproxy-gateway.md
Clash as transparent proxy gateway via TPROXY

Notes

  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

Reference

@aleung
aleung / install-docker.sh
Last active September 21, 2022 03:24
Install Docker CE on WSL2
#!/bin/bash
set -eu
echo Install Docker on WSL2 Ubuntu
echo =============================
echo It will prompt to input password for sudo.
echo
# Setup repo
@aleung
aleung / gz-covid-19.geojson
Last active June 8, 2021 14:10
2021 Guangzhou COVID-19
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aleung
aleung / git-history-extract.py
Last active June 15, 2020 11:15
Retrieve a file or a directory from git history at specific reversion
#!/usr/bin/env python3
#
# Usage:
# git-history-extract.py [-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
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 = input.id;
await saveDb(id, true);
const result = 'OK';
const rollback = async (context: SharedContext) => {
await saveDb(id, false);
}
For
* ES5
* ES6
* CoffeeScript

Keybase proof

I hereby claim:

  • I am aleung on github.
  • I am leoliang (https://keybase.io/leoliang) on keybase.
  • I have a public key whose fingerprint is 1ACE A9DD 75C1 ED20 408A 6E46 45D6 55B0 E6D1 C308

To claim this, I am signing this object:

<!DOCTYPE html>
<meta charset="utf-8">
<title>SANKEY Demo</title>
<style>
.node rect {
cursor: move;
fill-opacity: .9;
shape-rendering: crispEdges;
}