Skip to content

Instantly share code, notes, and snippets.

@yonatane
yonatane / logseq-todo-query.clj
Created March 27, 2021 21:33
Logseq query example: all TODOs that are tagged or has an ancestor (including page) that is tagged with #clojure
#+BEGIN_QUERY
{:query
[:find (pull ?b [*])
:where
[?b :block/marker "TODO"]
[?b :block/page ?p]
(or [?b :block/path-ref-pages [:page/name "clojure"]]
[?p :page/tags [:page/name "clojure"]]
[?p :page/name "clojure"])
]}
@yonatane
yonatane / mailli-require-either.clj
Created April 10, 2020 10:15
Require either of multiple related keys with humanized error message
(require '[malli.core :as m])
(require '[malli.error :as me])
(require '[malli.util :as mu])
(defn require-either [m ks]
[:and
(mu/optional-keys m ks)
[:fn
{:error/message (str "Must contain either of " ks)}
`(fn [x#] (some x# ~ks))]])