This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-09
Channels
- # alda (9)
- # announcements (1)
- # beginners (6)
- # boot (140)
- # cbus (2)
- # cider (27)
- # cljs-dev (19)
- # cljsrn (17)
- # clojure (104)
- # clojure-art (1)
- # clojure-brasil (5)
- # clojure-colombia (2)
- # clojure-russia (146)
- # clojure-sg (3)
- # clojurescript (64)
- # clojurex (1)
- # cursive (17)
- # data-science (22)
- # datomic (41)
- # editors-rus (5)
- # events (1)
- # hoplon (61)
- # ldnclj (35)
- # lein-figwheel (1)
- # off-topic (1)
- # om (119)
- # onyx (214)
- # re-frame (3)
- # reagent (13)
- # robots (5)
- # slack-help (1)
- # yada (17)
@twillis: I’ve used like
before, but not in sqlite:
(defn find-by-title-or-description
[db search-term]
(let [query "SELECT * FROM recordings WHERE title ILIKE ? OR description ILIKE ? "
search-q (str "%" search-term "%")
q (-> (h/select :*)
(h/from :recordings)
(h/where [:or
[:like :title :?title]
[:like :description :?title]])
(sql/format :params {:title search-q}))]
(j/query db q)))
Hey, any friendly clojure...ists? willing to help me answer a question? I have a vector of 1s and 0s and I want to sum the 1s and combine the 0s eg, [ 0 0 1 1 1 0 1 0 1 1] => [ 0 3 0 1 0 2 ] It seems like there should be a clojure-y way to do this, but I can't seem to figure it out
nvm, I figured it out
@fluffywaffles how did you do it? I would have partitioned by 0 and 1 and then reduced the sublists. Puzzles are always interesting 😄
ah and flattening at the end...maybe.. I need to try
For 0 partition you just take first, for 1 paritions you reduce with sum
I did it using partitions, partly, yeah!
(->> array
(partition-by #(= 1 %))
(map (partial reduce +)))
I didn't need a flatten
at the end, but I could have used that to get it back into normal list format
(->> [0 0 1 1 1 0 1 0 1 1]
(partition-by zero?)
(mapv #(apply + %)))
I wanted to play, too
@charliegriefer: I like using zero?
better; I didn't realize that would work
Yeah, seemed a bit cleaner
I’m constantly amazed by how many built-in functions Clojure has that make so many tasks easier than I expect they’ll be.
@tap: wow. That makes such perfect sense. I, too, am I’m constantly amazed by how many built-in functions Clojure has that make so many tasks easier than I expect they’ll be.
@bronsa: not really, no (group-by (comp boolean #{1}) [1 1.0 1N 1M]) => {true [1 1N], false [1.0 1M]}
in reality of course it just dispatches to Numbers.isZero
but that's implementation detail, the semantics are identical to (== 0)
Does anyone have a "gauge" for map/filter pipelines?
I'm thinking of a step you add to your processing pipeline that prints a dot for every 1,000 items processed
@delaguardo: that looks nice (but uses a global (init) function it seems)
yes, but also it has re-init function
Hello, someone here, who could me with clj-wamp?
@delaguardo: I just copied the idea of a tick
function with dynamic var
thanks!
you’re welcome)
Hi - I’m getting an error with lein/clojure typed that I’m not understanding: Caused by: java.io.FileNotFoundException: Could not locate clojure/tools/analyzer/passes/trim__init.class or clojure/tools/analyzer/passes/trim.clj on classpath.
This is using clojure 1.7, lein typed 0.3.5, and org.clojure/core.typed 0.3.15. Any tips to debug this? I’m new to both clojure and the java ecosystem.
@derwolfe: this looks to me like you’re messing something up in your :require
s somewhere
i’m not familiar with tools.analyzer
, but i suspect that you’re accidentally requiring a var as if it were a namespace
if you want something named trim
that lives in clojure.tools.analyzer.passes
, you’ll need to do something like (:require [clojure.tools.analyzer.passes :refer [trim]])
So what's the consensus around that hyped java serialization vulnerability? http://www.infoq.com/news/2015/11/commons-exploit?utm_source=infoq&utm_medium=popular_widget&utm_campaign=popular_content_list&utm_content=homepage
swizzard: interesting, it doesn’t look like I’m calling trim directly. I’m guessing a library on which I depend might be...
Hello, I'm trying since quite a bit of time to make a deep-walk
clojure function (I did ask a question on SO - hope it is ok to cross-post http://stackoverflow.com/questions/33594375/clojure-walk-with-path ).
@swizzard: so my error apparently has to do with how we are using Gradual Typing. Sorry for the goose chase
@ghadi: I don't see much java deserialization in clojure, so not too worried from my standalone services (with embeded jetty). If I was running things in a container that brings in a lot of java things I'd be very concerned.
Is there a substantive difference between require :refer :all and use?
@donaldball: no, :refer :all
was designed to do the same thing
Is there some EDN reader which can capture line/column position for keywords?
Yes, because keywords can't have metadat.
I'm thinking of replacing keyword with some other type as part of the read.
yeah, I want to parse EDN but with custom error messages for users who aren't Clojure programmers.
But not enough to write a complete parser
I had plans a while ago to implement tools.reader as a two-pass parsing+data-structure-reification process that might have helped
yeah, that would be useful in some rare instances, but more complicated than a standard reader
there actually was a project on github that used tools.reader internals to build an parse tree and had an emitter built on top
no worries, not worth it, thanks @bronsa
is there a good way to find (or estimate) the size in memory of a clojure.lang.PersistentArrayMap
?
you may be interested in this: https://www.youtube.com/watch?v=Szu0wNttfek
@stathissideris thanks, i'll check it out
@benslawski: sorry for the confusion, this has nothing to do with your question!
Hi! Please help me. I'm trying to use opencv3.0 in clojure in ubuntu 15.10. And I can't because of the following error:
Caused by: java.lang.UnsatisfiedLinkError: <...>/target/native/linux/x86_64/libopencv_java300.so: libIlmImf.so.6: cannot open shared object file: No such file or directory
And there is really no such file:
$ locate libIlmImf
/home/s/Downloads/opencv-3.0.0/build/3rdparty/lib/libIlmImf.a
/usr/lib/x86_64-linux-gnu/libIlmImf-2_2.so.22
/usr/lib/x86_64-linux-gnu/libIlmImf-2_2.so.22.0.0
/usr/lib/x86_64-linux-gnu/libIlmImfUtil-2_2.so.22
/usr/lib/x86_64-linux-gnu/libIlmImfUtil-2_2.so.22.0.0
Any idea how to get the lib?@domkm can't say I know the history but I would assume and = "true if all (empty set) clauses = true" and or = "true if any (empty set) clauses = true" which lead to those logical answers.
@rm googling finds http://docs.opencv.org/2.4/doc/tutorials/introduction/desktop_java/java_dev_intro.html instructions on building the native lib
@alexmiller: I tried already. The thing is it's ubuntu 15.10 specific. It worked on ubuntu 12.04, and then I decided to upgrade...
sorry, I haven't used it so don't know any more
a bit confused. i am using .addShutdownHook
the way I've always down to gracefully handle SIGINT
Thanks @alexmiller
I’m using test.check with a spec like (prop/for-all [v (gen/not-empty gen/bytes)] …)
— but the test output for a failing test is not entirely useful. In particular, it says :fail [#object["[B" 0x7fafbfb7 "[B@7fafbfb7”]]
— is there a way to post-process it, or provide a different printer so I can see which byte array breaks my function?
btw, I just forgot to remove target dir after OS upgrade and opencv lib tried to link with not existed lib. With fresh install everything is ok
So for the property (def p (cprop/for-all [v (gen/not-empty gen/bytes) :let [v-vector (into [] v)]] false))
, you would get {:result false, :seed 1447105698037, :failing-size 0, :num-tests 1, :fail [{v #object["[B" 0x24a5b313 "[B@24a5b313"], v-vector [98]}], :shrunk {:total-nodes-visited 15, :depth 7, :result false, :smallest [{v #object["[B" 0x7a8fb730 "[B@7a8fb730"], v-vector [0]}]}}
If you’re merging maps, is conj
considered idiomatic as well? It seems to work quite similarly to merge
, FWIW
while they overlap, merge communicates intent better for maps
Does anyone know what is the Clojure equivalent of cljs.core/IWatchable
? Specifically, I'm looking to implement notify-watches
@bsima: I do not think there is an equivalent in Clojure. the watch functionality is contained in clojure.lang.ARef super class
you could of course create a type in Java or a proxy that extends ARef
the interface for watching is in IRef
so you could also implement IRef - then add-watch etc will work with it
I've implemented IRef, add-watch, remove-watch - all I need is the notify-watches function, so I guess I can just make my own protocol called INotifyWatches to implement with my type. I don't think I want to extend ARef...
prob not - although you can look at the java impl in ARef for how to implement
@domkm: fwiw, there are other examples such as (+) => 0, (*) => 1, and (comp) => identity.
the result makes sense when you're potentially computing the arg-list, and want the empty list to work sensibly
@malcolmsparks: Yes, that makes sense. I wasn't questioning why the nullary version was implemented. I was just curious about the apparent inconsistency between the nullary versions of and
and or
.