Skip to content

Instantly share code, notes, and snippets.

View jeroenvandijk's full-sized avatar

Jeroen van Dijk jeroenvandijk

  • Amsterdam
View GitHub Profile
@jeroenvandijk
jeroenvandijk / sci_re_matches.clj
Created June 16, 2026 17:07
Sandboxed re-matches in Babashka Sci on the JVM
;; Try with deps-try org.babashka/sci 0.13.52 (see https://github.com/eval/deps-try)
;; The following takes 6 seconds on my machine
(time
(re-matches #"^(.*a){20}$" (str (apply str (repeat 28 \a)) "!")))
;; With Sci's new :interrupt-fn feature we can make regexp's safer:
(require '[sci.ctx-store :as store]
'[sci.core :as sci]
@jeroenvandijk
jeroenvandijk / README.md
Last active December 10, 2025 12:42
Partial CAD03 decoding in Clojure and Javascript (via Squint)
;; Follow up of https://gist.github.com/jeroenvandijk/cb5f3411943c24dc68b225f34a3e474b
;;
;; Now trying to use reitit.openapi still some work in muuntaja.format.json or maybe the json part can be done differently
;;
;; Run this script with `bb bb_reitit_demo_openapi.clj` and visit http://localhost:3000/openapi.json
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {metosin/reitit {:mvn/version "0.9.2"}}})
@jeroenvandijk
jeroenvandijk / reitit_demo.clj
Created October 30, 2025 18:25
Reitit in Babashka with monkey patching
;; TODO create a PR to Reitit to add some `:bb` conditionals
;;
;; Run this script with `bb reitit_demo.clj` and visit http://localhost:3000
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {metosin/reitit {:mvn/version "0.9.2"}}})
;; --- START Reitit monkey patch
@jeroenvandijk
jeroenvandijk / .clj
Last active February 19, 2025 08:19 — forked from apeckham/.clj
find free port in clojure
(defn get-free-port []
(with-open [socket (java.net.ServerSocket. 0)]
(.getLocalPort socket)))
@jeroenvandijk
jeroenvandijk / malli_inline_output.clj
Created November 3, 2022 14:25
Malli inline validation printing
(ns malli.inline-output
(:require
[edamame.core :refer [parse-string]]
[malli.core :as m]
[malli.error :as me]))
;; -- helper code to find location data in an edn file
(defprotocol IUnwrap
(unwrap [_]))
@jeroenvandijk
jeroenvandijk / smart_middleware.clj
Last active February 9, 2022 16:00
An example of composing ring middleware in a more robust and intuitive way?
;; When middleware comes with a certain dependency order things get a bit tedious and error prone.
;; Consider example 1 below:
(defn add-cmd [req cmd]
(update req :cmd (fnil conj []) cmd))
(defn add-cmd-handler [cmd]
(fn [req]
@jeroenvandijk
jeroenvandijk / kahn_sort.clj
Last active January 20, 2022 18:16
Malli composite schema that reuses the values of the underlying values during data generation
;; Copy of https://gist.github.com/alandipert/1263783
;;
;; Copyright (c) Alan Dipert. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns alandipert.kahn
@jeroenvandijk
jeroenvandijk / com.plex.pms.plist
Created January 18, 2022 10:01 — forked from wahlmanj/com.plex.pms.plist
Plex Media center startup plist for use with launchctl
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.plex.pms</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
{:name "Search the Clojurians Slack-archive"
:author "Gert Goet"
:license "MIT"}
;;---
(when-some [q (js/prompt "Search the Clojurians Slack-archive:")]
(.open js/window (str "https://clojurians.zulipchat.com/#narrow/stream/180378-slack-archive/search/" q)))