Skip to content

Instantly share code, notes, and snippets.

Avatar

Michiel Borkent borkdude

View GitHub Profile
View bb.edn
{:tasks {:requires ([babashka.fs :as fs])
:init (do (def platform-alias
(case (System/getProperty "os.name")
"Linux"
"backend/linux"
"Windows"
"backend/windows"
"Mac OS X"
"backend/macosx")))
dev-cljs {:doc "Runs front-end compilation"
@borkdude
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]
'[clojure.tools.cli :refer [parse-opts]])
(def deps '{:deps {com.github.seancorfield/clj-new
{:mvn/version "1.1.297"}}})
(def cli-opts [["-t" "--template NAME" "template"]
@borkdude
borkdude / jpoint_repl.clj
Created Apr 13, 2021
JPoint 2021 REPL session
View jpoint_repl.clj
(ns jpoint.repl
(:require [babashka.main :as bb]
[cheshire.core :as json]
[edamame.core :as e]
[sci.core :as sci]
[sci.impl.analyzer :as ana]
[sci.impl.evaluator :as eval]
[sci.impl.interop :as interop]
[sci.impl.parser :as p]))
@borkdude
borkdude / bb.edn
Created Apr 13, 2021
coffee bb.edn tasks
View bb.edn
{:tasks
{coffeep {:task (do (println "brewing coffee")
(Thread/sleep 3000))
:depends [groundsp hot-waterp filterp mugp]}
groundsp {:task (do
(println "grinding beans")
(Thread/sleep 2000))
:depends [beansp]}
hot-waterp {:task (do
(println "heating water")
View grasp_if_when_seq.clj
#!/usr/bin/env bash
#_" -*- mode: clojure; -*-"
#_(
"exec" "clojure" "-Sdeps" "{:deps {borkdude/grasp {:git/url \"https://github.com/borkdude/grasp\" :sha \"464f86af5866a134374af9ef7ed152882846b531\"}}}" "-M" "$0" "$@"
)
(require '[clojure.java.io :as io]
'[clojure.spec.alpha :as s]
'[clojure.string :as str]
'[grasp.api :as g])
@borkdude
borkdude / rewrite-if.clj
Last active Apr 7, 2021
Rewrite if with rewrite-clj and babashka
View rewrite-if.clj
#!/usr/bin/env bb
(require '[rewrite-clj.zip :as z])
(def code "(defn foo [] (if true :a :b))")
(defn rewrite-if [code]
(let [zip (z/of-string code)]
(loop [zloc zip]
(if (z/end? zloc)
@borkdude
borkdude / malli-match.clj
Created Mar 12, 2021
Core.match like matching with malli
View malli-match.clj
(require '[malli.core :as m])
(require '[clojure.string :as str])
(declare ->schema)
(defn variable? [x]
(and (simple-symbol? x)
(str/starts-with? (str x) "?")))
@borkdude
borkdude / markdown.clj
Created Mar 2, 2021
Markdown to HTML with babashka + bootleg
View markdown.clj
(require '[babashka.pods :as pods])
(pods/load-pod 'retrogradeorbit/bootleg "0.1.9")
(require '[pod.retrogradeorbit.bootleg.markdown :as md])
(def md-text
"# Hello
- This is a list
- Another item")
@borkdude
borkdude / init.el
Last active Feb 22, 2021
clojure-lsp config
View init.el
;; clojure-lsp
;; see https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/
;; and https://clojure-lsp.github.io/clojure-lsp/clients/#emacs
;; ensure the lsp-mode package is installed
(add-hook 'clojure-mode-hook 'lsp)
(add-hook 'clojurescript-mode-hook 'lsp)
(add-hook 'clojurec-mode-hook 'lsp)
@borkdude
borkdude / find-var.clj
Last active Feb 18, 2021
Babashka script to find var usages in current project
View find-var.clj
#!/usr/bin/env bb
;; usage:
;; $ find-var.clj babashka.main/main src:test
;; example output:
;; src/babashka/main.clj:672:32
;; src/babashka/main.clj:673:22
;; src/babashka/main.clj:676:28
;; test/babashka/test_utils.clj:31:59