Skip to content

Instantly share code, notes, and snippets.

View littleli's full-sized avatar

Aleš Najmann littleli

View GitHub Profile
@ikitommi
ikitommi / malli.scicloj.clj
Last active October 29, 2019 04:09
malli-sciclj
;; clj -Sdeps '{:deps {metosin/malli {:git/url "https://github.com/metosin/malli"
;; :sha "68b9940fcf4671a3fcff7bb4844f7f06b2277a34"}}}'
;
; ███▄ ▄███▓ ▄▄▄ ██▓ ██▓ ██▓
; ▓██▒▀█▀ ██▒▒████▄ ▓██▒ ▓██▒ ▓██▒
; ▓██ ▓██░▒██ ▀█▄ ▒██░ ▒██░ ▒██▒
; ▒██ ▒██ ░██▄▄▄▄██ ▒██░ ▒██░ ░██░
; ▒██▒ ░██▒ ▓█ ▓██▒░██████▒░██████▒░██░
; ░ ▒░ ░ ░ ▒▒ ▓▒█░░ ▒░▓ ░░ ▒░▓ ░░▓
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))
@yogthos
yogthos / clojure-beginner.md
Last active July 15, 2025 07:13
Clojure beginner resources

Introductory resources

@cldwalker
cldwalker / spike-day-02-03-20.md
Last active June 19, 2024 04:24
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

.ONESHELL:
test: .SHELLFLAGS := -i
test: SHELL := bb
test:
(println :wow)
(require '[clojure.string :as s])
(s/reverse (slurp "./Makefile"))
@borkdude
borkdude / delete.clj
Last active October 1, 2020 12:31
Delete file tree recursively using Java NIO
#!/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
@WebReflection
WebReflection / uce-vs-lit-element.md
Last active January 8, 2024 07:16
A very simple comparison table between uce and 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+
@jackrusher
jackrusher / AAA-README.md
Created October 16, 2020 12:02
Clojure + FUSE

Meld

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.

Trying it out

Create an empty directory at /tmp/meld to serve as your mount point, put these files in a directory called meld, then:

@borkdude
borkdude / router.clj
Last active November 8, 2024 01:22
Small ring router using core.mach in babashka
(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!"]))})))
@borkdude
borkdude / logger.clj
Last active April 27, 2021 20:23
Simple logger that works in bb
(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))