Fork me on GitHub
#beginners
<
2018-05-04
>
stardiviner05:05:29

When I execute clojure code (require '[clojue.tools.nrepl :as repl]). I got error:

FileNotFoundException Could not locate clojue/tools/nrepl__init.class or clojue/tools/nrepl.clj on classpath.  clojure.lang.RT.load (RT.java:456)
How to fix this?

seancorfield05:05:20

@stardiviner Put an r in clojue to make clojure...

stardiviner11:05:01

Thanks. I missed that, sloppy me.

quadron09:05:38

what is the idiomatic way to make a stateful value (database connection) accessible to all the namespaces without passing it down as function argument?

Alex Miller (Clojure team)12:05:21

The idiomatic way is to pass it

👍 16
val_waeselynck15:05:02

@veix.q5 I agree with @U064X3EF3, but some people prefer the approach taken by Mount: https://github.com/tolitius/mount. Again, I don't recommend that - one more function argument is an insignificant cost, and allows for reifying the environment and making environmental dependencies explicit.

❤️ 4
Alex Miller (Clojure team)15:05:50

yeah, I am not one of those people :)

quadron00:05:15

thanks for clearing this up for me, much appreciated

quadron00:05:41

:thinking_face:

Vincent Cantin04:05:35

if you have multiple environment states that you want to pass, you may also consider passing a map that contains them all and call it something like env.

delaguardo09:05:29

You can set this connection as def in some namespace. And when you need it from another namespace just use :require [db.ns :refer [my-connection]

✔️ 4
sveri09:05:09

@veix.q5 I'd argue the idiomatic way is to pass it down as a function argument. Either as a single argument or as an entry in a map. Non-idiomatic would be storing it in a var for instance. Or you could use something like mount or DIME https://github.com/kumarshantanu/dime

👍 16
delaguardo09:05:31

You also might want to use something like component or mount for organization that kind of statefull components

alan13:05:28

Hi everyone! Does anyone know if a Clojure headless CMS exists?

sjharms14:05:43

I would like to return the first item matching a regex. Here is what I have so far:

(first (filter #(re-find #"something = (\d+)" mydata))) 
;; "some matching thing without the items being grouped by regex match"

sjharms14:05:15

I guess I could use map instead, and then pass that to filter, or is there a more idiomatic way?

lum15:05:31

I've got zero experience with Java and have difficulties assessing a h2 database from a luminus project. When tried:

java org.h2.tools.Server -tcp -tcpPort 9091 -baseDir ~/prog/clojure/orio/orio_dev.db.mv.db 
Error: Could not find or load main class org.h2.tools.Server

seancorfield15:05:51

To start H2 as a server, I think you want java -jar path/to/h2.jar -various -options

seancorfield15:05:17

But you should be able to have it run in memory, without needing to start an external server instance.

lum16:05:26

@seancorfield I'd like to assess it from a client in order to check what I have there and to test some queries

seancorfield16:05:44

@lum Something to consider is starting your Luminus app from inside the REPL, and then also using the REPL to run queries etc.