Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
pesterhazy / geepaw-incrementalism.md
Last active Jul 10, 2021
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.

View background.clj
(ns background
(:require [clojure.tools.logging :as log])
(:import [java.util.concurrent]))
(defonce !executor (delay (java.util.concurrent.Executors/newCachedThreadPool)))
(defn background
"Calls the fn passed in a thread from a thread pool, returning immediately.
Unlike future, background does not swallow exceptions."
[f]
@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.

@pesterhazy
pesterhazy / git xargs.md
Last active Apr 23, 2021
git xargs: execute utility on files under source control
View git xargs.md

git xargs: execute utility on files in repository

Provides a new git command, git xargs, that runs an arbitrary shell command on all files under source control. Optionally you can specify a pathspec (such as a subpath or a glob expression), restricting the operation to a subset of the repository files.

As git xargs delegates the work to xargs(1), it supports all options provided by the version of xargs installed on your system.

Installation

@pesterhazy
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)))
the-composition)
(define ((iterate n) f)
(if (= n 0)
identity
View reagent-remount-component.cljs
;; This snippet forces React to unmount and remount the
;; entire component tree. Note that this is not the same
;; as using r/force-update-all. r/force-update-all causes
;; all components to update while staying mounted; the technique
;; used here causes a complete did-unmount/did-mount cycle.
(defonce !refresh-count (r/atom 0))
(defn refresh []
(swap! !refresh-count inc))
@pesterhazy
pesterhazy / using.md
Last active Feb 26, 2021
You shouldn't be using USING
View using.md
db=> create table a (x int);
CREATE TABLE
db=> create table b (x int, y int);
CREATE TABLE
db=> create table c (y int, z int);
CREATE TABLE

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
pesterhazy / indexeddb-multiple-tabs.md
Created Feb 26, 2019
Offline-first browser apps and multiple tabs
View indexeddb-multiple-tabs.md

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.