Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeroen van Dijk jeroenvandijk

View GitHub Profile
@jeroenvandijk
jeroenvandijk / smart_middleware.clj
Last active Feb 9, 2022
An example of composing ring middleware in a more robust and intuitive way?
View smart_middleware.clj
;; 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 Jan 20, 2022
Malli composite schema that reuses the values of the underlying values during data generation
View kahn_sort.clj
;; 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 Jan 18, 2022 — forked from wahlmanj/com.plex.pms.plist
Plex Media center startup plist for use with launchctl
View com.plex.pms.plist
<?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>
View bookmarklet-search-in-clojurians-slack-archive.cljs
{: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)))
@jeroenvandijk
jeroenvandijk / sorted.clj
Last active Jul 3, 2020
Babashka script for sorting clojure code lines
View sorted.clj
#!/usr/bin/env bb
(doseq [line (->> (file-seq (clojure.java.io/file (System/getenv "PWD")))
(filter #(.isFile %))
(filter (fn [f] (contains? #{"clj" "cljc" "cljs" "bb"}
(last (clojure.string/split (.getName f) #"\.")))))
(mapcat #(clojure.string/split-lines (slurp %)))
sort
)]
(println line))
@jeroenvandijk
jeroenvandijk / multitime.clj
Last active Jun 12, 2020
Idea for multitime test in Babashka
View multitime.clj
;; Like https://github.com/ltratt/multitime but with the power of Clojure: multi-processor, shuffling, advanced statistics
;; export BABASHKA_CLASSPATH=$(clojure -Sdeps '{:deps {org.clojure/data.generators {:mvn/version "1.0.0"}, org.clojure/math.combinatorics {:mvn/version "0.1.6"}}}' -Spath)
(do
(require '[clojure.math.combinatorics :as combo]
'[clojure.data.generators :as gen])
(let [binaries ["../sci/tmp/sci-25ace7c"
"../sci/tmp/sci-3c01531"
"../sci/tmp/sci-6c8852d"]
@jeroenvandijk
jeroenvandijk / repl_usage.txt
Created May 8, 2020
Babashka spire pod wrapper
View repl_usage.txt
bb
user=> (babashka.pods/load-pod "./simple-pod.bb")
nil
user=> (require '[pod.babashka.spire :as spire])
nil
user=> (spire/magic! )
java.lang.NullPointerException
#error {
:cause "Invalid netstring. Unexpected end of input."
:via
View keybase.md

Keybase proof

I hereby claim:

  • I am jeroenvandijk on github.
  • I am jeroenvandijk (https://keybase.io/jeroenvandijk) on keybase.
  • I have a public key whose fingerprint is EABD B08B 7E40 0750 54C2 9F31 1BDC C90E A3CA BA2D

To claim this, I am signing this object:

@jeroenvandijk
jeroenvandijk / sci_google_cloud.js
Created Feb 22, 2020 — forked from borkdude/sci_google_cloud.js
Google cloud function running sci
View sci_google_cloud.js
const { evalString } = require("@borkdude/sci");
let printlnArgs = null;
function println(...args) {
printlnArgs = args.map(arg => arg.toString()).join(" ");
}
exports.evalClojureExpr = (req, res) => {
const { text } = req.body;
try {
const result = evalString(text, {namespaces: {"clojure.core": {println: println}}});
let value = [];
@jeroenvandijk
jeroenvandijk / heredoc.clj
Created Feb 12, 2020 — forked from cgrand/heredoc.clj
An ugly hacky heredoc for Clojure
View heredoc.clj
(defn heredoc []
(let [delim (.readLine *in*)]
(->> (repeatedly #(.readLine *in*))
(take-while #(not= delim %))
(interpose \newline)
(apply str))))
; The following lines are read (by the reader) as:
; "Look )(\"\\T\na here doc!\n"
#=(heredoc)"""