Archive for the 'Clojure' Category

Datomic: Relationships and refs within a transaction

Wednesday, April 12th, 2017

Not being able to figure this out is what killed all my previous attempts to use Datomic.

You want to transact two Entities that have a relationship between them. You’ve tried all the different variations that Google shows you, but they all give you :db.error/not-an-entity

What you want is the TWO ARGUMENT version of #db/id

Here, Verna gets a Temporary ID of -1 in this transaction. We can then reference that same Temporary ID later under :mother

This of course assumes that you have a Schema that defines :mother as a Datomic Reference, such as:

Also note that #db/id is simply a Tagged Element (similar to a reader macro), not an inline function or symbol reference or anything else.

Notes on Component (Part 1)

Tuesday, April 11th, 2017

Stuart Sierra’s Component library for Clojure took awhile for me to really understand. Hence these notes.

(more…)

Luminus directories: src/clj, src/cljs, src/cljc

Saturday, January 28th, 2017

When you use the lein plugin luminus to create a web application based on the Luminus Web Stack, it creates three directories under src: clj, cljs, and cljc.

What are these for?
(more…)

Googlefood: Running luminus in Cursive (Clojure)

Tuesday, October 4th, 2016

It took me a bit to figure out how to use the REPL inside Cursive with a Luminus project.

The key difference is you have to add a Leiningen Run Configuration, instead of the usual Clojure Repl Configuration, with how you’d normally run it on the command line.

After that, create a Clojure REPL Configuration that connects to the port that is opened by the run configuration.

Example: If you normally do this:

lein run
lein repl :connect 7000

Then the Leiningen Run Configuration is the first command, and the Clojure REPL Configuration is the second one.

Picture, 1000 words, etc.

running-lumunus-project

Clojure Macro Explorations: cond->

Sunday, October 26th, 2014

Some notes I’ve taken on my journey to really understand Clojure macros. Today I basically walked through the cond-> macro in clojure.core, and these are my notes as I figured out how it works.

(more…)