I hereby claim:
- I am christophemarois on github.
- I am cmarois (https://keybase.io/cmarois) on keybase.
- I have a public key ASC_FRYqHGxz6zFSsGZyeK8PGOKgiCsD90h8euiHjQgXeAo
To claim this, I am signing this object:
| import { AsyncLocalStorage } from "node:async_hooks"; | |
| function createCtx<T>(name: string, defaultValue?: T) { | |
| const ctx = new AsyncLocalStorage<T>({ name }); | |
| const set = (x: T) => ctx.enterWith(x); | |
| const maybeGet = () => ctx.getStore(); | |
| const get = (): T => { | |
| const val = maybeGet(); | |
| if (val === undefined) { |
I hereby claim:
To claim this, I am signing this object:
| /** Make sure that an unknown object is an error. If it's not, wrap it in an | |
| * error with a useful inspection message */ | |
| export function ensureError(err: unknown): Error { | |
| if (err instanceof Error) { | |
| return err | |
| } | |
| let data: string | |
| try { |
| /** Typed context creation helper | |
| * @example | |
| * export const [useLevel, LevelProvider] = createTypedContext<{ level: number }>('LevelContext') | |
| */ | |
| export function createTypedContext<T>(name: string) { | |
| const Context = createContext<T | null>(null) | |
| function useEnsuredContext() { | |
| const ctx = useContext(Context) | |
| if (ctx === null) { |
| /* eslint-disable no-console */ | |
| /** | |
| * Represents a deeply readonly version of a type, including nested objects, | |
| * arrays, sets, and maps. | |
| * @template T - The type to make deeply readonly. | |
| */ | |
| export type DeepReadonly<T> = T extends (infer R)[] | |
| ? ReadonlyArray<DeepReadonly<R>> | |
| : T extends Set<infer R> | |
| ? ReadonlySet<DeepReadonly<R>> |
| /** Create a wrapped AbortController that is aborted when a SIGINT/SIGTERM is received. | |
| * Supports auto-unregistering via explicit resource management. | |
| * | |
| * @example | |
| * using shutdownSignal = new ShutdownSignal() | |
| * shutdownSignal.throwIfAborted() | |
| * | |
| * // or | |
| * const shutdownSignal = new ShutdownSignal() | |
| * try { shutdownSignal.throwIfAborted() } finally { shutdownSignal.unregister() } |
Cloudflare is a better and free ngrok. With a domain that uses it, set it up like this
cloudflared tunnel login
cloudflared tunnel create test
cloudflared tunnel route dns test test.christophemarois.com| /** Transform the password part of a connection string URL into [redacted]. | |
| * Useful for logging. */ | |
| export function redactPasswordFromUrl(url: string) { | |
| return url.replace(/^([^:]+):\/\/([^:]*):([^@]+)@/, '$1://$2:[redacted]@') | |
| } |
curl -s https://raw.githubusercontent.com/midnightmonster/icloud-calendar-urls/master/icloud_calendar_urls | bashMonitor in Node (PerformanceObserver is not yet implemented in Bun. in bun 1.0.3)
import { collectDefaultMetrics, register } from 'prom-client'
if (req.method === 'GET' && pathname === '/metrics/') {
return new Response(await register.metrics(), {
headers: {
'Content-Type': register.contentType,
},