Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
pesterhazy / wrong-dictionary.md
Last active Oct 2, 2022
You're using the wrong dictionary!
View wrong-dictionary.md

John McPhee famously considered a dictionary his secret weapon. What's your secret weapon?

If like me you're not a native speaker of English, you've probably used bilingual dictionaries to learn about English words. But at a certain level of proficiency, you almost certainly want to use a monolingual dictionary instead. You want to look up words the way a native speaker would.

Here are some of my favorites:

@pesterhazy
pesterhazy / unit-testing-tdd.md
Last active Sep 30, 2022
Automated Tests and Test Driven Development: A Reading List
View unit-testing-tdd.md

This is the best material I know out there on Automated Testing with Microtests (aka Unit Tests aka TDD style tests).

Monographs

Test Driven Development By Example (Kent Beck)

Unit Testing: Principles, Practices, and Patterns (Vladimir Khorikov)

The Art of Unit Testing 2nd ed (Roy Osherove)

@pesterhazy
pesterhazy / eglot-monorepos.md
Last active Nov 13, 2022
Emacs, Monorepos, Eglot, Clojure-lsp and Project.el
View eglot-monorepos.md

This gist is for anyone who's trying to use emacs + eglot + monorepo (with Clojure or any other language).

When you open a file in a buffer, eglot needs to determine the scope or folder to run the language server in. By default, the folder eglot will pick as the assumed project root is the repo root (the ancestory directory containing .git).

But in a monorepo, that's rarely what you want. In a large repo, analyzing all the *.clj files with clojure-lsp could take a minute or longer. As a limiting case, imagine Google with its gargantuan monorepo. Analyzing all the source files would take an indefinite period of time.

@pesterhazy
pesterhazy / building-sync-systems.md
Last active Nov 26, 2022
Building an offline realtime sync engine
View building-sync-systems.md

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles

@pesterhazy
pesterhazy / print-to-pdf.md
Last active Oct 2, 2022
Print web pages to PDF for readability
View print-to-pdf.md

It's often desirable to print articles or blog posts to PDF for easier reading. In fact you're almost always better off reading a cleaned-up printout than a noisy HTML page on a backlit screen.

Printing the web without all the noise

Why?

Offline reading has fewer distractions; you can mark up the article with your own notes; and it's easier on the eyes. Active reading, underlinding and annotating improves comprehension and retention. If you read on the reMarkable tablet, as I do, then you don't to print to actual paper and save trees.

If an article is worth reading, it's worth printing and reading with a pen in your hand.

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)) ) {
result.push(m[0]);
@pesterhazy
pesterhazy / github-print.md
Last active Jul 10, 2022
Print Github Markdown
View github-print.md

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
pesterhazy / geepaw-incrementalism.md
Last active Jun 17, 2022
GeePaw Hill on Incrementalism in Software Development
View geepaw-incrementalism.md

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

Muses

Later muses are also published as podcast episodes.

@pesterhazy
pesterhazy / software-architecture.md
Last active May 9, 2021
Software Architecture: Reading List
View software-architecture.md

Papers

  • 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.