This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-10
Channels
- # asami (41)
- # babashka (24)
- # beginners (48)
- # calva (41)
- # cider (10)
- # clj-commons (20)
- # clj-kondo (2)
- # cljdoc (8)
- # clojure (131)
- # clojure-australia (4)
- # clojure-europe (17)
- # clojure-hungary (2)
- # clojure-india (2)
- # clojure-nl (3)
- # clojure-uk (1)
- # clojurescript (12)
- # community-development (6)
- # core-logic (4)
- # cursive (11)
- # datomic (22)
- # emacs (25)
- # events (1)
- # exercism (2)
- # fulcro (30)
- # helix (5)
- # honeysql (6)
- # hugsql (3)
- # integrant (12)
- # introduce-yourself (4)
- # lsp (5)
- # malli (5)
- # nextjournal (31)
- # off-topic (4)
- # pedestal (3)
- # portal (51)
- # reitit (33)
- # remote-jobs (1)
- # shadow-cljs (12)
- # sql (10)
- # vim (7)
- # xtdb (37)
ClojureScript beginner, is there an equivalent to calling
on a text file in my jar? Where presumably that text file makes it into .... static assets in some other dir? ... or something? Basically I want my ClojureScript functions to be able to get to static data I control, and I'm used to doing this in Clojure through a resources
subdirectory that gets baked into my (ΓΌber)jar at build time. What is the preferred idiom for this, and should I be asking in #clojurescript instead? So many questions....
if you are using shadow-cljs
, you can use shadow.resource/inline
for reading a file on compile time.
I am not -- am just using lein-cljsbuild
... but I will look at that fn
to see if I can grok it. Thanks!
You can write a macro to access static files as well. Here is an example of slurping an SVG file https://mattgreer.dev/blog/embedding-svg-into-a-reagent-component/
Interesting, thanks!
Hello. I have a question on deftype
documentation (https://clojuredocs.org/clojure.core/deftype)
> You can also define overrides for methods of Object. Note that a parameter must be supplied to correspond to the target object ('this' in Java parlance).
> Thus methods for interfaces will take one more argument than do the interface declarations.
>
> Note also that recur calls to the method head should *not* pass the target object, it will be supplied automatically and can not be substituted.
The last sentence says that when calling the method recursively, this
should not passed. But how can I call the method recursively without passing this
?
It is like a normal recur, you just leave out the first argument (the this parameter)
(xml/alias-uri 'soap12 "")
(xml/emit-str
(xml/element ::soap12/Envelope
{:xmlns/xsi ""
:xmlns/xsd ""
:xmlns/soap12 ""}
(xml/element ::soap12/Body {}
(xml/element :GetWorkers {:xmlns " "}
(xml/element :dataNumber {} "xxx")
(xml/element :bagsBH {} "aaaa"))
)))
hello, i have use clojure.data.xml
generate xml data, and it outputs
<?xml version=\"1.0\" encoding=\"UTF-8\"?><soap12:Envelope xmlns:xsi=\"\" xmlns:xsd=\"\" xmlns:soap12=\"\"><soap12:Body><GetWorkers xmlns:a=\" \"><dataNumber>xxx</dataNumber><bagsBH>aaaa</bagsBH></GetWorkers></soap12:Body></soap12:Envelope>
there is a :a
after xmlns
in GetWorkers
, how can i remove itYou can't remove it unless you remove the xmlns attribute but you can customise it using namespaced xmlns keywords like you have for xsi/xsd/soap12.
does somebody have an idea how to convert a google sheet to clojure data? I coudl download as comma separated values and go from there
If you are still looking for other solutions, reading can be done in a clojure spreadsheet library, fxl. But does require some setup with access keys :) https://github.com/zero-one-group/fxl/blob/develop/src/zero_one/fxl/google_sheets.clj#L65
Google Sheets has an api to get the data directly as well, though I don't recall how easy it was to use.
yea I googled and followed a guide to get the json hackily. Really wierd - but I have what I need π
Hi I have a file coming in from the client multipart params to the server:
{:filename "download.png", :content-type "image/png", :tempfile #object[java.io.File 0x52ecc329 "/var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/ring-multipart-5763616289942355055.tmp"], :size 15035}
I want to save it to a file on the server. How do I do that?@U01F1TM2FD5 from the looks of it, it's already in a file (the :tempfile
property). You can copy it to another location using any available Clojure or Java function (take a look at https://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html#copyFile-java.io.File-java.io.File-).
I found this a little bit mind-twisting. For example, some
considers logical true, but if-some
considers not nil
and if-let
instead considers logical true. Why the inconsistency?
I somehow remember there being something about spec.gen and doing for example human readable strings for sample data. Like atm I get really random strings but the use case is sample data for a search completion thingy
Probably not what you're referring to but test.chuck's string-from-regex
might do what you want
https://github.com/gfredericks/test.chuck#string-from-regex
I want to write a macro my-nil
sets a given variable to nil
.
That is, (my-nil abc)
should be expanded to (def abc nil)
.
Is this implementation correct? (It seems to work at the first glance.)
(defmacro my-nil ""
[var-name]
(list 'def var-name nil)
)
Or macroexpand-1
Can anyone point to resources explaining how a Clojure library comes to be consumable via ClojureScript and/or how to determine if that is the case for a given library? I'm very new to the ecosystem, and confused by the fact that e.g. https://github.com/clojure/core.match explicitly states that it supports both, but the namespaces appear to be different, whereas https://github.com/clojure/algo.generic doesn't say whether it can be used via ClojureScript.
if you want to go beyond just looking at readmes, the presence of .cljs files or .cljc files may be indicators
My confusion is compounded by the fact that my .cljs file is actually using the "Clojure" namespace referenced in the core.match README, so currently looks like this
(ns foo.bar
(:require [clojure.core.match :refer [match]]))
but seems to work as far as I can tell.
The reason for my question is that I was trying to start using algo.generic.functor in my .cljs file as well, so far unsuccessfully. I wasn't sure if I was just fumbling the dependency updates or if I was trying to do something impossible.So there is no definitive way to tell beyond try it and see?
I don't deal much in clojurescript, but the compiler for cljs has some automatic support for swapping the clojure namespace name for the cljs namespace name
but the lib won't work automatically regardless - it has to have either cljs or cljc files (algo.generic does not)
(perhaps a better suggestion is that you probably shouldn't use algo.generic)
So the answer is something like, if the library is written in cljc then the compiler for cljs can handle it somewhat automagically, but if the library is written in clj than it cannot?
it is just some namespace names the cljs compiler will automatically replace with the cljs namespace name
more that if it has cljc then presumably the author has put thought into making it work with cljs
So the library writer has to explicitly provide cljs.* namespace versions of their stuff that actually work with CLJS, but if I try to load a clojure.foo namespace in a .cljs file the compiler will say, "Hey, you probably meant cljs.foo I bet."
That last part is a little odd and surprising, but fair enough.
a clojurescript namespace can come from a .cljs file or a .cljc file, and a clojure namespace can come from a .clj or a .cljc file
So if I want to see if a library supports CLJS, the best indicators are README and/or to see if they define a cljs namespace?
so .cljc files are intended as a way to share code between different clojure implementations
Ok. Thank you!