Skip to content

Instantly share code, notes, and snippets.

aleung /
Last active Jun 15, 2020
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 Mar 26, 2019 — 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 Mar 15, 2019
TypeScript logic flow execution engine
View example.ts
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);

Keybase proof

I hereby claim:

  • I am aleung on github.
  • I am 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:

View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>SANKEY Demo</title>
.node rect {
cursor: move;
fill-opacity: .9;
shape-rendering: crispEdges;
aleung /
Last active Sep 1, 2020
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
View console-output
Trace of ID 1
1497340609369: Received request. ID: 1
1497340609369: Step 1 1
1497340610599: Step 2 1
1497340610602: Response sent 1
Trace of ID 2
1497340606575: Received request. ID: 2
1497340606575: Step 1 2
1497340612700: Step 2 2
aleung / user.js
Last active Jun 8, 2017
User script to slideshow a serial of webpages in loop.
View user.js
// ==UserScript==
// @name Webpages slideshow
// @namespace
// @version 1.1.0
// @description Loop display a serial of webpages. Display time for each page can be set.
// @author Leo Liang
// @license MIT License
// @include *
// @noframes
// @require
View user.js
// ==UserScript==
// @name Tuleap Tracker Enhance
// @namespace
// @version 0.4
// @description Toggle detail in card wall
// @author Leo Liang
// @match https://*/plugins/tracker/*
// ==/UserScript==
(function() {