Skip to content

Instantly share code, notes, and snippets.

Avatar

Michiel Borkent borkdude

View GitHub Profile
@borkdude
borkdude / 01-README.md
Last active Aug 4, 2022
Shadow CLJS require ES Module in script
View 01-README.md

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 / cli_app.clj
Last active Aug 3, 2022
babashka.cli args->opts
View cli_app.clj
(ns cli-app
(:require [babashka.cli :as cli]))
(def spec {:hello {:desc "something"}
:foo {:desc "foo"}
:bar {:desc "bar"
:coerce []}})
(def cli-opts {:spec spec
:args->opts (cons :foo (repeat :bar))})
@borkdude
borkdude / gallery.cljs
Last active Aug 2, 2022 — forked from yogthos/gallery.cljs
script to download walpapers from windowsonearth.org, adapted for nbb
View gallery.cljs
@borkdude
borkdude / pw.clj
Created Aug 1, 2022
Playwright browser + bb chrome devtools
View pw.clj
;; run npx playwright install to install a browser
(require '[babashka.deps :as deps])
(deps/add-deps
'{:deps {tatut/devtools {:git/url "https://github.com/tatut/clj-chrome-devtools"
:git/sha "cc96255433ca406aaba8bcee17d0d0b3b16dc423"}
org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}})
@borkdude
borkdude / new
Last active Jul 23, 2022
Create clojure project with babashka using deps-new
View new
#!/usr/bin/env bb
(require '[babashka.classpath :as cp]
'[babashka.deps :as deps])
(deps/add-deps '{:deps {org.corfield/deps-new {:git/url "https://github.com/borkdude/deps-new"
:git/sha "76259a27c57dba4530671a3d18c610ed904297d7"}
org.babashka/cli {:mvn/version "0.3.31"}
org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}})
View scriptjure.clj
((requiring-resolve 'babashka.deps/add-deps)
'{:deps {scriptjure/scriptjure #_{:mvn/version "0.1.24"}
{:git/url "https://github.com/borkdude/scriptjure"
:git/sha "8d1f303557a0f4a021f33f2b01eb10b33509f46e"
:deps/manifest :deps}
#_{:local/root "/tmp/scriptjure" :deps/manifest :deps}}})
(ns scriptjure
{:clj-kondo/config
'{:config-in-call {com.reasonr.scriptjure/js
@borkdude
borkdude / scrape_tables.clj
Created Oct 5, 2020
Extract HTML tables with babashka and bootleg
View scrape_tables.clj
(ns scrape
(:require [babashka.pods :as pods]
[clojure.walk :as walk]))
(pods/load-pod "bootleg") ;; installed on path, use "./bootleg" for local binary
(require '[babashka.curl :as curl])
(def clojure-html (:body (curl/get "https://en.wikipedia.org/wiki/Clojure")))
@borkdude
borkdude / shell.nix
Created Dec 26, 2021
Mix and match older tools from nixpkgs
View shell.nix
{ pkgs ? import <nixpkgs> {} }:
let
graalvm21_2_0 = import (builtins.fetchGit {
# Descriptive name to make the store path easier to identify
name = "graalvm-21.2.0";
url = "https://github.com/NixOS/nixpkgs";
ref = "refs/heads/nixpkgs-unstable";
rev = "e4dda76e6397fb1e30b907abeaf6a72bb055a1e6";
}) {};
@borkdude
borkdude / zazzle.md
Last active Jun 18, 2022
Zazzle products
View zazzle.md
@borkdude
borkdude / 1) bb.edn
Last active Jun 15, 2022
Work bb.edn files
View 1) bb.edn
{:tasks {:requires ([babashka.fs :as fs])
:init (do (when (seq (fs/modified-since "deps.edn"
["deps.template.edn"
"../base/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"