#clojure log - Mar 11 2016

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

0:13 jrajav: Anyone used Clojure with Google App Engine before?

0:34 hiredman: yes, a long time ago, at the time it worked sort of fine, these was (is?) a lein plugin

0:55 matsu: what's the best way to check if all values of a map are empty/nil?

0:55 so { :foo {} :bar nil } would be considered empty

0:59 using `vals` would work, but only on top level keys

1:27 rhg135: (every? ... (vals m))

1:32 matsu: That would work only on the top level keys of m, right?

2:09 renl: hi can i do the following (def a :a) (def b {:a 1 :b 2}) (b a) works but (b (symbol "a")) doesnt

2:11 got disconnected not sure if my previous question went through re-posting it

2:11 hi can i do the following (def a :a) (def b {:a 1 :b 2}) (b a) works but (b (symbol "a")) doesnt

2:13 ridcully_: ,(symbol "a")

2:14 clojurebot: a

2:14 ridcully_: ,(keyword "a")

2:14 clojurebot: :a

2:14 ridcully_: ah didnt saw the first def... ignore me

2:15 renl: ah ok

2:19 ridcully_: something like: (b @(resolve (symbol "a"))) maybe?

2:19 renl: oh yeah

2:21 well my original problem is with java interop. if i do this (Color. com.badlogic.gdx.graphics.Color/CORAL) it works but (Color. @(-> "com.badlogic.gdx.graphics.Color/CORAL" symbol resolve) doesnt

2:26 ridcully_: isnt that just Color/CORAL ?

2:27 i'd not expect you need to look up symbols here? this is just java interop. if you had to find that by name, id rather expect that to find via reflection?

2:34 ,(import java.util.Locale)

2:34 clojurebot: java.util.Locale

2:34 ridcully_: ,(.get (.getField Locale "ENGLISH") nil)

2:34 clojurebot: #object[java.util.Locale 0x4be25710 "en"]

2:34 ridcully_: ,(.get (.getField Locale "BOOOM") nil)

2:34 clojurebot: #error {\n :cause "BOOOM"\n :via\n [{:type java.lang.NoSuchFieldException\n :message "BOOOM"\n :at [java.lang.Class getField "Class.java" 1584]}]\n :trace\n [[java.lang.Class getField "Class.java" 1584]\n [sandbox$eval73 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval73 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6927]\n [clojure.lang.Compiler eval "Compiler....

2:49 faxmodem: how do I change the log level in repl? is there a global way to do that?

3:05 AndreasO: Canvas listener mouseentered seesaw, how the hell??

3:09 ilevd: (+ 1 1)

3:09 clojurebot: 2

3:09 ilevd: Oho

3:11 (dotimes [i 10] (prn (str "Hello " i)))

3:15 AndreasO: How do I put an event listener on a canvas in seesaw?

3:55 TEttinger: ilevd: use ,() with the comma to eval, clojurebot sometimes evals random code-like messages for fun

3:56 ,(dotimes [i 10] (print "Hello" i))

3:56 clojurebot: Hello 0Hello 1Hello 2Hello 3Hello 4Hello 5Hello 6Hello 7Hello 8Hello 9

4:19 krl: ,(empty? [])

4:19 clojurebot: true

4:27 CStorm: when i just want a simple form method on my new compjure project i run into csrf-token problems

4:28 do i have to implement ring-anti-forgery? just want to have a input box and a send button which then post to another approute i have

4:29 mavbozo: CStorm, yes. if you use default compojure setup, you have to take into account csrf protection

4:31 CStorm: i have the following:

4:31 http://pastebin.com/FyYQ7dbT

4:31 the route i outcommented if i call that i get a token, and i can set that and then curl post to the send– however i am not sure how i should do when i want a setup like there is now

4:32 where i input something in the form, and send and it automatically handles the token.

4:34 i guess the question is how i can incorporate it into the little test i have linked so i dont really have to think about it.

4:35 clgv: cfleming: ping

4:36 TEttinger: I would also ping cfleming

4:36 clgv: :P

4:37 mavbozo: CStorm, you can put <input type='hidden' name='__anti-forgery-token' value='*anti-forgery-token*'/> inside your <form>

4:37 clgv: cfleming: Cursive/IntelliJ offers the "Extend Selection" command - is there any command to extend the selections to the left or right "siblings" within an s-expression?

4:37 CStorm: let me try that mavbozo, thanks for helping me out

4:38 TEttinger: clgv, I've been hoping to be online when cfleming is for weeks now

4:38 clgv: TEttinger: oh ok, so he isnt around here as frequent as in the past...

4:38 mavbozo: CStorm, try that using browser first

4:39 clgv: $seen cfleming

4:39 TEttinger: maybe just time

4:39 no lazybot

4:39 clgv: :(

4:39 ;(

4:39 TEttinger: :( indeed

4:39 hyPiRion: lazybot has been dead for a long time =|

4:39 clgv: what happened?

4:39 TEttinger: it doesn't have reconnect code

4:39 so during stuff like DDoS hellstorms, it has no hope of staying online

4:40 clgv: well that could be fixed easily, right?

4:40 TEttinger: indeed, I've hacked a fix into my lazybot that uses crappy windows stuff

4:40 clgv: why windows?

4:40 ,(inc 1)

4:40 clojurebot: 2

4:40 clgv: but clojurebot is a tougher guy? :P

4:41 TEttinger: (basically relaunches the app from the command line when there hasn't been a message in a while)

4:41 (including ping)

4:42 CStorm: hm, mavbozo still gives me "Invalid anti-forgery token"

4:43 TEttinger: maybe you need to forge an anti-forgery token in the smithing forge

4:43 CStorm: haha

4:46 hyPiRion: CStorm: I have no idea what mavbozo is, but I've seen that error message related to https://github.com/ring-clojure/ring-anti-forgery

4:46 mavbozo: mavbozo, that's harsh

4:47 CStorm: i have ring-anti-forgery added

4:47 and basicly the whole project is this: http://pastebin.com/JNN2DQc6

4:47 but this still gives me invalid token

4:48 hyPiRion: mavbozo: Oh sorry :x I thought the sentence "mavbozo still gives me "Invalid anti-forgery token"" meant that some project named mavbozo gave that error message

4:48 mavbozo: CStorm, add another route (GET "/csrf-token" [] (generate-string {:csrf-token *anti-forgery-token*}))

4:48 CStorm: yes?

4:48 mavbozo: and then check "/" source in the browserand "/csrf-token"

4:49 CStorm: ok

4:49 mavbozo: see if anti-forgery token in both pages are the same

4:49 hyPiRion, :)

4:50 clgv: TEttinger: you can only forge those in Mount Doom ;)

4:51 CStorm: mavbozo: seems like its not added to the request header, and i get a token when i visit csrf-token as expected

4:51 the request headers for / looks like this:

4:52 https://usercontent.irccloud-cdn.com/file/mMLO3Mva/Screen%20Shot%202016-03-11%20at%2010.51.32.png

4:56 mavbozo: CStorm, what's the return body of /csrf-token ?

4:56 CStorm: {"csrf-token":"yACvl/Y5lytBFK/VIPa29pVsxsLXhrbDcbSuaCTSXQLknlHQWuFyvtcca9lhrN9uxkOv5Q8Vc4CQEEli"}

4:58 mavbozo: CStorm, something's wrong with your form string in "/" route. try this one https://www.refheap.com/115804

4:58 CStorm: will try that, hang on

4:59 mavbozo: when you view the page source of "/" in your browser, the value of __anti-forgery-token must be same as that is returned from "/csrf-token" route

5:00 CStorm: now its the same!

5:00 hang on ill try to see if it works.

5:01 now it works, mavbozo.

5:02 mavbozo: CStorm, great! :)

5:02 CStorm: phew, thanks for taking your time.

5:02 really appreciate it

5:04 mavbozo: CStorm, you're welcome

5:04 CStorm: and happy friday :)

5:45 lizzin: how can this error output be used to debug the issue? https://gist.github.com/anonymous/fc2a30d7a5e9d8b9bfb1

5:54 ridcully_: ,("bang")

5:54 clojurebot: #error {\n :cause "java.lang.String cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6...

5:56 mavbozo: ,(_

5:56 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

5:58 TEttinger: lizzin: if ridcully_'s example isn't clear enough, somewhere you have a string where a fn should be.

5:58 (or macro)

5:58 ,(:keyword {:keyword 1})

5:58 clojurebot: 1

5:58 TEttinger: that works

5:58 ,("word" {"word" 1})

5:58 clojurebot: #error {\n :cause "java.lang.String cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval95 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval95 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval95 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6...

5:59 TEttinger: doesn't

6:00 lizzin: ridcully_ TEttinger got it. thanks

6:01 TEttinger: cool

6:02 lizzin: which http client shoudl i use? http-kit?

6:03 TEttinger: no idea what's the best

6:03 stick around and someone may come online soon-ish

6:03 6 AM east coast time

6:03 lizzin: ok

6:04 i should be sleeping myself

6:04 ridcully_: lizzin: i use clj-http for fooling around with apis all the time

6:04 lizzin: <-- east coaster

6:04 TEttinger: woo ridcully_ to the rescue

6:04 MJB47: i use http-kit client a fair bit

6:04 mostly because it has good support for websockets as well

6:05 which comes in handy sometimes

6:05 never had a problem with it

6:05 TEttinger: yay http people... I'm so drowsy

6:05 yer the best #clojure

6:06 lizzin: if i want to download a jpg and then write it to my desktop, i can just do a http get as a stream and then use output-stream to write it to disk right?

6:06 ridcully_: i'd assume that http-kit might make the better component for a library or within your application

6:06 clj-http is dead simple for the repl

6:08 and aleph also has a client, right? or is it just using something else?

6:09 lizzin: https://gist.github.com/anonymous/1bdb195f4128328159b9

6:14 mavbozo: aleph also has http client

6:31 lizzin, write method on wrtr object can not accept string

6:36 lizzin, i assume (:body @resp) return string

6:37 lizzin: mavbozo: i thought i had taken care of this with the '{:as stream}'

6:43 mavbozo: lizzin, sorry, I misread. Yeah, {:as :stream} returns the :body from response as java.io.InputStream but wrtr.write only accepts byte[] or byte

6:43 ilevd: ,(doseq [i ["nice", "cool", "beatiful"]] (print "Clojure is " i "! "))

6:43 clojurebot: Clojure is nice ! Clojure is cool ! Clojure is beatiful !

6:48 lizzin: mavbozo: where is that mentioned? im not seeing it here: https://clojuredocs.org/clojure.java.io/output-stream

6:49 i believe you, just wondering which docs i should be reading

6:52 mavbozo: io/output-stream returns java.io.BufferedOutputStream http://docs.oracle.com/javase/7/docs/api/java/io/BufferedOutputStream.html

6:52 lizzin: yep, just stumbled on that

6:52 thanks

6:53 also, changing stream to 'byte-array' fixed things as expected

6:53 mavbozo: happen to know of any good docs that cover the diff between byte stream and byte arrays?

6:54 ilevd: (map [i "Clojure"] (str (repeat (rand-int 10) i)))

6:54 ,(map [i "Clojure"] (str (repeat (rand-int 10) i)))

6:54 clojurebot: #error {\n :cause "Unable to resolve symbol: i in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: i in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: i in this context"\n ...

6:55 ilevd: ,(map #(str (repeat (rand-int 10) %)) "Clojure)

6:55 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading string>

6:55 ilevd: ,(map #(str (repeat (rand-int 10) %)) "Clojure")

6:55 clojurebot: ("(\\C \\C \\C)" "(\\l \\l)" "(\\o \\o \\o \\o \\o)" "(\\j \\j \\j \\j)" "(\\u \\u \\u \\u \\u ...)" ...)

6:56 ilevd: ,(str (mapcat (map #(str (repeat (rand-int 10) %)) "Clojure")))

6:56 clojurebot: "clojure.core$comp$fn__4727@3647b6c6"

6:58 mavbozo: lizzin, i haven't found any. for dealing with bytes in clojure, I usually use ztellman/byte-streams library

6:59 prohobo: damn clojure, you scary

6:59 lizzin: oh nice, i will check that out

7:13 ilevd: ,(map #(concat (repeat (rand-int 10) %)) "Clojure")

7:13 clojurebot: ((\C \C) (\l \l \l \l \l ...) (\o \o \o \o \o ...) (\j \j \j \j) (\u \u \u \u) ...)

7:14 ilevd: ,(concat (map #(concat (repeat (rand-int 10) %)) "Clojure"))

7:14 clojurebot: ((\C \C \C \C \C ...) (\l \l \l \l \l ...) (\o) (\j \j \j \j \j ...) (\u \u \u \u \u ...) ...)

7:15 ilevd: ,(reduce conj "" (map #(concat (repeat (rand-int 10) %)) "Clojure"))

7:15 clojurebot: #error {\n :cause "java.lang.String cannot be cast to clojure.lang.IPersistentCollection"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to clojure.lang.IPersistentCollection"\n :at [clojure.core$conj__4345 invokeStatic "core.clj" 82]}]\n :trace\n [[clojure.core$conj__4345 invokeStatic "core.clj" 82]\n [clojure.core$conj__4345 invoke "core.clj" 82]\n...

7:16 ilevd: ,(repeat 10 \c)

7:16 clojurebot: (\c \c \c \c \c ...)

7:17 ilevd: ,(str (repeat 10 \c))

7:17 clojurebot: "(\\c \\c \\c \\c \\c ...)"

7:17 ilevd: ,(.toString (repeat 10 \c))

7:17 clojurebot: "(\\c \\c \\c \\c \\c ...)"

7:18 ilevd: ,(.String (repeat 10 \c))

7:18 clojurebot: #error {\n :cause "No matching field found: String for class clojure.lang.Repeat"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching field found: String for class clojure.lang.Repeat"\n :at [clojure.lang.Reflector getInstanceField "Reflector.java" 271]}]\n :trace\n [[clojure.lang.Reflector getInstanceField "Reflector.java" 271]\n [clojure.lang.Reflector invokeNoArgIns...

7:18 ilevd: ,(String. (repeat 10 \c))

7:18 clojurebot: #error {\n :cause "No matching ctor found for class java.lang.String"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching ctor found for class java.lang.String"\n :at [clojure.lang.Reflector invokeConstructor "Reflector.java" 183]}]\n :trace\n [[clojure.lang.Reflector invokeConstructor "Reflector.java" 183]\n [sandbox$eval202 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbo...

7:18 ilevd: ,(apply str (repeat 10 \c))

7:18 clojurebot: "cccccccccc"

7:19 ilevd: ,(map #(apply str (repeat (rand-int 10) %)) "Clojure")

7:19 clojurebot: ("CCCCCCCC" "llllll" "o" "" "uu" ...)

7:20 ilevd: ,(apply str (map #(apply str (repeat (rand-int 10) %)) "Clojure"))

7:20 clojurebot: "CCClloojjuu"

7:21 ilevd: =(

7:21 ridcully_: what are you after?

7:21 TMA: ,(apply str (map #(apply str (repeat (inc (rand-int 10)) %)) "Clojure"))

7:21 clojurebot: "CCCClllllooojjjjuuuuuureeeeee"

7:21 ilevd: ! :)

7:21 ridcully_: ,(apply str (mapcat #(repeat (rand-int 10) %) "Clojure"))

7:21 clojurebot: "CCCCCCCoooooooojjjjjuuurrrrreeeee"

7:22 TMA: ilevd: rand-int returns zero at times

7:22 ilevd: Heh

8:52 (apply interleave "Clojure" "Clojure")

8:52 ,(apply interleave "Clojure" "Clojure")

8:52 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Character>

8:53 ilevd: ,(interleave "Clojure" "Clojure")

8:53 clojurebot: (\C \C \l \l \o ...)

8:53 ilevd: ,(apply interleave (repeat 10 "Clojure"))

8:53 clojurebot: (\C \C \C \C \C ...)

8:53 ilevd: ,(apply str (apply interleave (repeat 10 "Clojure")))

8:53 clojurebot: "CCCCCCCCCClllllllllloooooooooojjjjjjjjjjuuuuuuuuuurrrrrrrrrreeeeeeeeee"

8:54 ilevd: ,(apply str (apply interleave (repeat 10 "Clojure"))) -> print

8:54 clojurebot: "CCCCCCCCCClllllllllloooooooooojjjjjjjjjjuuuuuuuuuurrrrrrrrrreeeeeeeeee"

8:56 ilevd: ,(print "Hi")

8:56 clojurebot: Hi

8:56 ilevd: ,(print (apply str (apply interleave (repeat 10 "Clojure"))))

8:56 clojurebot: CCCCCCCCCClllllllllloooooooooojjjjjjjjjjuuuuuuuuuurrrrrrrrrreeeeeeeeee

8:56 stain: Oh my

8:57 I thought this was a SMILES string for a very long organic molecule!

8:57 (too much chemistry)

8:57 TimMc: ilevd: At this point you might try /msg clojurebot and play with it there.

8:57 or I guess /query clojurebot

8:58 ilevd: Yeah, he is a good interlocutor

9:07 ridcully_: if only i could remember the syntax to teach clojurebot facts

9:36 X-warrior: hey guys I'm new to clojure and I'm not sure if my code is readable and the right way of doing things on clojure. Could anyone review it? https://bitbucket.org/matheusbrat/clojure

9:41 TimMc: X-warrior: I only have time for a quick glance... but the indentation is pretty wild, what are you using for an editor?

9:41 MJB47: X-warrior: your indentation is pretty funky, and im not sure if thats the way i would do the node stuff

9:41 but otherwise it looks fine

9:41 TimMc: ~use

9:41 clojurebot: Only use :use with :only.

9:41 X-warrior: TimMc: sublime

9:42 xemdetia: yeah that indent is all over the place :(

9:42 TimMc: See if it has a clojure formatting mode or plugin or something.

9:42 X-warrior: Also you'll want to use :use *very* sparingly.

9:43 Those (use ...) blocks should be requires (with :as) and should be moved up into the ns block.

9:43 MJB47: sublime does

9:43 i used to use it

9:43 its acceptable

9:43 X-warrior: https://github.com/bbatsov/clojure-style-guide#source-code-layout--organization

9:43 this might be useful

9:44 TimMc: For instance, when I see (.printTree tree 0) at the bottom of core.clj, what does tree refer to? It's impossible to tell without looking through the other namespaces. You should be able to look at code and see where a var came from without going to another file.

9:45 X-warrior: TimMc: so it would be better to use the namespace instead of :refs :all so I would need to specify tree/tree

9:46 MJB47: I will take a look

9:46 MJB47: did you use any plugin with sublime? or just regular sublime?

9:46 MJB47: i used a few things

9:46 let me see if i can find

9:47 hmm, seems i actually on used LispIndent

9:47 and sublimeREPL (which tbh is quite bad)

9:48 TimMc: X-warrior: That's right, (:require [clojure.java.io :as io]) and then you can do io/reader

9:49 If there's something you use a whole lot of and it's a real pain to have a namespace prefix, you can :refer [foo bar baz] as needed.

9:49 X-warrior: The two let blocks in parse-line can be combined into one, since let evaluates and binds sequentially.

9:50 You could even do (let [[customer invited] (str/split line #" ")] ...) -- destructuring is great

9:59 X-warrior: TimMc: what do you mean by destructuring? using a single line? x)

10:00 MJB47: thanks! I will take a look at lispindent

10:03 TimMc: X-warrior: Destructuring is a syntax for taking apart data structures: http://clojure.org/reference/special_forms#binding-forms

10:03 so you don't have to say first, second

10:05 ridcully_: ,(let [[a b] [1 2]] (println a b))

10:05 X-warrior: Oh, now I see it

10:05 clojurebot: 1 2\n

10:09 X-warrior: I should change my indentation to two spaces too

10:10 going to eat, 5 minutes, thanks TimMc

10:12 timvisher: is it possible to create an uberjar without a main class?

10:12 via lein

10:13 justin_smith: timvisher: sure, but you could just make clojure.main your main class too

10:15 timvisher: justin_smith: how would you do it? if we don't specify :main and have no `:gen-class`es in the code base clojure.main seems to be set as main by default

10:15 justin_smith: timvisher: hmm, maybe that happened and I was OK with that - what specific reason do you have to not have a main class at all?

10:15 timvisher: apparently hadoop runs the main if it exists

10:16 justin_smith: that's so dumb

10:16 timvisher: which is 1000% :)

10:16 i mean in theory i could edit the jar afterwards

10:17 i'm not sure how difficult that would be but i imagine it would be removing a line or two from the properties file or something

10:20 TimMc: timvisher: It's the manifest.mf, I think...

10:21 Try :main nil and see what happens.

10:21 timvisher: TimMc: yeah that's what hyPiRion is suggesting

10:22 TimMc: Worst case you can write a script to extract the manifest, filter it with grep, and put it back in.

10:24 timvisher: TimMc: right. not a huge deal

10:24 the class file can stay in there too as long as the manifest isn't pointing to it

10:26 hyPiRion: It's annoying to do it manually though

11:26 ilevd: Ask, please

11:28 cortexma`: given having (blah (blerg)) in emacs, i'm looking for a way to, given having (blerg) selected, to then select (blah (blerg)), and vice versa

11:29 ilevd: I don't know I use light table

11:32 ,(str "Emacs or Light Table? Of course " (rand-nth ["Emacs" "Light Table"]) "!")

11:32 clojurebot: "Emacs or Light Table? Of course Light Table!"

11:32 ilevd: You see?

11:35 mavbozo: ,(str "Emacs or Light Table? Of course " (rand-nth ["Emacs" "Light Table"]) "!") ;; Emacs please

11:35 clojurebot: "Emacs or Light Table? Of course Emacs!"

11:35 mavbozo: yeah!!

11:36 ilevd: XD

11:46 ridcully_: ,(str "Emacs or Light Table? Of course " (rand-nth ["vim"]))

11:46 clojurebot: "Emacs or Light Table? Of course vim"

11:46 ridcully_: fix your odds

11:53 OscarZ: hi.. what do you recommend for logging?

11:55 ilevd: I want to know an answer too. I usually use print

11:56 justin_smith: ,((constantly "ed"))

11:57 clojurebot: "ed"

11:57 OscarZ: yeah same.. i dont need anything fancy.. maybe log into a file and stdout

11:58 ilevd: I think maybe some wrapper around log4j

11:59 OscarZ: hmm.. maybe ill try this: http://www.bahmanm.com/blogs/how-to-add-logging-to-a-clojure-project

12:11 bacon1989: i haven't used logging in any of my clojure projects, but if I did

12:12 i'd use some sort of log4j wrapper

12:12 first thing I found: https://github.com/clojure/tools.logging

12:13 which works with log4j

12:13 ilevd: It's the same

12:14 So it's the answer

12:16 ,(doseq [x (keep-indexed #(str (inc %1) ". " %2 ", ") (shuffle ["Vim" "Emacs" "Coursive" "LT" "Nightcode"]))] (print x))

12:16 clojurebot: 1. Nightcode, 2. Emacs, 3. LT, 4. Coursive, 5. Vim,

12:16 ilevd: ClojureBot, you are wrong

12:16 rcassidy: Lol

12:17 MJB47: the bot hasth spoken

12:20 ridcully_: five points for vim! whoopdidoo

12:40 sdegutis: ,(sort [nil 1])

12:40 Why?

12:40 clojurebot: (nil 1)

12:40 because that's not how macros work

12:40 sdegutis: ,(sort ["1" 1])

12:40 clojurebot: #error {\n :cause "java.lang.String cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to java.lang.Number"\n :at [clojure.lang.Util compare "Util.java" 152]}]\n :trace\n [[clojure.lang.Util compare "Util.java" 152]\n [clojure.core$compare invokeStatic "core.clj" 821]\n [clojure.core$compare invoke "core.clj" 812]\n ...

12:58 tavoris: ,(str "is this how clojurebot works?")

12:58 clojurebot: "is this how clojurebot works?"

12:59 parsecChar: I'm writing a "strict Haskell" -> JS compiler. Initially, I was targetting JS. But then I realized: I have to deal with persistent data structures, tail call optimization, + not having "everything is an expression." I'm now considering targeting "strict Haskell" ->CLJS, and using cljs for cljs -> js.

12:59 Are there any things I should keep in mind concerning cljs (or a different suggested target language?)

13:02 justin_smith: parsecChar: you should check out elm, elm is pretty awesome and it targets js

13:02 and is very haskell-like

13:02 parsecChar: yeah, but it lacks things like typeclasses

13:02 I'm currently compiling from GHC/Core

13:02 ridcully_: the idea that some haskell code gets transpiled to clojure would give some ppl a heart attack?

13:02 parsecChar: i.e. you can write literla Haskell code, type check it with ghc, and then get a strictly interpreted it as js

13:03 justin_smith: oh, OK

13:03 parsecChar: if you take haskell and strip out types, you basically have cllojure left over

13:03 justin_smith: depends if you count "strict tracking of side-effects" as a subset of types

13:04 because we don't track side effects for the most part

13:04 parsecChar: justin_smith: yeah, but my original code is in haskell

13:04 so haskell enforces the 'no side effect,s except in monads'

13:05 then the 'pure' code gets compiled to cljs

13:05 what's the quickest way to get started with clojure on ubuntu

13:05 I haven't used clojure in years

13:05 justin_smith: parsecChar: all you need is the leiningen script and a jvm newer than 1.5

13:06 an editor that doesn't suck is a nice to have, but those are strictly sufficient

13:06 parsecChar: do I use openjdk or the sun/oracle licensed one?

13:06 justin_smith: doesn't matter

13:06 newer than 1.5 is enough

13:08 parsecChar: got openjdk 8

13:08 got lein script

13:09 got lein-2.6.1-stanealone.jar

13:09 justin_smith: well the lein script takes care of that

13:09 parsecChar: yeah, running ./lein did the weget

13:09 justin_smith: right, right

13:09 parsecChar: reading https://github.com/clojure/clojurescript/wiki/Quick-Start

13:09 justin_smith: then you can use lein new, or use lein to run an existing cloned project, or whatever

13:09 parsecChar: but is ther a way to pull cljs with lein instead ?

13:11 justin_smith: parsecChar: that comes later in the Quick-Start

13:11 I'm actually a fan of how the Quick-Start starts with no tooling before introducing the magic

13:12 parsecChar: I've used lein before

13:12 I'm familiar with clojure/clojurecript, just not ofr the past 2-3 years

13:13 https://github.com/swannodette/mies I like more

13:13 full of magic

13:13 jumps me right into what I need

13:14 justin_smith: I like that the Quick-Start starts without lein not because there's any problem with lein, but because I think it's good to know how each part works (and is liable to break) before jumping into the thing that abstracts all of them. If every lein plugin were a reliable abstraction I would revisit that opinion, but as it is you might as well learn because the abstraction is going to break.

13:15 parsecChar: wait until I have to write job postings for hiring people

13:15 looking for people .. who knows Haskell ... and clojure .... and okay with using our custom in house Haskell -> CLJS compiler

13:15 justin_smith: haha

13:16 ridcully_: having a heartackack ;)

13:16 justin_smith: "hey, that's me! (kinda)"

13:16 zerokarmaleft: parsecChar: what about purescript?

13:16 parsecChar: I almost used purescript

13:17 but I found the tooling to be lacking compared to haskell

13:17 i.e. ghci / reload, vim-haskell-now

13:18 zerokarmaleft: `pulp psci` gives a decent repl reloaded experience

13:18 parsecChar: I found it very slow

13:18 zerokarmaleft: but I agree, haskell tooling is much further along

13:18 parsecChar: to the point where I liked ghcjs/haste more

13:23 justin_smith: ,(def seqseq (comp not-empty (partial keep not-empty)))

13:23 clojurebot: #'sandbox/seqseq

13:23 justin_smith: ,(seqseq [nil nil ""])

13:23 clojurebot: nil

13:23 justin_smith: ,(seqseq [nil nil "" :a])

13:23 clojurebot: #error {\n :cause "Don't know how to create ISeq from: clojure.lang.Keyword"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.lang.Keyword"\n :at [clojure.lang.RT seqFrom "RT.java" 542]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 542]\n [clojure.lang.RT seq "RT.java" 523]\n [clojure.core$seq__4357 invokeStatic "core.clj" 137]\n ...

13:23 justin_smith: ergh

13:23 ,(seqseq [nil nil "" [:a]])

13:23 clojurebot: ([:a])

13:28 ben_vulpes: most of the jdbc functions take a db spec, how would i best programatically /create/ a database in postgres from jdbc?

13:29 if shelling out to say psql is the thing to do, i can also do that i suppose but i'd rather not

13:29 ridcully_: there is a slight chance you simply can. if you have no "dba" user to create one in the first place, you simply can't

13:33 ben_vulpes: (jdbc/do-commands "postgresql://wherever:port/new-db" "create database new-db") doesn't seem like it'd work, as new-db wouldn't exist...

13:33 * ben_vulpes off to try

13:33 ben_vulpes: mnope

13:34 justin_smith: wouldn't you have to do that with postgres as your db?

13:35 ben_vulpes: justin_smith: huh

13:35 justin_smith: ben_vulpes: to run that command, I would run "psql postgres" first, to start with the postgres db opened

13:35 ridcully_: you can not connect to X to create database X

13:36 justin_smith: right, so you connect to the db called "postgres" if you have the perms to create a db

13:37 ben_vulpes: gotcha

13:37 ridcully_: myeah, suspected and confirmed.

13:41 freakcoder: some one use clojure to do statistical work? has some advantage to use it instead R?

13:43 justin_smith: freakcoder: for the small amount I've played with statistical stuff (our app does some statistical stuff, but I am not stats expert), clojure is much better than R performance wise, but the features are not nearly as friendly, even with the dedicated stats libraries.

13:45 freakcoder: I get it, maybe R is not a viable solution for production

13:45 justin_smith: freakcoder: for us, definitely not

13:46 but it's much easier for the "see what we can do with data" exploratory stage

13:46 even if it's not what backs the production api endpoint

13:47 freakcoder: but for research I think clojure can't beat it up yet

13:48 justin_smith: freakcoder: not until some stats genius implements a huge library in clj :)

13:55 ridcully_: i cargoculted both ggplot2 and c3 in cljs... and i am not the wiser

13:59 kwladyka: Do you use Clojure .NET? How is it work in practice?

14:00 justin_smith: kwladyka: it is not as extensively supported, but last I played with it it just worked

14:02 kwladyka: justin_smith Is it possible to write integration for apps in .NET in clear Java (Clokure) without .NET? For example ERP systems? I am not sure how is it work.

14:03 i know it is not clear Clojure qestion, but maybe you know :)

14:03 justin_smith: kwladyka: I have no idea, I used clj-clr without java at all, using clr to compile the code and generating clr output

14:03 unlike cljs, clj-clr doesn't use java for compiling

14:04 kwladyka: justin_smith true. Just i want to know if i want write integration for app workking on .NET i have to use .NET or i don't have to....

14:05 justin_smith: I think if you want something your .NET stuff can load as a library, you need to use the clj-clr compiler, the clojure compiler won't help

14:05 unless there is a bridge from clr to jvm I don't know about

14:06 kwladyka: justin_smith yeah it is not easy knowledge to get when i don't have any idea about .NET :)

14:07 hmm but i know one person who maybe know the answer...

15:08 Ok i know the answer: it is possible, but not worth if i want use complex API, because problems will appear.

15:08 So i will try Clojure .NET directly

16:34 X-warrior: TimMc, I changed that code, using destructuring, changing use for require with :as, fixing indentation (using 2 spaces)

16:34 :D

16:35 TimMc: great!

16:41 X-warrior: TimMc, could u take a final look? to check if I miss any of your points?

16:41 sorry if i'm being too baggy

16:46 TimMc: Busy now, sorry.

16:47 justin_smith: timvisher: does :main nil work?

17:26 ben_vulpes: how do i get exceptions thrown as a result of poking a ring app from, say, curl, to show up in cider?

17:28 justin_smith: I think you'd need a custom exception logging middleware. Also, have you checked the process buffer? I've mentioned the fact that many messages end up in the process buffer instead of the repl and bbatsov said this wasn't a bug, it was expected.

17:28 ben_vulpes: yeah, i've been checking the repl_server buffer

17:29 justin_smith: are you using jack-in or connect?

17:30 ben_vulpes: wrap-stacktrace is what i want, i believe.

17:30 justin_smith: jack-in

17:31 justin_smith: if you are fine with checking the process buffer, wrap-stacktrace should suffice yeah

17:40 ben_vulpes: hrm, wrap-stacktrace doesn't seem to be doing what i want either.

17:41 justin_smith: ben_vulpes: all you really need is a middleware that wraps all your other middleware and the handler, and prints stack traces to the right value for *out*, right?

17:41 that sounds like 3 lines of code to me (maybe with the addition of something that lets you manually mutate it's value of *out*)

17:41 ben_vulpes: myup

18:41 devn: Is it alright if I define defrecords inside of a toplevel defonce?

18:42 ,(defonce records (doseq [[name arglist] '{Foo [a b c] Bar [d e f]}] (eval `(defrecord ~name ~arglist))))

18:42 clojurebot: #'sandbox/records

18:43 devn: records

18:43 ,records

18:43 clojurebot: nil

18:43 devn: (Foo. 1 2 3)

18:43 ,(Foo. 1 2 3)

18:43 clojurebot: #sandbox.Foo{:a 1, :b 2, :c 3}

18:43 devn: ,(Bar. 1 2 3)

18:43 clojurebot: #sandbox.Bar{:d 1, :e 2, :f 3}

18:43 devn: heh, actually I'm kind of surprised that worked, what with the `eval` and all...

18:44 ,(eval `(+ 1 1))

18:44 clojurebot: 2

18:44 devn: ,(eval `(in-ns 'user))

18:44 clojurebot: #object[clojure.lang.Namespace 0x63bb17e9 "sandbox/user"]

18:44 devn: ,*ns*

18:44 clojurebot: #object[clojure.lang.Namespace 0x3d3d38b4 "sandbox"]

18:45 devn: anyway... anyone have any thoughts on the best way to go about defining a bunch of records? Is this the best way to do this?

19:15 X-warrior: TimMc, relax, sorry for the late response had to solve some problems here too :D

19:15 have a nice weekend :D

19:40 amalloy: why do you want to use defonce, devn?

20:33 TimMc: X-warrior: Glad I could help!

22:20 sdegutis: ,(re-seq #"[(\d\.)(?:,)]+" "$1,020.42")

22:20 I'm confused.

22:20 clojurebot: ("1,020.42")

22:25 sdegutis: Oh this is fun. Check this out.

22:25 ,(int (* 100 (Float. 20.32)))

22:25 clojurebot: 2031

22:26 amalloy: sdegutis: you know parens aren't metacharacters inside a character class?

22:26 sdegutis: amalloy: I do now.

22:28 amalloy: speaking of character classes, /[][]/ is a regex that perl accepts but java doesn't (it should, as far as i can understand PCRE)

22:28 devn: amalloy: I was worried that re-evaluating might be a problem. I seem to recall a problem with defining records inside of function definitions

22:29 If I had a function (defn make-records [] (doseq [[rec-name arglist] '{A [b] C [d]}] (eval `(defrecord ~rec-name ~arglist)))) which I called more than once, would I run into trouble?

22:33 amalloy: do you really want to redefine your records at runtime?

22:33 (correct answer: no)

22:36 TEttinger: ,(re-seq #"(?:(\d\.)|(?:,))+" "$1,020.42")

22:36 clojurebot: (["," nil] ["0." "0."])

22:37 TEttinger: ugh

22:45 devn: amalloy: so, could you help me out here then?

22:46 what is the right way to do this sort of thing?

22:46 amalloy: if you just want to define a bunch of related records, you can write a macro to do it (although it's a bit weird to define a bunch of related records to begin with)

22:47 if you want to do any of the other stuff you've been talking about, you probably shouldn't, but it's hard to be sure since you're talking about techniques instead of goals

22:49 devn: amalloy: i have a lot of record types, and they are born from a lot of different sources. I have a map which contains the desired name of the record, with the set of fields it needs to be defined with

22:49 amalloy: why do you have a lot of record types?

22:49 devn: rules engine

22:50 amalloy: what does that have to do with anything? why can't these just be maps?

22:50 TEttinger: sdegutis:

22:50 ,(apply str (remove nil? (map second (re-seq #"(?:([\d\.])|(?:,))+?" "$1,020.42"))))

22:50 clojurebot: "1020.42"

22:50 sdegutis: Thanks!

22:50 That's similar to what I ended up with.

22:50 TEttinger: cool!

22:51 sdegutis: Okay, our cart looks way better now. Woo!

22:51 TEttinger: it's a weird thing that I can't think of a straightforward way to do it with just regexes

22:51 devn: amalloy: I _can_ use maps with clara, but my understanding (and please forgive me, but i must admit I have not measured this yet) is that maps will wind up being considerably slower

22:51 amalloy: if you haven't measured, use maps

22:52 you can always replace them later, without breaking any kind of api compatibility

22:52 devn: heh, well that's sort of the thing

22:52 it's sort of the other way around

22:52 there are many records that already exist

22:52 i am into the idea of switching to maps, but it will require a lot of rework

22:56 TimMc: TEttinger: Whoa, didn't know you could use \d inside a character class...

22:56 TEttinger: heh, neat trick :D

22:56 wait wait it gets better!

22:57 TimMc: ooh, you can nest character classes, got it

22:57 TEttinger: ,(re-seq #"\PN" "$1,020.42")

22:57 clojurebot: ("$" "," ".")

22:58 TEttinger: ,(re-seq #"[\Pn\.]" "$1,020.42")

22:58 clojurebot: #<NoClassDefFoundError java.lang.NoClassDefFoundError: Could not initialize class java.util.regex.PatternSyntaxException>

22:58 TEttinger: wha

22:58 ,(re-seq #"[\PN\.]" "$1,020.42")

22:58 clojurebot: ("$" "," ".")

22:58 TEttinger: ,(re-seq #"[\pN\.]" "$1,020.42")

22:58 clojurebot: ("1" "0" "2" "0" "." ...)

22:58 TEttinger: gah

22:58 that last one does it

22:58 sorry about the spam

23:00 \pN is usually just a fancy version of \d

23:00 but it also matches things like circled numbers

23:00 TimMc: Yeah, that earlier expression could at *least* be reduced to #"[\d\.,]+", pretty sure

23:01 TEttinger: no

23:01 it needed to not match commas

23:01 devn: amalloy: so, you mentioned wrapping it with a macro. what are you suggesting?

23:02 TimMc: TEttinger: I see, only the [\d\.] was captured.

23:02 then why even mention commas?

23:03 ,(apply str (remove nil? (map second (re-seq #"(?:([\d\.]))+?" "$1,020.42"))))

23:03 clojurebot: "1020.42"

23:03 TEttinger: good point, TimMc

23:03 ,(clojure.string/replace "$1,0໕0.42" #"\p{Nd}" #(Integer/parseInt % 10))

23:03 clojurebot: #error {\n :cause "java.lang.Integer cannot be cast to java.lang.String"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Integer cannot be cast to java.lang.String"\n :at [clojure.string$replace_by invokeStatic "string.clj" 69]}]\n :trace\n [[clojure.string$replace_by invokeStatic "string.clj" 69]\n [clojure.string$replace invokeStatic "string.clj" 106]\n [clojure.string$...

23:04 TEttinger: aw

23:04 TimMc: ,(apply str (re-seq #"[\d\.]+" "$1,020.42"))

23:04 clojurebot: "1020.42"

23:04 TEttinger: ,(clojure.string/replace "$1,0໕0.42" #"\p{Nd}" #(str (Integer/parseInt % 10)))

23:04 clojurebot: "$1,050.42"

23:04 TEttinger: that's the Lao digit 5 in there

23:04 TimMc: I usually use Devanagari. :-)

23:05 devn: amalloy: does it make any difference if I told you that all of these record definitions are of the form: (defrecord A [a b c]) with nothing else to them?

23:05 amalloy: ,(.parse (java.text.NumberFormat/getCurrencyInstance) "$1,0໕0.42")

23:05 clojurebot: 1050.42

23:05 TEttinger: ,(clojure.string/replace "$६६६,0໕0.42" #"\p{Nd}" #(str (Integer/parseInt % 10)))

23:05 clojurebot: "$666,050.42"

23:05 TEttinger: nice amalloy

23:05 TimMc: heh

23:05 amalloy: i didn't actually notice the absurd 5 character

23:05 TEttinger: ha wow

23:05 TimMc: "absurd"

23:05 amalloy: the point is just that regexes are the wrong tool for parsing currency

23:06 TEttinger: you showed that well, yep

23:06 amalloy: they work fine, but...

23:06 the currency parser understands locales, too, so you can read euros or whatever

23:07 TEttinger: amalloy: it's only absurd until you go down the river to find technomancy and find he's started a jungle cult of Racket in Laos

23:07 TimMc: or handle commas vs. periods

23:08 TEttinger: "Java 9 has been delayed to 2017? the horror... the horror..."

23:18 devn: heh, no dice eh?

23:19 Is it as simple as wrapping a doseq in a defmacro, and dropping `(defrecord ~name ~arglist) in there?

23:21 err, with an eval wrapper, that is

Logging service provided by n01se.net