This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 5 Aug 2024 | |
// multiple inheritance | |
// "inspired" by tweet, 1 August 2024, from Colin McDonnell (and goaded by some | |
// benighted replies) at https://x.com/colinhacks/status/1819138095104905689 | |
// Challenge: Implement merge() to handle multiple inheritance, as per example: | |
// ``` | |
// class A {...} | |
// class B {...} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 15 July 2024 | |
// simulate chunked HTML response stream in the browser | |
// 1. create the response stream parts | |
var encoder = new TextEncoder; | |
var text = ` | |
<html lang="en"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 July 2024 | |
// parseBigInt | |
function parseBigInt(b, r) { | |
var n = String(b).split("n")[0]; | |
return parseInt(n, r); | |
} | |
var base10 = ["2n.3", "5.5", "FFnA", "n.3"].map(function (v, i) { | |
return parseBigInt(v, 8); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 22 June 2024 | |
// is-number with bigint support | |
function isNumber(n) { | |
var m = typeof n == 'bigint' | |
? 0n | |
: 0; | |
return n - m === Object(n).valueOf(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 12 June 2024 | |
// realizing the algorithm for processing event timestamps in Fidge (1988), | |
// "Timestamps in Message-Passing Systems That Preserve the Partial Ordering" | |
// https://fileadmin.cs.lth.se/cs/Personal/Amr_Ergawy/dist-algos-papers/4.pdf | |
// missing the query or aggregation step that collects the timestamps and sorts | |
// them by determinate vs. non-determinate ordering. | |
// determinate ordering should be singular (i.e., only one permutation) whereas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 8 June 2024 | |
// pass functions to workers and and call them in subsequent messages. | |
// similar to gists in 2022: | |
// pass functions as strings to workers and revive them with the Function() constructor | |
// https://gist.github.com/dfkaye/527f163b6913b163a579bbeb01858593 | |
// Not the same as "pass a stringified function in its own blob to a worker and | |
// import it using importScripts(blobUrl)." | |
// https://gist.github.com/dfkaye/ca9722cd247c6d907b3bbaf7273741e0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 31 May 2024 | |
// visibility change and visibility state to drive web worker processing, close | |
// and restart. | |
// previous version, pause and resume, at | |
// https://gist.github.com/dfkaye/3a9d6752301733fba81c740cf4fb68b2 | |
var source = ` | |
var count = 0; | |
var interval; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 30 May 2024 | |
// visibility change and visibility state to drive web worker processing, | |
// pause and resume. | |
// pretty sure I'd done this in 2022 or 2023. | |
// next version implements close and restart... | |
// https://gist.github.com/dfkaye/ee75271dd58e489d3a3ab9d209e51e02 | |
var source = ` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 13 May 2024 | |
// async/await dependency chains | |
// 14 May 2024 | |
// added explicit try-catch-finally to test error in "finalizer" function C. | |
// what | |
// laughing at ben lesh tweet complaining about async/await being difficult | |
// without explaining why: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 11 May 2024 | |
// chapter 8 Data oriented programming | |
// atomic value swap alg | |
function Atom (state) { | |
return { | |
state, | |
atomicCompareAndSet(current, previous, next) { | |
return current === previous ? (state = next, true) : false; |
NewerOlder