Skip to content

Instantly share code, notes, and snippets.

View splitLinesWithEols.mjs
import * as assert from "node:assert/strict";
function splitLinesWithEols(str) {
let r=/((?!(\n|\r\n)).)*(\n|\r\n)/y;
let m;
let last = 0;
let result = [];
while ( (m=r.exec(str)) ) {
pesterhazy /
Last active Aug 13, 2021
Print Github Markdown

I often want to read Markdown documentation on Github — or proof-read my own documents — without staring at a backlit screen. Here's an easy way to print the files in a readable format.

  1. Create a bookmarklet with the following code and give it the name "github print"

    javascript:void function(){b=document.body,c=document.querySelector("article"),b.innerHTML="",b.appendChild(c)}();
  2. Go to the markdown view on Github of the file you want to print, e.g. Ripgrep's user guide

  3. Click on the bookmarklet. Alternatively (in Chrome) type "github print" in the search bar, select the bookmarklet code with cursor keys if necessary and press enter.

  4. Use the browser print feature to print the document, to a physical printer or (to save paper) to PDF on a reMarkable eInk tablet.

pesterhazy /
Last active Jun 17, 2022
GeePaw Hill on Incrementalism in Software Development

This gist collects publications by GeePaw Hill around the topic of Incrementalism in Software Development - the advice to "take many more, much smaller steps."

Where to start

The good entry point into the discussion is a pair of 2020 muses: The RAT: Rework Avoidance Theory and Understanding Incremental Switchover


Later muses are also published as podcast episodes.

pesterhazy /
Last active May 9, 2021
Software Architecture: Reading List


  • Foote, Brian and Joseph Yoder, Big Ball of Mud

  • Wirth, Niklaus, "Program Development by Stepwise Refinement," Communications of the ACM, Vol. 14, No. 4, April 1971. Reprinted in: Software Pioneers

  • Parnas, David, "On the Criteria to be Used in Decomposing Systems into Modules", Communications of the ACM, 1972. Reprinted in: Software Pioneers

  • Parnas, David, "Designing Software for Ease of Extension and Contraction," IEEE Transactions on Software Engineering, Vol. SE-5, No. 1, pp. 128-138, March 1979.

pesterhazy / chapter2.scm
Created Apr 11, 2021
Software Design for Flexibility Ch. 2.1.1
View chapter2.scm
(define (identity x) x)
(define (compose f g)
(define (the-composition . args)
(f (apply g args)))
(define ((iterate n) f)
(if (= n 0)
pesterhazy /
Last active Feb 26, 2021
You shouldn't be using USING
db=> create table a (x int);
db=> create table b (x int, y int);
db=> create table c (y int, z int);

db=> select * from a join b using (x) join c using (y);
 y | x | z
View sloth.js
const { createServer } = require("http");
const PORT = 22002;
const server = createServer();
server.on("request", (request, response) => {
response.write("Hello, world!\n");
pesterhazy /
Last active Apr 4, 2022
Promises in ClojureScript

Chaining promises

Chaining promises in ClojureScript is best done using the thread-first macro, ->. Here's an example of using the fetch API:

(-> (js/fetch "/data")
    (.then (fn [r]
             (when-not (.-ok r)
               (throw (js/Error. "Could not fetch /data")))
 (.json r)))
pesterhazy /
Last active Jun 22, 2022
The pain and anguish of using IndexedDB: problems, bugs and oddities

This gist lists challenges you run into when building offline-first applications based on IndexedDB, including open-source libraries like Firebase, pouchdb and AWS amplify (more).

Note that some of the following issues affect only Safari. Out of the major browsers, Chrome's IndexedDB implementation is the best.

Backing file on disk (WAL file) keeps growing (Safari)

When this bug occurs, every time you use the indexeddb, the WAL file grows. Garbage collection doesn't seem to be working, so after a while, you end up with gigabytes of data.

Random exceptions when working with a large number of indexeddb databases (Safari)