This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-25
Channels
- # babashka (77)
- # beginners (107)
- # calva (20)
- # cider (2)
- # clj-kondo (7)
- # clojure (63)
- # clojure-australia (2)
- # clojure-europe (75)
- # clojure-germany (10)
- # clojure-italy (3)
- # clojure-nl (3)
- # clojure-serbia (15)
- # clojure-spain (2)
- # clojure-uk (24)
- # clojurescript (54)
- # clojureverse-ops (3)
- # cursive (20)
- # datahike (4)
- # datalog (5)
- # datascript (8)
- # datomic (13)
- # emacs (2)
- # fulcro (1)
- # graalvm (2)
- # instaparse (1)
- # jobs (2)
- # luminus (1)
- # malli (7)
- # off-topic (28)
- # pathom (6)
- # pedestal (2)
- # re-frame (5)
- # reagent (9)
- # remote-jobs (4)
- # rewrite-clj (4)
- # ring (19)
- # shadow-cljs (2)
- # spacemacs (2)
- # sql (10)
- # tools-deps (6)
- # xtdb (12)
On a linux system, where does lein install dependencies to, if i use sudo . Was trying to see if the steps for a tutorial wasn't working because I was not running in sudo. I understand that dependencies are normally installed in /home/.m2
$HOME/.m2/repository
(same as macOS and effectively the same as Windows)
All Clojure dependency tools use the same location.
If you use sudo
, I would expect it to use root
’s ~/.m2
location (but… why on earth would you use sudo
with this?)
I mistakenly believed that I might need sudo permissions for ssh capabilities 😅 Am trying to use jepsen
for testing for a distributed systems project
I realise is perhaps a bad habit, cause there have been many instances where I spent a lot time figuring out what is wrong with my commands, only to realise all i needed was sudo
https://cursive-ide.com/ check #cursive as well
Might be the case that cursive can't "see" the clojure compiler but I'm not sure, it's been a while since I last used it. Better to ask over at #cursive I think.
this might help: https://cursive-ide.com/userguide/eap/troubleshooting.html#help-lots-of-symbols-don-t-resolve
The best ide for <language> is the one you're most comfortable with. Which one do you already have experience with? Start with that and if for some reason at some point that's not enough and you want to switch to something else, do it then, not before. It's hard having to learn Clojure and a new editor workflow at the same time.
Yup, I'd say start with that then, it's a decent IDE and was my first experience with clojure as well. Have fun!
@U01P6LWQD1S definitely checkout Cursive then, you won’t be disappointed. Been using it for years.
Is Cursive plugin free with intellij Ultimate @U050KSS8M or Do I need to buy a cursive license separately?
the Non-Commercial license of cursive is free, regardless of you version of intellij
You've read the linked page and you're still not sure?
I was wondering if there is any difference at the usage level for the two. Looks like its same for all the licences
I have installed the cursive plugin in my intellij idea ultimate. Only after putting the license in intellij, it will start working. Right?
After restarting IDEA, Cursive should be working out of the box. Follow the user guide to fine-tune appearance, keybindings, code style etc.
Does anyone have any recommendations of TCP clients to use with Clojure? I want to programatically communicate with a prepl over the wire. I'm assuming the answer is Aleph, but it feels like there is a lot of buy-in with manifold and byte-streams.
I wrote this Gist some time ago about communicating with prepl using core.async: https://gist.github.com/eerohele/e06551b115c6a31d1280a115c4c2abb2
But if you don't already have core.async as a dependency or don't want to add it, you could just use something like java.util.concurrent.LinkedBlockingQueue
.
Is it possible to use http-kit to do raw tcp communication? I reckoned it was limited to http requests. Networking is not my stronget suite, so forgive me if those terms are interchangable in this context.
No you can't. My bad, I read your request too quickly. 🙏
If you want to keep it simple as possible, you can use Java interop like that https://github.com/clojure-cookbook/clojure-cookbook/blob/master/05_network-io/5-09_tcp-client.asciidoc, otherwise, I think Aleph is the most likely solution.
Hi Clojurians. I'm not very familiar with libraries in cljs (or Clojure in general) but I noticed that most frontend frameworks are React inspired in some way. Are there any frameworks that work similar to Svelte?
Thomas Heller who makes Shadow-cljs is working on something like that: https://www.reddit.com/r/Clojure/comments/m2bvy1/shadowgrove_playground_sneak_preview/
Hi all, I am trying to set up tracing in Datadog for a Clojure app which is packaged with Capsule, and I need to specify the packages whose methods I want to trace. Can someone please tell me how Clojure namespaces map on to Java packages? e.g. if I have ns's john.core
, john.foo.core
, ... will these each become their own package at run-time (since I am not using AOT)? Thank you 🙂
when considering an external map structure, is it best practice to convert all keys to keywords (assuming they're all strings) and internally leverage keywords for access?
the external structure is some serialized format - it has not types or implementation yet it's common practice to keywordize keys, but I've seen massive waste of effort in turning some external data into an internal "idiomatic" structure of the same shape, eg. turning "camelCase" into "kebab-case" etc. and implicit keywordizing can lead to the problem of the concretization of the serial format into program data being implicit, and then spread through the program maybe you want keywords maybe you don't, but definitely have an explicit step where the input-stream / string / whatever is turned into usable internal data
the bug where keywordizing arbitrary strings would use up the heap is gone, but keywordizing keys when you aren't converting to a specified internal format is still silly
I'd rather see (get input-data "someJSONKey")
than (:someJSONKey input-data)
e.g. keywordize-keys on all external map structures
I think maybe you can make the argument for keywordizing when the maps have a closed known set of keys, but otherwise it is a waste
in this case, i have a known set of keys which i'm treating as a schema. I wish to walk an external structure and assert those keys are present and perform some additional validation on the values associated. The inbound map would likely arrive as string keys. So given your advice, i should treat my schema keys as strings and not keywords.
(def internal-schema #{:a :b})
(def external-content {:a 1 :b 2})
(remove #(contains? external-content %) internal-schema)
()
(def external-content {"a" 1 "b" 2})
(remove #(contains? external-content %) internal-schema)
(:b :a)
external-data would be sourced from an input stream containing json maps.
Hey everyone, I’m trying to figure out a way to enable a css class for xx number of seconds when a user clicks a button, for example, I have this:
[:div {:class "refresh-icon -animate"}]
but i only want to show the -animate
class for xx number of seconds when a user clicks some button.
In React, I would do something like this:
<div className={`refresh-icon ${showAnimation ? '-animate' : ''}`}>{props.icon}</div>
and then have a method where I would toggle showAnimation true/false
can someone lend a hand please? Thanksthanks @U11BV7MTK, i’ll if i can make that work
at my last job we had a nice utility function for combining class names (u/classes "refresh-icon" {"-animate" show-animation?})
that would take the map of classes and the booleans of whether to add them and combine them. you could implement a function that does this or just use the one-off cond-> style here. The implementation of the utility function would be some kind of accumulation followed by a string/join with a space
@U11BV7MTK, should my entire line look something like this:
[:div {:class (cond-> "refresh-icon" show-animation? (str " -animate"))}
your problem is you need to dynamically create a string. the context doesn't seem relevant. that expression should create the string you care about, provided you have a local var called show-animation?
. Did it work?
actually that doesn’t look right, my compiler is yelling at me, it doesn’t like the show-animation
property
don't put def
s inside of functions. use (let [show-animation? false] your-stuff-here)
yeah i read that somewhere and changed it to
(let [show-animation false])
in my on-click I have:
:on-click (fn [] (show-animation true))
because i want to change it to true when clicked
which should show[:div {:class (cond-> "tasks--toast-icon" show-animation? (str " -animate"))}
is there a simple way in clojure to say if not nil this else that e.g. (player :fantasy-team) ?? "No Team"
Keywords too
Because they do a get
under the covers (essentially).
A hash map can be treated as a function that calls get
on itself with the provided argument(s). A keyword or symbol can be treated as a function that calls get
on its first argument, passing itself as the second argument to get
, optionally passing the last argument (default) through.
It’s why when folks end up with a symbol (instead of an actual function) and do (f 1)
or (f 1 2)
they get nil
instead of an exception.
(having (f)
or (f 1 2 3...)
would give an arity error)
something to keep in mind is a map lookup with a default will only return the default if the key does not exist in the map, so if the key is in the map and associated with nil, you will get nil back
(f 1) will probably give you undeclared var exception. ('f 1) shouldn't
@U04V4KLKC f
was illustrative of a bound symbol: my comment was about passing in a symbol instead of a function value, into code that tried to call it. Sorry, that wasn’t clear.
(that cropped up the other day in relation to someone trying to pass a configurator function into the Jetty adapter via Leiningen project.clj
config — because project.clj
is data, some.ns/my-cfg
is a symbol instead of a function, and the Jetty adapter assumed it was given a function and just “called” the symbol… which “worked” insofar as not throwing an exception but just evaluated to nil
because it was basically (f server)
)
terminal/repl question: For some reason, when I type something into the repl and press "Enter", it deletes the prompt (pushing my input to the left edge of the screen). any ideas why or how to fix this?
There was some Q&A on line in the last 4 weeks or so I saw, but not sure where. http://ask.clojure.org maybe?
With workaround and to track when rlwrap release fixes it
Here: https://ask.clojure.org/index.php/10025/have-prompts-previous-lines-command-started-disappearing
thank you! that's great
@nbtheduke I believe that’s a bug in an older ve… yeah, what @hiredman said.
I’m on an old Mac and have an old rlwrap
and it happens to me. I’ve just learned to live with it 🙂
maybe answered in my replies above
yes it did thanks! and i was able to remove the workaround after upgrading rlwrap so double thank you
Ah, yes! I remember that now. And I think I added that workaround on one of my machines…
its quite annoying if you're creating a bug report and the prompt disappears and you have to manually add it back in
that snippet fixes it, thank you!
I have that .inputrc
file on my old Mac but it doesn’t fix it. I guess my rlwrap is too old?
(for multi-line pasting — if it’s just a single line, the prompt doesn’t disappear)
Hi Everyone, I think I’m pretty close to figuring out this issue, but I’m wondering why my show-animation
property isn’t updating to true and I wanted to find out if the steps below look correct.
I created a variable in my method (let [show-animation? (r/atom false)]...
I have a -animate
style that I want to show when show-animation
is true
[:div {:class ["refresh-icon"
(when @show-animation? "-animate")]}
and I have an on-click
method that sets show-animation
to true when clicking:
:on-click (fn [] (reset! show-animation? true))} "Show Animation"]...
Nothing is happening when I click the Show Animation button. Is there something obvious that I’m missing here?
Edit: might also be worth mentioning when I println show-animation I see #<Atom: true>
I don't use clojurescript, or do much javascript, but you are almost certainly running afoul of whatever is rending [:div ...] as html not knowing it needs to re-render when the atoms value changes
I think most js/cljs frameworks need to be told about those kind of dependencies in someway
one common bug is to put the let binding of the atom inside the render function, which sets the value of the r/atom to false on each render
(defn component [] (let [show? (r/atom false)] [:div {:classname (if show? "show" "hide") :on-click #(swap! show? not)}])) ;; vs (defn component [] (let [show? (r/atom false)] (fn [] [:div {:classname (if show? "show" "hide") :on-click #(swap! show? not)}])))
(if @show? "show" "hide")
right?