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 / README.md
Created June 21, 2026 03:28
Enabling `--require-sha` on all Homebrew casks checksum verifiable in Brewfile

Enabling --require-sha on all Homebrew casks checksum verifiable in Brewfile

You may want to set --require-sha as a default option in your Homebrew casks for extra security, either with the environment variable HOMEBREW_CASK_OPTS="--require-sha" or adding cask_args require_sha: true to your Brewfile.

The thing is, many casks do not have a SHA256 checksum since their download link is not versionable. This includes: chromium, google-chrome, logi-options+ (Ventura+), onyx, spotify. For more information, see Homebrew/homebrew-cask#147305. This will lead to this error:

...
==> Verifying checksum for '89947a18e10d5bbda8e2b5d15a60b6823353f019ea1a4b74e3d9c4f91248776e--chromium.rb'
==> Checking cask has checksum
@jeremy-code
jeremy-code / error.log
Created June 9, 2026 06:35
tanstack-radix-rsc
$ vite build
[1/5] analyze client references...
vite v8.0.16 building rsc environment for production...
✓ 16 modules transformed.
✓ built in 57ms
[2/5] analyze server references...
vite v8.0.16 building ssr environment for production...
✓ 288 modules transformed.
✓ built in 379ms
[3/5] build rsc environment...
@jeremy-code
jeremy-code / README.sh
Created June 9, 2026 03:24
Get last accessed/last modified/creation date of file with stat in macOS
TZ=UTC stat -f '%Sa' -t "%Y-%m-%dT%H:%M:%SZ" ./path/to/file.txt # last accessed
TZ=UTC stat -f '%Sm' -t "%Y-%m-%dT%H:%M:%SZ" ./path/to/file.txt # last modified
TZ=UTC stat -f '%SB' -t "%Y-%m-%dT%H:%M:%SZ" ./path/to/file.txt # created
@jeremy-code
jeremy-code / npm.svg
Created June 7, 2026 07:50
NPM logo SVG using only polygon
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

react-diff-viewer-continued colors turned into tailwind css colors. I commented out the grays so you can use your own. Might want to remove black/white too

@jeremy-code
jeremy-code / useBreakpoint.tsx
Created May 26, 2026 05:47
useBreakpoint.tsx
import { useSyncExternalStore } from "react";
type Breakpoint = "sm" | "md" | "lg" | "xl" | "2xl";
type BreakpointWithUtility = Breakpoint | `max-${Breakpoint}`;
const useBreakpoint = (breakpoint: BreakpointWithUtility) => {
const breakpointValue = window
.getComputedStyle(document.body)
.getPropertyValue(
@jeremy-code
jeremy-code / README.md
Created May 25, 2026 02:26
Formatting and parsing with the Temporal API

The Temporal API is very nearly baseline with support in 67.52% of browsers including beta opt-in support in Safari and support in Node.js 26. Of course, the polyfills @js-temporal/polyfill and temporal-polyfill also exist.

One of the larger points of contention is the parsing and formatting support in the Temporal API. Regarding parsing, in addition to object literals or epochNanoseconds/epochMilliseconds, there is currently support for parsing RFC 9557, JavaScript.toString(), ISO 8601, RFC 7231.[^1] While there originally was a proposal for a Temporal.parse API, it has since been abandoned based on the claim that "A type-span

@jeremy-code
jeremy-code / README.md
Created May 12, 2026 05:55
Switching from Radix UI to React Aria

Switching from Radix UI to React Aria

Differences

No <ScrollArea>

Radix UI offers a custom <ScrollArea> implementation both as its own component and in some of its components (e.g. Select).

Per adobe/react-spectrum#7286, React Aria maintainers claim that due to accessibility issues and being unable to adhere to user system preferences, they don't intend on supporting a customizable scroll area. Per this tweet, it seems maintainer Devon Govett strongly dislikes overriding user preferences.

@jeremy-code
jeremy-code / approximateRational.ts
Created May 11, 2026 07:19
approximateRational.ts
import { Decimal } from "decimal.js";
const DEFAULT_MAX_ITERATIONS = 10;
const DEFAULT_TOLERANCE = 1e-10; // = 1/10_000_000_000
/**
* Computes the continued fraction coefficients [a_0, a_1, ..., a_n] for a
* **non-negative** finite number
*
* @see {@link https://en.wikipedia.org/wiki/Simple_continued_fraction}
@jeremy-code
jeremy-code / README.md
Created May 11, 2026 07:16
getImageDimensions()

getImageDimensions TypeScript function using Image constructor and onLoad/onError. Much faster than Window.createImageBitmap. Uses imageOrientation = "from-image" to set width and height based on Exif data.