- High level overview https://yogthos.github.io/ClojureDistilled.html
- An Animated Introduction to Clojure https://markm208.github.io/cljbook/
- Interactive tutorial in a browser https://tryclojure.org/
- Interactive exercises http://clojurescriptkoans.com/
- Clerk notebooks with introductory examples https://github.clerk.garden/anthonygalea/notes-on-clojure
- More interactive exercises https://4clojure.oxal.org/
- Lambda Island tutorials https://lambdaisland.com/
- Functional Programming with Clojure resources https://practicalli.github.io/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; clj -Sdeps '{:deps {metosin/malli {:git/url "https://github.com/metosin/malli" | |
;; :sha "68b9940fcf4671a3fcff7bb4844f7f06b2277a34"}}}' | |
; | |
; ███▄ ▄███▓ ▄▄▄ ██▓ ██▓ ██▓ | |
; ▓██▒▀█▀ ██▒▒████▄ ▓██▒ ▓██▒ ▓██▒ | |
; ▓██ ▓██░▒██ ▀█▄ ▒██░ ▒██░ ▒██▒ | |
; ▒██ ▒██ ░██▄▄▄▄██ ▒██░ ▒██░ ░██░ | |
; ▒██▒ ░██▒ ▓█ ▓██▒░██████▒░██████▒░██░ | |
; ░ ▒░ ░ ░ ▒▒ ▓▒█░░ ▒░▓ ░░ ▒░▓ ░░▓ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final case class ZIO[-R, +E, +A](run: R => Either[E, A]) { | |
final def map[B](f: A => B): ZIO[R, E, B] = | |
ZIO(r => run(r).map(f)) | |
final def flatMap[R1 <: R, E1 >: E, B](f: A => ZIO[R1, E1, B]): ZIO[R1, E1, B] = | |
ZIO(r => run(r).flatMap(a => f(a).run(r))) | |
final def provide(r: R): ZIO[Any, E, A] = | |
ZIO(_ => run(r)) |
I looked into the state of GraalVM and Clojure and wrote some small work-related scripts.
- Downloaded GraalVM and set $GRAALVM_HOME
- Found two main libraries for building GraalVM CLIs - https://github.com/luchiniatwork/cambada#packaging-as-a-native-image and https://github.com/taylorwood/clj.native-image (or https://github.com/taylorwood/lein-native-image for the lein equivalent). I chose clj.native-image as it seemed more focused on doing one thing well.
- First tried its template example which was easy to follow.
- Then added a graalvm build to one of our small cli tools
- Found it to be pretty straightforward except for a stdout flushing issue that was trivial to fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.ONESHELL: | |
test: .SHELLFLAGS := -i | |
test: SHELL := bb | |
test: | |
(println :wow) | |
(require '[clojure.string :as s]) | |
(s/reverse (slurp "./Makefile")) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bb | |
;; requires bb 0.2.2 or higher | |
(require '[clojure.java.io :as io]) | |
(defn delete-recursively [f] | |
(let [dir (io/file f)] | |
(if (.exists dir) | |
(do (java.nio.file.Files/walkFileTree |
uce vs lit-element
A very simple comparison table between these two libraries.
uce | lit-element | |
---|---|---|
version | 1.11.9 | 2.4.0 |
license | ISC (simplified MIT) | BSD-3-Clause License |
language | JS w/ TS definition | TS w/ JS transpilation |
size ( brotli ) | 9437b ES5 / 6811b ES2015+ | 8634b ES5 / 6708b ES2015+ |
A minimal example of creating a (mostly) working FUSE filesystem using Clojure. NOTE: I have only tested this with OSX, and it assumes you have already installed libfuse.
Create an empty directory at /tmp/meld
to serve as your mount point,
put these files in a directory called meld
, then:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.core.match :refer [match]] | |
'[clojure.string :as str] | |
'[hiccup2.core :refer [html]] | |
'[org.httpkit.server :as server]) | |
(defn router [req] | |
(let [paths (vec (rest (str/split (:uri req) #"/")))] | |
(match [(:request-method req) paths] | |
[:get ["users" id]] {:body (str (html [:div id]))} | |
:else {:body (str (html [:html "Welcome!"]))}))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns logger) | |
(defmacro log [& msgs] | |
(let [m (meta &form) | |
_ns (ns-name *ns*) ;; can also be used for logging | |
file *file*] | |
`(binding [*out* *err*] ;; or bind to (io/writer log-file) | |
(println (str ~file ":" | |
~(:line m) ":" | |
~(:column m)) |