Skip to content

Instantly share code, notes, and snippets.

@dustingetz
dustingetz / electric-references.md
Last active June 5, 2025 13:07
Reference list — Electric Clojure

References — Electric Clojure

Electric Clojure implements a form of arrowized continuous time dataflow programming with extensions for network-transparent function composition.

@dustingetz
dustingetz / missionary-concept-map.md
Last active October 24, 2025 14:56
Missionary concept map

Missionary concept map

Missionary primitives fit into three categories:

Effect descriptions = pure functional programming which is about trees not graphs

  • continuous flow, m/?< (switch)
  • m/watch, m/latest, m/cp
  • m/observe
  • m/reductions, m/relieve
@leonoel
leonoel / deps.edn
Created December 30, 2022 10:30
Missionary implementation of kafka consumer with backpressure and manual offset commits
{:deps {org.clojure/clojure {:mvn/version "1.11.1"}
org.apache.kafka/kafka-clients {:mvn/version "3.3.1"}
missionary/missionary {:mvn/version "b.26"}}}
@borkdude
borkdude / test_args.clj
Created November 8, 2022 12:15
Clojure deftest with arguments
;; {:deps {org.babashka/cli {:mvn/version "0.5.40"}
;; babashka/fs {:mvn/version "0.1.11"}}}
(ns test-args
{:clj-kondo/config '{:lint-as {test-args/deftest clojure.core/defn}}}
(:require
[babashka.cli :as cli]
[clojure.test :as t :refer [is]]))
(def ^:dynamic *test-args* (cli/parse-opts *command-line-args*))
@leonoel
leonoel / parallel_processing.clj
Last active October 30, 2022 01:25
Parallel processing
;; Experiment - parallel processing using missionary primitives.
;; Inspired by Rx's parallel 'rails' :
;; http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/parallel/ParallelFlowable.html
;; https://dzone.com/articles/rxjava-idiomatic-concurrency-flatmap-vs-parallel
(ns parallel-processing
(:require [missionary.core :as m]))
(defn map-task [f >x]
(m/ap (m/? (f (m/?> >x)))))
(ns dustin.y2021.missionary_promise
(:require [hyperfiddle.rcf :as rcf :refer [tests % !]]
[missionary.core :as m]))
; We want to turn a promise-thing into a Task
; Leo: The problem with Promise and CompletableFuture is no cancellation
; What task do we want? Is the task listening to the promise? Or is the task the process backing the promise?
; Background: when you get a promise, there is a process in the background which eventually completes the promise.
; Do you want to await the result of an already running promise
; or do you want to run the process of the promise when the task is run?
(ns leo.file-watcher
(:require
[clojure.edn :as edn]
[clojure.java.io :as io]
[missionary.core :as m])
(:import
(java.nio.file Path FileSystems Paths WatchEvent$Modifier StandardWatchEventKinds
StandardWatchEventKinds$StdWatchEventKind WatchEvent)
(com.sun.nio.file SensitivityWatchEventModifier)
(java.io File PushbackReader)))
@leonoel
leonoel / complex_business_process_example_missionary.clj
Last active October 12, 2023 11:16
An alternative solution to didibus' business process using missionary.
(ns complex-business-process-example-missionary
"A stupid example of a more complex business process to implement as a flowchart."
(:require [missionary.core :as m])
(:import missionary.Cancelled))
;;;; Config
(def config
"When set to :test will trigger the not-boosted branch which won't write to db.
When set to :prod will trigger the boosted branch which will try to write to the db."
@Aerijo
Aerijo / tree_sitter_guide.md
Last active March 11, 2026 15:40
Guide to writing your first Tree-sitter grammar

Guide to your first Tree-sitter grammar

NOTE: The Tree-sitter API and documentation has changed and improved since this guide was created. I can't guarantee this is up to date.

About

Tree-sitter is the new way Atom is providing language recognition features, such as syntax highlighting, code folding, autocomplete, and more. In contrast to TextMate grammars, which work by regex matching, Tree-sitter will generate an entire syntax tree. But more on that can be found in it's own docs.

Here, we look at making one from scratch.

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea