Skip to content

Instantly share code, notes, and snippets.

View bvisness's full-sized avatar

Ben Visness bvisness

View GitHub Profile
@bvisness
bvisness / fuss.ts
Created August 29, 2025 22:05
A simple black-box fuzzer.
import { assert } from "./utils.js";
type Awaitable = unknown;
export class Fusser {
buffer: Uint32Array;
init: () => Awaitable;
action: (v: number) => Awaitable;
private canceled: boolean;
@bvisness
bvisness / esbuild-wasi.mjs
Created September 11, 2025 16:16
An esbuild plugin to get WASI 0.1 modules running in the browser.
import { createWriteStream } from "node:fs";
import { access, readFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { isAbsolute, join, relative } from "node:path";
import { pipeline } from "node:stream/promises";
import * as esbuild from "esbuild";
import { componentNew, transpile } from "@bytecodealliance/jco";
const WASI_ADAPTER_URL = "https://github.com/bytecodealliance/wasmtime/releases/download/v36.0.2/wasi_snapshot_preview1.command.wasm";
@bvisness
bvisness / ntutil.py
Last active December 8, 2025 00:39
A helpful wrapper for the WPILib NetworkTables API.
from typing import Any, Dict, Generic, List, Type, TypeVar
import ntcore
import wpilib
import wpiutil.log
nt = ntcore.NetworkTableInstance.getDefault()
T = TypeVar("T")
@bvisness
bvisness / dom.ts
Created December 30, 2025 18:55
Simple utilities for creating DOM elements.
/**
* DOM utilities to ease the pain of document.createElement.
*/
type NonNull<T> = T extends null ? never : T;
type CopyNullable<Src, Dst> = Src extends null ? Dst | null : NonNull<Dst>;
type Falsy = null | undefined | false;
/**
* A slightly relaxed Node type for my DOM utilities.
@bvisness
bvisness / stopwatch.js
Created January 14, 2026 17:32
A little JS timing utility
class Stopwatch {
constructor(name, silent = false) {
this.silent = silent;
this.samples = [];
this.reset(name);
}
reset(name) {
this.name = name;
this.last = performance.now();