Skip to content

Instantly share code, notes, and snippets.

import { useSignal, signal, effect } from '@preact/signals';
import { useLayoutEffect, useMemo, useRef } from 'preact/hooks';
/** @template T @typedef {T extends (infer U)[] ? U : never} Items */
/** @param {{ v, k?, f }} props */
const Item = ({ v, k, f }) => f(v, k);
/**
* Like signal.value.map(fn), but doesn't re-render.
@ststeiger
ststeiger / offline_mdn_docs.md
Last active October 4, 2025 16:31 — forked from zed-dz/offline_mdn_docs.md
Offline MDN Docs
@pesterhazy
pesterhazy / building-sync-systems.md
Last active November 11, 2025 02:54
Building an offline realtime sync engine

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles

@nichoth
nichoth / npm-tricks.md
Last active August 13, 2025 06:17
`npm` tricks

misc

npm list

npm list <module>

Show all the different copies of a module that are installed.

@HDegroote
HDegroote / replicate-corestores.js
Created July 25, 2022 18:24
Replicate corestores example
// Tested on Hyperswarm V4, corestore V6, Hypercore V10
// Server
const Hyperswarm = require('hyperswarm')
const Corestore = require("corestore")
const ram = require("random-access-memory")
async function runServer(){
const corestore = new Corestore(ram)
@101arrowz
101arrowz / README.md
Created September 25, 2020 01:14
How FFlate works

FFlate is the fastest, smallest, and most effective JavaScript compressor/decompressor currently; to create it, I used a variety of modified or optimized algorithms.

Part 1: The DEFLATE spec

The core of most popular compressed file formats is DEFLATE, or RFC1951. GZIP data, Zlib data, .zip files, PNG images, and more all use some variant of DEFLATE under the hood. At its core, the DEFLATE format is actually not too complex: it's merely a combination of Huffman coding and LZ77 compression.

If you don't understand either of these concepts, feel free to read the following subsections, or skip to Part 2 if you already know what these are and just want to get to implementation details.

Section I: Huffman Coding

Computers think of basically everything as numbers. The smallest unit of information in a computer is a single bit, which can only be either a 0 or a 1. When multiple bits are stringed together, they can be interpreted as a ba

@swapnilshrikhande
swapnilshrikhande / webtorrent_demo.js
Last active December 11, 2024 19:01
WebTorrent Configure Custom STUN / TURN Server
var client = window.client = new WebTorrent({
tracker: {
rtcConfig: rtcConfig
}
})
client.on('warning', onWarning)
client.on('error', onError)
torrent = client.add(TORRENT, onTorrent)

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

@pedrouid
pedrouid / webcrypto-examples.md
Created December 15, 2018 01:07
Web Cryptography API Examples
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active November 15, 2025 02:15
set -e, -u, -o, -x pipefail explanation