Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
pesterhazy / six-questions.md
Last active May 4, 2026 17:30
Eli Goldratt's six questions about a new technology
  1. What is the power of the technology?
  2. What limitation does it diminish?
  3. What are the old rules that accommodated the old limitation?
  4. What are the new rules that should be used now?
  5. In light of the new rules, what changes are required in the technology?
  6. How to cause the change to take advantage of the new technology?

Source: Eli Goldratt, Beyond the Goal

@pesterhazy
pesterhazy / building-sync-systems.md
Last active May 1, 2026 20:42
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 / indexeddb-problems.md
Last active May 1, 2026 17:54
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)

@pesterhazy
pesterhazy / github-print.md
Last active April 25, 2026 22:39
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 / why-classes-in-typescript.md
Last active January 14, 2026 15:21
Why Use Classes in TypeScript?

Why use classes in TypeScript?

There are many reasons why people like Object-Oriented Programming, but personally, my main reason for the use of classes in TypeScript is making dependencies explicit and replaceable. For example, suppose you have a module, Calendar, which depends on another module, GCalClient - i.e. Calendar uses the functionality from GCalClient but not vice versa. The most straightforward way to write that code is by simply using the functionality from GCalClient when needed:

// calendar.ts

import {bookAppointment} from "google-calendar-client"

function createMeeting() {
@pesterhazy
pesterhazy / tech-interviews.md
Last active December 2, 2025 04:32
Interviewing for Jobs in Tech: a Reading List

Behavioral questions (aka "Tell me about a time when...")

@pesterhazy
pesterhazy / clj_to_js.md
Last active October 18, 2025 12:01
ClojureScript Do's and Don'ts: clj->js

ClojureScript Do's and Dont's: clj->js

You should prefer

#js["tag" #js{"k1" v1, "k2" v2}]

over

@pesterhazy
pesterhazy / indexeddb-multiple-tabs.md
Created February 26, 2019 08:37
Offline-first browser apps and multiple tabs

Offline-first browser apps and multiple tabs

For offline-first operation, browser apps cache data in an IndexedDb database. When the user makes a change while offline, they persist the change optimistically. When connectivity is restored, changes are synced to the server.

This pattern is well established today. However, given the possibility of opening the app in multiple tabs at the same time, we seem to be faced with a dilemma:

  • We allow users to use the app and to make changes in multiple tabs at the same time. But then two "threads" are writing to the same shared resource at the same time. Co-ordinating writes seems to be difficult.

    To make things worse, while the localStorage API allows you to register a callback that fires whenever an item is changed outside the current tab, the IndexedDb API doesn't, at least not in a widely-available way.

@pesterhazy
pesterhazy / geepaw-incrementalism.md
Last active October 13, 2025 14:57
MMMSS: 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." (MMMSS)

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.