Skip to content

Instantly share code, notes, and snippets.

View JLHwung's full-sized avatar
💺
Working from home

Huáng Jùnliàng JLHwung

💺
Working from home
  • Waterloo, ON, Canada
View GitHub Profile
@JLHwung
JLHwung / test.js
Created March 6, 2024 17:47
A small stress test on decorator transforms
class CaptureFactory {
static *id(fn) {
yield fn;
}
}
function dummy() {}
class C {}
class A extends CaptureFactory {
@JLHwung
JLHwung / problem.md
Last active June 8, 2022 14:21
The last problem of NCEE Math Guangdong 2022 (English translation)

Let $f(x) = e^x - ax$, $g(x) = ax - \mathrm{ln}x$, $f$ shares the minimum with $g$.

  1. Determine $a$
  2. Prove that there exists a line $y = b$, such that there are three different intersections of $y = b$, $y = f(x)$ and $y = g(x)$, and the x-coordinates of these points form an arithmatic sequence
@JLHwung
JLHwung / codemod.js
Created August 17, 2021 14:57
Transform @babel/types namespace import to named import
/**
input
```
import * as t from "@babel/types"
t.isIdentifier(node)
```
output
```
@JLHwung
JLHwung / ast-examples.md
Last active December 25, 2022 03:01
AST examples for ESTree pattern-matching proposal

Note: The ExpressionStatement and Program node are omitted in the examples.

1. Object Match Pattern and "else" Match Clause

match (x) {
    when ({ colour: "#000000" }) { "yes" }
    else {
        "no"
@JLHwung
JLHwung / set-has-bench.mjs
Created May 31, 2021 19:19
Download and run under github.com/babel/babel/packages/babel-parser/benchmark/
import Benchmark from "benchmark";
import { report } from "./util.mjs";
const suite = new Benchmark.Suite();
const reservedWords = [
"break",
"case",
"catch",
"continue",
@JLHwung
JLHwung / remove-empty-babel-parser-fixture-options.js
Created April 19, 2021 19:28
A script to remove empty options.json in babel parser fixtures
const glob = require("glob");
const fs = require("fs");
glob(
"./packages/babel-parser/test/fixtures/**/options.json",
{},
function (err, files) {
if (err) throw err;
for (const file of files) {
const contents = JSON.stringify(JSON.parse(fs.readFileSync(file)));

Workflow:

Sort current dictionary in the order of Block > Cangjie code

node ./sort-dict.mjs /path/to/cangjie5.dict.yaml

Merge Cangjie5.txt of https://github.com/Jackchows/Cangjie5 to cangjie5.dict.yaml

node ./merge-cangjie5-txt.mjs /path/to/Cangjie5.txt /path/to/cangjie5.dict.yaml
@JLHwung
JLHwung / README.md
Created January 15, 2021 15:52
Forked cluster does not fixup process.execArgv when executed by module.runMain()
node --expose_gc ./wrapper.js ./payload.js

Expected:

[Function: gc] true
[Function: gc]
@JLHwung
JLHwung / explainer.md
Last active June 10, 2020 02:08
Safari console should not apply string normalization on pasteboard content

Intro

This is an example gist repo showcasing a bug that Safari applies string normalization when pasteboard content is applied

Reproduction

curl -o- https://gist.githubusercontent.com/JLHwung/64fed33e2dbb3da7a18566fab26f045f/raw/75a7be7ac00626e58ec93a90ade70909b1bd7fe1/test.js | pbcopy
@JLHwung
JLHwung / optional-chaining.md
Created June 2, 2020 22:17
Babel's optional chaining AST spec

Expressions

OptionalMemberExpression

interface OptionalMemberExpression <: Expression {
  type: "OptionalMemberExpression";
  object: Expression;
  property: Expression;
 computed: boolean;