This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-11
Channels
- # admin-announcements (1)
- # aws (2)
- # beginners (32)
- # boot (147)
- # capetown (1)
- # cider (11)
- # cljs-dev (45)
- # cljsrn (57)
- # clojure (187)
- # clojure-russia (5)
- # clojure-spec (97)
- # clojure-uk (33)
- # clojurescript (33)
- # cloverage (17)
- # clr (4)
- # conf-proposals (93)
- # core-async (6)
- # cursive (9)
- # data-science (1)
- # datomic (24)
- # defnpodcast (1)
- # devcards (3)
- # emacs (3)
- # hoplon (95)
- # jobs (1)
- # off-topic (7)
- # om (97)
- # onyx (32)
- # overtone (1)
- # parinfer (4)
- # pedestal (1)
- # proton (1)
- # protorepl (13)
- # re-frame (4)
- # reagent (10)
- # specter (14)
- # untangled (40)
Can anyone show me how to do a java script hover on this element: #clj_webdriver.element.Element{:webelement #<Tag: <li>, Class: dropdown-submenu pull-left, Value: 0, Object: [[ChromeDriver: chrome on XP (8ff1a709570edb6244915d8fb4bd8c04)] -> xpath: //li[@class='dropdown-submenu pull-left']]>}
@josh_tackett: Have you looked at move-to-element
? https://github.com/semperos/clj-webdriver/wiki/Composite-Actions
yep got it š
Question from @lamelambda in #C03RZGPG1 room >[{:keys [state] :as env} key params] - this are the parameters of the read method >Specifically what does this represent? {:keys [state] :as env} >Does this represent the map of keys which is exposed as an env?
yes, {:keys [state] :as env}
represent a map. The whole map will be bound to env
and value of :state
key will be bound to state
This feature is called Destructuring. You can read more about it here http://clojure.org/guides/destructuring#_associative_destructuring
thank you! i got tripped up by that!
Note that you don't need the :as env
part if you only care about the value under the state
key š
@lamelambda: in the future please use #C053AK3F9 for questions, the channel you used is for announcements only to almost 7k people
sure - will be more prudent in the future! first time on this channel!
i got the :as point as well - thanks!
trying to parse the login field i get back from http-kit.client/get "
tried cheshire and clojure.data.json
Iām looking for a gui lib, and I found seesaw. Is there any other you could recommend?
because you canāt map macros
in this case you could do something like (map #(and %) ā¦)
but it depends on the macro
and takes any number of args
and your map will only supply one arg
maybe you want something like (map #(and %1 %2) [[false true]])
?
oh wait that wonāt work
then you donāt want to map
what are you trying to do?
something like (every? identity [arg1 arg2 arg3 ā¦])
note that if you donāt know how many args, you canāt actually write (function arg1 arg2 argā¦)
(def from-form-id "123ā)
(def forms [{:formid "123"} {:formid "456"}])
(r/fold and (fn [form] (not= from-form-id (:formid form))) forms)
(every? (fn [form] (not= from-form-id (:formid form))) forms)
I think that would work
also, every? returns when the first test fails, r/fold etc need an explicit (reducedā¦ ) call otherwise it will always test the whole collection
it should - until itās found an exception
youāre welcome
So a bit of an odd question (and probably has highly opinionated answers) but I wanted to get a rough idea of what people thought. I am currently weighing up the use of Elixir vs Clojure for running a web server to handle many concurrent Web socket connections. Now Elixir/Phoenix seems a natural fit for this and you see benchmarks demonstrating how far it scales (I doubt this has an bearing on real life load) but most of our infrastructure is written in Clojure. So the question is - would you consider taking on another language/ecosystem because it is a better fit for a particular job (and I am not even sure how much better it would be at the task) vs using a tool that is already a large part of your existing ecosystem. And in case anyone knows the answer to this, does Elixir/Phoenix exceed Clojure/JVM by a significant margin under real world loads for this kind of task?
(I may also ask this on SO as the question feels bigger than I originally anticipated š )
@jamesmintram: I would try to stay with clojure and look for a server that supports "many" concurrent websocket connections, perhaps using aleph (https://github.com/ztellman/aleph)
i need to send a get request which has a body. how do i do that using one of clojure libraries?
https://stackoverflow.com/questions/978061/http-get-with-request-body this page has lots of reasons to not, especially regarding caching
yeah it's weird that you're not supposed to send a request body with GET -- encoding as query params is so inconvenient
how do I parse a json response that i get with client/get? I tried cheshire and clojure.data.json to no avail.
(http/get ""
(fn [{:keys [status headers body error]}]
(if-not error
(parse-string body))))
the doc says that if the top level object is an array it will be processed lazily, but itās not
how can I write a defmulti
that dispatches on a vector not a map? i.e.:
instead of something like this:
(defmulti greeting :language)
(defmethod greeting "English" [_] "Hiā) (defmethod greeting "French" [_] "Salut")
(greeting {:language "English"}) ; => āHiā
It could be called more like this:
(defmethod bar :foo [label amount] ā¦.)
(greeting :foo āTitleā 42)
@(http/get ""
(fn [{:keys [status headers body error]}] ;; asynchronous response handling
(when-not error
(parse-string body))))
@ag: defmulti
takes a function to dispatch on as the value. I don't really understand your question very much. Can you provide another example of what you're trying to achieve?
(defmulti greeting (fn [lang _] lang)) (defmethod greeting āEnglish" [_ b] (str āHello, ā b)) (greeting āEnglishā āagā) ;;=> āHello, ag"
is it still hard to run a single clojure.test test with fixtures?
(from a repl)
hard but not impossible š
you can use run-all-tests
with the appropriate regex (but maybe that matches only namespaces?)
you can run the fixtures manually I believe, e.g. (-> my-test schema.test/validate-schemas .call)
@gnejs: I still canāt wrap my head around multimethods. Every example I found describes it how to make it work when a map being passed. But I need something like this:
(defmulti element ...)
(defmethod element :text-field
[ctx label key]
(html [:div.text-field label]))
(element :text-field "This is a simple text-field" :main-text-field)
I can of course make it work easily if I was ok with it to be invoked like this:
(element {:type :text-field :label "This is a simple text-field" :key :main-text-field})
but this seems to be unnecessarily cumbersomealso a side question; mutlimethods in clojure and clojurescript are the same? at least syntactically? In my case Iām actually need them in cljs
@ag: that :text-field keyword in the defmethod is the dispatch function (the keyword acting as a function in this case on the argument passed in)
in this exact snippet, how exactly defmultiās body should be in order it to work:
(defmulti element ...)
(defmethod element :text-field
Ā [ctx label key]
Ā (html [:div.text-field label]))
(element :text-field "This is a simple text-field" :main-text-field)
so I can render an element and have access to all 3 params in the function ctx, label and key
(and, if youāre getting strange arity errors in the repl - try restarting the repl. Iāve read something about defmulti
being sensitive to arity changes)
so, defmulti should wrap a function that returns thing that it would dispatch on, in this case first argument, in my exact case it is :text-field
keyword, right?
the function defined by defmulti
returns a value. That value is used to select the proper defmethod
. So in my example the function simply returns the first argument.
this finally worked for me:
(defmulti filter-element
(fn [type _ _ _] type))
(defmethod filter-element :text-field
[_ ctx label key] ...
I'm debugging what looks like a server-side transit encoding issue. While debugging, I want to create an edn literal that includes an #C06DT2YSY/id tagged literal. Here's what I'm trying:
(def edn-body
{some/new-item {:tempids {#om/id["2e486bfc-aacb-4736-8aa2-155411274e84"] 852154481843896390}}})
When I do so, I'm getting No reader function for tag om/id
Is there a way to quote this so the compiler ignores it? Or include a reader?@grzm ehhhā¦. prob, really stupid suggestion. maybe handle it in :default
handler for read
?
I ended up constructing the id instead:
(def edn-body
`{some/new-item {:tempids {~(tempid/tempid "2e486bfc-aacb-4736-8aa2-155411274e84") 852154481843896390}}})
now I dug up and opened another can of worms. I have no idea where to put docstring for defmethod. Google not helping
@ag: https://github.com/gdeer81/marginalia/blob/master/src/problem_cases/general.clj#L50-L52
does anyone have a link to a blog post / one pager / any explanation of why hot reloading in Clojure seems (is?) so much more robust than hot reloading in Java?
this is nonscientific but I would imagine it has a lot to do with the way each handles state
Because Clojure DynamicClassLoader is much different than the typical Java class loader hierarchy
And because Clojure programs have late binding via vars
In Java one method calls another. In Clojure, a function looks up a var, resolved it to a function, then invokes it
So if the var has changed, you see it
The DCL helps in making new classes immediately visible globally
great, thanks @chris and @alexmiller
by āgloballyā I mean up and down a tree of DCLs (as they share a static class cache)
tree of DCLs?
I think I need to spend some hammock time on the DCL
there are cases where you will have nested DCL instances
I have not worked on it in long enough that I can not precisely describe when that happens and when it does not, but looking at where DCLs are created in the source can tell you that
thanks, Iāll look it up
basically I have no idea if generating a class creates something that is persistent forever? š
On older jvms classes are part of what is called the permgen space, which means they are not garbage collected, but newer jvms get rid of the permgen, so classes can get gc
Hi. Is there a separate channel to discuss project ideas/finding people with similar interests etc?
I can't imagine a channel dedicated to that, and if there was it would have 5 participants
I'm wondering now that specs are coming in 1.9, is it better for me to model my entities as records or simple maps. Which one will be easier to add spec functionality to it
@dpsutton: yes, sorry. that sounded more like offtopic. And what's worse sounds like I'm begging. Now I understood it would be still more interesting to work on that "ideas" myself š
oh i didn't mean you were being offtopic to this room, just that that would be a great place to talk to people
@didibus: you can spec either (but plain maps are currently a little nicer)
@dpsutton: yeah, sure, I've been here for a while too. So thanks for answering
@didibus I keep falling into a pattern of using spec on maps, and then using a multimethod to build records out of the conformed values (since you can dispatch on the name returned from s/or
)
@alexmiller: I see, so unless I want protocols, map seems like the way to go for Spec.
@dg: Hum, so do you use the record in your code, but create the record using a map through a multimethod which validates the spec and returns the record?
What are the current best practices re: tooling that might have its own dependencies but canāt conflict with the software it runs? Iām asking for cloverage, which would like to use e.g. a templating engine but canāt conflict with the software it instruments. Iām guessing part of it is āminimal core with basically no dependencies, extended processing around it that runs in a separate processā?
@lvh Iāve run into this painful problem several times, your options are minimal core with no deps, manually vendoring deps you need, or using something like https://github.com/benedekfazekas/mranderson
Also keep in mind that Leiningen deps are uberjarred, so you wonāt see any warnings for conflicts, but you will silently get the Leiningen versions instead of your ones
You probably know this already, but for completeness, keep in mind that Leiningen plugins run in Leinās JVM and dependency space unless you use the eval-in-project
function
Fun times!
heh, I guess that confirms my fears š Thanks @danielcompton š For cloverage I think itās going to be the minimal core solution, I donāt think itās a very big deal; thereās already a clear separation between instrumentation and processing of resulting data