This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-09
Channels
- # aleph (16)
- # bangalore-clj (1)
- # beginners (57)
- # cider (4)
- # clara (1)
- # cljs-dev (25)
- # cljsrn (12)
- # clojure (76)
- # clojure-dusseldorf (2)
- # clojure-italy (41)
- # clojure-russia (4)
- # clojure-spec (3)
- # clojure-uk (122)
- # clojurescript (101)
- # cursive (8)
- # data-science (30)
- # datomic (2)
- # emacs (2)
- # figwheel (10)
- # fulcro (53)
- # garden (5)
- # gorilla (6)
- # hoplon (1)
- # jobs (1)
- # juxt (14)
- # leiningen (12)
- # om (1)
- # om-next (1)
- # onyx (21)
- # pedestal (40)
- # perun (5)
- # portkey (2)
- # re-frame (16)
- # reagent (1)
- # ring-swagger (3)
- # rum (6)
- # shadow-cljs (239)
- # spacemacs (10)
- # specter (9)
- # uncomplicate (2)
- # unrepl (1)
- # vim (13)
- # yada (16)
there's clojure library FooBar, which uses JNI. There's two JNI options. CPU support and GPU support. Maven package of FooBar has CPU support. I built a local *.so with GPU support. How do I properly package up FooBar so that my local boot config picks up my LOCAL *.jar with the GPU support ?
I expect this to be a mess, so if you can point me at some docs / tutorials, I can go hash it out myself.
Emacs related question, but is there any way go get a list of definitions/functions in the current buffer or project?
Thanks, works like a charm, found imenu-list emacs plugin as well.
sensible testers, how do you access the test result from clojure.test after a test run via lein test
, what I'm looking to do is send email/slackmsg after all tests.
I use use-fixture
to correctly sequence the test, didn't try, but maybe it returns what I'm looking for...
is there an idiomatic way to write a function that will read a string per edn/read-string, but return values that get returned as symbols to be returned as strings instead?
so I can’t really control the input to read-string very well, or I’d prefer not to
I guess i have to try to parse the string as a number, and if it fails just return the string
you can also use a function, not in clojure.core tough, numeric?
if you only want to get the numbers out of the string and read them only.
this one from rosetta stone works for floats I believe
(defn numeric? [s]
(if-let [s (seq s)]
(let [s (if (= (first s) \-) (next s) s)
s (drop-while #(Character/isDigit %) s)
s (if (= (first s) \.) (next s) s)
s (drop-while #(Character/isDigit %) s)]
(empty? s))))
user=> ((fn [n] (try (Float. n) (catch NumberFormatException _ n))) "hello")
"hello"
user=> ((fn [n] (try (Float. n) (catch NumberFormatException _ n))) "10")
10.0
user=> ((fn [n] (try (Float. n) (catch NumberFormatException _ n))) "10.5")
10.5
Does that work for you?is there a clojure built-in for compositing multiple boolean checks? i.e. (?? arg [is-x? is-y? is-z?]))
also I doubt anyone would find this intuitive (though it’s probably useful in some context)
peregrine.circle=> ((every-pred even? pos?) 2 -1 1)
false
peregrine.circle=> ((every-pred even? pos?) 2 4 6)
true
I usually only use the combinators when I'm passing the resulting function somewhere else
I found today a really weird behaviour with insert-multi! and Redshift jdbc driver. If I give to insert-multi! two rows like [["id1" 1.1] ["id2" 2.2]], I get values 1.1 and 2.2 in Redshift. But if I give rows [["id1" 1] ["id2" 2.2]] then I get values 1 and 2 (not 1 and 2.2) in Redshift. I was wondering that this should probably not be the default behaviour (the first row is used to interpret the type of columns or something weird like that)?
can you run into the 20 arg limit of function calls with apply? I'm a little confused why (apply str (take 100 (range)))
works, as i assume this is calling str on 100 args
there’s no such limit, after 20 args it takes a varargs
this is the highest arity defined, notice it ends with Object… at the end https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IFn.java#L89
at least the basics seems to work. the tests are not yet converted to .cljc so there could be dragons
@kaosko re-frame on JVM is only intended for testing/development, not production use
At least at the moment, we haven’t had people want to use it in prod (not sure what the use case is)
But people do use it. re-frame-test allows you to write cross platform tests too
thanks @danielcompton. I'm happily using re-frame on the client but I'm seeing a use case for it on the server as I have to keep a fairly complex load state tree in memory per user. I'm trying it right now!
ok, good luck, let us know how it goes, and feel free to open issues about it on re-frame. It's not a core use for us, but happy to take PRs on it. The architectural pattern for "re-frame on the server" is CQRS, so take a look for other CQRS systems for more inspiration
thanks, sounds good. it's a shot in the dark, but at this point I felt the alternative would have been a plain global atom, so might just as well try re-frame here
I'm trying to add some server side rendering to a pedestal+reframe project
so I just added clostache
and in theory it should be quite simple
I just changed it from
(defn home-page
[request]
(-> (ring-resp/file-response "index.html" {:root "resources/public"})
(ring-resp/content-type "text/html")))
to
(defn- get-config
[language]
(merge
ENV
{:language (str language)}
(get TEXT language)))
(defn render-homepage
[language]
(clostache/render-resource
"public/index.moustache"
(get-config language)))
(defn home-page
[request]
(-> (ring-resp/response (render-homepage :en) {:root "resources/public"})
(ring-resp/content-type "text/html")))
but with the second version Figwheel keeps on complaining that it doesn't find the resource
even though playing around in the REPL it seems all correct
any idea about what it could be the problem?
clojure.tools.logging/log* is the function that all those macros eventually delegate to