A cheatsheet inspired by the book "Clojure for the Brave and True".
- C = Control Key
- M = Meta Key (Alt on PCs, Option on Macs)
Examples:
(require '[clojure.edn :as edn]) | |
;; props to didibus https://clojuredocs.org/clojure.core/num | |
(defn numberize | |
[value] | |
(edn/read-string value)) |
;; Returns a function with retries. | |
;; retries: num of retries | |
;; delay: delay between retries in milliseconds | |
;; f: function to apply | |
;; ef: error function, determines if f should be retried | |
;; f and ef should not throw Exceptions | |
(defn with-retry | |
[retries delay f ef] | |
(fn [& args] |
.PHONY: build test deploy | |
##-- Environment Variables --# | |
# Image and container registry | |
IMAGE_NAME := my-image-name | |
IMAGE_PATH := mygroup/myproject | |
REGISTRY := registry-url:port | |
IMAGE := $(REGISTRY)/$(IMAGE_PATH)/$(IMAGE_NAME) |
;; This macro is also available in: https://github.com/wdhowe/clj-contrib | |
(defmacro as-some-> | |
"as->, with the nil checking of some->. | |
Binds name to expr. When name is not nil, evaluates the first | |
form in the lexical context of that binding. When that result | |
is not nil, then binds name to result, repeating for each | |
successive form." | |
[expr name & forms] | |
(let [steps (map (fn [step] `(if (nil? ~name) nil ~step)) |
Notes from watching Stuart Halloway's "Debugging with the Scientific Method" from Clojure/conj 2015.
Clear problem statement: steps you took, what you expected, what actually happened.
Efficient hypothesis: bisect the problem.