#clojure log - Feb 02 2016

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:16 patchwork: Are there any performance issues or otherwise with having deeply nested vectors? (like hundreds of levels deep)

0:16 They are not broad, just deep

0:17 Or is there a better data structure for representing deeply nested trees?

5:03 jonathanj: ,#{:a :a}

5:04 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: :a>

5:04 jonathanj: ,(hash-set :a :a)

5:04 clojurebot: #{:a}

5:05 digiorgi: ,(println "i'm happy")

5:05 clojurebot: i'm happy\n

5:07 steerio: ,(:doc (meta #'hash-set))

5:07 clojurebot: "Returns a new hash set with supplied keys. Any equal keys are\n handled as if by repeated uses of conj."

5:07 jonathanj: ,(doc hash-set)

5:07 clojurebot: "([] [& keys]); Returns a new hash set with supplied keys. Any equal keys are handled as if by repeated uses of conj."

5:08 steerio: I was afraid that'll return too many lines.

5:09 ...but it's nifty that it has its own version of doc. :)

6:49 athinggoingon: testing

6:50 ecelis: Test failed :)

9:01 Kneiva: What is "-?>"?

9:02 wmealing: i'm far from being awesome at this, but is that used in a macro Kneiva ?

9:02 dysfun: i don't think that's core, which library is it from?

9:02 steerio: Kneiva: (doc -?>)

9:03 dysfun: ,(doc -?>)

9:03 clojurebot: Pardon?

9:03 steerio: like you said, not core. :)

9:03 but they probably have it referred, so it'll work on their REPL

9:03 dysfun: no, that was clojurebot telling me the syntax was invalid :)

9:03 wmealing: i thought ~ meant it was used as unquoted in macros

9:03 ?> may be something else.

9:03 it might be defined somewhere

9:03 steerio: ,(list '-?>)

9:03 clojurebot: (-?>)

9:03 wmealing: in his code base

9:03 steerio: it's accepted as as symbol

9:04 * wmealing goes back to his hole in the ground

9:04 steerio: (there could've been the possibility that ? is only acceptable in a final position)

9:04 dysfun: ,(doc ->?)

9:04 clojurebot: Titim gan éirí ort.

9:04 dysfun: i see

9:04 steerio: i don't

9:04 * dysfun does not see at all

9:06 dysfun: meanwhile, anyone know how to write Array.prototype.slice.call(div_list) in clojurescript? :)

9:07 ridcully: js/Array.slice?

9:07 Glenjamin: ,(doc to-array) ; perhaps

9:07 clojurebot: "([coll]); Returns an array of Objects containing the contents of coll, which can be any Collection. Maps to java.util.Collection.toArray()."

9:07 dysfun: does that take a NodeList?

9:08 Glenjamin: (to-array (js/document.querySelectorAll "div")) seems to work

9:08 tried it in http://himera.herokuapp.com/index.html

9:09 dysfun: ooh, nice, thanks :)

9:09 so what's the easiest way to turn a nodelist into an appropriate cljs data structure?

9:10 Kneiva: -?> is mentioned in an example in a a readme of cemericks bandalore library

9:10 dysfun: (comp js->cljs to-array) ?

9:11 okay, it's probably from bandalore then

9:12 hrm, okay, i see it in the README

9:12 i think it's probable he meant -> and typo'd it

9:13 (great excuse to pull request it)

9:14 ridcully: or some-> in disguise?

9:14 dysfun: https://github.com/cemerick/bandalore

9:14 i'm pretty sure it was ->

9:14 ridcully: maybe from some lib? isn't swiss arrows full of those?

9:14 dysfun: yeah my immediate thought was swiss arrows, but it's the only instance on the page and -> makes sense from a quick scan of the code

9:15 Glenjamin: probably a typo of ->>, since all other examples use ->>

9:15 dysfun: yeah, or that one

10:34 souterrain: Anyone using clojure with openjdk on FreeBSD? Any pitfalls?

10:34 wmealing: i used it on linux, i dont imagine it'll be much different

10:35 dysfun: souterrain: i don't have any practical advice yet, but if you get any good experience, i'd love for you to keep me up to date about it since i'm planning to deploy some clojure on freebsd soon

10:36 jsabeaudry: Is it correct to say that (send! ...) is pretty much (future (swap! ... ))?

10:36 souterrain: ok, will do. I'm a clojure noob so was hoping for some sage advice, but I will certainly relay my experiences.

10:37 dysfun: i think i was just sort of hoping it would work. i've seen a few patchsets floating about and a tool that builds jdk releases for freebsd

10:37 but when we have acquired the kit and test it, we'll soon find out what's wrong

10:38 remember that java runs on solaris as well, so i imagine the codebase is fairly portable

11:41 cortexman: can you explain what this is doing and why (def ^:dynamic *base-url* "https://news.ycombinator.com/&quot;)

11:41 from the enlive tutorial

11:43 opqdonut: it defines a constant named *base-url* with the value "https://news.ycombinator.com/&quot;

11:43 cortexman: that would be (def *base-url* "https://news.ycombinator.com/&quot;)

11:43 opqdonut: the :^dynamic marks the variable as dynamic, so you can override it locally with (binding [*base-url* ...] ...)

11:43 perhaps for testing

11:43 cortexman: ok thanks

11:44 opqdonut: in general ^ attaches metadata to the next thing

11:44 and :dynamic is metadata that the compiler interprets

11:44 you could also say for example (def ^{:doc "this is a docstring"} foo ...)

12:34 averagehat: Hello all. Does anyone know how to create a list of bounded size in core.logic?

12:39 Shayanjm: dam is clojars down?

12:39 justin_smith: again?

12:39 cap10morgan_: yes: http://status.clojars.org

12:42 cap10morgan: you can use a clojars mirror for reading (but not deploying new artifacts): https://github.com/clojars/clojars-web/wiki/Mirrors

12:55 fuuduCoder: is clojars down

12:55 tcrawley: yes

12:55 see http://status.clojars.org/

12:55 in the meantime, you can use https://github.com/clojars/clojars-web/wiki/Mirrors to still pull dependencies

13:31 clojars is back up, but upstream is still reporting issues, so we it may go down again: http://status.clojars.org/incidents/pdpppjllmjff

13:43 rcassidy: kinda funny that clojars opening line on the site is "clojars is a dead easy community repository...."

13:43 cos then I just read "clojars is a dead"

14:15 macrolicious: is there a command for evaluating a clojure expression a pointer is anywhere within, rather than at the end of, in an emacs buffer? maybe that's illogical, as emacs wouldn't know which expression to evaluate… although I often want to evaluate a block with a blank line before and after it.

14:15 I'm using cider, btw

14:18 once again, I'm asking an #emacs question in here, sorry

14:20 tolstoy: I think C-c C-c works, no?

14:31 justin_smith: macrolicious: C-M-x

14:34 amalloy: either of the two above commands work, presuming you want the top-level form

14:34 if you want magical inference of subforms, then as you guessed you are out of luck

14:36 rhg135: I'm pretty sure fireplace did this with 'cpp'

14:39 ridcully: cpp is for where your cursor is, :Eval for the whole form

14:40 rhg135: I think that's what he meant, but i'm not sure

14:40 csd_: Will it create a race condition if i have a function that does (do (quartz-delete-task...)(quartz-add-same-task-id)) where those functions are actually writing to a core async channel which then from a go-loop does the work?

15:04 macrolicious: C-c C-c did the trick! playing with theo others now

15:14 rhg135: that issue with lazybot reconnecting to a void may be a freenode thing

15:15 or a common bug in irc code

15:15 Shayanjm: for some reason requiring clj-http.client is throwing a weird error for me suddenly

15:17 namespace 'potemkin.utils' not found

15:18 http://pastebin.com/GCD8hAGF

15:18 narrowed it down to it being caused by clj-http but not sure why/how to fix

15:19 dakrone: Shayanjm: probably due to version conflict on classpath, check out `lein deps :tree` and see where else potemkin is being pulled in

15:22 melipone: hiya! is it possible to have a variable number of arguments and also some keywords as arguments to a function?

15:22 Shayanjm: dakrone: Just did lein deps :tree and weirdly its only a dep of clj-http

15:23 dakrone: Shayanjm: what version of clj-http? can you gist the deps somewhere?

15:23 Shayanjm: but there are some suggested exclusions which throw kafka-clj into question, despite potemkin not showing up under its deps

15:23 yup

15:23 i'll gist the whole output

15:24 dakrone: https://gist.github.com/shayanjm/89192c933ec6598494c3

15:28 dakrone: Shayanjm: hmm.. doesn't look like it should be a problem, fun-utils also uses potemkin, but 0.4.1 (same version as clj-http)

15:28 if you manually put potemkin 0.4.1 in your project.clj and try it does it work?

15:28 Shayanjm: Let me check

15:28 dakrone: do you have a plugin that might be interferring?

15:30 Shayanjm: dakrone: nope, didn't work. And not that I know of, but let me check

15:32 dakrone: I don't think any of these conflict

15:32 dakrone: you removed the original paste :( now I can't see the error again

15:32 Shayanjm: oh shit my bad 2 secs

15:33 dakrone: https://gist.github.com/shayanjm/7aabb450c36d4a899354

15:35 dakrone: hmmm... doesn't really make sense to my why it wouldn't be there..

15:35 is this a public project I can try out?

15:38 Shayanjm: dakrone: not at the moment unfortunately

15:39 dakrone: if you want I can add you to the private project quickly?

15:45 Kamuela: Seems like this book Clojure Applied is exactly what I need for this phase

15:45 cortexman: i'm new to clojure and wanting to use clj-webdriver. however, these instructions are really obscure https://github.com/semperos/clj-webdriver/wiki/Clojure-and-Java-Dependencies

15:45 i obtained selenium-java-2.50.1.zip - now where do i put its contents?

15:45 just on my CLASSPATH?

15:45 dakrone: Shayanjm: I can try and look, but I'm not an expert where classloading is concerned :-/

15:45 cortexman: it says "You must add the Selenium-WebDriver JAR's you need explicitly in your project's dependencies. This library does not ship with runtime dependencies on any version of Selenium-WebDriver to allow compatibility with Selenium-WebDriver's upstream releases."

15:46 Shayanjm: No worries, would love a second opinion anyway. Mind sending me over your gh username?

15:46 cortexman: however, there is no example code for what that explicit dependency should look like

15:55 annnd nothing.

16:23 blake__: I want to pass data to a Reac component function. The server's sending data and I want to use that to update the component. Should I just create an atom and update that rather?

16:23 dakrone: Shayanjm: dakrone :)

16:25 blake__: It seems so ... non-Clojure-y. =P

16:32 dysfun: blake__: a future perhaps?

16:32 or promise. i always forget which is which

16:32 blake__: Hmmm.

16:33 dysfun: or a core.async channel

16:33 blake__: I'm not sure how that would get the data to the component.

16:33 dysfun: which approach?

16:34 blake__: Either, really. It seems like you encapsulate a zero-parameter function to make a react comopnent.

16:35 dysfun: i have to confess i haven't really used react directly, so i don't know how it models state

16:35 but there are a bunch of clojurescript react tools

16:35 and you can use them with all of these approaches

16:36 blake__: Everything I've seen has state in an atom. So I guess that's what I'll do.

16:36 dysfun: you might just want to use someone else's library

16:36 i think reagent looked most promising last time i was playing, but i went off react

16:37 blake__: dysfun: I'm using reagent. =)

16:37 dysfun: right, my memory is a bit hazy, but i'm sure you can use that with atoms

16:37 (it does seem to be the most sensible way to manage state)

16:38 blake__: Sure. I was trying to avoid atoms. 'cause the actual state is the displayed object.

16:39 dysfun: i remember it all being generally quite frustrating

16:39 * dysfun is currently hacking on a template library, as it happens

16:41 blake__: Well, I'll see how well this works out for me. Reagent seems pretty straightforward.

16:41 dysfun: yes, i think it's about as good as it gets without ripping out the javascript element entirely

16:46 averagehat: blake__, reagent should handle interfacing with react for you?

16:48 blake__: averagehat: Sure. But in straight Clojure, I'd expect to call a function with the parameters describing how to draw the component.

16:48 But I think the "automaticity" requires state.

16:49 averagehat: I'm not quite sure what you're looking for, but reagent revolves around atoms. The atoms trigger the re-rendering functions that dereference that atom

17:49 * devth wonders why there isn't a single command to load and switch to a namespace from the repl

17:52 MJB47: in-ns ?

18:01 amalloy: (doto 'ns require in-ns)

18:08 devth: MJB47: doesn't load it

18:08 amalloy: yeah ok. not that bad

18:08 meanwhile: clojure.lang.Reflector.invokeInstanceMethod on prod box that I can't reproduce locally :(

18:11 * devth thanks Reflector.java

18:22 amalloy: devth: what can't it find? nobody can help if you truncate the useful part of an error message

18:22 devth: not really asking for help. just lamenting the sadness of invokeInstanceMethod

18:22 it came from tentacles

18:23 found out why - i had a slight config difference and github was 301'ing on a post

18:23 which causes tentacles' `safe-parse` to blow up

18:24 thanks for the offer though :-)

19:23 tolstoy: Hm. Is it possible to use prismatic schema to validate a map for just one or two keys, not all of them? As in, not have to mention all possible "optional" keys?

19:24 justin_smith: tolstoy: you can add a k/v that basically mean "any set of kays with any values are allowed"

19:25 *keys

19:25 or you can do a select-keys first, and validate what remains

19:25 tolstoy: Oh, that might do it.

19:26 I mean, select keys sounds great. If only my map wasn't so nested.

19:28 justin_smith: tolstoy: {s/Any s/Any :a s/Int} => validates as long as you have :a mapped to an integral, doesn't care what other keys are or are not present

19:28 tolstoy: So, s/Any can map to multiples? I'll try it. ;)

19:29 justin_smith: yeah, it will hapilly map to anything

19:30 tolstoy: I don't know why they don't have these extreme corner cases I'm interested in right there on the front page! ;)

19:32 Worked!

19:50 mb123: compojure-api: do you guys have an example of passing command line arguments with an uberjar?

19:51 justin_smith: mb123: java -jar my-uber.jar a b c d

19:51 a b c and d are command line args

19:52 or, java -cp my-uber.jar clojure.main -m my.ns a b c d

19:54 mb123: justin_smith: ah, we did that, but getting "clojure.lang.ArityException: Wrong number of args" when using this library https://github.com/metosin/compojure-api

19:54 justin_smith: mb123: does it define main for you or something?

19:56 mb123: I see this, for example, which would mean it eats all your command line args and sends them to start

19:57 which would be specified by :start in project.clj

19:57 err, this that is https://github.com/metosin/compojure-api/blob/71ae7304b0f9cbb7cfa50d381b1bf7559c117809/src/compojure/api/main.clj#L16

19:59 mb123: ah gotcha, thanks justin_smith

20:09 lockdown: does someone has the clojure applied book close to him?

21:02 sfz-: Is it possible to have a let assignment that can be used within all blocks of a multi-signature function?

21:03 But that's local to the function, not the namespace?

21:05 Ah, nevermind, I figured it out, just needed to use (def f (fn)) instead of shortcut (defn f)

21:13 ferz_: is there a way to connect to nREPL on a specific port from a terminal?

21:14 justin_smith: ferz_: lein repl :connect <port>

21:15 ferz_: that did it, thanks, I couldn't find info online for some reason.

21:16 justin_smith: for future reference, lein help, lein help repl, etc.

22:30 Shayanjm: justin_smith: gotta pick your brain about kafka again if you have a bit...

22:31 I'm using this: https://github.com/gerritjvv/kafka-fast/ and having some trouble making my consumer work.

22:38 justin_smith: Shayanjm: be back in a moment

22:39 Shayanjm: take your time :)

22:52 justin_smith: Shayanjm: so what's the issue?

22:54 Shayanjm: are you sure this is a kafka lib and not a redis wrapper that inexplicably has kafka in the name?

22:57 Shayanjm: OK, looks like this lib implements the kafka server / client in clojure, but does not use the actual kafka implementation from the kafka project at all

23:09 Shayanjm: oops, leaving again, maybe we can catch up tomorrow

23:30 Shayanjm: justin_smith: sorry about that - just got back to my desk

23:30 let me know if you're still there otherwise I'll pick your brain tomorrow

Logging service provided by n01se.net