Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
pesterhazy / yikes
Last active November 29, 2022 19:25
Yikes! A safer git push
#!/usr/bin/env bash
#
# When using "git push", I frequently find myself overlooking git's
# dreaded 'Updates were rejected because the remote contains work that
# you do not have locally' error message.
#
# After I push, I don't typically wait around for the command to
# complete. So while I _think_ that my changes have been pushed to
# remote branch, in fact the push wasn't successful. Because the
# branch has changed in the meantime, I need to `git pull --merge` to
@pesterhazy
pesterhazy / chromium-mac-arm.md
Last active May 31, 2023 08:12
Download Chromium on Mac

Google doesn't make it easy for users to download a stable build of Chromium. If you just download the latest version, fine, but you might be getting an unstable version in between releases. I want a stable Chromium!

After years of trying, this is the process I've settled on - on macOS ARM:

@pesterhazy
pesterhazy / wrong-dictionary.md
Last active December 21, 2022 09:20
You're using the wrong dictionary!

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 January 30, 2024 08:40
Automated Tests and Test Driven Development: A Reading List

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 May 13, 2024 12:14
Emacs, Monorepos, Eglot, Clojure-lsp and Project.el

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 March 28, 2025 14:37
Building an offline realtime sync engine

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 October 2, 2022 15:43
Print web pages to PDF for readability

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.

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 July 10, 2022 04:52
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
pesterhazy / geepaw-incrementalism.md
Last active June 17, 2022 09:02
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

Muses

Later muses are also published as podcast episodes.