Skip to content

Instantly share code, notes, and snippets.

View cometkim's full-sized avatar
🫠
I may be slow to respond.

Hyeseong Kim cometkim

🫠
I may be slow to respond.
View GitHub Profile
@cometkim
cometkim / README.md
Last active December 23, 2024 17:19
There are too many LRU implementations in JS...

JavaScript LRU library benchmark

There are too many LRU(Least Recently Used) implementations in JS.

I recommend to use [flru] which is the smallest one and fast enough. Unless you need more rich functionality.

However, it's performance is vary depend on the host environment. For example, flru loses on Bun.

If you need micro-optimization on it, measure it yourself in your environment.

@cometkim
cometkim / early-hints-test.mjs
Last active March 18, 2025 12:24
Do your infra hops preserve HTTP 103 Early Hints?
import * as http from 'node:http';
import { Readable } from 'node:stream';
import { setInterval } from 'node:timers/promises';
async function* chunksWhile(ms) {
let count = 0;
for await (const startTime of setInterval(1000, Date.now())) {
yield `<div>Looking for your cat... (n=${++count})</div>`;
if (Date.now() - startTime > ms) {
return;
@cometkim
cometkim / download-hira.md
Last active January 7, 2025 08:05
보건의료빅데이터개방시스템(opendata.hira.or.kr) 공공데이터 상세 페이지 첨부파일 일괄 다운로드 스크립트

보건의료빅데이터개방시스템(opendata.hira.or.kr) 공공데이터 상세 페이지 첨부파일 일괄 다운로드 스크립트

Usage

bun install

PAGE="https://opendata.hira.or.kr/op/opc/selectOpenData.do?sno=11925&publDataTpCd=&searchCnd=&searchWrd=%EC%A0%84%EA%B5%AD&pageIndex=1"
bun download-hira.ts "$PAGE"
@cometkim
cometkim / varint.js
Created February 24, 2025 17:31
Variable Integer (LEB128) encoding with BigInt
export function encode(value) {
const long = BigInt(value);
const result = [];
let shift = 0n;
while (true) {
const number = Number(BigInt.asUintN(7, long >> shift));
if (number) {
result.push(number);
shift += 7n;
@cometkim
cometkim / opt-out-telemetry.md
Last active May 5, 2025 08:16
Curated list to opt-out telemetry collection from tools and frameworks
# Cargo binstall
# https://github.com/cargo-bins/cargo-binstall?tab=readme-ov-file#telemetry-collection
export BINSTALL_DISABLE_TELEMETRY=true

# Go Telemetry (not opt-in by default)
# https://go.dev/doc/telemetry
export GOTELEMETRY=off

# GatsbyJS
@cometkim
cometkim / v11-Evaluator.res.mjs
Created April 30, 2025 11:24
ReScript v11 to v12 compile output diff
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as Objects from "./Objects.res.mjs";
import * as Caml_obj from "rescript/lib/es6/caml_obj.js";
import * as Caml_int32 from "rescript/lib/es6/caml_int32.js";
import * as Environment from "./Environment.res.mjs";
var cTRUE = {
TAG: "MBoolean",
_0: {
@cometkim
cometkim / README.md
Last active May 6, 2025 00:17
Illustrate how early-returning syntax (let-else) in Rust eliminates nested pattern matching

Maybe you can flat using dot-free style function calls too.

However, it unnecessarly add runtime overhead, pollute the callstack, and even not intuitive as direct-style control flows are.

@cometkim
cometkim / worker.js
Created June 24, 2025 16:47
Cloudflare Containers' bundle dumped
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// node_modules/unenv/dist/runtime/_internal/utils.mjs
// @__NO_SIDE_EFFECTS__
function createNotImplementedError(name) {
return new Error(`[unenv] ${name} is not implemented yet!`);
}
__name(createNotImplementedError, "createNotImplementedError");
// @__NO_SIDE_EFFECTS__