Skip to content

Instantly share code, notes, and snippets.

View zoren's full-sized avatar

Søren Sjørup zoren

  • Copenhagen, Denmark
View GitHub Profile
@borkdude
borkdude / konsami.clj
Last active January 13, 2022 15:26
clj-kondo + asami
;; deps.edn:
;; {
;; :deps {
;; clj-kondo/clj-kondo {:mvn/version "2021.10.19"}
;; org.clojars.quoll/asami {:mvn/version "2.2.3"}
;; }
;; }
import tactic
def transform : ℚ × ℚ × ℚ × ℚ × ℚ × ℚ × ℚ × ℚ × ℚ → ℚ × ℚ → ℚ × ℚ
| (a, b, c, d, e, f, g, h, i) (x, y) := ((a * x + b * y + c) / (g * x + h * y + i), (d * x + e * y + f) / (g * x + h * y + i))
def xy : ℚ × ℚ := (1, 1)
def xy' : ℚ × ℚ := (1, -1)
def x'y' : ℚ × ℚ := (-1, -1)
def x'y : ℚ × ℚ := (-1, 1)
@pesterhazy
pesterhazy / indexeddb-problems.md
Last active April 19, 2024 02:40
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)

@seancorfield
seancorfield / README.md
Last active October 28, 2022 04:11
map-vals and map-keys

NOTE: Clojure 1.11 Alpha 2 added update-keys and update-vals which provide similar functionality directly in clojure.core, but with the hash map first and the function second.

Running this code:

clj -Sdeps '{:deps 
             {seancorfield/map-utils 
              {:git/url "https://gist.github.com/seancorfield/6e8dd10799e9cc7527da5510c739e52f"
               :sha "cfde3c2c83379e93ab1a49752611ae663008129f"}}}'

That starts a REPL:

@jboner
jboner / latency.txt
Last active May 2, 2024 09:45
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@athos
athos / gist:1033052
Created June 18, 2011 12:34
An example code to generate a class with ASM in Clojure.
(import '[clojure.asm Opcodes Type ClassWriter]
'[clojure.asm.commons Method GeneratorAdapter])
(defn make-class [name]
(let [cw (ClassWriter. ClassWriter/COMPUTE_FRAMES)
init (Method/getMethod "void <init>()")
meth (Method/getMethod "int fact(int)")]
(.visit cw Opcodes/V1_6 Opcodes/ACC_PUBLIC (.replace name \. \/) nil "java/lang/Object" nil)
(doto (GeneratorAdapter. Opcodes/ACC_PUBLIC init nil nil cw)
(.visitCode)