Skip to content

Instantly share code, notes, and snippets.

View jeremy-code's full-sized avatar

Jeremy Nguyen jeremy-code

View GitHub Profile
@jeremy-code
jeremy-code / zod.gen.js
Last active November 10, 2026 11:52
Generated Zod schemas
import * as z from "zod";
//#region src/generated/zod.gen.ts
/**
* Additional entity definition for AccountRole
*/
const accountRoleSchema = z.object({
color: z.string(),
id: z.string(),
name: z.string()
});
@jeremy-code
jeremy-code / README.md
Created October 29, 2026 03:41
Benchmarks — Constructing new Array from TypedArray

Constructing new Array from TypedArray

https://jsbm.dev/ZT94T5AtlsFW3

Benchmarks

Benchmark Test Status Error Ops/s Average Mean batch Median p95 Std deviation 95% RME Batches Operations Measured Relative
Constructing new Array from TypedArray Array.from Success 1,133 882.9 µs 882.9 µs 879.7 µs 893.7 µs 17.34 µs 0.323% 142 9,088 8.024 s 93.91% slower
Constructing new Array from TypedArray Array.from({ length }) Success 580.4 1.723 ms 1.723 ms 1.634 ms 1.815 ms 488.5 µs 4.599% 146 4,672 8.049 s 96.88% slower
@jeremy-code
jeremy-code / README.md
Created October 28, 2026 22:57
Base64 JavaScript
const decodingTable = [
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60,
  61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
  14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26,
  27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
  46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
];
@jeremy-code
jeremy-code / README.md
Created October 14, 2026 07:07
Web APIs/CSS/JavaScript features supported by Chrome and Firefox, but not Safari

Web APIs/CSS/JavaScript features supported by Chrome and Firefox, but not Safari

Ever been curious what features are supported by the main browsers except Safari? As of October 2026, the count is 429 Web API features, 95 CSS features, and 8 JavaScript features (Of course, this includes features that are preview-only by Firefox, so this list isn't really meaningful for determining feature availability for actual users). Code is provided at index.ts using data from @mdn/browser-compat-data.

Web APIs

Feature Chrome Firefox
AuthenticatorAttestationResponse.getPublicKey.algorit
@jeremy-code
jeremy-code / README.md
Created September 30, 2026 05:08
`libheif.py` port configuration

libheif.py port configuration

For my port of libheif, I decided to do it similar to how emscripten also handled ".cc" files for harfbuzz, where the srcs and cflags are inlined based on what CMake would've generated.

The above is the port file that was used to generate the initial build. After that, I just used the following command to get the list of paths.

jq \
  --raw-output \
 --arg pwd "$PWD/" \
@jeremy-code
jeremy-code / README.md
Created September 27, 2026 04:58
zod toZod preprocess/transform behavior

zod toZod preprocess/transform behavior

import * as z from "zod";

import { Readable } from "node:stream";

const readableStreamSchema = z.toZod<ReadableStream<unknown>>()(
  z.instanceof(ReadableStream),
);
@jeremy-code
jeremy-code / libavif.py
Created September 12, 2026 05:03
libavif.py Emscripten port
import os
import shutil
from tools import shared, utils
URL = 'https://github.com/AOMediaCodec/libavif'
DESCRIPTION = 'libavif is a library for encoding and decoding .avif files'
LICENSE = 'BSD 2-Clause License'
TAG = '1.4.2'
@jeremy-code
jeremy-code / README.md
Created August 31, 2026 04:08
Emscripten Compiler Options

Emscripten Compiler Options

  • ASSERTIONS
  • STACK_OVERFLOW_CHECK
  • CHECK_NULL_WRITES
  • VERBOSE
  • INVOKE_RUN
  • EXIT_RUNTIME
  • STACK_SIZE
  • MALLOC
@jeremy-code
jeremy-code / README.md
Created August 28, 2026 02:44
TextDecoderStream vs TextDecoder Benchmark

TextDecoderStream vs TextDecoder Benchmark

https://jsbm.dev/DBsfstlxUQexn

TextDecoderStream Ops/s: 2,565 Average run time: 0.39 ms

TextDecoder Ops/s: 7,597