Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
pesterhazy / building-sync-systems.md
Last active November 11, 2025 02:54
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 October 21, 2025 03:41
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 / 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.

@pesterhazy
pesterhazy / typescript-interface-wat.ts
Last active August 12, 2025 11:03
typescript interface unsoundness wat
import test from "node:test";
import assert from "node:assert";
interface IExperiment {
foo(opts: {}): void;
}
class Experiment implements IExperiment {
// Wat?!
// Why is Experiment allowed to implement IExperiment (the typechecker doesn't complain)
@pesterhazy
pesterhazy / tech-interviews.md
Last active July 27, 2025 20:06
Interviewing for Jobs in Tech: a Reading List

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

@pesterhazy
pesterhazy / .zshrc
Created November 13, 2023 15:26
ZSH: show current git branch on enter
# This prints the current git branch when you submit an empty
# line (i.e. press enter) in zsh
#
# Less distracting than adding it to your prompt, but still
# very easy to run.
git-status-on-enter () {
if [ ${#${(z)BUFFER}} -eq 0 ]; then
if git rev-parse --git-dir > /dev/null 2>&1 ; then
echo
@pesterhazy
pesterhazy / macos-setup.md
Last active July 20, 2025 15:18
Setting up macOS

This guide helps me set up my macOS laptop in a fairly simple manner. I'll need to go back to this guide roughly every 2–3 years. Maybe it'll help you, too!

Smart Caps Lock

Use Karabiner Elements

Map Caps Lock to Ctrl (when long-pressed) or Escape (when tapped). See this guide

Put backtick/tilde character to the left of 1 key

@pesterhazy
pesterhazy / six-questions.md
Last active June 15, 2025 14:55
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