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 / dec64.nasm
Last active May 10, 2023 10:47
The DEC64 number type for Linux, MacOS (Intel and Silicon) and Android. Include these files alongside https://github.com/douglascrockford/DEC64.
; title dec64.nasm for x64.
; dec64.com
; 2022-09-03
; Public Domain
; No warranty expressed or implied. Use at your own risk. You have been warned.
; This file implements the elementary arithmetic operations for DEC64, a decimal
; floating point type. DEC64 uses 64 bits to represent a number. The low order