Fork me on GitHub

you shouldn't put things in resources/ you don't want included in built artifacts


i’m still interested though


i found: :uberjar-exclusions [#"resources/my-excluded-directory/*"]


that's not the correct format though - it's a regex not a shell glob


each file is checked against the regex


is the problem with that then that it’s slow?


it's that nothing that it tries to put in the jar will match that pattern


other than the directory itself I guess - that * is "zero or more /" which isn't useful


ah thanks-- do i undertand correctly that :uberjar-exclusions [#"resources/my-excluded-directory/.*"] fixes it?


yeah - that should do it - I'm not sure if leiningen is doing a whole string match or substring match though

👍 4

ok--i was wondering why it seemed to do what i want. files like resources/my-excluded-directory/myfile.xml were being excluded because they match my first regex.


oh - then it's doing substring exclusion - the * threw me off because it's a valid glob and this matcher is definitely not doing glob matches


so you can use your original without the * and the substring match should suffice


Because it would have matched zero or more / at the end so it was matching the directory and excluding everything in it 🙂

Ivan Koz01:11:48

More of a Java question, does anybody know why

CompletableFuture<Object> anyOf(CompletableFuture<?>... cfs)
has a varargs argument and lets say not a Collection


so that you can write anyOf(cf1, cf2, cf3) and not create a List

Ivan Koz02:11:03

eh.. not fun, ty ghadi


@nxtk One of those interop cases where a wrapper can make life a bit more friendly...


After a fresh lein new app and a (require '[clojure.spec.alpha :as s]) (same thing if adding it to ns), the only method defined is s/even-number-of-forms?. No s/valid?, etc. What did I do wrong?


Nevermind, it was a typo.


Is even-number-of-forms? something from the core.specs for the language itself @dromar56?


I think it's a helper function for the specs of core. When doing the require using auto-complete I somehow required clojure.core.specs.alpha instead of clojure.spec.alpha


Ah, yeah, sounds about right.


Hi everyone! Have any of you guys tried static analysis with SonarQube for Clojure? I'm having trouble running it on a multi-level project, because it says "plugin_name is not a task", but when I run it in every individual sub-project it runs fine. with all of its plugins (cloverage, lein ancient, kibit, nvd)

Mehdi H.09:11:22

hello! I am using vase and trying to allow CORS on the underlying jetty server. But adding :io.pedestal.http/allowed-origins {:allowed-origins (constantly true)} to the http-options for the service map doesn't have any effect (I even set :io.pedestal.http/secure-headers {:cross-domain-policies-settings "all"} out of desperation). Anyone has any clue what I am doing wrong? My service is up (a request targetting localhost works), but not when I use my IP, I get a connection refused...


"Connection refused" implies that the problem is lower down in the stack than CORS. Are you perhaps running a server bound to the localhost interface ( only?

Mehdi H.13:11:01

no I am not. Maybe a problem with a WSL iptable or firewall but I see none being active

Mehdi H.13:11:29

Hold on, you may be right, but I have no clue how I did that if that is the problem. How can one specify which interface to bind the service to?


How are you running your server?


Nm. I see you got helped 🙂

Mehdi H.20:11:58

yeah but you helped me first! Thanks a lot for that!!

😜 4
Mehdi H.10:11:13

I am on WSL running ubuntu 18.04. I deactivated the windows host firewall but with no luck. I thought WSL1 didn’t support iptables but this could be a reason (that or a firewall in ubuntu...)

Mehdi H.13:11:49

So it turns out that I may be indeed running a server bound to the localhost interface only. Can someone lend me a hand in understanding how to launch my server and bind it to instead?


i don't know how pedestal wraps it, but servers usually accept options like :host and :port


for ring's run-jetty i'd give {:port 3000 :host ""}. the makes it listen on every address


you should run it with a similar option too (and be sure the port in question is accessible from the host)

Mehdi H.14:11:35

thanks a lot!

Mehdi H.14:11:48

just tried :host indeed and it works with

Mehdi H.14:11:58

much appreciated


👍 good luck!

Mehdi H.14:11:48

thanks, needed badly haha

Edward Hughes14:11:03

Hey there, I just downloaded the clojure RealWorld API backend from to play around with it a bit but I've had some trouble actually getting it running. Tried calling lein run server-headless at the command line from the development directory as indicated, but it threw a compiler exception while getting the dependencies. Somehow got a syntax error while macroexpanding something from clojure.core. Not sure what could be causing it - apart from some arcane dependency issue - or what to do, really.

Sandae Macalalag15:11:44

leningen or boot? which should I use for new project


If you don't know that you need boot, use leiningen.

👍 8
Sandae Macalalag15:11:23

Thanks, I'm back to leiningen

Sandae Macalalag15:11:04

I'm coming from JS land, what's the best way to interact with a REST API in clojure?

Sandae Macalalag15:11:19

Is it still clj-http? Sorry been hiatus with Clojure and now I'm trying back don't know whats modern way anymore.

Edward Hughes15:11:07

That's what I would use in forming the requests, yeah.

Sandae Macalalag15:11:00

Does anyone here uses VSCode + Calva + VIM plugins?

Sandae Macalalag15:11:20

It seems VIM is not working properly, ESC not working on the editor when I'm trying to get back to navigation mode


I do not know, but noticed there is a #calva-dev channel on Slack that you could try asking in.

❤️ 4

For completeness, this is the relevant doc:

Sandae Macalalag15:11:12

I remap the keys for now, seems the keys are conflicting

Andrea Imparato16:11:07

hello, anybody can help me? I’m trying to connect to a repl inside a docker container and I get CompilerException java.lang.ClassNotFoundException: nrepl.core even though I added nrepl as dependency both in the host and in the container


how did you require it?

Andrea Imparato16:11:08

[org.clojure/tools.nrepl "0.2.13"]

Andrea Imparato16:11:19

in the lein profiles.clj file

Andrea Imparato16:11:52

and in the project.clj file of the project that runs in docker


that's extremely old. you probably want [nrepl/nrepl "0.6.0"]


and how are you requiring it from your code?

Andrea Imparato16:11:54

in the lein :dependencies


in your code presumably you have (:require [nrepl.server :as server]) or something similar?


and use the newer version i listed above

Andrea Imparato16:11:56

i’m not using it programmatically, i just want to connect to the repl that is running in the container

Andrea Imparato16:11:19

namely by running lein :connect docker-port

Andrea Imparato16:11:45

so, let me explain better 🙂

Andrea Imparato16:11:02

in docker compose i run: lein repl :start :host :headless :port 5678; as the container’s command

Andrea Imparato16:11:10

this opens a repl

Andrea Imparato16:11:31

from the host i try to connect to this repl by doing lein repl :connect 5678

Andrea Imparato16:11:48

and then i get that exception, CompilerException java.lang.ClassNotFoundException: nrepl.core,

Andrea Imparato16:11:55

makes sense? 🙂


ah, remove the [org.clojure/tools.nrepl "0.2.13"] from your deps. lein provides this by itself and the newer version and older version conflict

Andrea Imparato16:11:21

still same error 😕


did you rebuild the containers?

Andrea Imparato16:11:06

i might have found the issue, the nrepl version running in the container is nREPL 0.2.12


what version of lein is that?

Andrea Imparato16:11:29

if i upgrade it to the latest one everything works

Andrea Imparato16:11:57

(in the host i have 2.9.1)


ah. yeah. there's a mismatch there. you had old nrepl connecting to new nrepl

Andrea Imparato16:11:45

thanks a lot @dpsutton for the support 🙂


Hallo, I'm trying to use Selmer to render some user data. I have the user data in an atom.


looks like { "" {:prop1 "" :prop2 "" :prop3 ""}}


Selmer lets me do {% for user in users %} but i'm not sure how to do sub-indexing on each email. I can do {{user}} and get the whole chunk, email and props. how can i dissect this?


oh neat I can just use numbers! 😃


user.1 and user.1.prop1 work great


how 2 numbers in for loop....


{{users.{{forloop.counter}}.prop1}} does not work, how can I iterate over this data?


Nevermind. I was doing too much work xD

Aleks Abla20:11:00

Hi everyone! Hope you are all having a great day. I am a novice programmer, who recently picked up Clojure. It's been a lot of fun, and I have started playing around with ClojureScript and Re-Frame.

Aleks Abla20:11:12

I am having trouble wrapping my head around the interplay of routers, data stores, views, handlers and subscriptions. I understand what each one does theoretically, but I am shaky on how each interacts, especially as the app listens to the user and adapts. Could anyone recommend good resources to for me to look at? I am trying to build a single page application, that would act as a dashboard with basic statistics. Further down the line would love to add graphs and whatnot.


I gave a talk at the last conj that might be helpful

Aleks Abla21:11:54

Thank you Mark! I will watch it and follow-up with you after.

Aleks Abla14:11:26

Mark, I watched the video and it was extremely helpful, particularly the diagram between app db, components and event handler. A cherry on the cake would have been to see a similar inner-working diagram for the code of subs, dispatching and handling. Any chance you have some resources on those?


I think the best resources for those are the re-frame docs themselves.

Aleks Abla22:11:01

Yep, I found this which has been a step in the right direction. Thanks for all the help!


I heard in many talks the expression “please, push the side effects to the edge” or “isolate the side effects” .. I was re-studying the haskell and purescript. both languages the side effect is delayed until really is needed and isolated on IO/Effects. two questions: 1. How can I accomplish that using clojure ? 2. What benefits isolating side effects the project will gain ? ( will make tests easy — how ? )


I have always viewed it as an issue of code structure, rather than language feature. An application is a system which composes pure logic with effectful behaviour, so the "isolate side effects" is about structuring your code into pure functions, effectful functions, and application logic to explicitly compose them together. Not specifically about side-effects, but I found this talk by Rafal Dittwald very helpful in conveying the benefits of good code structure:


As for benefits, testing and reasoning about decoupled components is easier in that pure logic can be tested, say, without setting up a database. Likewise, testing that your side-effects behave properly doesn't require understanding a bunch of unrelated logic.


what "push effects to the edges" means in practice is when writing abstractions, don't hide side effects under layers of abstractions, rather make abstractions for the things that are "pure" (don't rely on external state or mutation), and then put the side effects generally closer to the top


because what happens when you put side effecting code inside supposedly functional abstractions is that every layer between the top level and the side effect now has to care about that side effect


which tends to make code harder to maintain and more complex to test


generally, my code contains “3” layers, web (handlers, validating output values ), service layer ( coordination ) and datalayer ( talks with persistence ). my service layer will communicate with my datalayer ( side effect ) .. how could achieve that using my “3" layers


the way that tests are made easier is that in order to test something with side effects you need to manage and/or mock state, with pure code none of that matters, you can just use it directly


all three of those layers are side effects


inside each one you isolate the action (store data, send data to a user, get data from a user) from the transforms (strict function of input to output)


my service layer is responsible for the logic … for instance, my invoice system will sum the invoice items and validate with invoice total


I might have misunderstood what you mean by "coordination"


if it communicates to another layer that isn't on the same cpu or in the same program, that's a side effect


yeah, maybe not the best word . I meant , my service layer will be responsible to call the function which will validate the invoice, and then call the database layer


right, and calling something which does a side effect is a side effecting operation


so it's not just your service layer that has logic in it - really every useful program has some combination of data -> data pure operations, and something that pokes or responds to external state


and in clojure every working function is a program


(defn create-invoice [db invoice-payload] 
   (ensure-valid-invoice invoice-payload)
   (db/save-invoice db invoice-payload))


ensure will throw exception if invoice-payload is not valid (ex-info "invalid invoice" {:type :invalid-invoice :reason "whatever" })


don’t know how to refactor that, for instance


there's no logic there - it's just side effects


a throw is also a side effect


the logic is already factored into ensure-valid-invoice


so, what could be a logic then ?


there's logic inside each of the functions you call there, surely - logic you don't have to care about in that top level function (which is a sign it's already well factored surely)


what the guideline we are talking about addresses is for example usage of map and filter - these are lazy functions best suited to pure code, and if you do side effecting ops like validating data (with a potential throw) or io to a db, inside them, you will get weird and hard to debug problems


yeah, makes sense


Hi is there a way to process human readable dates easily/


I'd like to be able to type in 2020-12-9 and not break the world 😄


Check Selmer docs there’s everything about formatting dates :).. just today I parsed that into Dec 9, 2020


What's the issue? The 9 instead of 09?


Thanks @UE35Y835W I will take a look. I'm mostly trying to do time equality check to see if subscriptions are valid currently


I have an atom indexed by e-mail


{ email {:prop1 val1 ...}} how can i swap and add a new entry like the one above?


(swap! atom conj email {:k v}) is not working


maybe i'm missing something


you want to add a new entry in the {:prop val1 ...} map?


(swap! atom update :email assoc :k :v)


or (swap! atom assoc-in [:email] :k :v)


I guess email is not a keyword but the actual email string


But yeah the idea is the same


then assoc-in


it has the benefit of creating intermediate maps if they don't yet exist


i'm adding a new entry


user=> (assoc-in {} [:a :b :c] :val)
{:a {:b {:c :val}}}


(swap! atom assoc email {:k v})


Or the above


mm.. still not getting the result i'm expecting


What are you expecting


the email is not getting written, just the map i have with it


(swap! atom assoc email {:p v})


Okay it must be a typo someplace then


Thanks it is working ^.^

👏 4

you're using it like assoc


Replace assoc with conj indeed