This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-14
Channels
- # announcements (3)
- # babashka (189)
- # beginners (157)
- # calva (5)
- # cider (5)
- # clj-kondo (7)
- # cljdoc (34)
- # clojure (61)
- # clojure-dev (2)
- # clojure-europe (42)
- # clojure-nl (15)
- # clojure-poland (1)
- # clojure-spec (5)
- # clojure-uk (6)
- # clojured (2)
- # clojurescript (31)
- # clojureverse-ops (8)
- # component (2)
- # cursive (41)
- # datomic (15)
- # depstar (44)
- # figwheel-main (9)
- # fulcro (14)
- # holy-lambda (1)
- # inf-clojure (13)
- # introduce-yourself (1)
- # jobs (1)
- # lsp (98)
- # malli (12)
- # off-topic (12)
- # pedestal (1)
- # polylith (3)
- # re-frame (51)
- # reitit (4)
- # releases (1)
- # reveal (5)
- # shadow-cljs (3)
- # tools-deps (56)
- # vim (12)
- # xtdb (36)
Some more clojure interop question: Cannot cast clojure.lang.PersistentVector to [F
what is [F
in Java again? 馃檹
Solution is float-array
, nevermind
how do you web devs handle content escaping for your ring webapps? i'm specifically thinking of the server->client direction, in case of e.g. bad html/JS content having been saved to the db bypassing input field validation on the client
Prevent bad data from being saved in the first place. Validate also on the server, using CLJC helps. Have reasonable DB constraints.
client side frameworks and templating engines for example have these baked in (well except for things like PHP).
for example reactjs does this, when you pass a prop as a child it will get escaped by default
you need to pass it through a function that is marked as unsafe (i think it is called dangerouslysomething) if you want unescaped stuff
In other words: you defend against such things where they are used. The issue with not doing that is that you can put two things together (relational data) and pass it to the client. In isolation they might be fine, but not in combination. Not every system can know of the usage context of every other system.
Another Java interop question, in https://github.com/SpaiR/imgui-java/blob/master/example/src/main/java/Main.java#L81, the sliderFloat
method changes the value of flt
(if I understand correctly) that is declared above in the class. How can I reproduce this? I've tried using atoms, but that didn't work.
Solution was a question of scope, it works
In general, you probably want to return the ImGui object to a calling scope, for example after calling necessary functions on it in a separate fn, and pass that around. Exact code would depend on the use case.
@U06KGH6LB No I was really not sure how to even pass flt in this context, but now that I know it's a question of scope, I guess it makes sense to have a state atom and pass it to the whole UI. @U52RNHDRN I am not sure how to do that at the moment
now gui-obj
is a ImGui object where the sliderFloat
function has been called and probably modified it's state. now you can do other stuff with it
I am not sure that's feasible because when you start ImGui it has its own render loop and a process
method that is called at each iteration, so I think it's mostly a question of keeping a state somewhere and have the ui read it
is there a way to print edn in a way that it includes ' quotes? e.g. i want to print code that has a datomic query in it, and i want the query vector to be printed with a preceding quote.
if you want to print code (which is a superset of EDN) this is a different question, I think?
yeah, seems that way. thanks for responding!
yeah i tried that but it's a macro so you can't give it dynamic data to quote 馃槀
exporting datomic transaction functions to a clojure file for use when constructing throw-away in-memory databases for unit tests
would like to be able to emit evaluated code directly into the buffer (thanks CIDER) and then save it, and have tests pick it up. this is why i'm trying to print quotes
the first code block on this page shows what needs quoting; the :params value https://docs.datomic.com/on-prem/reference/database-functions.html
What about if you construct it as data
(let [umap (symbol "umap")]
(list (symbol "if") (list (symbol "every?") umap [:name :email])
[{:user/name (list :name umap)
:user/email (list :email umap)}]
(list (symbol "datomic.api" "cancel")
{:cognitect.anomalies/category :cognitect.anomalies/incorrect
:cognitect.anomalies/message "User map must contain :email and :name"})))
Interesting, I'll give that a go!
How to get String.class in Clojure?
Just String
or java.lang.String
will refer to the Java class @karol.wojcik
(.getDeclaredMethod (Class/forName "java.lang.ProcessEnvironment") "getenv" java.lang.String)
throws
java.lang.Class cannot be cast to [Ljava.lang.Class;It鈥檚 a variable-arity method and that error means that it was expecting to see an array. To call variable-arity Java methods from Clojure, you just have to pass a Java array as the last argument
Yeah!
Thaaanks!
I saw a talk @seancorfield gave a while back on his repl workflow, and he mentioned a helper that eval鈥檇 a let binding but bound the named vars in the scope of the namespace rather than just in the scope of the let. Anyone happen to know more details or a link to a gist or some such? (I鈥檓 thinking it might be an editor-specific helper: hoping to port it to Emacs if need be)
Not sure about the talk, but Cider has C-c C-v C-b
which will ask you for some bindings before evaluating the preceding form ... Does that sound like what you're talking about? Or have I got the wrong end of the stick?
@grzm All of that is in my dot-clojure repo on GH. Specifically, all that key binding does is take the text from the let
binding -- the symbol and the expression -- and wraps it in (def ...)
and evals that.
Cheers. I thought it might be there. I was digging around in there and must have overlooked it. I鈥檒l dig further.
Ah, sorry, no. It's here https://github.com/seancorfield/vscode-clover-setup
Because it's the VS Code stuff (and Clover).
This is what I use too, I call it "inline def" on my blog. I assumed everybody was doing this, but when I published this blog, for some people it was a new idea. https://blog.michielborkent.nl/2017/05/25/inline-def-debugging/ which is being DDOS-ed now :-S Some people use tools for this but I find this usually sufficient to capture values.
Thanks, @U04V15CAJ and @seancorfield! These kinds of snippets/habits may be quotidian, but they鈥檙e oh-so-helpful when you start using them.
Ya, that's a neat little trick, if you use Calva or Cider, you should also try out the debugger, unlike in other language, it is very simple to enter into, its all happening in the REPL. It can be useful for more complicated cases
https://docs.cider.mx/cider/debugging/debugger.html https://docs.cider.mx/cider/debugging/tracing.html
I do use CIDER but I've never really gotten into these features, I keep it very basic in my REPL :)
And enlighten mode as well is neat: https://docs.cider.mx/cider/debugging/enlighten.html
I just say it, because, they take like very little to learn to use and they're great and super quick to use once you know them
There is also https://github.com/vvvvalvalval/scope-capture
I like that one, it does support the simple method of turning a let
into a series of def
s (at least, it's equivalent to that) ... it also supports not introducing new symbols for development purposes (instead using letsc
)
The cider debugger is extraordinarily nifty
Does the clojure starting page always list the latest version of CLI tools? e https://clojure.org/guides/getting_started > curl -O https://download.clojure.org/install/linux-install-1.10.3.855.sh
it would seem so, the docs answered my question a moment later, which was how to see the changelog.
yes, it always lists the latest stable version of the tools