Skip to content

Instantly share code, notes, and snippets.

View PEZ's full-sized avatar
🎯
Focusing

Peter Strömberg PEZ

🎯
Focusing
View GitHub Profile
@PEZ
PEZ / keybindings.json
Last active April 15, 2025 13:59
Calva custom repl commands and keybinding for Snitch
...
// --- SNITCH CONVENIENCE, Thanks, Abhinav! ♥️🙏
// https://github.com/AbhinavOmprakash/snitch
{
// Instrument as snitched defn*
"key": "cmd+enter",
"when": "editorLangId == 'clojure' && calva:connected",
"command": "calva.runCustomREPLCommand",
"args": {
"snippet": "${top-level-form|replace|^\\(defn-?|(defn*}"
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 20 columns, instead of 11 in line 4.
benchmark,timestamp,commit-sha,is-checked,user,model,ram,os,arch,gcc,g++,llvm,clang,language,run-ms,mean-ms,std-dev-ms,min-ms,max-ms,runs
loops,2025-02-06T22:36:31Z,08471f6,true,PEZ,Apple M1 Max,32GB,darwin24,arm64,gcc (Homebrew GCC 14.2.0_1) 14.2.0,g++ (Homebrew GCC 14.2.0_1) 14.2.0,,Apple clang version 16.0.0 (clang-1600.0.26.6),Babashka,10000,7414.845771,34.810146,7380.035625,7449.655917,2
loops,2025-02-06T22:36:31Z,08471f6,true,PEZ,Apple M1 Max,32GB,darwin24,arm64,gcc (Homebrew GCC 14.2.0_1) 14.2.0,g++ (Homebrew GCC 14.2.0_1) 14.2.0,,Apple clang version 16.0.0 (clang-1600.0.26.6),C,10000,62.525219,1.846617,62.097000,85.542000,160
loops,2025-02-06T22:36:31Z,08471f6,true,PEZ,Apple M1 Max,32GB,darwin24,arm64,gcc (Homebrew GCC 14.2.0_1) 14.2.0,g++ (Homebrew GCC 14.2.0_1) 14.2.0,,Apple clang version 16.0.0 (clang-1600.0.26.6),Clojure,10000,63.30155329746835,0.2950020737574292,63.00025,65.484208,158
loops,2025-02-06T22:36:31Z,08471f6,true,PEZ,Apple M1 Max,32GB,darwin24,arm64,gcc (Homebrew GCC 14.2.0_1) 14.2.0,g
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 20 columns, instead of 10 in line 4.
benchmark,timestamp,commit-sha,is-checked,user,model,ram,os,arch,gcc,g++,llvm,clang,language,run-ms,mean-ms,std-dev-ms,min-ms,max-ms,runs
loops,2025-02-05T21:48:28Z,38b719f,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,gcc (Homebrew GCC 14.2.0_1) 14.2.0,g++ (Homebrew GCC 14.2.0_1) 14.2.0,19.1.6,Homebrew clang version 19.1.6,Crystal,10000,49.30541871921182,0.9362449735720588,47,54,203
loops,2025-02-05T21:48:28Z,38b719f,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,gcc (Homebrew GCC 14.2.0_1) 14.2.0,g++ (Homebrew GCC 14.2.0_1) 14.2.0,19.1.6,Homebrew clang version 19.1.6,Ruby,10000,2918.7309999833815,20.273635754519336,2903.303999919444,2948.1689999811356,4
loops,2025-02-05T21:48:28Z,38b719f,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,gcc (Homebrew GCC 14.2.0_1) 14.2.0,g++ (Homebrew GCC 14.2.0_1) 14.2.0,19.1.6,Homebrew clang version 19.1.6,Ruby YJIT,10000,988.1454545538872,14.971385805672192,976.9550000783056,1030.6579999160022,11
fibonacci,2025-02-05T21:48:28Z,38b719f,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,gcc (Homebr
@PEZ
PEZ / throttle.cljs
Last active February 2, 2025 21:28
ClojureScript Leading Throttle utility
(ns pez.throttle)
(defonce !throttles (atom {}))
(defn dispatch! [{::keys [id timeout thunk]}]
(let [maybe-schedule (fn [current-throttles]
(if (contains? current-throttles id)
current-throttles
(assoc current-throttles id
{:timeout
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 20 columns, instead of 10 in line 4.
benchmark,timestamp,commit-sha,is-checked,user,model,ram,os,arch,gcc,g++,llvm,clang,language,run-ms,mean-ms,std-dev-ms,min-ms,max-ms,runs
loops,2025-02-11T00:08:14Z,46f0f4b,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,gcc (Homebrew GCC 14.2.0_1) 14.2.0,g++ (Homebrew GCC 14.2.0_1) 14.2.0,,Apple clang version 16.0.0 (clang-1600.0.26.6),Babashka,10000,4608.662527666667,21.09709503196786,4586.421916,4637.006292,3
loops,2025-02-11T00:08:14Z,46f0f4b,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,gcc (Homebrew GCC 14.2.0_1) 14.2.0,g++ (Homebrew GCC 14.2.0_1) 14.2.0,,Apple clang version 16.0.0 (clang-1600.0.26.6),C,10000,46.258032,0.446943,45.687000,48.242000,217
loops,2025-02-11T00:08:14Z,46f0f4b,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,gcc (Homebrew GCC 14.2.0_1) 14.2.0,g++ (Homebrew GCC 14.2.0_1) 14.2.0,,Apple clang version 16.0.0 (clang-1600.0.26.6),Clojure,10000,45.70783538356164,0.5665339677239569,45.039208,50.217,219
loops,2025-02-11T00:08:14Z,46f0f4b,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,gcc (Homebrew GCC 14.2.0
@PEZ
PEZ / baldr.cljc
Last active November 27, 2024 12:50
Baldr, clojure.test and cljs/test with Mocha-inspired positive reporting
(ns pez.baldr
(:require #?(:cljs [cljs.test :as t]
:clj [clojure.test :as t])
[clojure.string :as string]))
(defn- default [text]
(str "\033[39m" text "\033[22m"))
(defn- gray [text]
(str "\033[90m" text "\033[39m"))
@PEZ
PEZ / fuzzy.cljs
Last active November 3, 2024 13:07
Joyride script for adding fuzzy search in files with instant previews to VS Code
(ns fuzzy
(:require ["vscode" :as vscode]
[clojure.string :as string]
[joyride.core :as joyride]
[promesa.core :as p]))
(defn- get-configured-exclude-patterns! []
(->> ["search.exclude" "files.exclude"]
(mapcat (fn [config-key]
(-> (.get (vscode/workspace.getConfiguration) config-key)
@PEZ
PEZ / highlight_thousands.cljs
Last active October 30, 2024 04:51
A highlighter for long numbers in VS Code, using Joyride
;; Joyride thousands highlighter
;; The end goal here is to help humans read long numbers by highlighting groups of thousands
;; First we need to find the groups of thousands. We only want to highlight _odd_ groups
;; of thousands, starting with the least significant group to the most significant group.
;; We also consider the most significant group of thousands when it is not three digits long.
; Here is some test data, line numbers are on the left
; The xxx are the groups of thousands we want to highlight on the numbers on the line above them.
;08 1111111222111333444 :foo 555666 :bar 123 :baz 1234
;09 x xxx xxx xxx xxx xxx
@PEZ
PEZ / repl_fiddle.clj
Last active October 9, 2024 21:41
Learn Datalog Today REPL Fiddle
(ns learndatalogtoday.repl-fiddle
(:require [learndatalogtoday.handler :as handler]
[datomic.client.api :as d]))
(defn exercise-chapter [n]
(reduce (fn [acc {:keys [question inputs :as exercise]}]
(conj acc [(count acc)
question ((fn [[query & args]]
(list 'comment
(apply list
@PEZ
PEZ / dumdom_defcomponent_macro.clj
Created February 18, 2024 09:37
A workaround to make default linting resolve `dumdom.core/defcomponent` without complaints.
(ns my-dumdom.macros
(:require [dumdom.core :as dumdom]))
(defn- extract-docstr
[[docstr? & forms]]
(if (string? docstr?)
[docstr? forms]
["" (cons docstr? forms)]))
(defn- extract-opts