Skip to content

Instantly share code, notes, and snippets.

View jmglov's full-sized avatar

Josh Glover jmglov

View GitHub Profile
@jmglov
jmglov / bb-bootleg-pod-nixos.md
Created October 26, 2024 11:44
How to make the retrogradeorbit/bootleg Babashka pod work in NixOS

As per Jakub Holý's great Awesome Babashka: Parse & produce HTML and SQLite post, you can use the retrogradeorbit/bootleg pod to get Hickory (HTML to Hiccup parser) in Babashka. However, if you're on NixOS, you're going to get yelled at when you try to start a REPL:

: bb-playground; bb repl                                                                                                                                                                       
Downloading pod retrogradeorbit/bootleg (0.1.9) 
Successfully installed pod retrogradeorbit/bootleg (0.1.9)                                                                                                                                     
Exception in thread "main" java.io.IOException:
@jmglov
jmglov / logger-factory-exception.txt
Created November 6, 2023 06:34
The exception that I get when trying to eval clojure.tools.logging.test in babashka
clojure.lang.ExceptionInfo: Could not resolve symbol: impl/LoggerFactory
{:type :sci/error, :line 202, :column 3, :message "Could not resolve symbol: impl/LoggerFactory", :sci.impl/callstack #object[clojure.lang.Volatile 0x495819d3 {:status :ready, :val ({:line 198, :column 1, :ns #object[sci.lang.Namespace 0x22328391 "clojure.tools.logging.test"], :file "/home/jmglov/Documents/code/clojure/awno-api/src/clojure/tools/logging/test.clj"} {:line 198, :column 1, :ns #object[sci.lang.Namespace 0x22328391 "clojure.tools.logging.test"], :file "/home/jmglov/Documents/code/clojure/awno-api/src/clojure/tools/logging/test.clj", :sci.impl/f-meta {:ns #object[sci.lang.Namespace 0x60734cc4 "clojure.core"], :macro true, :sci/built-in true, :name defn, :doc "Same as (def name (fn [params* ] exprs*)) or (def\n name (fn ([params* ] exprs*)+)) with any doc-string or attrs added\n to the var metadata. prepost-map defines a map with optional keys\n :pre and :post that contain collections of pre or post conditions.", :arg
@jmglov
jmglov / exception.edn
Created February 16, 2023 06:07
Babashka exception
{:cause src/page_views.clj
:via [{:type java.nio.file.NoSuchFileException, :message "src/page_views.clj", :at [sun.nio.fs.UnixCopyFile copy "UnixCopyFile.java" 548]}]
:trace [[sun.nio.fs.UnixCopyFile copy "UnixCopyFile.java" 548]
[sun.nio.fs.UnixFileSystemProvider copy "UnixFileSystemProvider.java" 258]
[java.nio.file.Files copy "Files.java" 1295]
[babashka.fs$copy invokeStatic "fs.cljc" 361]
[babashka.fs$copy invoke "fs.cljc" 346]
[babashka.fs$copy invokeStatic "fs.cljc" 352]
[babashka.fs$copy invoke "fs.cljc" 346]
[sci.lang.Var invoke "lang.cljc" 182]
build-deps {:docs "Builds a layer for dependencies"
:requires ([clojure.java.shell :refer [sh]]
[clojure.edn :as edn])
:task (let [{:keys [deps-path target-dir work-dir]} (th/parse-args)
deps-zipfile (th/deps-zipfile target-dir)]
(when-not deps-path
(th/error "Mising required argument: --deps-path"))
(fs/create-dirs target-dir work-dir)
[java.io.BufferedOutputStream flushBuffer BufferedOutputStream.java 81]
[java.io.BufferedOutputStream flush BufferedOutputStream.java 142]
[babashka.pods.impl$write invokeStatic impl.clj 23]
[babashka.pods.impl$invoke invokeStatic impl.clj 109]
[babashka.pods.impl$bencode__GT_vars$fn__27137$fn__27142 doInvoke impl.clj 134]
[clojure.lang.RestFn invoke RestFn.java 408]
[sci.lang.Var invoke lang.cljc 176]
[sci.impl.analyzer$return_call$reify__5207 eval analyzer.cljc 1205]
[sci.impl.fns$fun$arity_0__3012 doInvoke fns.cljc 83]
[clojure.lang.RestFn invoke RestFn.java 397]
@jmglov
jmglov / tja.js
Last active May 3, 2021 12:58
Userscript to give Gmail a Hey-like UX
// ==UserScript==
// @name Tja
// @version 1
// @grant none
// ==/UserScript==
const elementType = {
bottomBar: 'aeG',
categoryList: 'nH oy8Mbf nn aeN',
chromeDivs: 'nH nn',
openapi: "3.0.0"
info:
version: "0.1"
title: clj-prod-YOURNAME
description: Checkout reporting API
paths:
/events:
put:
summary: Publish new events
(defmethod json-schema/accept-spec 'clojure.spec.alpha/keys [_ spec children _]
(let [name (comp #(clojure.string/replace % "-" "_") name)
{:keys [req req-un opt opt-un]} (impl/parse-keys (impl/extract-form spec))
names-un (map name (concat req-un opt-un))
names (map impl/qualified-name (concat req opt))
required (map impl/qualified-name req)
required-un (map name req-un)
all-required (not-empty (concat required required-un))]
(#'json-schema/maybe-with-title
(merge
@jmglov
jmglov / cffp-02.clj
Last active February 12, 2019 08:26
Clojure for Functional Programmers, lesson 02
;; # Clojure for Functional Programmers 02
;; [<- Lesson 01](https://www.maria.cloud/http-text/https%3A%2F%2Fs3-eu-west-1.amazonaws.com%2Fjmglov.net%2Fteaching%2Fclojure%2Fcffp%2Fcffp-01.clj)
;; Last time on Clojure for Functional Programmers, we learned about s-expressions, literal data structures, and persistent data structures.
;; This time, we'll start with:
;; ## The sequence abstraction
@jmglov
jmglov / fpwc-02.clj
Created February 9, 2019 07:19
Functional Programming with Clojure, lesson 02
;; # Functional Programming with Clojure - L02
;; [<- Lesson 1](https://www.maria.cloud/http-text/https%3A%2F%2Fs3-eu-west-1.amazonaws.com%2Fjmglov.net%2Fteaching%2Fclojure%2Fcffp%2Fcffp-01.clj)
;; In the last lesson, we learned:
;; - What Clojure looks like (prefix notation)
;; - What functional programming is and how it differs from imperative programming
;; - The big three functions: `map`, `filter`, and `reduce`
;; - The meta-algorithm for recursive algorithms