Skip to content

Instantly share code, notes, and snippets.

View simon-brooke's full-sized avatar
💭
Semper in faecibus sumus, sole profundam variat.

Simon Brooke simon-brooke

💭
Semper in faecibus sumus, sole profundam variat.
View GitHub Profile
@simon-brooke
simon-brooke / README.md
Last active August 1, 2026 16:37
Reagami calculator

Reagami calculator

This is just a very quick experiment with Michiel Borkent's Reagami package.

I found it an astonishingly easy way to build a web GUI. To play with this:

  1. Create a reagami app as documented here, but do not start it:
npm create reagami-app my-app
@simon-brooke
simon-brooke / Jolt-lang-Debian.md
Last active July 6, 2026 15:36
Bringing the Jolt language compiler up on Debian

The Jolt language is an experimental Clojure source to native executable compiler built on Chez Scheme. This Gist describes how I got it running on Debian Trixie.

Firstly, in the jolt repository, the file bin/joltc is a (clever) shell script wrapper. It assumes that the chez scheme executable on your system will be invoked as chez. If you install chez scheme using the Debian package manager, it will be installed as chezscheme, and consequently the script won't find it. I intend to submit a pull request to make the shell script try a number of possible variant names for the chez scheme executable, but I haven't yet done so and, even if I do, it may not be accepted.

I tried creating a symbolic link /home/simon/bin/chez → /usr/bin/chezscheme but this did not work, apparently because the executable constructs the path to its boot file as a relative path from its ex

@simon-brooke
simon-brooke / are_you_lazy.clj
Created August 8, 2025 09:21
Are you lazy?
(ns are-you-lazy
"Sometimes it's useful to check whether an object is lazy without
exploring the whole of it!"
(:import [clojure.lang IPending LazilyPersistentVector LazySeq]))
(defn lazy?
"Return `true` if this `coll` lazy, else `false`.
**NOTE THAT** Probably all lazy sequences are instances of
`clojure.lang.LazySeq`, but `LazySeq` implements an interface `IPending`
@simon-brooke
simon-brooke / map_interval.clj
Created June 5, 2025 11:28
Map, but with a delay
(defn map-interval
"Like `map` -- apply function `f` to each element in `col` in turn and
return the values returned in sequence, but in a single thread and pausing
between each invocation of `f`.
Useful for example in circumstances where you're querying a rate-limited
service."
[f col interval]
(let [a (atom ())]
(doseq [x col]
@simon-brooke
simon-brooke / update-origins.sh
Last active May 20, 2025 17:16
Moving a lot of projects off GitHub
#!/bin/bash
# Script to set all origin URLs of all my projects in my workspace to the new
# (forgejo) URL, replacing previous GitHub URLs.
# Background: I keep all my active projects as subdirectories of the
# directory `workspace`. You need to clone all the projects from GitHub to
# Forgejo **first**, before running this script; but this is simply done
# through the Forgejo user interface. See
# https://www.journeyman.cc/blog/posts-output/2025-03-08-installing-forgejo/
@simon-brooke
simon-brooke / recursive-iterative-performance.md
Last active December 23, 2025 18:34
Comparison of recursive vs iterative performance in various Lisp family languages

Comparison of recursive vs iterative performance in various Lisp family languages

WARNING: These are very crude tests. Note in particular that I should really average times over about fifty runs, because they do vary; and I have not done this.

common lisp (sbcl)

Recursive performance in Common Lisp is very good — better on this test than iterative performance, which surprises me. Note that the iterative algorithm takes about one third more processor cycles, and slightly more store.

@simon-brooke
simon-brooke / fibonacci.clj
Last active December 17, 2024 19:35
Fairly idiomaticFibonacci sequence in Clojure, using `reduce`
(ns fibs.fibonacci
"Compute Fibonacci sequences.
The motivation for writing this was reading a presentation by Stuart
Sierra on Fibonacci sequences in which he showed both recursive and tail
recursive solutions in Clojure, both of which he correctly noted blew up
for large values of `n`, but did not show a `reduce` based solution which
would seem efficient, idiomatic and (relatively) robust.
Stuart's presentation is here:
@simon-brooke
simon-brooke / latest_version.clj
Last active June 9, 2024 14:23
Get the latest stable version of a Clojure (or Java) package
(ns latest-version
"Find the most current stable version identifier of a Clojure (and Java) package."
;; This builds on Yannick Scherer's [ancient-clj](https://github.com/xsc/ancient-clj),
;; which in turn builds on Chas Emerick's
;; [pomegranate](https://github.com/clj-commons/pomegranate/). It goes without saying
;; that I could not have done this without them.
;; Usage: (latest-stable-version 'org.jmonkeyengine/jme3-core)
@simon-brooke
simon-brooke / Downgrading Shotwell database.md
Created June 4, 2024 09:49
Downgrading Shotwell database from 23/0.31.5 to 20/0.30.17

Downgrading Shotwell database from 23/0.31.5 to 20/0.30.17

What this is about

I decided to move back from Ubuntu (23.04) to Debian (Bookworm), essentially because the Snap package management system just annoyed the hell out of me. The one significant thing that broke was Shotwell. Debian Stable is stable precisely because it's not at the bleeding edge, and the version of Shotwell it ships with is older than that in Ubuntu 23.04, to the extent that the databases are incompatible.

How I arrived at this fix

@simon-brooke
simon-brooke / getstarstar.clj
Created May 27, 2024 12:54
Getting multiple properties from a Java object: or, how not to do it.
(ns getstarstar
(:require [camel-snake-kebab.core :refer [->camelCase ->kebab-case-keyword]])
(:import [clojure.lang Keyword]
[java.io File]))
;; What this is about: Ertuğrul Çetin's [jme-clj](https://github.com/ertugrulcetin/jme-clj)
;; contains a very elegant `get*` macro which constructs the name of a java
;; gatter instance method on the fly and then calls that method. This allows you to get
;; an arbitrary instance value from a java 'bean'. It's very neat. But sometimes
;; you will want to get many instance values from the same object, and to return them as