Skip to content

Instantly share code, notes, and snippets.

View jamesdiacono's full-sized avatar

James Diacono jamesdiacono

View GitHub Profile
@jamesdiacono
jamesdiacono / generate_password.js
Last active January 17, 2024 03:15
Generates a password from a supply of (presumably random) bytes.
// Generates a password from a supply of (presumably random) bytes.
// The makeup of the password is described by the 'constraints' parameter,
// which is an array of constraint objects. The ordering of constraints does
// not matter.
// Each constraint has an "alphabet" property containing a string of allowed
// characters to choose from.
// A constraint's "position" property controls placement of a single character.
@jamesdiacono
jamesdiacono / pool.js
Last active August 4, 2023 02:14
A pooling requestor.
// The "pool" requestor runs a dynamic collection of requestors in parallel.
// It is like parseq.parallel, except that instead of providing any array of
// requestors up front, they are added wun at a time.
// The 'pool' function takes an optional 'throttle' parameter that limits how
// many requestors are run at wunce.
// It returns an object with two methods:
// add(requestor, initial_value)
@jamesdiacono
jamesdiacono / capability_sealer.js
Last active February 11, 2023 03:01
Safely translate capabilities between string and object reference representations, in JavaScript.
// capability_sealer.js
// James Diacono
// 2023-02-11
// Public Domain
// A capability sealer is a two-way mapping between strings and opaque object
// references. A capability's string representation is suitable for transmission
// over the network, whereas its object representation is suitable for use
// within a single memory address space.
@jamesdiacono
jamesdiacono / masm_to_nasm.sh
Last active October 16, 2024 15:37
The DEC64 number type for Linux (x64 and ARM), MacOS (Intel and Silicon) and Android. Include these files alongside https://github.com/douglascrockford/DEC64.
#!/bin/sh
# Translates DEC64's Windows-compatible MASM on stdin to
# UNIX-compatible NASM on stdout. Not general purpose.
# 0. Use the UNIX calling convention.
# 1. Replace equ with %define.
# 2. Replace public with global.
# 3. Replace unary macro with %macro.
# 4. Replace nullary macro with %macro.