This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-09
Channels
- # beginners (108)
- # boot (14)
- # cider (8)
- # clara (13)
- # cljs-dev (63)
- # cljsrn (5)
- # clojure (57)
- # clojure-brasil (1)
- # clojure-italy (69)
- # clojure-losangeles (10)
- # clojure-nl (6)
- # clojure-poland (2)
- # clojure-spec (6)
- # clojure-uk (50)
- # clojurescript (116)
- # core-async (1)
- # cursive (9)
- # data-science (8)
- # datascript (4)
- # datomic (43)
- # duct (2)
- # editors (1)
- # fulcro (29)
- # instaparse (7)
- # jobs (6)
- # keechma (3)
- # mount (16)
- # off-topic (61)
- # om (10)
- # onyx (5)
- # parinfer (17)
- # pedestal (2)
- # portkey (5)
- # quil (2)
- # re-frame (84)
- # reagent (9)
- # remote-jobs (2)
- # ring-swagger (2)
- # shadow-cljs (17)
- # slack-help (1)
- # tools-deps (29)
- # vim (23)
I’m using figwheel with cursive. Does anyone know how to make doc, pprint, dir, to etc. follow me around from namespace to namespace? Or do I have to require it everywhere separately?
I have a process (datomic fwiw) that's sending over a lot of logging messages to cider-nrepl. I asked on #datomic how to lower the logging level in the logback.xml file[0]. But noisy processes logging-too-much is a problem I encounter often enough that I'd like a solution that works on the cider-nrepl side. This would be ideal: https://github.com/clojure-emacs/cider/pull/1907 But I recognize that it's not good practice. Question: How do you deal with noisy processes? [0] The specific problem is: "datomic start" command isn't finding my logback.xml file.
I have the same problem all the time (with cider) and haven't found a solution yet 😞
what happens in binding
stays in binding
so what's the difference between binding and with-binding? The docs suggest with-bindings is more thread-safe (if only because it specifically mentions threadlocals)
binding is also thread-safe
both call push-thread-bindings
@xlevus: the difference is that with-thread-bindings wants a function to apply, and a collection of args, while binding takes an arbitrary body of code
otherwise they do the same thing
I just can't figure out how to change the server port in Figwheel. If I change the server port to anything else than the default 3449 (using :server-port 3445) then in the browser (Chrome) I get an error saying "WebSocket connection to '<ws://localhost:3449/figwheel-ws/app>' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED". I have tried to give in the :websocket-url parameter the needed url (:websocket-url "<ws://localhost:3445/figwheel-ws/app>" but Chrome still gives the same error message (complaining that it tries to connect port 3449).
@kari.marttila can we see your figwheel code?
Just a sec...
@funyako.funyao156: here is my figwheel configuration: This works: :figwheel {:http-server-root "." :nrepl-port 7002 :nrepl-middleware ["cemerick.piggieback/wrap-cljs-repl"] :css-dirs ["public/css"]} :cljsbuild {:builds {:app {:source-paths ["src" "env/dev/cljs"] :compiler ... :figwheel {:on-jsload "simplefrontend.core/mount-root" } } ... => Browser works just fine in http://localhost:3449 This ain't working: :figwheel {:http-server-root "." :server-port 3445 ;; default is 3449 :nrepl-port 7002 :nrepl-middleware ["cemerick.piggieback/wrap-cljs-repl"] :css-dirs ["public/css"]} :cljsbuild {:builds {:app {:source-paths ["src" "env/dev/cljs"] :compiler ... :figwheel {:on-jsload "simplefrontend.core/mount-root" :websocket-url "<ws://localhost:3445/figwheel-ws/app>" } } ... => In http://localhost:3445 browser complains: socket.cljs?rel=1523021762398:71 WebSocket connection to '<ws://localhost:3449/figwheel-ws/app>' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
I might be wrong, have you tried delete the generated js before running the figwheel command again?
Haven't tried that. Let's try it.
@kari.marttila Are you using ClojureScript 1.10.238 with :aot-cache
enabled?
If so ~/.cljs/.aot_cache/1.10.238/*/figwheel/connect.js
will have a port number compiled into it.
[org.clojure/clojurescript "1.10.238"] but there is no :aot-cache (unless the default value is enabled).
@kari.marttila I tried it using lein figwheel template, changing the port several time and it works just okay. What I did is delete the generated js and clear the browser cache
@funyako.funyao156: Thanks. Tried lein clean and then in Opera (instead Chrome) - and it worked. So, I write to my instructions: If you change the server port, then: 1. lein clean, 2. Clear browser cache, 3. lein figwheel.
Damn, you guys are great!
This is a great community! It's really great that you guys help beginners like me. This issue was solved pretty fast (like the previous cors one) as soon as I stopped hitting my head on the wall and instead asked for help in this site. 🙂
I'm really excited about ClojureScript. I'm an old backend programmer and I have implemented only one SPA using Angular. I never liked Javascript that much. I have implemented one backend microservice using Clojure and loved it. It's exciting to learn ClojureScript so that in the future I can implement frontends to my backend systems using the same familiar great language.
@kari.marttila best of luck! 🙂 I’m also primarily a backend developer but I’ve have managed to cobble together a few frontends using Cljs and Reagent without too much trouble 😄
@kari.marttila Nice! Happy to hear it's working.
i put a clojure server together with clojurescript in the same project
when i try and run figwheel, I get this error
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
if i include
[com.novemberain/monger "3.1.0"]
but if i comment it out, lein figwheel
runs fine
is there any way to have some dependencies only for the client side?
check the output of lein deps :tree
, you'll likely find that you have a conflict
most likely with guava, because monger depends on clojurewerkz/support, which depends on guava 21.0
you'll likely have another thing that needs a more recent guava
oh i see, it does show conflicts
what does this conflict thing mean?
I had to add a [com.google.guava/guava "23.0"]
dependency for things to work
does the system pick the oldest?
check that
or the newest?
it picks the newest among all the requirements?
Hi! Is there any elegant solutions to circular dependencies in namespaces? I couldn’t think of possible refactoring, because symbols themselves depend on each other.
whatever it picks you want to make sure it only has 1 choice, by using exclusions or explicit dependencies
what it picks is not relevant
why doesn't lein just include all of them?
and limit each dependency chain to use its own
try adding the explicit dependency or doing this [com.novemberain/monger "3.1.0" :exclusions [com.google.guava/guava]]
I don't think that's even possible with the JVM
i see
[com.novemberain/monger "3.1.0"] -> [clojurewerkz/support "1.1.0"] -> [com.google.guava/guava "18.0"]
overrides
[reagent "0.8.0-alpha2"] -> [org.clojure/clojurescript "1.9.946"] -> [com.google.javascript/closure-compiler-unshaded "v20170910"] -> [com.google.guava/guava "20.0"]
and
[hickory "0.7.1"] -> [org.clojure/clojurescript "1.9.293"] -> [com.google.javascript/closure-compiler-unshaded "v20160911"] -> [com.google.guava/guava "19.0"]
and
[org.clojure/clojurescript "1.10.238"] -> [com.google.javascript/closure-compiler-unshaded "v20180204"] -> [com.google.guava/guava "22.0"]
Consider using these exclusions:
[reagent "0.8.0-alpha2" :exclusions [com.google.guava/guava]]
[hickory "0.7.1" :exclusions [com.google.guava/guava]]
[org.clojure/clojurescript "1.10.238" :exclusions [com.google.guava/guava]]
it seems like they're recommending me to use the oldest, which is provided by monger?
@troglotit There is no other solution than refactoring your code until you have a clean dependency graph.
even though it recommends the oldest, it's not always the best solution
and, as I said, I had to use the most recent guava, not the oldest, for things to work
i see. thanks!
do you normally resolve all the issues with exclusions, or do you just resolve it if something breaks?
should do the former, tend to do the latter 🙂
haha i see. excluding guava from monger worked for me too
Hi, i'm trying to sort an array with elements which can has the key :rank but some elements don't have this key, then i want to sort the elements in first by :rank if they have it and if they don't have it i want to sort them by :id. Can you help me to do that plz ? My first approach here was to do 2 arrays then concatenate them.
do you have an example of the array?
[{:rank 0 :id 2} {:rank 1 :id 3} {:id 9}]
?
yes that's it
and the expected output is that too?
@kevin.beaux (sort-by (juxt :rank :id) your-array)
hm i think that doesn't work because nil
is sorted before a number
anyway the first thing that comes to mind is sort-by
[{:rank 0 :id 2} {:rank 4 :id 3} {:rank 1 :id 4} {:id 9} {:id 2} {:id 6}] expected output : [{:rank 0 :id 2} {:rank 1 :id 4} {:rank 4 :id 3} {:id 2} {:id 6} {:id 9}]
maybe sort-by
with a custom comparator
i'm going to try
it gives me this result : ({:id 2} {:id 6} {:id 9} {:rank 0, :id 2} {:rank 1, :id 4} {:rank 4, :id 3})
(sort-by (juxt :rank :id) (fn [[ra ia] [rb ib]] (or (and ra rb (< ra rb)) (< ia ib))) [{:rank 0 :id 2} {:rank 4 :id 3} {:rank 1 :id 4} {:id 9} {:id 2} {:id 6}])
maybe something like that
it doesn't work now
but by tweaking the comp function
you could probably get something
ok thanks 🙂
Hello guys: I need your help in following code: I have data like: [{:number "A1", :name "Alex",:Grade "A"} {:number "2", :name "Bob", :Grade "B"} {:number "B2", :name "Cindy", :Grade "C"} ] I need to print all the data which has ':number' pattern as [A-Z][0-9] So the output should be: [{:number "A1", :name "Alex",:Grade "A"} {:number "B2", :name "Cindy", :Grade "C"} ] The pattern matching I am using is: "#(re-matches #"[A-Z][0-9]*" (:number %))" How can I pass the data and get the filtered data based on the pattern matching on :number.
@rachna.rajput99 does (filter f v)
not return what you want? (where f is your pattern function, and v is your input)
you can use (run! println (filter f v))
if all you want is to print it
you added parens
in clojure, (f) means call f
so ((f)) means call the thing f returns if you call it
you can't call a lazy seq, and filter returns a lazy seq, you can fix the error by removing the extra parens
@rachna.rajput99 if you are familiar with other languages, you can convert f(x) in most languages to (f x) in clojure - the paren does the same thing, it's just in a different position
@U051SS2EU: this code works: (filter #(re-matches #"[A-Z][0-9]*" (:number %)) [{:number "A1", :name "Alex",:Grade "A"} {:number "2", :name "Bob", :Grade "B"} {:number "B2", :name "Cindy", :Grade "C"} ])
Hi everyone, I'm writing my very first macro. I want to generate something like this:
(defn date
[hiccup]
(-> hiccup hiccup-zip second :date))
from something like this:
(zipfunc date second :date)
This is the closest I've gotten, but it's still not working and I'm not sure where I'm going wrong.
(defmacro zipfunc
[fname & xs]
`(defn (quote fname)
[hiccup#]
(-> hiccup# hiccup-zip ~@xs)))
@lgessler Pretty sure you want ~fname
instead of (quote fname)
since you want the value of fname
as the name of the function.
Depending on which namespace hiccup-zip
is in, you may need to use the fully-qualified symbol name there.
Hmm... OK, so here's what I have in my file (hiccup-zip is defined in the same file/namespace, just a bit above this macro definition):
(defmacro zipfunc
[fname & xs]
`(defn ~fname
[hiccup#]
(-> hiccup# hiccup-zip ~@xs)))
(zipfunc date second :date)
CLJS points to date
in the last line and says "Use of undeclared var ewan.spec.eaf30/date". I'm puzzled, because that makes it seem like cljs is trying to evaluate the args to a macro, which of course it's not supposed to do for macrosAnd what is that date
function supposed to signify (in terms of a fully-qualified symbol)?
Oh, sorry, yes, I misread the call.
Are you trying to evaluate zipfunc
in the REPL or is it in the file?
Macros are a bit strange in cljs -- you have zipfunc
in a .cljc
or .clj
file, right? Not .cljs
.
(I don't use cljs at all)
that would be the issue - a macro and it's usage can't be in the same "compilation unit" in cljs
I think that is your problem then: I believe that if you try to define a macro in a .cljs
file, it is treated as a regular function instead.
even with self-hosting cljs, it doesn't work to define and use in the same ns