Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
pesterhazy / github-print.md
Last active Aug 13, 2021
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 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.

@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 / 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
@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 / promises-cljs.md
Last active Oct 7, 2021
Promises in ClojureScript
View promises-cljs.md

Chaining promises

Chaining promises in ClojureScript is best done using the thread-first macro, ->. Here's an example of using the fetch API:

(-> (js/fetch "/data")
    (.then (fn [r]
             (when-not (.-ok r)
               (throw (js/Error. "Could not fetch /data")))
             (.json r)))
@pesterhazy
pesterhazy / indexeddb-problems.md
Last active Oct 18, 2021
The pain and anguish of using IndexedDB: problems, bugs and oddities
View indexeddb-problems.md

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.

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)

View clojure-comment-dwim.txt
(ns scrap.scrap
(:require [clojure.test :as t]))
=>
;;(ns scrap.scrap
(:require [clojure.test :as t]))