#clojure log - Jul 16 2015

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

0:02 TEttinger: ,(boolean 0)

0:02 clojurebot: true

0:02 TEttinger: ,(boolean (/ 0.0 0.0))

0:02 clojurebot: true

0:02 TEttinger: ,(if Double/NaN true "wat")

0:02 clojurebot: true

0:07 whomp: is traversal of a set as a sequence deterministic?

0:25 tomjack: whomp: I _think_ (= (seq xs) (seq xs)), but definitely not necessarily (if (= xs ys) (= (seq xs) (seq ys)))

0:36 vas: So I want to make a "remember which page the user requested and forward them after they log in" feature

0:39 H4ns: vas: popular solutions include including the original url in the login form as hidden parameter, in a query parameter of the login page, using an extra cookie or storing the url in the user's session if you already have session tracking set up at that point.

0:40 vas: H4ns: thank you so very much. My login system is a bit different in that a user just gives me their email and I send them a login link which they must click to login. I'm going to try setting a session variable and see if that does the trick (assuming the user uses the same browser for both accesses)... perhaps it makes sense to encode it into the login link.

0:42 H4ns: vas: a session variable is unlikely to work unless you have persistent sessions and can refer to them through the url that you send out. i'd just use a parameter in the url.

0:44 vas: ah, i did not read carefully. anyway, an extra parameter will be more robust. you could also store the "initial url" in the user's record in the database if you want to avoid the extra parameter.

0:49 vas: H4ns: Thanks, that makes sense. I think I'll just tag it onto the link. I'm avoiding database reads/writes by just checking a hash in the provided link/URL instead of reading to see if the user has the credentials so avoiding a db read would be in keeping with that.

0:50 H4ns: there is an initial read to make sure the user has the right privs and all when they request a link, but the handler just checks a hash (which can only be received with proper creds). ... dunno if i explained that well enough but you might get the picture

0:52 crocket: Hello clojour guys

0:52 multimethod rocks.

0:52 It lets me code polymorphic behaviors without types.

0:57 vas: H4ns: anyway, thanks for your help :D

0:57 H4ns: vas: yw

1:12 bcham: Can someone help me?

1:12 I can't seem to find why these two functions aren't equivalent

1:13 (defn clean-code [class-name]

1:13 #((html/wrap :pre) (html/wrap :code '{class (str "src" class-name)}) (html/text %)))

1:13 (defn clean-code [class-name]

1:13 (fn [x] ((html/wrap :pre) ((html/wrap :code '{:class (str "src " class-name)}) (html/text x)))))

1:13 why aren't those equivalent?

1:21 crocket: bcham, Do you want (= f1 f2) to return true?

1:22 bcham: I get an arity issue when I use the first one in another function, but not if i use the second function

1:22 crocket: Plus, your functions are awfully difficult to read.

1:22 bcham: and I can't seem to figure out why.

1:22 baby steps crocket :)

1:23 I don't want to functions themselves to be equal, rather i want what they do to be equal.

1:24 crocket: They are not equal

1:25 bcham: empirically I know that, I'm wondering why.

1:25 crocket: bcham, I formatted those functions in emacs clojure-mode, and I got http://dpaste.com/1KTZV06

1:25 They are not equal.

1:25 You got parens wrong.

1:26 Also, there are other differences.

1:26 You should look for differences.

1:26 bcham: what's the hot key to format in clojure-mode?

1:26 I will thank you.

1:26 crocket: bcham, tab

1:27 bcham, You should seriously learn emacs.

1:27 bcham: I use emacs

1:27 crocket: I don't think you use emacs effectively.

1:28 By the fact that you don't know how to use TAB in emacs, I think you're a newbie.

1:28 bcham: I am.

1:28 amalloy: crocket: this is not very welcoming behavior

1:28 crocket: And, you should use a pastebin to paste codes.

1:29 bcham: Thank you for the feedback, as I sated above. I'm just learning. "Baby steps" means I don't know what I'm doing, and am trying to figure it out.

1:30 amalloy: bcham: you're doing just fine. do keep in mind refheap.com for pasting larger snippets in future

2:11 crocket: How do I call a function whose symbol obtained by (symbol "log" "info")?

2:12 H4ns: if you're thinking clojure.tools.logging/log, then that is a macro and cannot be called.

2:12 crocket: no

2:13 It's taoensso.timber/info

2:13 (require '[taoensso.timber :as log])

2:14 rpaulo_: is there any lisp language that you can compile and deploy?

2:14 TEttinger: rpaulo_: sorta an odd question, what do you mean by deploy?

2:14 rpaulo_: I'm looking for something small that can be run standalone on a server

2:15 H4ns: crocket: ((resolve (symbol "log" "info")) [arg])

2:15 rpaulo_: i.e., without installing the actual VM (it would be bundled in the file)

2:15 TEttinger: small as in language or small as in installation requirements?

2:16 rpaulo_: installation requirements

2:16 TEttinger: there are almost certainly Common Lisp implementations that produce somewhat small binaries. there's more work done at the embedded-ish hardware field with Scheme variants than Common Lisp ones.

2:17 rpaulo_: scheme would work too

2:17 TEttinger: I'd look into Chicken Scheme and maybe Gambit Scheme

2:17 I'm no expert there though

2:17 rpaulo_: nice, thanks

2:27 crocket: H4ns, good

2:55 http://dpaste.com/2G6Y88A is a config file for DDNS client I'm writing.

2:56 I want a function named update! to behave differently according to provider name.

2:56 How should I implement it?

2:56 H4ns: so you're doing the resolve/symbol thing to log at the correct level? sounds gross.

2:56 crocket: Protocol + record, multimethod, or ???

2:56 lazybot: crocket: How could that be wrong?

3:00 crocket: hmm....

3:00 Currently, it separates provider name from config.

3:00 This justifies passing two arguments to a multimethod.

3:07 https://github.com/crocket/clj-ddns-client/blob/master/src/clj_ddns_client/providers/dnsever.clj#L28

3:07 I feel that this is wrong.

3:08 Why should I have to pass the name of provider to a log function?

3:08 I shouldn't have to

3:19 Ok, this is ok.

4:09 Wow

4:10 Is there an eager version of map?

4:12 (doall (map...

4:40 Do you usually avoid dynamic vars?

4:49 magnars: crocket: if you want an eager map, you could use mapv - but maybe you are doing side-effects and should look at doseq?

5:37 Pupeno: Is it possible to somehow resolve a symbol to the namespace it is located in lexically, and not dynamically? Inside the namespace korma.db I'm doing this (ns-resolve 'korma.db (symbol protocol)) and I would like not to have to repeat myself with korma.db there.

5:42 oddcully: Pupeno: just `resolve`?

5:43 Pupeno: oddcully: that resolves to the current dynamically scoped namespace, not the lexically one.

5:44 Phoh4ang: So I've tried clojurescript with figwheel+cider and it's totally awesome, everything works, super cool! But now I want to have not only cljs repl, but the clojure one too. I'm not sure how can I get one more repl buffer in cider without starting another jvm process. Can anybody give a direction?

5:45 Pupeno: there is no such thing as "lexical namespace". I guess you are writing macro; google about &env and &syms hidden arguments.

5:46 Pupeno: Phoh4ang: no, I'm not writing a macro, I'm calling a function by having the name on a string. Since there's no lexical namespace, I'll have to hard-code it.

5:47 Phoh4ang: Pupeno: I'm not sure what do you mean... So you have to call a function by its name given as a string, and the function is defined in a let block?

5:47 So (let [foo (fn ...)] (magic "foo")) something like this?

5:47 Pupeno: Phoh4ang: no, the function is a top level function in the namespace 'korma.db.

5:48 Phoh4ang: Pupeno: well then you don't need anything "lexical" at all, just use ns-resolve or whatever.

5:49 Pupeno: Phoh4ang: well, with ns-resolve I have to specify the namespace 'korma.db when this function I'm writing is already in the 'korma.db namespace and I was hopping to be able to infer it (so that for example, if the name of the namespace changes, it doesn't break).

5:50 Phoh4ang: Pupeno: eh, what's wrong with just `resolve` then?

5:51 Pupeno: If I'm in namespace foo.bar and I call korma.db/db-uri and db-uri evaluates (resolve :func), it evaluates to foo.bar/funk, not korma.db/func. I want korma.db/func.

5:51 (db-uri is the function I'm writing)

5:52 Phoh4ang: Ah, you have a function, not a macro, right. Well just save the *ns* somewhere when you defining your function.

5:52 Like (let [my-ns *ns*] (defn my-fn ...)) or something similar. It should work, if I undestand thing correctly.

5:57 Pupeno: yep, just quickly checked it: https://www.refheap.com/106617 that's what you want, right?

5:57 Pupeno: Phoh4ang: yes.

5:58 Phoh4ang: I don think the loss in readability of having a defn inside a let is not worth the gains in the case the namespace name changes or something like that.

5:59 Phoh4ang: but it does answer my question.

5:59 Phoh4ang: Pupeno: well, having defn inside a let doesn't reduce readibility at all in my opinion.

6:00 Pupeno: I can see that. I'm contributing to someone else's code, so I'm trying to stay as readable and clean as possible

6:02 Phoh4ang: Oh, I see. Actually it's kinda interesting. I can't imagine why such weird thing with all that resolving stuff is required.

6:04 Pupeno: Phoh4ang: in korma.db there's a set of functions named after database protocol, postgres, mysql, oracle, etc. They enhance a database connection specification with some sane defaults. I'm making a function that takes a jdbc uri (instead of a hashmap with user, pass, host, db, port, etc) and calls the appropriate function, mysql, postgresql, etc. So I'm extracting the name of the function I'm calling from the jdbc uri: ht

6:04 tps://gist.github.com/pupeno/bc0363f61e0da2d73da4

6:09 Phoh4ang: Pupeno: hm, I see. That makes sense, though imho it would be somewhat clearer to explicitly define these functions with a special macro which would maintain a map of strings->functions.

6:09 On the other hand, less code is better.

6:21 Akshay: why clojure not lisp

6:21 ??

6:21 lazybot: Akshay: What are you, crazy? Of course not!

6:21 clojurebot: BOT FIGHT!!!!!111

6:25 loke: Note that Akshay just asked the opposite thing on #lisp

6:25 oddcully: what was the bot response there?

6:28 loke: oddcully: No bot response.

6:28 ronh: <loke> There are no benefits to clojure compared to Lisp

6:28 loke: Yep

6:28 oddcully: then clojure wins clearly in terms of bot hilarity

6:28 loke: oddcully: Indeed

6:28 * ronh pours more gasoline to fire :P

6:28 loke: I somewhat intentionally fed the troll

6:29 tdammers: bot hilarity is strictly the most important factor in a programming language's success

6:29 loke: tdammers: the #lisp bot used to do meme quotes

6:29 Like doge

6:29 H4ns: back in the day, when it still worked

6:29 loke: Since it doesn't do that anymore, I guess that's the death of lisp :-(

6:31 tdammers: death of lisp... not again...

6:34 loke: tdammers: None of us want that, I think. Therefore the #lisp bot must immediately be fixed.

6:34 H4ns: loke: you can discuss #lisp's problems in #lisp, i guess :)

6:34 loke: H4ns: Yes

6:35 H4ns: But you'd kick me if I did :-)

6:35 H4ns: loke: i got no ops and with my temper, it is good that way

6:48 crocket: less is better

7:14 Does anyone know a good clojure logging library than timbre?

7:14 Does anyone know any other good clojure logging library than timbre?

7:14 timbre doesn't have a decent rolling appender.

7:17 oddcully: unilog?

7:21 crocket: unilog?

7:22 unilog uses logback.

7:22 an uberjar would have to include logback as well.

7:33 So, I'd have to choose between small and big.

7:40 xificurC: yesterday I got a recommendation for fighweel and react from justin_smith. Can anyone point me to some nice guide to cljs in general and possibly these libs? I did clojure for a couple of months when it was 1.3 so I'm not completely clueless, but not up to speed either

7:41 kwladyka: if i want to do random test x times should i use "dorun" or is there something better?

7:43 oddcully: xificurC: have you seen the figwheel quickstart? https://github.com/bhauman/lein-figwheel/wiki/Quick-Start

7:45 xificurC: there are lots of libs around react (om, reagent, rum, ...)

7:45 xificurC: also clojurescript has it's own irc channel - just fyi

7:49 xificurC: oddcully: no I haven't, and that actually links to a quick start for cljs as well, thanks

7:58 kwladyka: https://www.refheap.com/3fc8e81c4cf03e0631232fb53 - how to run this test x times? The problem is when i do (dorun x (deftest)) or (deftest foo (dorun x (testing))) etc. it wouldn't work because deftest has to be first and is has to be first in testing etc.

8:14 noncom: kwladyka: what?

8:15 kwladyka: can you describe more? i don't get your question

8:15 kwladyka: noncom, i want run this test x times, how to do that?

8:15 it is random test so i want run it more then once

8:16 and it is not so simple as it looks :)

8:17 noncom: kwladyka: are you using this? https://clojuredocs.org/clojure.test/deftest

8:18 kwladyka: noncom, as i shown https://www.refheap.com/3fc8e81c4cf03e0631232fb53

8:18 noncom: so, yeah

8:18 kwladyka: the problem is about "is" in tests

8:18 because of java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Boolean

8:19 this exception occur when somebody is between is and testing or between testing and deftest

8:19 noncom: can you post full stack trace?

8:19 kwladyka: "is" has to be always just behind "testing" or "deftest"

8:20 noncom, https://www.refheap.com/e18f0703e8291bc76681dcc15

8:20 *somebody - something

8:21 you can do this in repl, just change my code to anything else, even (= 1 1)

8:21 and try do it 5 times

8:25 maybe what i am trying to do is impossible with clojure.test and i have to use additional library like test.check

8:25 but honestly i dont want in this case

8:30 m-erger: is closure a good first language?

8:30 kwladyka: mmm but maybe i will do (for) or something like that in condition and i will return list of true/false.... i don't see better solution

8:31 m-erger, i don't know. I am not sure somebody try. It is still new technology :)

8:32 m-erger, i think it is like question about is it better to start play on violin or guitar or something like that

8:32 wasamasa: m-erger: closure is a concept, not a language

8:32 noncom: m-erger: from me, i'd say "yes"

8:33 kwladyka: hmmm, honestly i never used the testing framework...

8:33 kwladyka: so, you need to run this very test like 100 times and get the 100 results, right?

8:34 kwladyka: wasamasa, i guess it is misspell and he wanted write clojure?

8:34 noncom, yes

8:35 first i wanted to run test x times, but now i see only one solution using clojure.test is return '(true true true true true ....) to check condition

8:35 it is still good but no so elegant :)

8:36 just it makes code more unreadable

8:37 m-erger: closure is a concept?

8:38 oddcully: m-erger: cloJure vs cloSure

8:38 noncom: m-erger: https://en.wikipedia.org/wiki/Closure_(computer_programming)

8:40 kwladyka: which function works like (for [x (1 2 3 4 5)] body) but like (f 5 body)? I mean i want this function to return results like for, but i don't need input as x

8:41 i can't find function like this, maybe is it just doesn't exist? :)

8:43 lumafi_: how about repeatedly

8:43 noncom: repeatedly, yes

8:45 kwladyka: (repeat x body) :)

8:50 so if somebody is interested in it is my solution https://www.refheap.com/106622

8:50 i am not repeating tests, but i am repeating the condition

8:51 i don't see any other way

8:59 tgoossens: is it possible (not just plain JavaCompiler) in clojure to take clojure code and compile it

8:59 and how?

9:01 as far as I understand clojure

9:01 this should be extremely easy

9:01 puredanger: call the http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/compile function

9:02 tgoossens: -.-

9:02 thanks puredanger

9:02 puredanger: most build tools have a way to ahead-of-time (AOT) compile many source files

9:05 tgoossens: puredanger, What I actually am going to do is (using instaparse) to convert a DSL into clojure code wich then needs to be compiled to a java class

9:05 *which

9:06 puredanger: I presume you have requirements that rule out the option of gen-class ?

9:07 tgoossens: not that I'm aware of

9:07 (yet)

9:07 that might be a good idea actually

9:08 puredanger: well depends on your process a bit but it's effectively a Clojure DSL to generate Java classes

9:08 kwladyka: is function like repeatedly but without lazy-seq?

9:08 puredanger: but it can't do everything

9:08 kwladyka: i don't wont unnecessary (take x)

9:08 tgoossens: puredanger, thanks for the hint :)

9:08 kwladyka: i just want something like (repeatedly 5 f)

9:09 tgoossens: puredanger, now i'm going to try and figure out how to take a string of generated clojure code and use core.compile on it

9:09 kwladyka: or in another words something like (for [x (range 5)] body) but (for 5 body)

9:10 what i did last time when i asked doesn't work

9:10 so problem coming back :)

9:11 snowell: kwladyka: repeatedly takes an optional length arg

9:11 So (repeatedly 5 f) should work

9:11 puredanger: loop?

9:11 clojurebot: loop is https://www.refheap.com/90332

9:11 kwladyka: snowell, thx!

9:12 puredanger, loop is not the same, because it return values in another way

9:14 puredanger: if you're collecting results in addition to running side-effecty functions, you should look at run! (new in 1.7)

9:14 actually I guess you can't return results with run!

9:15 but you could get similar eager return with reduce

9:17 fourq: Anyone here know the answer to Anna's clojure question posted on Twitter? I'm curious too. https://twitter.com/AnnaPawlicka/status/621667387847348224 "#clojure folks, why isn't x cleared when it’s a number in a ^:once-decorated function, but is for strings & keywords? "

9:18 Bronsa: fourq: Herwig responded

9:18 fourq: Is that the answer?

9:18 kwladyka: huh so who can explain this magic ? https://www.refheap.com/b41e5a2b51028306dbefb883d for [x (range 3)] works but repeatedly 3 throw exception

9:18 Bronsa: fourq: only Objects can be set to null, x is a primitive long in that binding

9:18 fourq: he said "i bet"

9:18 kwladyka: ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn clojure.core/repeatedly/fn--4750 (core.clj:4716)

9:19 Bronsa: fourq: well that's the right answer anyway :)

9:19 kwladyka: so magic :)

9:19 fourq: =)

9:19 thanks Bronsa

9:20 snowell: kwladyka: Try putting a # before the call to make it an anonymous function.

9:21 Right now it's using the return value, where repeatedly needs a Fn

9:21 kwladyka: snowell, oh....

9:22 snowell, thx

9:23 i need a brake

9:31 kaiyin: how can i `lein deploy clojars` without entering password every time?

9:32 tcrawley: kaiyin: take a look at https://github.com/technomancy/leiningen/blob/master/doc/DEPLOY.md#gpg

9:54 kaiyin: tcrawley: thanks!

10:18 kwladyka: what is the best way to not pass all the time the same parameters to all functions? i have parameter cols and rows which mean number of columns and number of rows. I need this information in almost every function in namespace. Should i use ref or atom or something like that or another solution?

10:19 snowell: You could always (defonce cols 8) at the top of the ns

10:19 Who doesn't like a good global variable? :D

10:20 kwladyka: snowell, but rows and cols are not constant

10:20 snowell: Ha, oh...

10:21 kwladyka: i have to operate on board

10:21 but board can have different dimension each time

10:21 but i have many operations on each board and each operation need to know about size of this board

10:21 snowell: You can probably make a Board object with things like deftype and just pass that around

10:22 Having no experience with that sort of thing in clojure, however, I will defer to others :)

10:22 kwladyka: but still in all function i need to add additional parameter, i am not sure it is good way

10:22 or maybe it is

10:23 i have this code to remember terminal size:

10:23 (def terminal-size (ref [0 0]))

10:23 (defn handle-resize [cols rows]

10:23 (dosync (ref-set terminal-size [cols rows])))

10:23 and maybe it is good idea to remember board size

10:23 or maybe i shouldn't do that and i should pass this as parameter

10:24 i am not sure how looks the best practice

10:24 snowell: I might consider using deftype to define a Board, with cols and rows fields

10:24 Then you can pass the Board into your function and read the cols and rows from it

10:25 Differently-sized boards would then just be separate Board objects

10:25 kwladyka: and also i have to pass iteration, because i draw many boards on screen and i have to know which one it is

10:25 and again i have to pass to all functions additional parameter

10:26 but maybe it is like it should be

11:04 justin_smith: kwladyka: the error you got with the test was not related to testing or is or deftest, it is some issue with your code https://www.refheap.com/106627

11:05 kwladyka: justin_smith, the problem wasn't about that

11:05 justin_smith: kwladyka: also, you can run is inside a doseq or loop

11:05 kwladyka: but it is solved anyway

11:05 justin_smith: OK

11:06 kwladyka: justin_smith, hmm i tried with (dorun 5 (is)) and it didn't work

11:06 but maybe i did some mistake

11:10 justin_smith: kwladyka: that's not how dorun works...

11:10 kwladyka: 5

11:11 justin_smith: kwladyka: test updated to use totimes to run is 100 times https://www.refheap.com/106627

11:11 *dotimes

11:12 kwladyka: oh yes dotimes not dorun, sorry i have mess in my head after all day

11:12 but for me it wasn't work... mmm so good to know it works

11:17 justin_smith, hmm and why it doesn't work with dorun? Is any function works like dotimes but without x? (dotimes [x 5]) - i know i can use _

11:18 it didn't work because i was trying use dorun...

11:18 justin_smith: kwladyka: dorun is a function that forces a lazy value without holding onto the results

11:18 that is all it does

11:18 ,(dorun (map inc (range 100)))

11:18 clojurebot: nil

11:18 justin_smith: ,(dorun (map inc (range 1000000000)))

11:19 clojurebot: eval service is offline

11:19 kwladyka: oh...

11:19 justin_smith: that timed out

11:19 because it was evaluating every inc

11:22 kwladyka: do you have maybe any idea can i find font with size NxN (square)? I need that for console to draw board

11:23 justin_smith: kwladyka: quick google finds this http://www.dafont.com/theme.php?cat=301

11:23 kwladyka: yeah but i didin't mention as default system font :)

11:24 justin_smith: kwladyka: what system?

11:24 kwladyka: every :)

11:24 justin_smith: that's a really tall order

11:24 kwladyka: i need only numbers, Q, K, B, N, B letter

11:24 and space

11:25 i know :)

11:25 justin_smith: wouldn't it just be easier to make some tiles and use those instead of a font?

11:25 kwladyka: but my purpose is to have board to be square on screen

11:26 justin_smith, i use clojure-lanterna

11:26 i don't know any better solution

11:30 i don't know any better solution to draw in console board

11:31 chess board exactly

11:33 justin_smith: and you control the font of the console?

11:34 kwladyka: justin_smith, yes it has option to set font http://sjl.bitbucket.org/clojure-lanterna/reference/#font-names

11:35 justin_smith: oh, it launches a new terminal window, you could do it that way, of course :)

11:35 kwladyka: this is just to be good if i achieve square but it is not the main problem

11:36 justin_smith: at first I thought that meant it was somehow changing the font from inside the terminal (which afaik is not possible)

11:37 kwladyka: but still i don't know how to draw square board :)

11:37 because font is not square

11:39 but... maybe it is just mission impossible :)

11:39 TimMc: mission improbable

11:40 justin_smith: TimMc: cue theme music. Zoom in on man in black, climbing down a rope, to buy a lottery ticket.

11:42 TimMc: "The Terms and Conditions, should you choose to accept them..."

11:42 justin_smith: rofl

11:43 kwladyka: i need definitely break, going train Wing Tsun. See you later! :)

11:46 sdegutis: Hello. This is my question. Is Instaparse suitable for parsing an INI file. Thank you for your time. Good bye.

11:46 blkcat: um

11:48 wasamasa: this is even weirder than that guy's requests over at #emacs

11:48 hellofunk: clj ninja: two maps, same keys. want new map containing only keys where value is different, always using the second map's values where applicable. what's a good one-liner to do this?

11:53 oddcully: the ninja disqualifies me, but i'll give it a shot ,(into {} (let [old {:a 1 :b 2} new {:a 1 :b 3}] (filter (fn [[k v]] (not (= (k old) v))) new)))

11:55 justin_smith: oddcully: that's better than mine was going to be

11:57 hellofunk: oddcully: was hoping for something even more elgant. i asked because i too come up with these little monsters

11:58 where is amalloy when you need him

11:58 justin_smith: ,(first (reduce (fn [[m' m] [k :as e]] (if (= (find m k) e) m' (conj m' e))) [{} {:a 0 :b 1 :c 2}] {:a 0 :b 1 :c 3})

11:58 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

11:58 justin_smith: err

11:58 hellofunk: glad to know this simple task requires much verbosity from others than just me :)

11:59 sdegutis: Does anyone know whether this is the case or not. Thank you.

12:00 ambrosebs: hellofunk: tried clojure.data/diff ?

12:00 amalloy: (into {} (remove (set m1) (select-keys m2 (keys m1))))?

12:01 ,((fn [m1 m2] (into {} (remove (set m1) (select-keys m2 (keys m1))))) {:a 1 :b 2} {:a 1 :b 3})

12:01 clojurebot: {:b 3}

12:01 justin_smith: ,(let [m {:a 0 :b 1 :c 2}] (reduce (fn [m' [k :as e]] (if (= (find m k) e) m' (conj m' e))) {} {:a 0 :b 1 :c 3}))

12:01 hellofunk: amalloy: since both maps will always have same keys, select-keys is probably unnecessary?

12:01 clojurebot: {:c 3}

12:01 amalloy: oh, same keys

12:02 then sure

12:02 sdegutis: I am finding it difficult to get started with a sample of Instagram.

12:02 Thanks in advance.

12:02 hellofunk: amalloy wins

12:02 sdegutis: I mean Instaparse.

12:02 crocket: Why does clojure say "clojure.lang.Symbol cannot be cast to clojure.lang.IPersistentVector" when it compiles https://www.refheap.com/106630 ?

12:02 amalloy: (into {} (remove (set m1) m2))

12:02 hellofunk: amalloy: totally awesome. i knew it was out there

12:02 (inc amalloy)

12:02 amalloy: ,(disj {1 2} [3 4])

12:02 lazybot: ⇒ 287

12:02 clojurebot: #error {\n :cause "clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.IPersistentSet"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.IPersistentSet"\n :at [clojure.core$disj invoke "core.clj" 1452]}]\n :trace\n [[clojure.core$disj invoke "core.clj" 1452]\n [sandbox$eval101 invoke "NO_SOURCE_FILE" 0]\n [cloj...

12:03 hellofunk: amalloy: funny how three of us had these paragraph-long ideas. if there's one thing 4clojure has taught me, there is almost always a simple expression for stuff like this

12:04 wasamasa: sdegutis: well, it requires you to already know the theory behind parsing

12:04 sdegutis: Thank you.

12:04 wasamasa: sdegutis: perhaps you find it easier to get into https://github.com/youngnh/parsatron

12:04 crocket: Help

12:05 sdegutis: I have a simple INI file.

12:05 Please if you know how these two libraries compare in terms of community mentality.

12:05 crocket: Ah...

12:05 sdegutis: wasamasa: Thank you in advance, best regards.

12:06 wasamasa: sdegutis: the former does a lot more than the latter

12:06 sdegutis: basically it supports every approach to parsing you'd encounter in the wild

12:06 sdegutis: wasamasa: I only need to parse a simple INI format. So it sounds like the latter might be suitable. However if it is completely terrible, and everybody hates it, that might be a problem.

12:06 wasamasa: sdegutis: while the latter does recursive-descent parser combinators only

12:06 crocket: I should surround an anonymous function in parentheses in ->

12:07 sdegutis: I admire that it uses ClojureScript however this is not a feature I have absolutely any need for. So if this is the primary target of this library then we have differing philosophies and thus should part ways.

12:07 Thank you.

12:08 wasamasa: wat

12:08 could you please drop this superfluous speak, this isn't email

12:09 asides from that, I find it very hard to believe there's no existing library for parsing ini files: https://clojars.org/search?q=ini

12:09 sdegutis: I do not really have an INI file, it is very similar though. It is a custom text based format that we employ and which is very similar to INI format and simply has a defined text-based format.

12:10 It has a simple specification, mostly using newlines for delimiters, but at one well-defined point also using brackets.

12:10 Our CEO asked me originally to just use an Excel file as the format but I had to explain why this was not an appropriate idea.

12:12 It might even be simple enough to use simple Clojure sequence processing to transform it. However this is not strictly a good idea and thus I want to use some technique and/or methodology that is quite a bit more appropriate.

12:12 However that is why I have considered Instaparse and now Parsatron.

12:12 Thank you for your advice and continued help.

12:13 wasamasa: have fun learning parsing theory then

12:13 sdegutis: This person suggests that Parsatron is dead: https://twitter.com/kurisuwhyte/status/382699042938974208

12:13 wasamasa: suuure

12:14 that must be why I had to extend its grammar for a work project

12:14 sdegutis: That does make sense.

12:15 wasamasa: I may be able to come up with an EBNF grammar, will that suffice for this?

12:15 Thanks in advance.

12:17 wasamasa: sdegutis: if you get it perfectly right the first time, yes

12:19 sdegutis: Thank you.

12:24 How do you specify "any alphanumeric, punctuation, or whitespace character except newline"?

12:24 In other words "any printable character except newline" in Instaparse?

12:25 blkcat: have you considered using a regex?

12:28 wasamasa: lol, you write parsers *because* you're doing something better than merely using regex

12:28 anyhow, I'm out as this is as far as my knowledge on the topic goes

12:28 blkcat: haha, that's fair :P

12:37 sdegutis: blkcat: that might be appropriate

12:37 Shayanjm: Does anyone here have implementation experience in quantum computing?

12:39 sdegutis: I don't think that's a real thing yet.

12:39 I think it's mostly theoretical.

12:39 justin_smith: Shayanjm: gfredericks has done some qc related projects

12:39 Shayanjm: sdegutis: nah there are tons of quantum simulators

12:39 sdegutis: Oh.

12:40 justin_smith: Shayanjm: simulator related, of course

12:40 sdegutis: Brb writing Clojure instead of Haskell or JavaScript.

12:40 Shayanjm: justin_smith: great, thanks. I'm trying to build my own simulator on clj

12:40 tolstoy: Is there a way to make lein use the latest clojure when running outside a project context?

12:40 Shayanjm: @ gfredericks - would love to pick your brain a little bit when you have a moment

12:40 justin_smith: Shayanjm: yeah, you could probably start with one of his

12:40 tolstoy: Corollary: Is leiningen ever going to be updated?

12:41 Shayanjm: justin_smith: creeping his site, checking out his quantum circuit visualization. Looks really cool

12:43 sdegutis: I am attempting the following: Str = #'\\w|\\W'+

12:43 Please advice.

12:45 Anyone here prefer Boot over Lein?

12:45 * rhg135 raises his hand

12:48 puredanger: they serve different users imo - for a basic Clojure project, lein is going to satisfy most of your needs for a long while

12:48 justin_smith: puredanger: who do you see as the target demographic for boot?

12:48 puredanger: boot is better the more customization you have to do, particularly intermediate file generation type tasks

12:48 most cljs builds can probably benefit from it (I think) and more advanced large-project builds

12:49 rhg135: puredanger is correct. I do my plain clj in lein

12:50 gfredericks: Shayanjm: what's up?

12:50 hiredman: I disagree

12:50 puredanger: I'd love to hear your opinion

12:52 rhg135: Simpler cljs builds are fine with figwheel imo

12:52 hiredman: generally, builds are terrible, and javascript builds (for whatever reason) are the worst

12:52 puredanger: I think the other thing is that lein comes at the problem from the "declarative project model / lifecycle" perspective (like Maven) and boot comes more from an imperative "task" perspective - assembling pipelines of things that are useful for your particular build.

12:53 those might fit different projects and people differently

12:53 cfleming: I agree that the more complicated the build, the more flexible something like boot will end up being.

12:53 hiredman: people generally react to that by calling for more tooling, I've already seen people calling for tooling above and beyond boot for wiring together all the cljs build parts

12:53 but the tooling is more strata to dig through when it breaks

12:54 it is terrible

12:54 sdegutis: I am successfully using Instagram to parse my text file format.

12:54 rhg135: I'm hoping for a lein update soon

12:55 I like my 1.7

12:56 sdegutis: Is Clojure 1.7 released then?

12:56 rhg135: Yeah

12:57 hiredman: boot may or may not be good, but I think it's adoption is driven by an need to escape the terribleness of ui builds and a willingness to try anything to do that, without much reflection about if a solution actually solved anything

12:59 rhg135: It's better than writing dozens of shell scripts

12:59 puredanger: I'm looking at it for stuff that has nothing to do with ui and there many things I like about it

12:59 hiredman: the same impluse behind all the javascript build tools that make it impossible to get a node project up and running from source

13:00 sdegutis: I had to add this rule: Str = #'.+'

13:01 rhg135: It'd be useful for post/pre processing

13:01 Like js gen or dexing

13:04 sdegutis: puredanger: Thanks for the comprehensive analysis and comparison of Boot vs Lein. I appreciate it. And it seems very accurate and compatible with my own experience using both and reading their documentations.

13:05 puredanger: my opinions are still forming on it, so for sure, do your own analysis

13:06 sdegutis: My understanding is that Lein + a few mainstream plugins are what most Clojure people will use, since they share the common mentality of wanting to as much as possible in Clojure, and letting other libraries and plugins help them with the common cases, such as building dependencies, uploading to EC2, etc.

13:06 And that Boot is a reaction to this, to try simplifying it when you want more flexibility in any of these steps, which currently is a headache involving creating custom Lein plugins etc.

13:07 I am a fan of neither and would prefer to just use GNU Make.

13:07 But alas we're in the Java world here.

13:07 puredanger: sdegutis: you might want to look at cmma

13:07 https://github.com/ohpauleez/cmma/

13:07 Paul uses it pretty extensively to manage Clojure apps with make

13:08 sdegutis: Its README's rhetoric is too vague: cannot tell what it does, and how it's different than anything else.

13:08 puredanger: it uses make to manage Clojure projects

13:08 sdegutis: Oh!

13:08 puredanger: it wraps other build systems (lein, boot, etc) to steal the dep-mgmt parts

13:09 sdegutis: Ahh crap.

13:09 Implies: So many JVMs starting and stopping constantly.

13:10 puredanger: mmm, don't think so? once you grab jars, you have them. no need to do that on every build.

13:10 sdegutis: Every `lein run` rebuilds my Clj source and runs it.

13:10 That's where this would come in.

13:14 slester: Hello hello; I'm sure this channel gets this question frequently, but since I can't use Clojure at work, I'm looking for a project (pref. GPL) to work on. Any suggestions? Sometimes it's a bit opaque how to get started in a community

13:15 justin_smith: slester: is epl good enough? there isn't much gpl clojure

13:15 but there is a lot of epl clojure

13:16 slester: the leiningen project has a tag for issues that would be easy for a newcomer to work on in their github issue tracker

13:17 It's EPL

13:17 sdegutis: Is there a better way to write (fn [s & _] s) ?

13:17 justin_smith: first

13:17 well, no, not first

13:17 (comp first list)

13:18 ,((comp first list) :a :b :c :d :e)

13:18 sdegutis: I tried `first` at first.

13:18 clojurebot: :a

13:18 sdegutis: justin_smith: Thanks. Which way do you think is clearer?

13:19 justin_smith: sdegutis: probably your version

13:19 sdegutis: also (apply (comp first list) (range)) goes into a loop, (apply (fn [s & _] s) (range)) returns 0 immediately

13:20 TMA: sdegutis: if you need a name, in common lisp this function is called prog1

13:20 sdegutis: TMA: Thank you. That fully solidifies my distaste for CL.

13:21 justin_smith: clearly program-one is the right name for it

13:22 TMA: sdegutis: maybe you shall restructure the solution to avoid the need for such a distasteful function :)

13:22 slester: justin_smith: whoa, thanks, for some reason my IRC client/internet connection just sent me 20 messages at once

13:23 justin_smith: slester: yeah, the IRC protocol is kind of weird, things like this are not uncommon

13:23 slester: justin_smith: and yep, EPL is fine.

13:23 justin_smith: leiningen seems kind of massive, I'll have a look through its issues though. I do like it a lot and would like to help.

13:24 justin_smith: another bonus to working on leiningen is that nearly all of us use it

13:24 which amplifies the warm-fuzzies of contribution

13:24 slester: a very important part of contribution, if often not spoken of :)

13:24 sdegutis: TMA: I am interfacing with Instaparse. It is impossible to rework anything.

13:25 Oops. It's actually (fn [s _] s) that I wanted to investigate replacing.

13:25 It's a two-argument thingy.

13:26 Actually, wait. Is it possible to just tell Instaparse to omit a certain thing from the output tree?

13:26 I have a literal '\n' in my rule (to indicate end of line as the terminator for that rule). But it keeps emitting this stupid character in my output tree.

13:27 TimMc: slester: lein has some issues marked "newbie" which don't require as much background

13:27 justin_smith: TimMc: yeah, that's why I brought it up

13:27 sdegutis: Anyone know if this is possible somehow?

13:27 To tell it "hey don't omit this character in my rule"?

13:28 xemdetia: sdegutis, did you look at 'transform'

13:28 sdegutis: I am currently using it.

13:29 That's where I'm putting (fn [s _] s)

13:30 One way would be to give a name to my Newline character and then transform it into nil in the transform, if that even works. But that might not work. And even if it does, I don't want to name Newline.

13:30 xemdetia: can't you just do :newline-token nil

13:30 well it is a token in your input stream?

13:30 sdegutis: xemdetia: It's a literal '\n'

13:30 xemdetia: since you are using it as a meaningful delimiter instead of whitespace?

13:31 sdegutis: Entry = Thing+ '\\n'

13:31 xemdetia: so for the grammar to accept the input it must have a literal newline token

13:31 so it makes sense it would be in your output

13:32 sdegutis: Not with how well-structured Instaparse's output tree already is.

13:32 I don't need the newline in my output, it's just there for the sake of the parser. Now that it's parsed, I don't need this token anymore.

13:33 xemdetia: so tag it as a token and do a tree transform to get rid of it, that's really the answer if you are not able to override how the newline token is added to the tree

13:33 this is more general parser theory than exactly instaparse

13:36 sdegutis: Oh.

13:36 Thanks xemdetia for your expert help.

13:36 xemdetia: accepting a grammar in a parser is one job, the data structure it emits as a representation is a separate part, if the path between lexer and tree is a black box to you

13:36 you just have to deal with it on the output side

13:37 sdegutis: Most excellent.

13:38 Transforming it into `nil` does not help.

13:38 It is still present, only now as nil.

13:38 (hehehehehheh)

13:39 justin_smith: sounds like a job for mapcat

13:39 * justin_smith now imagines the mapcat as a special feline superhero.

13:40 xemdetia: only when you need mapcat to be

13:40 during the day mapcat is just cat, a noble blue collar worker

13:40 taking files from over there and dumping them to screens for the luxurious

13:40 but at night

13:40 mapcat gets lispy

13:40 justin_smith: haha

13:40 (doc cat)

13:40 clojurebot: "([rf]); A transducer which concatenates the contents of each input, which must be a collection, into the reduction."

13:42 xemdetia: sdegutis, will nil be happily handled by the reader of that tree

13:42 if not maybe you just have to do some dissoc/remove-keys magic

13:42 sdegutis: xemdetia: no, it still requires me to use (fn [s _] s)

13:43 xemdetia: well I didn't mean through instaparse transfor

13:43 just use it like a tree

13:43 sdegutis: It ends up inside a ["mystring" "\n"], where I ultimately just want to get "mystring" out.

13:44 xemdetia: I mean you have a ref to a map that is your output, just use it like a map? filter maybe?

13:44 I am not remembering how instaparse emits

13:44 been playing with antlr more lately

13:45 sdegutis: How do you match the very end of a file?

13:45 Should I just append \0 to the file and match for that?

13:47 xemdetia: we're talking about a few different things? when/how do you want to match the eof?

13:48 I mean from lexer/parser land usually you just invent an eof token so you don't have to worry about it

13:48 sdegutis: Pretend that, in the file my professor will give us, there may not be a trailing newline at the end of the file, whereas it belongs to a repeating rule.

13:49 For example if Line was a rule to match a line and ends in '\n', and you might have many lines, but the last one doesn't end in a newline.

13:49 Does this make sense?

13:49 snowell: sdegutis: You can use brackets to exclude it from the output: Entry = Thing <'\n'>?

13:49 sdegutis: snowell: Awesome!!!

13:50 Let me try.

13:50 Ahhh: "Angle brackets on the right-hand side of a rule correspond to the hide combinator."

13:50 I did not look for "hide" anywhere ever. Only "ignore" and "omit".

13:56 Yes, <> works perfect. To ignore the token itself but leave the rule name, I put it on the right side. To ignore both, I put it on both sides.

13:56 I never even saw the "Controlling the tree structure" section! This is useful.

13:56 xemdetia: sorry, haven't used instaparse enough

13:57 but yeah there is a separation between 'accept grammar' and 'data structure'

13:57 you either have hooks or you don't

14:06 sdegutis: So if you have a file with multiple Lines, each Line ending in '\n', but the last line omits the newline -- how do you express this?

14:06 Or do you just add an \n at the end of the file just in case, ignoring a second \n that might be at the end?

14:08 xemdetia: sdegutis, one way could just accept '\n'+

14:08 sdegutis: xemdetia: But it might have 0 newlines on the last line

14:09 xemdetia: or I might have misread it

14:09 sdegutis: And * doesn't work since every line before it requires at least one

14:09 snowell: ? translates to 0 or 1

14:09 sdegutis: It's a text file where each line is an entry, but the whole file might not end with a newline

14:09 xemdetia: right, are you slurping the input file directly into instaparse or are you buffering it first

14:09 sdegutis: (slurp)

14:10 (->> file (slurp) (parse))

14:10 xemdetia: can you just stick an extra newline on the end? *_*

14:10 sdegutis: Yep. That's my current plan.

14:10 snowell: I would use ?

14:10 xemdetia: he can't

14:10 sdegutis: But it makes me feel dirty.

14:10 xemdetia: newline is a meaningful character

14:10 hellofunk: cljs repl experiments by mfikes are trending high on HN right now

14:11 sdegutis: (inc mfikes)

14:11 lazybot: ⇒ 1

14:11 xemdetia: sdegutis, its not really dirty. massaging input before lexing is just something you have to do

14:11 sdegutis: It's a thing?

14:11 Phew.

14:11 xemdetia++

14:11 xemdetia: well I mean in most of my grammars I have an end of input thing

14:12 and usually that is something I glue in lexer - EOF APPEND - parser

14:12 if it is not convenient to do another way

14:13 snowell: You could parse with a regex

14:13 justizin: anyone using clojure to test existing java code with no coverage?

14:13 snowell: sdegutis: Entry = Thing + <#

14:13 bah

14:14 hiredman: justizin: yes

14:14 snowell: Entry = Thing + <#"[\n|\Z]">

14:14 sdegutis: xemdetia: I've done that too in the past -- my lexer would append a special :EOF token to the end of the token stream.

14:14 xemdetia: But Instaparse is fun.'

14:14 snowell: That will match on \n or end of string

14:14 hiredman: well, maybe "that depends"

14:14 xemdetia: that's true

14:15 but yeah just throwing an eof on the token string is easiest

14:15 because then you aren't relying on some condition of the input to be exactly right

14:15 which makes debugging easier

14:15 snowell: Easiest, sure. But like sdegutis I feel dirty doing something like that :D

14:16 xemdetia: well

14:17 this is why using whitespace as a delimiter is awkward

14:17 if you used semis for every line you wouldn't have this problem at all

14:17 and you would have a clean token string to feed the parser

14:17 sdegutis: +1

14:17 snowell: Of course then a user comes along and puts a semi in the input

14:18 sdegutis: xemdetia: the real problem is having to parse something that humans edited

14:18 xemdetia: yes

14:18 justizin: hiredman: any tips on where to start? examples?

14:18 sdegutis: *and assembled

14:18 xemdetia: the real problem is the people

14:18 remove the people

14:18 sdegutis: OF COURSE


14:18 how could i not think of this

14:18 Welp, at least I'm not parsing Excel files.

14:19 slester: this is how the robot wars begin

14:19 hiredman: justizin: the first thing you'll need to figure out is how to tie the clojure tests in to your java project, the easiest way to do that is to build the java project using lein, then you can run with tests with `lein test` and write them using clojure.test

14:20 if you can't do that you can look at clojure, it is a java and clojure project, built using maven, tested in clojure

14:21 sdegutis: Thanks in advance, regards.

14:21 justizin: hiredman: tks

14:22 sdegutis: My awful hacky solution: https://gist.github.com/sdegutis/7ca83a4a4a61b7ced970

14:22 Passes all tests!

14:22 And now I'm done 3 hours early.

14:22 Time to convert Sass to Stylus.

14:23 I really want to convert it to Clj to be honest. But let's face it JVM startup time won't be acceptable for 15 more years.

14:24 justizin: hiredman: somehow this idea came out of the thought of using lein instead of maven

14:24 i have a little experience with lein from working with jepsen and LightTable

14:25 hiredman: sure, lein does well building java, and then you can point test.check at your java, it is great

14:25 justizin: sweet

14:25 it feels like it might be less typing to write lots of new tests of a java module with clojure

14:26 bauhaus: anyone seen a deps error in the latest version of datomic: I/O exception caught when processing request to {}->http://jline.sourceforge.net:80: Connection reset >.<

14:28 sdegutis: We are very far behind in Datomic versions. Years old.

14:29 Also in Clojure version.

14:29 We can't update. Too expensive.

14:30 bauhaus: thought the sourceforge ship had sunk

14:31 guess not

14:31 sdegutis: bauhaus: yes it has

14:31 bja: just submitted a PR to a project that introduces eval, preparing to get roasted...

14:34 wasamasa: for what reason?

14:34 inb4 it's in a macro

14:38 bja: I'm generating destructure arguments and have a macro that does let passing those bindings in (manual-let), I need to eval the result of that along with the symbols I want out

14:38 at least as far as I can tell

14:39 so the macro builds a let*, then I want to eval it so I can grab the result of the destructuring

14:39 justizin: hiredman: any examples of java projects built with lein? the documentation is all like 'clojure clojure clojure'

14:39 bja: https://github.com/stuartsierra/component/pull/37/files#diff-998bb67cf5bc59512267d4e162873450R137

14:40 hiredman: https://github.com/sonian/Greenmail/blob/master/project.clj

14:40 bja: justizin: storm used to be built with lein, but it's moved to straight maven during the 0.9 cycle

14:43 wasamasa: bja: can I get a cookie for guessing right?

14:43 bja: well, the eval isnt' in a macro

14:44 but I guess you can have a cookie anyway, since it's pretty close

14:44 wasamasa: yay

14:45 bja: (inc wasamasa)

14:45 lazybot: ⇒ 1

14:56 sdegutis: Is there a nice way to prettily diff two not-too-deep maps. Thanks?

14:56 H4ns: sdegutis: https://clojuredocs.org/clojure.data/diff

14:58 minus the "nice" and "pretty", i fear

14:58 sdegutis: Sorry I mean to print.

14:59 snowell: ,(doc prn)

14:59 clojurebot: "([& more]); Same as pr followed by (newline). Observes *flush-on-newline*"

14:59 snowell: sdegutis: ^

15:00 sdegutis: snowell: Thanks. I fear prn does not work well for many vectors.

15:01 snowell: Well you said they weren't too deep. pr-str / pr / prn are about as pretty as you can print

15:02 You could try clojure.pprint/pprint I suppose

15:03 xemdetia: you could print to legal and get out some highlighters

15:03 I think I still have some stickers in a drawer somewhere

15:21 atyz: Does anyone know where I can find information on how to efficiently query nested entities (of the same type, they all have the same ref - like a tree) in datomic?

15:41 iwillig: atyz: you might want to try the datomic channel

15:41 but would the pull api be enough for you ?

15:41 fredfe: Is net.mikera/core.matrix a prefered/stable matrix match lib?

15:59 gfredericks: sdegutis: the puget library might be useful

16:09 hcumberdale: Hi! :)

16:09 How to register a log4j.properties file during a lein plugin execution ?

16:10 Files under ./resources does not seem to be seen during plugin execution

16:21 nicola: i'm having a similar issue - my (clojure) code uses cassandra which logs A LOT of stuff on the console; is there a simple way to turn it off?

16:24 hcumberdale: nicola: generally you can set things via resources/log4j.properties

16:24 but this isn't recogniced during a plugin run

16:24 nicola: i'll try that, thanks

16:27 justin_smith: nicola: another option is to use lein repl in the console, which will start a repl and also start listening on a port, then you can use 'lein repl connect' in another terminal. The logging goes to the first one, and will not interrupt your work in the second.

16:27 in place of lein repl :connect, you can also use a client like cider of course

16:28 nicola: hcumberdale: didn't seem to work :( still logs a lot of stuff

16:29 hcumberdale: nicola: depends on what logging framework loggs this stuff.

16:29 nicola: justin_smith: by console i meant stdout, not repl/cider

16:29 hcumberdale: i'm pretty sure it's log4j (at least from looking at cassandra's source code) but i'm still trying to sort this out so i might be wrong

16:29 justin_smith: nicola: then explicitly open a file handle and output to that instead of using stdout?

16:29 hcumberdale: nicola: what is writing to stdout? A framework? Yur application

16:30 nicola: it might be java commons logging

16:30 nicola: i'm calling some function from cassandra; these functions in turn log a bunch of stuff to stdout, which i don't want

16:30 justin_smith: nicola: that would be the hack version at least. if you figure out what logger it is using, you can configure that logger of course.

16:30 hcumberdale: you can bundle all logs into a slf4j adapter

16:30 see: https://github.com/kremers/clojurewebtemplate/blob/master/project.clj << logging

16:31 it is using logback as backend

16:31 justin_smith: nicola: what is consuming your stdout?

16:31 hcumberdale: configured here: https://github.com/kremers/clojurewebtemplate/blob/master/src/logback.xml

16:32 nicola: the java driver for cassandra is using slf4j

16:33 nicola: justin_smith: i'm just printing to console; i mean lein uberjar, then java -jar target/...-standalone.jar; i'm not piping this to anything

16:33 hcumberdale: oh interesting

16:35 justin_smith: nicola: the reason I ask, is if nothing is programatically consuming it in real time, you can even just use something like grep

16:35 nicola: justin_smith: oh i see; i'd want to take it out anyway though

16:36 justin_smith: clearly a misunderstood a few things, heh

16:40 nicola: YES! here's the solution (set to only warnings) (.setLevel (org.slf4j.LoggerFactory/getLogger ch.qos.logback.classic.Logger/ROOT_LOGGER_NAME ) ch.qos.logback.classic.Level/WARN)

16:40 thanks for the tip about slf4j hcumberdale

16:41 hcumberdale: nicola: better you use a file. So you are able to adjust it later without redeployment etc.

16:42 nicola: true

16:49 hcumberdale: hmmm technomancy not here

16:51 slester: Just read this on HN: "Slow launch means you tend to write monolithic applications. You can't write cli tools with Clojure. You can't compose Clojure applications. You have to write a big bulky JVM app. Which definitely has its place, but ClojureScript is expanding Clojure's reach." -- Is that true? I mean the repl does take forever to start, but does that inhibit CLI?

16:54 hiredman: it is ridiculous

16:54 my ~/src has 18 shebang scripts written in clojure in it

16:55 blkcat: the jvm startup time is not what i would call ideal

16:55 hiredman: (counted via find $PWD -name \*.clj -exec head -1 {} \;|grep '#!'|grep jar|wc -l)

16:55 blkcat: just getting usage from lein takes a little under 4 seconds on my system

16:56 hiredman: the shebang lines for those 18 files are some variation of #!/usr/bin/java -jar /Users/hiredman/src/clojure/target/clojure-1.7.0-master-SNAPSHOT.jar

16:56 justin_smith: blkcat: the lein repl startup time is not caused by the jvm, the culprits are mainly nrepl, lein, and clojure.core, in that order last I checked

16:57 if you can avoid the lein and nrepl parts of the equation, you'll like your startup time much more

16:57 slester: hiredman: and I guess the responsiveness is fast?

16:57 I searched and found https://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Shebang_Scripting_in_Clojure

16:59 hiredman: I have no idea, they are not interactive, there is one to delete old clojurebot postgres backups from s3, one to launch the daily show on my roku, one to generate a youtube playlist from the gist of songs played in the strange loop main hall

17:00 I've never cared, or used time on them, and they work great

17:00 puredanger: I can run this in 0.893 sec: time java -cp clojure.jar clojure.main -e "(+ 1 1)"

17:00 which starts a repl, evaluates an expr and shuts down

17:00 slester: hiredman: launch the daily show on your roku? :O

17:00 puredanger: well I guess starts a runtime, not a repl

17:01 hiredman: slester: sure, that script is retired, replaced by a little web app that I used from phone, and then I moved and never set it up again

17:03 the webapp was sweet, I ran it on a beaglebone and could use it to drive my tv, roku, even the fireplace

17:04 I touching a single button it would turn on the tv, set it to right input, then launch the hulu roku app, search of the daily show, then launch the most recent episode

17:05 I do a lot of stuff, and I do with clojure, and it works great

17:07 https://gist.github.com/hiredman/7682917

17:08 vas: hiredman; that's impressive.

17:11 csd_: does there exist some macro that makes it easy to thread a async channel through a stateful series of functions for testing purposes? is this even a good practice to consider?

17:26 adrians: Anyone around who is using Emacs/cider and who could answer a few questions?

17:27 mk: adrians: best way to find out is to just ask :)

17:29 Seylerius: adrians: I'm not massively experienced, but I'm using CIDER atm and could experiment. Speak your queries.''

17:37 adrians: for some reason I don't seem to be getting the doc popup in my editor buffer when using cider/company-mode, but I do have it in my *cider-repl* buffer - same minor modes seem to be in effect for both buffers

17:42 Would anyone know what I should look for to determine why I'm not getting the help popup in the editor?

17:45 Seylerius, mk: still around?

17:45 Seylerius: adrians: Yep.

17:46 adrians: Any suggestion?

17:46 mk: yes, but I don't use either of those

17:46 Seylerius: adrians: Which help popup?

17:46 adrians: one that comes up after the auto completion popup appears

17:54 Seylerius: adrians: The one that's supposed to provide the argument possibilities?

17:56 adrians: Seylerius: the package is called company-quickhelp

17:56 Seylerius: Ah, that one.

17:56 adrians: it shows the function signature plus the doc string

17:56 is this meant to work only in the repl buffer?

17:56 arrdem: there's also eldoc-mode

17:57 adrians: arrdem: yes, I'm using that too, but I like the multi-line popup in addition to that

17:57 arrdem: and no both will work fine in both code and the repl

17:58 assuming you're in cider-mode with a live connection among other things

17:58 adrians: aardem: so what could be a reason not to see it in a regular editor?

17:58 aardem: I am connected - I get the popup in the repl buffer

17:59 and on the github page, I see no configuration other than for turning it on and setting the delay

17:59 arrdem: so you have to hook company-quickhelp-mode to cider-mode

17:59 or turn it on yourself

17:59 I don't think cider does that automagically

18:00 that's something I think got added to the README recently along with adding company-mode to cider-mode. if not then it needs to be in the README

18:02 adrians: did/does that help?

18:02 adrians: yes, thanks aardem

18:16 broma0: a good data structure for O(1) push/pop at both the front and back?

18:20 arrdem: broma0: doubly linked list

18:20 not immutable tho.

18:21 finger trees may be able to do that as well, but they're gonna be O(log32(n)) push/pop

18:21 amalloy: i think the main persistent options are finger trees and RRB trees

18:21 arrdem: really? i know that's true of RRB trees, but i don't think finger trees have and kind of 32-wide branching

18:21 arrdem: amalloy: I don't remember the specifics of finger trees, maybe I have them confused with vectors

18:21 s/maybe/probably/g

18:22 amalloy: i think so. RRB trees are the thing bagwell gave a talk about, as a way to improve clojure's vectors

18:22 arrdem: heh

18:24 hcumberdale: How to enable the log4j debug logger on root level when executing leiningen plugins

18:38 broma0: arrdem: amalloy: Thank you

18:39 TEttinger: gfredericks: I have some RNG puzzling to do that perhaps you are already an expert on

18:39 gfredericks: I'm interested in implementing the PCG family of RNGs in Java (making them usable to Clojure as well, of course)

18:40 http://www.pcg-random.org/

18:43 they're a very conceptually simple modification on a linear congruential generator (or multiplicative congruential generator, which is what I'm interested in) where they use the values in the low-period low bits as shift or rotation operands, and/or use them to perform a xorshift on the high bits of the LCG output

18:45 downside is I need a better LCG than Java's, since java will only produce 32 bits with a period of 2^48, and there aren't nearly enough bits to work with there

19:03 crocket: Can anyone recommend a good command line parser?

19:04 Surgo: tools.cli

19:04 https://github.com/clojure/tools.cli

19:04 your definition of good may vary

19:05 crocket: Is tools.cli simple and small?

19:05 Surgo: simple, you can decide on that yourself by checking the readme

19:06 small, it has no dependencies aside from clojure

20:57 jhn: if I have a set of maps, how can I test if there is some key in any of the maps that has a particular value?

20:59 scriptor: ,(map #(contains? % :key) [[:key 1] [:bar 2]])

20:59 clojurebot: (false false)

20:59 scriptor: sorry

20:59 ,(map #(contains? % :key) [{:key 1} {:bar 2}])

20:59 clojurebot: (true false)

21:03 jhn: ty

21:16 julianleviston: um

21:17 that’s not going to test if there’s a key that has some particular value… unless you mean “how can I test that the map has a particular key”? which wasn’t what you asked.

21:18 jhn Precision of language: This is a set of maps: #{{:a 1} {:b 2}} is this what you meant when you said “if I have a set of maps”?

21:19 jhn: julianleviston Yes, I noticed, but that gave me the hint as to what I could do.

21:19 And yes, I meant an actual set.

21:21 julianleviston: good o

21:23 gfredericks: TEttinger: was there a question associated with that?

21:24 TEttinger: gfredericks: ah I assumed you weren't around and it was going to get passed out of history

21:25 gfredericks: are you familiar with L'Ecuyer's LCG constants?

21:26 I was having a hard time understanding why he claims certain numbers for MCGs produce reversed-order generators compared to certain other numbers, and I think I don't understand his meaning

21:26 gfredericks: it doesn't sound familiar

21:26 TEttinger: http://www.ams.org/journals/mcom/1999-68-225/S0025-5718-99-00996-5/S0025-5718-99-00996-5.pdf

21:26 gfredericks: the most I looked into LCGs was to read the knuth volume without doing any of the exercises

21:27 TEttinger: I gotta say I still haven't finished watching your splittable RNG talk :(

21:27 it was starting to go over my head when I stopped

21:27 I did look into Java 8' SplittableRandom source

21:28 http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/util/SplittableRandom.java

21:28 gfredericks: what part was head-over? the algorithm descriptions?

21:28 yeah I looked at that file quite a lot :)

21:28 TEttinger: I can't remember, I don't understand the threading stuff that well

21:28 * gfredericks threading?

21:28 TEttinger: why you would want splittability, I mean

21:28 gfredericks: oh there are different reasons

21:28 doesn't have to be threading

21:29 e.g. test.check more or less needs it and is single-threaded

21:29 TEttinger: ah

21:29 gfredericks: laziness is the key factor in the test.check case

21:29 but the biggest reason is just that the state monad is a giant pain

21:29 especially if the haskell compiler is not holding your hand

21:29 TEttinger: hm.

21:30 gfredericks: so if you want to write complex deterministic programs that depend on pseudorandomness, you can't give them an arbitrary structure, you have to manually linearize the program

21:30 I will admit this probably doesn't matter for most people

21:31 TEttinger: I think I can implement PCG-Random's bit-fiddling over any 64-bit-state, 64-bit-output generator and get a 32-bit generator out of it

21:31 gfredericks: if you're using a haskellesque language though, the language forces this to be important

21:32 TEttinger: gfredericks, are you using SplittableRandom now or your own RNG?

21:32 (in test.check)

21:32 gfredericks: I ported it to clojure

21:32 TEttinger: ah!

21:32 gfredericks: SplittableRandom is OOP style

21:32 the port is clojure/functional style

21:32 TEttinger: cool

21:32 gfredericks: but it gives you identical results

21:33 TEttinger: can you skip ahead?

21:33 (efficiently?)

21:33 gfredericks: I don't think there's a need to?

21:33 I'd be curious to hear a use for that

21:33 that can't be met by general splittability

21:33 (you might still be able to, I just haven't thought about it)

21:34 TEttinger: eh, it's sometimes a handy feature. you can do it regardless of having been split, so it could be added onto a SplitMix style RNG

21:35 you could have a decent-sized collection of SplitMix RNGs, right? each has tiny state so having lots isn't a problem

21:36 julianleviston: is there a flip combinator in clojure?

21:36 gfredericks: I'm not sure what splitmix means exactly

21:36 TEttinger: gfredericks: it's the type of generator SplittableRandom uses

21:36 gfredericks: oh that sounds familiar

21:36 the "skipping ahead" question doesn't actually fit well with the API I aimed at because it's not linear at all

21:36 there is no inherent "sequence of numbers" to skip ahead in

21:37 though the SplittableRandom algorithm is more sequence-like

21:37 I just decided to more or less ignore that sequence

21:37 TEttinger: they could all be seeded with the same state. the update step for SplittableRandom adds the gamma to state, then takes that value (not modifying state anymore) and xorshifts/multiplies it some

21:38 it's fairly straightforward to add gamma many times and only get the overflow out of it

21:38 gfredericks: oh yes, that's right

21:38 TEttinger: that would be equivalent to skipping ahead

21:38 gfredericks: yep

21:39 f(state + gamma * n)

21:39 TEttinger: yes, but not quite

21:40 gfredericks: eh?

21:40 TEttinger: if you wanted to skip ahead 1000 iterations, will that be OK with regards to overflow?

21:40 hm, to the clojurebot

21:40 gfredericks: I believe the unchecked jvm arithmetic ops Just Work

21:40 you just want to do modular arithmetic

21:41 TEttinger: oh, also: do you know how to get either of the bots to do *unchecked-math* ?

21:41 gfredericks: ,(set! *unchecked-math* true)

21:41 clojurebot: #error {\n :cause "Can't change/establish root binding of: *unchecked-math* with set"\n :via\n [{:type java.lang.IllegalStateException\n :message "Can't change/establish root binding of: *unchecked-math* with set"\n :at [clojure.lang.Var set "Var.java" 221]}]\n :trace\n [[clojure.lang.Var set "Var.java" 221]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compile...

21:41 gfredericks: you can always just call unchecked-foo directly

21:41 ,(unchecked-multiply 382947923 723782542342)

21:41 clojurebot: 469860187885181426

21:42 TEttinger: ,(unchecked-multiply (quot Long/MAX_LONG 2) (quot Long/MAX_LONG 2))

21:42 clojurebot: #error {\n :cause "Unable to find static field: MAX_LONG in class java.lang.Long"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to find static field: MAX_LONG in class java.lang.Long, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to f...

21:43 TEttinger: ,(unchecked-multiply (quot Long/MAXVALUE 2) (quot Long/MAX_VALUE 2))

21:43 clojurebot: #error {\n :cause "Unable to find static field: MAXVALUE in class java.lang.Long"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to find static field: MAXVALUE in class java.lang.Long, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to f...

21:43 TEttinger: ,(unchecked-multiply (quot Long/MAX_VALUE 2) (quot Long/MAX_VALUE 2))

21:43 clojurebot: -9223372036854775807

21:43 TEttinger: NICE

21:43 gfredericks: you gotta be careful with them though

21:43 TEttinger: yeah I got some weird thrown errors

21:43 gfredericks: there's this goofy half-bug where they do checked arithmetic if you're not using primitives

21:43 ,((fn [a b] (unchecked-multiply a b)) 2984289278487 472737237232)

21:43 clojurebot: #error {\n :cause "integer overflow"\n :via\n [{:type java.lang.ArithmeticException\n :message "integer overflow"\n :at [clojure.lang.Numbers throwIntOverflow "Numbers.java" 1501]}]\n :trace\n [[clojure.lang.Numbers throwIntOverflow "Numbers.java" 1501]\n [clojure.lang.Numbers multiply "Numbers.java" 1867]\n [clojure.lang.Numbers$LongOps multiply "Numbers.java" 467]\n [clojure.lang.Numbers ...

21:44 TEttinger: that helps a lot thanks

22:33 bcham: Quick question: In this test, the code isn't being executed and I'm not sure why. The result of the expression ((clean-code "python") ...) is the correct answer, but when I run the test it just shows the unexecuted code. http://pastebin.com/bpv1K7bF

22:36 Actually I think I figured it out

23:55 lvh: In Compojure, how do I spell "anything with this route match *prefix*, go to this handler fn"

23:57 basically /xyzzy, /xyzzy/ and /xyzzy/* (where the asterisk means "anything") should be handed off to this ring handler fn

Logging service provided by n01se.net