This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-12
Channels
- # adventofcode (2)
- # aleph (2)
- # announcements (5)
- # aws (5)
- # babashka (25)
- # beginners (167)
- # calva (8)
- # cider (1)
- # clj-kondo (3)
- # cljsrn (19)
- # clojure (87)
- # clojure-conj (7)
- # clojure-dev (19)
- # clojure-europe (1)
- # clojure-italy (14)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-norway (3)
- # clojure-spec (18)
- # clojure-uk (29)
- # clojuredesign-podcast (3)
- # clojurescript (40)
- # clojurex (11)
- # core-async (13)
- # core-logic (2)
- # cursive (16)
- # data-science (4)
- # datascript (10)
- # datomic (53)
- # emacs (1)
- # events (15)
- # fulcro (71)
- # jobs (1)
- # jvm (2)
- # malli (4)
- # nrepl (2)
- # pathom (74)
- # re-frame (1)
- # reitit (19)
- # remote-jobs (1)
- # rewrite-clj (18)
- # ring (2)
- # shadow-cljs (132)
- # spacemacs (22)
- # tools-deps (65)
that's not the correct format though - it's a regex not a shell glob
each file is checked against the regex
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
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 🙂
More of a Java question, does anybody know why
CompletableFuture<Object> anyOf(CompletableFuture<?>... cfs)
has a varargs argument and lets say not a Collection
@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?
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)
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 (127.0.0.1) only?
no I am not. Maybe a problem with a WSL iptable or firewall but I see none being active
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?
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...)
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 0.0.0.0 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 "0.0.0.0"}
. the 0.0.0.0 makes it listen on every address
you should run it with a similar 0.0.0.0 option too (and be sure the port in question is accessible from the host)
Hey there, I just downloaded the clojure RealWorld API backend from https://github.com/furkan3ayraktar/clojure-polylith-realworld-example-app
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.
leningen or boot? which should I use for new project
This podcast ep is great if you want to delve more into it https://clojuredesign.club/episode/040-should-i-use-lein-boot-or-tools-deps/
Thanks, I'm back to leiningen
I'm coming from JS land, what's the best way to interact with a REST API in clojure?
Is it still clj-http
? Sorry been hiatus with Clojure and now I'm trying back don't know whats modern way anymore.
That's what I would use in forming the requests, yeah.
Thank you
Does anyone here uses VSCode + Calva + VIM plugins?
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.
Oh, thanks!
For completeness, this is the relevant doc: https://calva.readthedocs.io/en/latest/vim.html
I remap the keys for now, seems the keys are conflicting
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
[org.clojure/tools.nrepl "0.2.13"]
in the lein profiles.clj
file
and in the project.clj
file of the project that runs in docker
in the lein :dependencies
in your code presumably you have (:require [nrepl.server :as server])
or something similar?
i’m not using it programmatically, i just want to connect to the repl that is running in the container
namely by running lein :connect docker-port
so, let me explain better 🙂
in docker compose i run: lein repl :start :host 0.0.0.0 :headless :port 5678;
as the container’s command
this opens a repl
from the host
i try to connect to this repl by doing lein repl :connect 5678
and then i get that exception, CompilerException java.lang.ClassNotFoundException: nrepl.core,
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
still same error 😕
i might have found the issue, the nrepl
version running in the container is nREPL 0.2.12
it’s 2.8.1
if i upgrade it to the latest one everything works
(in the host i have 2.9.1
)
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 { "
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
it's all there
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.
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.
these are what I have researched so far: https://github.com/day8/re-frame http://www.multunus.com/blog/2016/02/noobs-walkthrough-re-frame-app/
I gave a talk at the last conj that might be helpful https://www.youtube.com/watch?v=JCY_cHzklRs
Thank you Mark! I will watch it and follow-up with you after.
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. https://github.com/day8/re-frame/tree/master/docs
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: https://www.youtube.com/watch?v=vK1DazRK_a0
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" })
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
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
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
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
i'm adding a new entry
i don't get it
mm.. still not getting the result i'm expecting
{"[email protected]" {:p v}
"" {:p v}}
the email is not getting written, just the map i have with it
Okay it must be a typo someplace then