Skip to content

Instantly share code, notes, and snippets.

View borkdude's full-sized avatar

Michiel Borkent borkdude

View GitHub Profile
@borkdude
borkdude / index.js
Created November 5, 2021 12:46
Clojure highlighting with JS
import { tags, styleTags, defaultHighlightStyle } from "@codemirror/highlight";
import { LezerLanguage } from "@codemirror/language";
import { EditorState } from "@codemirror/state";
import { EditorView } from "@codemirror/view";
import { parser } from "lezer-clojure";
let style = {
DefLike: tags.keyword,
"Operator/Symbol": tags.keyword,
"VarName/Symbol": tags.definition(tags.variableName),
@borkdude
borkdude / logos.md
Last active October 26, 2021 15:49
company logos

Doctor Evidence

Screen Shot 2021-10-26 at 17 45 01

Pitch

Screen Shot 2021-10-26 at 17 49 37

@borkdude
borkdude / analyze.clj
Created October 25, 2021 16:28 — forked from roman01la/analyze.clj
analyzing unused and undefined re-frame subscriptions via clj-kondo
(ns analyze.core
(:require [clj-kondo.core :as clj-kondo]
[clojure.set :as set]))
;; checks re-frame's :<- syntax
;; to mark dependency subscriptions as used
(def analyze-reg-sub
"(require '[clj-kondo.hooks-api :as api])
(fn [{node :node}]
(let [[_ kw & children] (:children node)
@borkdude
borkdude / gh-releases.rb
Last active September 27, 2021 16:14
Brew install babashka script
# install with brew reinstall --build-from-source ./gh-releases.rb
# set GITHUB_TOKEN to a personal Github token
# then run: gh-releases list :org babashka :repo :babashka
class GhReleases < Formula
desc ""
homepage ""
license ""
url "file:///dev/null"
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
@borkdude
borkdude / vendor-deps.clj
Last active September 26, 2021 09:28
Download deps using bb and unpack in out dir
(ns vendor-deps
(:require
[babashka.classpath :as cp]
[babashka.deps :as deps]
[babashka.fs :as fs]
[clojure.string :as str])
(:import [java.nio.file Files]))
(defn unzip [{:keys [^java.io.File zip-file
^java.io.File destination-dir]}]
@borkdude
borkdude / bb.edn
Last active September 21, 2021 11:43
Babashka tasks + JVM Clojure pREPL
{:tasks
{:requires ([babashka.deps :as deps]
[babashka.process :refer [tokenize]]
[clojure.edn :as edn]
[clojure.java.io :as io])
:init
(do
(def prepl
(delay
(do
@borkdude
borkdude / async.mjs
Last active September 25, 2021 13:14
Async mutable state
var counter = 0;
async function randomSleep() {
return new Promise(r => setTimeout(r, Math.random() * 100));
}
async function doSomething() {
await randomSleep();
counter++;
await randomSleep();
@borkdude
borkdude / 01-README.md
Last active May 4, 2023 03:42
Shadow CLJS require ES Module in script

This shows how to require ES modules in a node script which is itself compiled as an ES module by shadow. I made this to verify if nbb's way of requiring ES modules aligns with other tools that accomplish the same using the CLJS compiler.

Build with npx shadow-cljs compile script. Run with node out/script.js. It will print something like:

#js {:columns 202, :rows 45}
[Function: Spinner]
@borkdude
borkdude / gallery.cljs
Last active March 30, 2024 17:36 — forked from yogthos/gallery.cljs
script to download walpapers from windowsonearth.org, adapted for nbb
@borkdude
borkdude / plet.cljs
Last active August 9, 2021 14:01
plet
;; This code works with https://github.com/borkdude/nbb
(ns plet
{:clj-kondo/config '{:lint-as {plet/plet clojure.core/let}}}
(:require ["https" :as https]))
(defmacro plet
"See https://gitlab.com/clj-editors/repl-tooling/blob/b4962dd39b84d60cbd087a96ba6fccb1bffd0bd6/src/repl_tooling/editor_integration/interpreter.cljs#L26"
[bindings & body]
(let [binding-pairs (reverse (partition 2 bindings))