Skip to content

Instantly share code, notes, and snippets.

@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 January 15, 2024 11:23
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 January 27, 2022 05:27
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"]}
@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"
@yogthos
yogthos / clojure-beginner.md
Last active May 6, 2024 08:11
Clojure beginner resources

Introductory resources

@eviltester
eviltester / gist:11093f0e4c501a41990e227393184eda
Last active April 24, 2024 11:35
uncheck twitter interests
var timer=100;document.querySelectorAll("div > input[type='checkbox']:checked").forEach((interest) => {setTimeout(function(){interest.click()},timer);timer+=2000;});