Skip to content

Instantly share code, notes, and snippets.

View dcj's full-sized avatar

Don Jackson dcj

View GitHub Profile
Bordertown (Finnish)
Trapped (icelandic)
The Bureau (French)
Deutschland 83
Giri/Haji
Vera
Wallander
Young Wallenberg
Collateral
Detective Montalbano
@MrGung
MrGung / gitlab.clone-group.clj
Created November 10, 2020 15:31
Gitlab: Clone all repositories in group
(ns gitlab.clone-group
(:require
[cheshire.core :as json]
[gitlab.api :refer [get-config]]
[babashka.curl :as curl]
[clojure.java.io :as io]
[clojure.tools.cli :refer [parse-opts]]
[babashka.process :refer [$]]))
(defn clone-all-repos-from-group [{:keys [gitlab-token gitlab-root group-id local-root]}]
@cstby
cstby / cider-eval-n-defuns.md
Last active January 17, 2022 23:12
Faster feedback in Clojure with `cider-eval-n-defuns`.

Summary

You can use this Emacs function to easily evaluate multiple top-level forms in Clojure using CIDER.

(defun cider-eval-n-defuns (n)
  "Evaluate N top-level forms, starting with the current one."
  (interactive "P")
  (cider-eval-region (car (bounds-of-thing-at-point 'defun))
                     (save-excursion
 (dotimes (i (or n 2))
@serioga
serioga / core.clj
Created May 7, 2020 16:45
Example how to handle postgresql arrays in result set (next.jdbc)
(ns app.database.core
(:require
[app.database.sql-array :as sql-array]))
(set! *warn-on-reflection* true)
; SQL Helper functions
(defn text-array
@ikitommi
ikitommi / user.clj
Last active April 5, 2020 16:38
Documenting malli keys and values
(require '[malli.core :as m])
;; using :and
(def Name
[:and {:documentation "Human name"} string?])
;; adding props to predicate schema
(def Name
[string? {:documentation "Human name"}])
@ikitommi
ikitommi / postgres.clj
Last active April 5, 2020 16:33
Postgres key transformations
(ns postgres)
(require '[clojure.string :as str])
(require '[malli.core :as m])
(require '[malli.transform :as mt])
(defn -transform-keys [f m]
(reduce-kv
(fn [acc k v] (assoc acc (f k) v))
(empty m)
@cldwalker
cldwalker / spike-day-02-03-20.md
Last active December 29, 2023 04:52
GraalVM dive in Clojure at work

Spike

I looked into the state of GraalVM and Clojure and wrote some small work-related scripts.

GraalVM Build Tools

@mfikes
mfikes / ESP32-REPL.md
Last active July 6, 2022 22:32
ClojureScript REPL into ESP32

To set up a REPL that has cljs.core available, we need to re-partition the ESP32 and allocate more memory in Espruino for "JsVars".

The default Espruino bootloader.bin, pre-built variants of partitions_esprinuo.bin and rebuilt espruino_esp32.bin, and the ClojureScript runtime core.bin are also available here.

bootloader.bin gets flashed to 0x1000, partitions_espruino.bin gets flashed to 0x8000, and espruino_esp32.bin gets flashed to 0x10000 as per a usual ESP32 Espruino setup, and we put the ClojureScript runtime at 0x2C0000:

Loading :advanced Code into an Unmodified WROVER running Espruino

You can load ClojureScript :advanced code directly into an ESP32 WROVER running Espruino for execution upon boot, by creating a binary and flashing it to the JavaScript "boot ROM" area. This has the same effect as when loading code via the Espruino Web IDE, in the "Direct to Flash (execute code at boot)" mode, but flashing is much quicker and more reliable.

Note: To do this, you'll need an ESP32 WROVER with SPI PSRAM, as opposed to just a WROOM, as the ClojureScript in this example uses more RAM than is available in the WROOM.

Create :advanced Code

Here is a small program that uses enough to pull in data structures, etc, leading to nearly 100 KiB:

(ns mock-avro-example
(:require
[clojure.data.json :as json]
[jackdaw.streams :as k]
[jackdaw.serdes.avro :as avro]
[jackddaw.serdes.avro.schema-registry :as reg]
[jackdaw.test :as jdt]))
(def foo-schema
{:type :record