Skip to content

Instantly share code, notes, and snippets.

@ChrisBlom
ChrisBlom / datomic-cdc.clj
Last active January 20, 2025 17:48
Datomic change data capture
(ns datomic-cdc.core
"proof-of-concept that shows how setup change-data-capture for datomic"
(:require [datomic.api :as d]))
(def processed-t- (atom nil))
(defn start-cdc-thread
"starts a new thread to processes all past transactions starting at start-t, then continues processing incoming transactions, using the provided `change-handler`
`change-handler` must be a function that takes a single map argument with
@favila
favila / compact-datomic-dev.sh
Created July 18, 2022 18:50
Vaccum or compact unused space from an h2 database (especially for datomic)
#!/bin/sh
# Uses the h2 jar in a datomic distribution to give raw SQL access
# to the h2 database datomic "dev" storage uses.
# The 'SHUTDOWN COMPACT' command in particular performs all
# vaccum-like compaction of the h2 database file to remove
# unused blocks from deleted (garbage-collected) segments.
DATOMIC_HOME=${DATOMIC:-$HOME/lib/datomic/current}
DATOMIC_ADMIN_PASSWORD=${1:?Storage admin password must be provided}
@didibus
didibus / clojure-right-tool.md
Last active February 3, 2025 02:38
When is Clojure "the right tool for the job"?

My answer to: https://www.reddit.com/r/Clojure/comments/pcwypb/us_engineers_love_to_say_the_right_tool_for_the/ which asked to know when and at what is Clojure "the right tool for the job"?

My take is that in general, the right tool for the job actually doesn't matter that much when it comes to programming language.

There are only a few cases where the options of tools that can do a sufficiently good job at the task become limited.

That's why they are called: General-purpose programming languages, because they can be used generally for most use cases without issues.

Let's look at some of the dimensions that make a difference and what I think of Clojure for them:

How to turn your sync API into an async one

Let's suppose that you have a sync API send

(send params)

This API has at least 2 behaviors:

  1. Return a value
  2. Throw an exception
@holyjak
holyjak / fulcro-gotchas.adoc
Last active March 3, 2021 01:11
WIP Fulcro Gotchas document

Common misconceptions and pitfalls in Fulcro.

General

You query the client DB, not the server!

A common misconception is that the Root’s :query is used to load! the app data, i.e. that something like Root query → load! → Root props → rendered UI is happening. It is not. What is happening is Root query → client DB → Root props → rendered UI. You can use a query to also load some data from the backend to feed the client DB but this is up to you, has nothing to do with the just described cycle, and does not need to happen. Also, you essentially never load! the Root query. Instead, you load data for distinct UI subtrees, i.e. sub-queries. So these are two orthogonal, independent processes: rendering client data into the UI and feeding the client database.

A component’s query is relative to its parent component, only Root can "see" keys at the root of the client DB*

@saitonakamura
saitonakamura / iterm2-set-colors-preset.sh
Created November 20, 2020 16:44
Sets iTerm2 color preset based on MacOS setting
# Paste in your .bashrc/.zshrc
# Change to your color presets
ITERM2_DARK_PRESET='OneHalfDark'
ITERM2_LIGHT_PRESET='OneHalfLight'
theme=`defaults read -g AppleInterfaceStyle` &>/dev/null
if [ "$theme" = 'Dark' ] ; then
theme='dark'
@ethpran
ethpran / config.edn
Last active July 21, 2023 21:27
clj-kondo hook for mount/defstate
{:linters {:mount/defstate {:level :warning}}
:hooks {:analyze-call {mount.core/defstate hooks.defstate/defstate}}}
@pyrmont
pyrmont / deps.edn
Last active March 10, 2025 23:39
Figwheel setup with Conjure
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
org.clojure/clojurescript {:mvn/version "1.10.597"}}
:paths ["src" "resources"]
:aliases {:fig {:extra-deps
{com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
com.bhauman/figwheel-main {:mvn/version "0.2.4"}}
:extra-paths ["target" "test"]}
:build {:main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]}
:min {:main-opts ["-m" "figwheel.main" "-O" "advanced" "-bo" "dev"]}
:release {:main-opts ["-m" "figwheel.main" "-bo" "release"]}
@skazhy
skazhy / jargon_spell.md
Created March 24, 2020 09:45
Creating project-specific spellcheck files for Vim

If you want to write technical documentation in Vim with spell check enabled, but do not want to put project-specific jargon in global spell check files, you can create project-specific spellfiles.

First, ensure that markdown files have spell check enabled (either via autocmd or an ftplugin file): setlocal spell spelllang=en_us, Then create a file with some project-specific words in it (it can be empty in the beginning as well, it's okay!)

monadic
@favila
favila / safe-merge.clj
Created February 28, 2020 22:11
merge, but throws on conflicts
(defn safe-merge
"Like merge, but throws if maps have the same keys but different values."
[& maps]
(reduce
(fn [m [m2k m2v :as re]]
(if-some [[_ mv :as le] (find m m2k)]
(if (= mv m2v)
m
(throw (ex-info "Attempted to safe-merge maps with conflicting entries"