Skip to content

Instantly share code, notes, and snippets.

@zptr1
zptr1 / README.md
Last active July 3, 2026 11:02
A small type-safe framework for creating DOM objects

This mini-framework lets you create DOM objects in a very convenient way, and has a simple selector parser in TypeScript types to ensure type hints.

Example

const makeUser = (user: User) => _("div.user",
  _("img.avatar", {
    // This object has properties from HTMLImageElement, as inferred from the selector
    src: user.avatarURL,
@thdxr
thdxr / string.txt
Created November 5, 2025 23:25
Bun.stripAnsi hates this string
com.apple.lastuseddate#PS: S�\u000bi\ncom.apple.macl: \u0007@��Y6�>J��'��\u0003�FS\ncom.apple.metadata:kMDItemWhereFroms: bplist00�\u0001\u0002_\u0011\u0002\u0004https://software.download.prss.microsoft.com/dbazure/Win11_25H2_English_Arm64.iso?t=984c522c-a10b-41d5-99ec-68cc848694c9&P1=1762014682&P2=601&P3=2&P4=G6eN0uFrG64Ft%2bDz061PD0rTvYV2UQjZUVtyS9Rn9Ytt0F%2bscgadBtf%2fUs5BKFyowVlDqPhEbTtqBsPEk21bgNAyRwBj%2fgnQcRhiIwEcqSJ9Wyf4ChE%2bYRuc0Eeha9IJakJwuBizc38a4qKsEIxihqroM01TM8iANCExlWWZKG3Gayc%2b18OcvGefTc1G%2bvtvd57AWmeK1kho00yTFtT1sqdS6OXV000YyaYoIVLjVypaoQj7MYJ46vCQb%2bVvn3QZgXaMVwbKjCMI15ezgpGptQPWBssWz9hYC9Fv1OuWcmBwvLGkvL1MczAWSuY3P0kqfezG%2fdkh2cX5NUo2G3zPtw%3d%3d_\u0010\u001ahttps://www.microsoft.com/\ncom.apple.provenance: \u0001\u0002\n

If it's so easy to guess a uuid, here you go

I ran crypto.randomUUID() twice on my machine.

The first ID was 15041508-fd38-4eda-bc1d-7b74e4738cd9

The second? That's your challenge.

I encrypted a text file with the following command:

@t3dotgg
t3dotgg / try-catch.ts
Last active November 21, 2026 05:34
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@ornicar
ornicar / browser-ndjson-stream-reader.js
Last active December 10, 2025 00:19
Read a ND-JSON stream from the browser or from nodejs
/* FOR THE BROWSER
Utility function to read a ND-JSON HTTP stream.
`processLine` is a function taking a JSON object. It will be called with each element of the stream.
`response` is the result of a `fetch` request.
See usage example in the next file.
*/
const readStream = processLine => response => {
const stream = response.body.getReader();
const matcher = /\r?\n/;
@christianparpart
christianparpart / terminal-synchronized-output.md
Last active July 13, 2026 23:44
Terminal Spec: Synchronized Output

This page has moved!

Please see here: contour-terminal/vt-extensions

Synchronized Output

Synchronized output is merely implementing the feature as inspired by iTerm2 synchronized output, except that it's not using the rare DCS but rather the well known SM ? and RM ?. iTerm2 has now also adopted to use the new syntax instead of using DCS.

Semantics