Skip to content

Instantly share code, notes, and snippets.


Michiel Borkent borkdude

View GitHub Profile
borkdude /
Last active Jun 18, 2022
Zazzle products
borkdude / bbsh.clj
Last active May 27, 2022
Fun (non-serious) small shell in babashka
View bbsh.clj
#!/usr/bin/env rlwrap bb
(ns bbsh
[babashka.fs :as fs]
[babashka.process :as process]
[clojure.string :as str]))
(defmacro % [& args]
`(do @(process/$ {:inherit true} ~@args)
borkdude / install-dev-certificate
Created May 26, 2022
View install-dev-certificate
#!/usr/bin/env bash
set -eo pipefail
CERT_NAME="Nextjournal Development Root CA"
echo "Installing development Root CA into system store..."
if uname -a | grep -q Darwin; then
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain $CERT_FILE
borkdude /
Last active May 24, 2022
Project conventions

Some of my conventions:

  • Create initial build.clj with neil add build :deps-deploy true and then tweak. Use vanilla for maximum control and better startup time.
  • Have bb directory with task code which you can require from bb.edn
  • bb dev launches the dev REPL
  • bb publish prepares repo for publish (e.g. by updating something and creating tag), pushes and CI takes over. The name publish originated from vsce publish here
  • Probably going forward: use release count rather than commit count (less complicated to deal with and smaller numbers are easier to remember)
  • For new projects: neil license add mit (or epl1 or so)
View export.clj
foo=> (defmacro export [& var-names]
(let [var-names (set var-names)]
(doseq [[k v] (ns-publics *ns*)]
(when-not (contains? var-names k)
(alter-meta! v assoc :private true)))))
foo=> (defn foo [])
foo=> (defn bar [])
borkdude / inc_number.joyride.cljs
Last active May 11, 2022
Increment number on line in joyride
View inc_number.joyride.cljs
(require '["vscode" :as vscode]
'[clojure.string :as str])
(defn insert-num
(let [editor vscode/window.activeTextEditor
position (.-active (.-selection editor))
doc (.-document editor)
line (-> (.lineAt doc position) (.-text))
character (last (str/trim line))
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