Skip to content

Instantly share code, notes, and snippets.


Michiel Borkent borkdude

View GitHub Profile
borkdude /
Created Jun 22, 2021
Decompiled Clojure
$ clj -Sdeps '{:deps {com.clojure-goes-fast/clj-java-decompiler {:mvn/version "0.3.0"}}}'
Clojure 1.10.1
user=> (require '[clj-java-decompiler.core :refer [decompile]])
user=> (decompile (do (ns (defn foo [])))
// Decompiling class: foo/bar$loading__6721__auto____199
package foo;
import clojure.lang.*;
borkdude / promised_let.cljs
Last active Jun 15, 2021
promised-let from Chlorine's repl-tooling
View promised_let.cljs
(ns promised-let
(:require [sci.core :as sci]))
(def ^:private promised-let
"Async let macro from"
(fn [_&form _&env bindings & body]
(let [binds (->> bindings (partition-all 2 2) reverse)]
(loop [body (cons 'do body)
[[var elem] & rest] binds]
borkdude /
Created Jun 15, 2021 — forked from mukel/
Compiling Java code dynamically and running it in Espresso.
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;
borkdude /
Last active May 21, 2021
C's setenv called from Java in a native image
import org.graalvm.nativeimage.c.function.CFunction;
import org.graalvm.nativeimage.c.function.CFunction.Transition;
import org.graalvm.nativeimage.c.function.CLibrary;
import org.graalvm.nativeimage.c.CContext;
import org.graalvm.nativeimage.c.type.CCharPointer;
import org.graalvm.nativeimage.c.type.CTypeConversion;
import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder;
import java.util.List;
import java.util.Collections;
borkdude / transit_arrays.clj
Created May 19, 2021
Handling arbitrary array types with transit
View transit_arrays.clj
;; clojure -Sdeps '{:deps {com.cognitect/transit-clj {:mvn/version "RELEASE"}}}' -M /tmp/transit_arrays.clj
(require '[cognitect.transit :as transit])
(def default-write-handler
(transit/write-handler (fn [x]
(when (.isArray (class x))
(fn [x]
(when (.isArray (class x))
borkdude / jasentaa.clj
Last active May 8, 2021
Jasentaa parser combinator with babashka
View jasentaa.clj
#!/usr/bin/env bb
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {jasentaa/jasentaa
{:git/url ""
:sha "7161b0bd8029eb29760abd1eb3026a48a8cde318"}}})
(ns jasentaa.worked-example-1
borkdude / kern.clj
Created May 6, 2021
Kern parser combinator with bb
View kern.clj
#!/usr/bin/env bb
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {org.blancas/kern {:git/url ""
:sha "34a8c2f0c1ec5ab3e0e9aac56e6278abc3ed5a0b"}}})
(use 'blancas.kern.core
borkdude / cljstyle.clj
Created May 1, 2021
cljstyle with babashka
View cljstyle.clj
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {borkdude/spartan.spec {:git/url ""
:sha "e5c9f40ebcc64b27b3e3e83ad2a285ccc0997097"}
mvxcvi/cljstyle {:git/url ""
:sha "d264e1e7e634d9f3b3b0aacb3829d430b826766c"}}})
(require '[spartan.spec]) ;; creates clojure.spec.alpha
(require '[cljstyle.config :refer [default-config]]
'[cljstyle.format.core :as fmt]
borkdude / 1) bb.edn
Last active May 28, 2021
Work bb.edn files
View 1) bb.edn
{:tasks {:requires ([babashka.fs :as fs])
:init (do (when (seq (fs/modified-since "deps.edn"
(shell {:dir ".."} "script/gen-deps.clj")))
;; Maintenance tasks
install {:doc "Install frontend dependencies from NPM"
:task (shell "npm install")}
clean {:doc "Clean all artifacts"
borkdude / new.clj
Last active Apr 13, 2021
Babashka script that invokes -X clj-new/create
View new.clj
;; Usage:
;; bb new.clj -t luminus -n foobar/baz --force +h2
(require '[babashka.deps :as deps]
'[ :refer [parse-opts]])
(def deps '{:deps {com.github.seancorfield/clj-new
{:mvn/version "1.1.297"}}})
(def cli-opts [["-t" "--template NAME" "template"]