Skip to content

Instantly share code, notes, and snippets.


Michiel Borkent borkdude

View GitHub Profile
borkdude / extension.js
Created Apr 22, 2022
Nbb in VSCode extension
View extension.js
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const vscode = require('vscode');
const path = require('path');
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
* @param {vscode.ExtensionContext} context
borkdude / reaction.cljs
Last active Apr 12, 2022
Reagent ratom / reaction
View reaction.cljs
(require '[promesa.core :as p]
'[reagent.ratom :as ratom])
(def app-state (ratom/atom {:state-var-1 {:var-a 2
:var-b 3}
:state-var-2 {:var-a 7
:var-b 9}}))
(def app-var2a-reaction (ratom/make-reaction
#(get-in @app-state [:state-var-2 :var-a])))
borkdude / class_to_package.clj
Last active Apr 10, 2022
Retrieve the package string from a .class file
View class_to_package.clj
(require '[ :as io]
'[clojure.string :as str])
(defn class->package
"Implementation by Marco Marini."
(with-open [dis ( (io/input-stream class-file))]
;; skip first 8 bytes
(.skipBytes dis 8)
(let [constant-pool-count (.readUnsignedShort dis)
borkdude /
Created Mar 18, 2022 — forked from jackrusher/
Writing and deploying Google Cloud Functions in Clojure using NBB
# command line to deploy the project
gcloud functions deploy hello --runtime nodejs14 --trigger-http
borkdude / find_git_dirs.clj
Last active Mar 16, 2022
View find_git_dirs.clj
(require '[babashka.fs :as fs])
(let [counter (volatile! 0)]
(fs/walk-file-tree "." {:pre-visit-dir (fn [d _]
(if (= ".git" (fs/file-name d))
(do (vswap! counter inc )
borkdude / polyglot.cljs
Created Jan 31, 2022
GraalVM Node + nbb + JVM Clojure
View polyglot.cljs
$ $GRAALVM_HOME/bin/node --jvm --polyglot --vm.cp=$(clojure -Spath) $(which nbb)
user=> (.-version js/process)
user=> (require '["path" :as path])
user=> (path/resolve ".")
user=> (def Clojure (js/Java.type ""))
user=> (def clj:require (.var Clojure "clojure.core" "require"))
View dev.docgen.clj
(ns dev.docgen
(:require [clojure.pprint :refer [pprint]]
[ :as z]
[clojure.string :as str]
[ :as io])
(:import ( File)))
(defn -form->markdown
"Clojure forms are evaluated and the result is automatically inserted in the generated markdown.
There is a special handling for 'def, we show their var binding instead"
View guestbook.clj
(ns guestbook
(:require [cheshire.core :as cheshire]
[hiccup2.core :as hiccup]
[clojure.string :as str]))
(require '[babashka.pods :as pods])
(pods/load-pod "./pod-babashka-postgresql")
(def db {:dbtype "postgresql"
:user "guestbook"
borkdude / shell.nix
Created Dec 26, 2021
Mix and match older tools from nixpkgs
View shell.nix
{ pkgs ? import <nixpkgs> {} }:
graalvm21_2_0 = import (builtins.fetchGit {
# Descriptive name to make the store path easier to identify
name = "graalvm-21.2.0";
url = "";
ref = "refs/heads/nixpkgs-unstable";
rev = "e4dda76e6397fb1e30b907abeaf6a72bb055a1e6";
}) {};
View Segfault
$ bb nrepl-server
Started nREPL server at
For more info visit:
[ [ SubstrateSegfaultHandler caught a segfault in thread 0x00007feb86c0ae00 ] ]
siginfo: si_signo: 11, si_code: 1, si_addr: 0x0000000000000039
General purpose register values:
RAX 0x0000700003f2bf60 points into the stack for thread 0x00007feb86c0ae00
RBX 0x0000000107d78120 points into the image heap (read-only huge)