This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-07
Channels
- # bangalore-clj (2)
- # beginners (53)
- # boot (30)
- # cider (27)
- # clara (1)
- # cljs-dev (18)
- # cljsrn (16)
- # clojure (153)
- # clojure-brasil (1)
- # clojure-dusseldorf (5)
- # clojure-italy (20)
- # clojure-losangeles (3)
- # clojure-spec (4)
- # clojure-uk (177)
- # clojurescript (115)
- # component (4)
- # core-logic (1)
- # datomic (29)
- # emacs (9)
- # figwheel (2)
- # gorilla (1)
- # graphql (36)
- # hoplon (4)
- # jobs (1)
- # jobs-discuss (3)
- # juxt (2)
- # keechma (22)
- # lumo (4)
- # off-topic (1)
- # onyx (17)
- # parinfer (96)
- # protorepl (10)
- # re-frame (31)
- # reagent (14)
- # ring-swagger (17)
- # spacemacs (32)
Hi everyone, im looking into web scraping with clojure and I have some basic things working with enlive but i'm trying to figure out how to do things like form submissions and deal with dynamic javascript. Any suggestions?
You're going to need an actual JavaScript engine ... PhantomJS?
user=> (conj '(1 2 3) 4)
(4 1 2 3)
user=> (cons 4 '(1 2 3))
(4 1 2 3)
What do I actually have to do to produce '(1 2 3 4)`thanks @bnvinay92 that's roughly what I had, I wasn't sure if there was a better way
@akiroz thanks for the reply. I meant, add-and-get is not a defn, but a def, so ai is part of add-and-get this variable, rather than part of function body.
@clumsyjedi if you want to add efficiently to the end of a collection, use a vector instead:
user=> (conj [1 2 3] 4)
[1 2 3 4]
I have an indexed map like ([0 -12] [1 -5] [2 -137] [3 5] [4 32] [5 45])
and I would like to find every value with 5. But in this case I get the 45 too.. if that isn’t indexed map works everything fine.. (filter #(= (second %) 5) indexed-map)
this works for me well
(filter #(= (second %) 5) [[0 -12] [1 -5] [2 -137] [3 5] [4 32] [5 45] [6 5]])
;; => ([3 5] [6 5])
Is there a standard function to take until converge? like (take-until-converge (100 50 20 10 10 10 10...)) -> (100 50 20 10)
here is the situation i am making questionnaire i've got questions(variable amount based on topic) and answers (predetermined, input radio button, variable amount) which i am sending to the client how do i send id, value or whatever from that radio button to the server?
@leira you could probably do it with take-while
after reductions
@leira try this for the "last two" bit (reductions (fn [[_ p] n] [p n]) nil (range 4))
What does the @(...)
mean in Clojure?
@stardiviner It is a reader macro that is equivalent to (deref (...))
@stardiviner @michaelwfogleman This (article) is kinda recent: https://clojure.org/guides/weird_characters#__code_code_deref
Thanks.
@stardiviner the thing to google is “destructuring”
I only know that a symbol like :keys
can be used as function to query data. But don't understand the upper style.
@noisesmith Thanks. I will google it
{:keys [foo]} {:foo “a”} -> now foo is bound to “a”
@stardiviner Hey mate the @
is a reader macro and the {:keys [...} {}
in a let binding uses clojure destructuring capabilities. If you were to macroexpand you would get code along the line of
(let [status (:status (deref (http/get "")))]
(= status 200))
You can take a look at https://clojure.org/guides/destructuring
hey everyone, trying to write my first clojure service, using Java interop to interface with Kafka and OrientDB, things are acting really weird though where sometimes my println
or (info "log")
show up and sometimes they don't, anyone ever have a problem with that? Ik this is very vague sorry
@aryzle the most common cause of that symptom is printing from inside map or for
remember that these are lazy, and don’t do anything if nobody touches their return value
one of the hardest lessons in early clojure learning can be “for is not a loop, and you can’t count on anything lazy happening”
of course I don’t know that this is your problem, but it’s common enough to speculate a bit
@noisesmith thanks man! that did get me before, but I just checked and I had a bunch of rogue Java processes and after killing them my next run of the program worked
oh - they were probably stealing your kafka messages, eh?
yup, that would do it
my inclination more and more is to always broadcast (fan out) from kafka (that is, every client has a unique id), and then if only one client should act on a given message, use a separate logic for coordinating who claimed the message and a follow up in case someone else should retry etc.
but that has to do with my job times being very high though