#clojure logs

2016-03-11

00:13jrajavAnyone used Clojure with Google App Engine before?
00:34hiredmanyes, a long time ago, at the time it worked sort of fine, these was (is?) a lein plugin
00:55matsuwhat's the best way to check if all values of a map are empty/nil?
00:55matsuso { :foo {} :bar nil } would be considered empty
00:59matsuusing `vals` would work, but only on top level keys
01:27rhg135(every? ... (vals m))
01:32matsuThat would work only on the top level keys of m, right?
02:09renlhi can i do the following (def a :a) (def b {:a 1 :b 2}) (b a) works but (b (symbol "a")) doesnt
02:11renlgot disconnected not sure if my previous question went through re-posting it
02:11renlhi can i do the following (def a :a) (def b {:a 1 :b 2}) (b a) works but (b (symbol "a")) doesnt
02:13ridcully_,(symbol "a")
02:14clojurebota
02:14ridcully_,(keyword "a")
02:14clojurebot:a
02:14ridcully_ah didnt saw the first def... ignore me
02:15renlah ok
02:19ridcully_something like: (b @(resolve (symbol "a"))) maybe?
02:19renloh yeah
02:21renlwell 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
02:26ridcully_isnt that just Color/CORAL ?
02:27ridcully_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?
02:34ridcully_,(import java.util.Locale)
02:34clojurebotjava.util.Locale
02:34ridcully_,(.get (.getField Locale "ENGLISH") nil)
02:34clojurebot#object[java.util.Locale 0x4be25710 "en"]
02:34ridcully_,(.get (.getField Locale "BOOOM") nil)
02:34clojurebot#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....
02:49faxmodemhow do I change the log level in repl? is there a global way to do that?
03:05AndreasOCanvas listener mouseentered seesaw, how the hell??
03:09ilevd(+ 1 1)
03:09clojurebot2
03:09ilevdOho
03:11ilevd(dotimes [i 10] (prn (str "Hello " i)))
03:15AndreasOHow do I put an event listener on a canvas in seesaw?
03:55TEttingerilevd: use ,() with the comma to eval, clojurebot sometimes evals random code-like messages for fun
03:56TEttinger,(dotimes [i 10] (print "Hello" i))
03:56clojurebotHello 0Hello 1Hello 2Hello 3Hello 4Hello 5Hello 6Hello 7Hello 8Hello 9
04:19krl,(empty? [])
04:19clojurebottrue
04:27CStormwhen i just want a simple form method on my new compjure project i run into csrf-token problems
04:28CStormdo 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
04:29mavbozoCStorm, yes. if you use default compojure setup, you have to take into account csrf protection
04:31CStormi have the following:
04:31CStormhttp://pastebin.com/FyYQ7dbT
04:31CStormthe 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
04:32CStormwhere i input something in the form, and send and it automatically handles the token.
04:34CStormi 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.
04:35clgvcfleming: ping
04:36TEttingerI would also ping cfleming
04:36clgv:P
04:37mavbozoCStorm, you can put <input type='hidden' name='__anti-forgery-token' value='*anti-forgery-token*'/> inside your <form>
04:37clgvcfleming: 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?
04:37CStormlet me try that mavbozo, thanks for helping me out
04:38TEttingerclgv, I've been hoping to be online when cfleming is for weeks now
04:38clgvTEttinger: oh ok, so he isnt around here as frequent as in the past...
04:38mavbozoCStorm, try that using browser first
04:39clgv$seen cfleming
04:39TEttingermaybe just time
04:39TEttingerno lazybot
04:39clgv:(
04:39clgv;(
04:39TEttinger:( indeed
04:39hyPiRionlazybot has been dead for a long time =|
04:39clgvwhat happened?
04:39TEttingerit doesn't have reconnect code
04:39TEttingerso during stuff like DDoS hellstorms, it has no hope of staying online
04:40clgvwell that could be fixed easily, right?
04:40TEttingerindeed, I've hacked a fix into my lazybot that uses crappy windows stuff
04:40clgvwhy windows?
04:40clgv,(inc 1)
04:40clojurebot2
04:40clgvbut clojurebot is a tougher guy? :P
04:41TEttinger(basically relaunches the app from the command line when there hasn't been a message in a while)
04:41TEttinger(including ping)
04:42CStormhm, mavbozo still gives me "Invalid anti-forgery token"
04:43TEttingermaybe you need to forge an anti-forgery token in the smithing forge
04:43CStormhaha
04:46hyPiRionCStorm: I have no idea what mavbozo is, but I've seen that error message related to https://github.com/ring-clojure/ring-anti-forgery
04:46mavbozomavbozo, that's harsh
04:47CStormi have ring-anti-forgery added
04:47CStormand basicly the whole project is this: http://pastebin.com/JNN2DQc6
04:47CStormbut this still gives me invalid token
04:48hyPiRionmavbozo: 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
04:48mavbozoCStorm, add another route (GET "/csrf-token" [] (generate-string {:csrf-token *anti-forgery-token*}))
04:48CStormyes?
04:48mavbozoand then check "/" source in the browserand "/csrf-token"
04:49CStormok
04:49mavbozosee if anti-forgery token in both pages are the same
04:49mavbozohyPiRion, :)
04:50clgvTEttinger: you can only forge those in Mount Doom ;)
04:51CStormmavbozo: seems like its not added to the request header, and i get a token when i visit csrf-token as expected
04:51CStormthe request headers for / looks like this:
04:52CStormhttps://usercontent.irccloud-cdn.com/file/mMLO3Mva/Screen%20Shot%202016-03-11%20at%2010.51.32.png
04:56mavbozoCStorm, what's the return body of /csrf-token ?
04:56CStorm{"csrf-token":"yACvl/Y5lytBFK/VIPa29pVsxsLXhrbDcbSuaCTSXQLknlHQWuFyvtcca9lhrN9uxkOv5Q8Vc4CQEEli"}
04:58mavbozoCStorm, something's wrong with your form string in "/" route. try this one https://www.refheap.com/115804
04:58CStormwill try that, hang on
04:59mavbozowhen 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
05:00CStormnow its the same!
05:00CStormhang on ill try to see if it works.
05:01CStormnow it works, mavbozo.
05:02mavbozoCStorm, great! :)
05:02CStormphew, thanks for taking your time.
05:02CStormreally appreciate it
05:04mavbozoCStorm, you're welcome
05:04CStormand happy friday :)
05:45lizzinhow can this error output be used to debug the issue? https://gist.github.com/anonymous/fc2a30d7a5e9d8b9bfb1
05:54ridcully_,("bang")
05:54clojurebot#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...
05:56mavbozo,(_
05:56clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
05:58TEttingerlizzin: if ridcully_'s example isn't clear enough, somewhere you have a string where a fn should be.
05:58TEttinger(or macro)
05:58TEttinger,(:keyword {:keyword 1})
05:58clojurebot1
05:58TEttingerthat works
05:58TEttinger,("word" {"word" 1})
05:58clojurebot#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...
05:59TEttingerdoesn't
06:00lizzinridcully_ TEttinger got it. thanks
06:01TEttingercool
06:02lizzinwhich http client shoudl i use? http-kit?
06:03TEttingerno idea what's the best
06:03TEttingerstick around and someone may come online soon-ish
06:03TEttinger6 AM east coast time
06:03lizzinok
06:04lizzini should be sleeping myself
06:04ridcully_lizzin: i use clj-http for fooling around with apis all the time
06:04lizzin<-- east coaster
06:04TEttingerwoo ridcully_ to the rescue
06:04MJB47i use http-kit client a fair bit
06:04MJB47mostly because it has good support for websockets as well
06:05MJB47which comes in handy sometimes
06:05MJB47never had a problem with it
06:05TEttingeryay http people... I'm so drowsy
06:05TEttingeryer the best #clojure
06:06lizzinif 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?
06:06ridcully_i'd assume that http-kit might make the better component for a library or within your application
06:06ridcully_clj-http is dead simple for the repl
06:08ridcully_and aleph also has a client, right? or is it just using something else?
06:09lizzinhttps://gist.github.com/anonymous/1bdb195f4128328159b9
06:14mavbozoaleph also has http client
06:31mavbozolizzin, write method on wrtr object can not accept string
06:36mavbozolizzin, i assume (:body @resp) return string
06:37lizzinmavbozo: i thought i had taken care of this with the '{:as stream}'
06:43mavbozolizzin, sorry, I misread. Yeah, {:as :stream} returns the :body from response as java.io.InputStream but wrtr.write only accepts byte[] or byte
06:43ilevd,(doseq [i ["nice", "cool", "beatiful"]] (print "Clojure is " i "! "))
06:43clojurebotClojure is nice ! Clojure is cool ! Clojure is beatiful !
06:48lizzinmavbozo: where is that mentioned? im not seeing it here: https://clojuredocs.org/clojure.java.io/output-stream
06:49lizzini believe you, just wondering which docs i should be reading
06:52mavbozoio/output-stream returns java.io.BufferedOutputStream http://docs.oracle.com/javase/7/docs/api/java/io/BufferedOutputStream.html
06:52lizzinyep, just stumbled on that
06:52lizzinthanks
06:53lizzinalso, changing stream to 'byte-array' fixed things as expected
06:53lizzinmavbozo: happen to know of any good docs that cover the diff between byte stream and byte arrays?
06:54ilevd(map [i "Clojure"] (str (repeat (rand-int 10) i)))
06:54ilevd,(map [i "Clojure"] (str (repeat (rand-int 10) i)))
06:54clojurebot#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 ...
06:55ilevd,(map #(str (repeat (rand-int 10) %)) "Clojure)
06:55clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
06:55ilevd,(map #(str (repeat (rand-int 10) %)) "Clojure")
06:55clojurebot("(\\C \\C \\C)" "(\\l \\l)" "(\\o \\o \\o \\o \\o)" "(\\j \\j \\j \\j)" "(\\u \\u \\u \\u \\u ...)" ...)
06:56ilevd,(str (mapcat (map #(str (repeat (rand-int 10) %)) "Clojure")))
06:56clojurebot"clojure.core$comp$fn__4727@3647b6c6"
06:58mavbozolizzin, i haven't found any. for dealing with bytes in clojure, I usually use ztellman/byte-streams library
06:59prohobodamn clojure, you scary
06:59lizzinoh nice, i will check that out
07:13ilevd,(map #(concat (repeat (rand-int 10) %)) "Clojure")
07:13clojurebot((\C \C) (\l \l \l \l \l ...) (\o \o \o \o \o ...) (\j \j \j \j) (\u \u \u \u) ...)
07:14ilevd,(concat (map #(concat (repeat (rand-int 10) %)) "Clojure"))
07:14clojurebot((\C \C \C \C \C ...) (\l \l \l \l \l ...) (\o) (\j \j \j \j \j ...) (\u \u \u \u \u ...) ...)
07:15ilevd,(reduce conj "" (map #(concat (repeat (rand-int 10) %)) "Clojure"))
07:15clojurebot#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...
07:16ilevd,(repeat 10 \c)
07:16clojurebot(\c \c \c \c \c ...)
07:17ilevd,(str (repeat 10 \c))
07:17clojurebot"(\\c \\c \\c \\c \\c ...)"
07:17ilevd,(.toString (repeat 10 \c))
07:17clojurebot"(\\c \\c \\c \\c \\c ...)"
07:18ilevd,(.String (repeat 10 \c))
07:18clojurebot#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...
07:18ilevd,(String. (repeat 10 \c))
07:18clojurebot#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...
07:18ilevd,(apply str (repeat 10 \c))
07:18clojurebot"cccccccccc"
07:19ilevd,(map #(apply str (repeat (rand-int 10) %)) "Clojure")
07:19clojurebot("CCCCCCCC" "llllll" "o" "" "uu" ...)
07:20ilevd,(apply str (map #(apply str (repeat (rand-int 10) %)) "Clojure"))
07:20clojurebot"CCClloojjuu"
07:21ilevd=(
07:21ridcully_what are you after?
07:21TMA,(apply str (map #(apply str (repeat (inc (rand-int 10)) %)) "Clojure"))
07:21clojurebot"CCCClllllooojjjjuuuuuureeeeee"
07:21ilevd! :)
07:21ridcully_,(apply str (mapcat #(repeat (rand-int 10) %) "Clojure"))
07:21clojurebot"CCCCCCCoooooooojjjjjuuurrrrreeeee"
07:22TMAilevd: rand-int returns zero at times
07:22ilevdHeh
08:52ilevd(apply interleave "Clojure" "Clojure")
08:52ilevd,(apply interleave "Clojure" "Clojure")
08:52clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Character>
08:53ilevd,(interleave "Clojure" "Clojure")
08:53clojurebot(\C \C \l \l \o ...)
08:53ilevd,(apply interleave (repeat 10 "Clojure"))
08:53clojurebot(\C \C \C \C \C ...)
08:53ilevd,(apply str (apply interleave (repeat 10 "Clojure")))
08:53clojurebot"CCCCCCCCCClllllllllloooooooooojjjjjjjjjjuuuuuuuuuurrrrrrrrrreeeeeeeeee"
08:54ilevd,(apply str (apply interleave (repeat 10 "Clojure"))) -> print
08:54clojurebot"CCCCCCCCCClllllllllloooooooooojjjjjjjjjjuuuuuuuuuurrrrrrrrrreeeeeeeeee"
08:56ilevd,(print "Hi")
08:56clojurebotHi
08:56ilevd,(print (apply str (apply interleave (repeat 10 "Clojure"))))
08:56clojurebotCCCCCCCCCClllllllllloooooooooojjjjjjjjjjuuuuuuuuuurrrrrrrrrreeeeeeeeee
08:56stainOh my
08:57stainI thought this was a SMILES string for a very long organic molecule!
08:57stain(too much chemistry)
08:57TimMcilevd: At this point you might try /msg clojurebot and play with it there.
08:57TimMcor I guess /query clojurebot
08:58ilevdYeah, he is a good interlocutor
09:07ridcully_if only i could remember the syntax to teach clojurebot facts
09:36X-warriorhey 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
09:41TimMcX-warrior: I only have time for a quick glance... but the indentation is pretty wild, what are you using for an editor?
09:41MJB47X-warrior: your indentation is pretty funky, and im not sure if thats the way i would do the node stuff
09:41MJB47but otherwise it looks fine
09:41TimMc~use
09:41clojurebotOnly use :use with :only.
09:41X-warriorTimMc: sublime
09:42xemdetiayeah that indent is all over the place :(
09:42TimMcSee if it has a clojure formatting mode or plugin or something.
09:42TimMcX-warrior: Also you'll want to use :use *very* sparingly.
09:43TimMcThose (use ...) blocks should be requires (with :as) and should be moved up into the ns block.
09:43MJB47sublime does
09:43MJB47i used to use it
09:43MJB47its acceptable
09:43MJB47X-warrior: https://github.com/bbatsov/clojure-style-guide#source-code-layout--organization
09:43MJB47this might be useful
09:44TimMcFor 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.
09:45X-warriorTimMc: so it would be better to use the namespace instead of :refs :all so I would need to specify tree/tree
09:46X-warriorMJB47: I will take a look
09:46X-warriorMJB47: did you use any plugin with sublime? or just regular sublime?
09:46MJB47i used a few things
09:46MJB47let me see if i can find
09:47MJB47hmm, seems i actually on used LispIndent
09:47MJB47and sublimeREPL (which tbh is quite bad)
09:48TimMcX-warrior: That's right, (:require [clojure.java.io :as io]) and then you can do io/reader
09:49TimMcIf 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.
09:49TimMcX-warrior: The two let blocks in parse-line can be combined into one, since let evaluates and binds sequentially.
09:50TimMcYou could even do (let [[customer invited] (str/split line #" ")] ...) -- destructuring is great
09:59X-warriorTimMc: what do you mean by destructuring? using a single line? x)
10:00X-warriorMJB47: thanks! I will take a look at lispindent
10:03TimMcX-warrior: Destructuring is a syntax for taking apart data structures: http://clojure.org/reference/special_forms#binding-forms
10:03TimMcso you don't have to say first, second
10:05ridcully_,(let [[a b] [1 2]] (println a b))
10:05X-warriorOh, now I see it
10:05clojurebot1 2\n
10:09X-warriorI should change my indentation to two spaces too
10:10X-warriorgoing to eat, 5 minutes, thanks TimMc
10:12timvisheris it possible to create an uberjar without a main class?
10:12timvishervia lein
10:13justin_smithtimvisher: sure, but you could just make clojure.main your main class too
10:15timvisherjustin_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:15justin_smithtimvisher: 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:15timvisherapparently hadoop runs the main if it exists
10:16justin_smiththat's so dumb
10:16timvisherwhich is 1000% :)
10:16timvisheri mean in theory i could edit the jar afterwards
10:17timvisheri'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:20TimMctimvisher: It's the manifest.mf, I think...
10:21TimMcTry :main nil and see what happens.
10:21timvisherTimMc: yeah that's what hyPiRion is suggesting
10:22TimMcWorst case you can write a script to extract the manifest, filter it with grep, and put it back in.
10:24timvisherTimMc: right. not a huge deal
10:24timvisherthe class file can stay in there too as long as the manifest isn't pointing to it
10:26hyPiRionIt's annoying to do it manually though
11:26ilevdAsk, please
11:28cortexma`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:29ilevdI don't know I use light table
11:32ilevd,(str "Emacs or Light Table? Of course " (rand-nth ["Emacs" "Light Table"]) "!")
11:32clojurebot"Emacs or Light Table? Of course Light Table!"
11:32ilevdYou see?
11:35mavbozo,(str "Emacs or Light Table? Of course " (rand-nth ["Emacs" "Light Table"]) "!") ;; Emacs please
11:35clojurebot"Emacs or Light Table? Of course Emacs!"
11:35mavbozoyeah!!
11:36ilevdXD
11:46ridcully_ ,(str "Emacs or Light Table? Of course " (rand-nth ["vim"]))
11:46clojurebot"Emacs or Light Table? Of course vim"
11:46ridcully_fix your odds
11:53OscarZhi.. what do you recommend for logging?
11:55ilevdI want to know an answer too. I usually use print
11:56justin_smith,((constantly "ed"))
11:57clojurebot"ed"
11:57OscarZyeah same.. i dont need anything fancy.. maybe log into a file and stdout
11:58ilevdI think maybe some wrapper around log4j
11:59OscarZhmm.. maybe ill try this: http://www.bahmanm.com/blogs/how-to-add-logging-to-a-clojure-project
12:11bacon1989i haven't used logging in any of my clojure projects, but if I did
12:12bacon1989i'd use some sort of log4j wrapper
12:12bacon1989first thing I found: https://github.com/clojure/tools.logging
12:13bacon1989which works with log4j
12:13ilevdIt's the same
12:14ilevdSo it's the answer
12:16ilevd,(doseq [x (keep-indexed #(str (inc %1) ". " %2 ", ") (shuffle ["Vim" "Emacs" "Coursive" "LT" "Nightcode"]))] (print x))
12:16clojurebot1. Nightcode, 2. Emacs, 3. LT, 4. Coursive, 5. Vim,
12:16ilevdClojureBot, you are wrong
12:16rcassidyLol
12:17MJB47the bot hasth spoken
12:20ridcully_five points for vim! whoopdidoo
12:40sdegutis,(sort [nil 1])
12:40sdegutisWhy?
12:40clojurebot(nil 1)
12:40clojurebotbecause that's not how macros work
12:40sdegutis,(sort ["1" 1])
12:40clojurebot#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:58tavoris,(str "is this how clojurebot works?")
12:58clojurebot"is this how clojurebot works?"
12:59parsecCharI'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:59parsecCharAre there any things I should keep in mind concerning cljs (or a different suggested target language?)
13:02justin_smithparsecChar: you should check out elm, elm is pretty awesome and it targets js
13:02justin_smithand is very haskell-like
13:02parsecCharyeah, but it lacks things like typeclasses
13:02parsecCharI'm currently compiling from GHC/Core
13:02ridcully_the idea that some haskell code gets transpiled to clojure would give some ppl a heart attack?
13:02parsecChari.e. you can write literla Haskell code, type check it with ghc, and then get a strictly interpreted it as js
13:03justin_smithoh, OK
13:03parsecCharif you take haskell and strip out types, you basically have cllojure left over
13:03justin_smithdepends if you count "strict tracking of side-effects" as a subset of types
13:04justin_smithbecause we don't track side effects for the most part
13:04parsecCharjustin_smith: yeah, but my original code is in haskell
13:04parsecCharso haskell enforces the 'no side effect,s except in monads'
13:05parsecCharthen the 'pure' code gets compiled to cljs
13:05parsecCharwhat's the quickest way to get started with clojure on ubuntu
13:05parsecCharI haven't used clojure in years
13:05justin_smithparsecChar: all you need is the leiningen script and a jvm newer than 1.5
13:06justin_smithan editor that doesn't suck is a nice to have, but those are strictly sufficient
13:06parsecChardo I use openjdk or the sun/oracle licensed one?
13:06justin_smithdoesn't matter
13:06justin_smithnewer than 1.5 is enough
13:08parsecChargot openjdk 8
13:08parsecChargot lein script
13:09parsecChargot lein-2.6.1-stanealone.jar
13:09justin_smithwell the lein script takes care of that
13:09parsecCharyeah, running ./lein did the weget
13:09justin_smithright, right
13:09parsecCharreading https://github.com/clojure/clojurescript/wiki/Quick-Start
13:09justin_smiththen you can use lein new, or use lein to run an existing cloned project, or whatever
13:09parsecCharbut is ther a way to pull cljs with lein instead ?
13:11justin_smithparsecChar: that comes later in the Quick-Start
13:11justin_smithI'm actually a fan of how the Quick-Start starts with no tooling before introducing the magic
13:12parsecCharI've used lein before
13:12parsecCharI'm familiar with clojure/clojurecript, just not ofr the past 2-3 years
13:13parsecCharhttps://github.com/swannodette/mies I like more
13:13parsecCharfull of magic
13:13parsecCharjumps me right into what I need
13:14justin_smithI 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:15parsecCharwait until I have to write job postings for hiring people
13:15parsecCharlooking for people .. who knows Haskell ... and clojure .... and okay with using our custom in house Haskell -> CLJS compiler
13:15justin_smithhaha
13:16ridcully_having a heartackack ;)
13:16justin_smith"hey, that's me! (kinda)"
13:16zerokarmaleftparsecChar: what about purescript?
13:16parsecCharI almost used purescript
13:17parsecCharbut I found the tooling to be lacking compared to haskell
13:17parsecChari.e. ghci / reload, vim-haskell-now
13:18zerokarmaleft`pulp psci` gives a decent repl reloaded experience
13:18parsecCharI found it very slow
13:18zerokarmaleftbut I agree, haskell tooling is much further along
13:18parsecCharto the point where I liked ghcjs/haste more
13:23justin_smith,(def seqseq (comp not-empty (partial keep not-empty)))
13:23clojurebot#'sandbox/seqseq
13:23justin_smith,(seqseq [nil nil ""])
13:23clojurebotnil
13:23justin_smith,(seqseq [nil nil "" :a])
13:23clojurebot#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:23justin_smithergh
13:23justin_smith,(seqseq [nil nil "" [:a]])
13:23clojurebot([:a])
13:28ben_vulpesmost of the jdbc functions take a db spec, how would i best programatically /create/ a database in postgres from jdbc?
13:29ben_vulpesif shelling out to say psql is the thing to do, i can also do that i suppose but i'd rather not
13:29ridcully_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:33ben_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:33ben_vulpesmnope
13:34justin_smithwouldn't you have to do that with postgres as your db?
13:35ben_vulpesjustin_smith: huh
13:35justin_smithben_vulpes: to run that command, I would run "psql postgres" first, to start with the postgres db opened
13:35ridcully_you can not connect to X to create database X
13:36justin_smithright, so you connect to the db called "postgres" if you have the perms to create a db
13:37ben_vulpesgotcha
13:37ben_vulpesridcully_: myeah, suspected and confirmed.
13:41freakcodersome one use clojure to do statistical work? has some advantage to use it instead R?
13:43justin_smithfreakcoder: 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:45freakcoderI get it, maybe R is not a viable solution for production
13:45justin_smithfreakcoder: for us, definitely not
13:46justin_smithbut it's much easier for the "see what we can do with data" exploratory stage
13:46justin_smitheven if it's not what backs the production api endpoint
13:47freakcoderbut for research I think clojure can't beat it up yet
13:48justin_smithfreakcoder: not until some stats genius implements a huge library in clj :)
13:55ridcully_i cargoculted both ggplot2 and c3 in cljs... and i am not the wiser
13:59kwladykaDo you use Clojure .NET? How is it work in practice?
14:00justin_smithkwladyka: it is not as extensively supported, but last I played with it it just worked
14:02kwladykajustin_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:03kwladykai know it is not clear Clojure qestion, but maybe you know :)
14:03justin_smithkwladyka: I have no idea, I used clj-clr without java at all, using clr to compile the code and generating clr output
14:03justin_smithunlike cljs, clj-clr doesn't use java for compiling
14:04kwladykajustin_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:05justin_smithI 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:05justin_smithunless there is a bridge from clr to jvm I don't know about
14:06kwladykajustin_smith yeah it is not easy knowledge to get when i don't have any idea about .NET :)
14:07kwladykahmm but i know one person who maybe know the answer...
15:08kwladykaOk i know the answer: it is possible, but not worth if i want use complex API, because problems will appear.
15:08kwladykaSo i will try Clojure .NET directly
16:34X-warriorTimMc, I changed that code, using destructuring, changing use for require with :as, fixing indentation (using 2 spaces)
16:34X-warrior:D
16:35TimMcgreat!
16:41X-warriorTimMc, could u take a final look? to check if I miss any of your points?
16:41X-warriorsorry if i'm being too baggy
16:46TimMcBusy now, sorry.
16:47justin_smithtimvisher: does :main nil work?
17:26ben_vulpeshow do i get exceptions thrown as a result of poking a ring app from, say, curl, to show up in cider?
17:28justin_smithI 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:28ben_vulpesyeah, i've been checking the repl_server buffer
17:29justin_smithare you using jack-in or connect?
17:30ben_vulpeswrap-stacktrace is what i want, i believe.
17:30ben_vulpesjustin_smith: jack-in
17:31justin_smithif you are fine with checking the process buffer, wrap-stacktrace should suffice yeah
17:40ben_vulpeshrm, wrap-stacktrace doesn't seem to be doing what i want either.
17:41justin_smithben_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:41justin_smiththat 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:41ben_vulpesmyup
18:41devnIs it alright if I define defrecords inside of a toplevel defonce?
18:42devn,(defonce records (doseq [[name arglist] '{Foo [a b c] Bar [d e f]}] (eval `(defrecord ~name ~arglist))))
18:42clojurebot#'sandbox/records
18:43devnrecords
18:43devn,records
18:43clojurebotnil
18:43devn(Foo. 1 2 3)
18:43devn,(Foo. 1 2 3)
18:43clojurebot#sandbox.Foo{:a 1, :b 2, :c 3}
18:43devn,(Bar. 1 2 3)
18:43clojurebot#sandbox.Bar{:d 1, :e 2, :f 3}
18:43devnheh, actually I'm kind of surprised that worked, what with the `eval` and all...
18:44devn,(eval `(+ 1 1))
18:44clojurebot2
18:44devn,(eval `(in-ns 'user))
18:44clojurebot#object[clojure.lang.Namespace 0x63bb17e9 "sandbox/user"]
18:44devn,*ns*
18:44clojurebot#object[clojure.lang.Namespace 0x3d3d38b4 "sandbox"]
18:45devnanyway... 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:15X-warriorTimMc, relax, sorry for the late response had to solve some problems here too :D
19:15X-warriorhave a nice weekend :D
19:40amalloywhy do you want to use defonce, devn?
20:33TimMcX-warrior: Glad I could help!
22:20sdegutis,(re-seq #"[(\d\.)(?:,)]+" "$1,020.42")
22:20sdegutisI'm confused.
22:20clojurebot("1,020.42")
22:25sdegutisOh this is fun. Check this out.
22:25sdegutis,(int (* 100 (Float. 20.32)))
22:25clojurebot2031
22:26amalloysdegutis: you know parens aren't metacharacters inside a character class?
22:26sdegutisamalloy: I do now.
22:28amalloyspeaking of character classes, /[][]/ is a regex that perl accepts but java doesn't (it should, as far as i can understand PCRE)
22:28devnamalloy: I was worried that re-evaluating might be a problem. I seem to recall a problem with defining records inside of function definitions
22:29devnIf 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:33amalloydo you really want to redefine your records at runtime?
22:33amalloy(correct answer: no)
22:36TEttinger,(re-seq #"(?:(\d\.)|(?:,))+" "$1,020.42")
22:36clojurebot(["," nil] ["0." "0."])
22:37TEttingerugh
22:45devnamalloy: so, could you help me out here then?
22:46devnwhat is the right way to do this sort of thing?
22:46amalloyif 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:47amalloyif 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:49devnamalloy: 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:49amalloywhy do you have a lot of record types?
22:49devnrules engine
22:50amalloywhat does that have to do with anything? why can't these just be maps?
22:50TEttingersdegutis:
22:50TEttinger,(apply str (remove nil? (map second (re-seq #"(?:([\d\.])|(?:,))+?" "$1,020.42"))))
22:50clojurebot"1020.42"
22:50sdegutisThanks!
22:50sdegutisThat's similar to what I ended up with.
22:50TEttingercool!
22:51sdegutisOkay, our cart looks way better now. Woo!
22:51TEttingerit's a weird thing that I can't think of a straightforward way to do it with just regexes
22:51devnamalloy: 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:51amalloyif you haven't measured, use maps
22:52amalloyyou can always replace them later, without breaking any kind of api compatibility
22:52devnheh, well that's sort of the thing
22:52devnit's sort of the other way around
22:52devnthere are many records that already exist
22:52devni am into the idea of switching to maps, but it will require a lot of rework
22:56TimMcTEttinger: Whoa, didn't know you could use \d inside a character class...
22:56TEttingerheh, neat trick :D
22:56TEttingerwait wait it gets better!
22:57TimMcooh, you can nest character classes, got it
22:57TEttinger,(re-seq #"\PN" "$1,020.42")
22:57clojurebot("$" "," ".")
22:58TEttinger,(re-seq #"[\Pn\.]" "$1,020.42")
22:58clojurebot#<NoClassDefFoundError java.lang.NoClassDefFoundError: Could not initialize class java.util.regex.PatternSyntaxException>
22:58TEttingerwha
22:58TEttinger,(re-seq #"[\PN\.]" "$1,020.42")
22:58clojurebot("$" "," ".")
22:58TEttinger,(re-seq #"[\pN\.]" "$1,020.42")
22:58clojurebot("1" "0" "2" "0" "." ...)
22:58TEttingergah
22:58TEttingerthat last one does it
22:58TEttingersorry about the spam
23:00TEttinger\pN is usually just a fancy version of \d
23:00TEttingerbut it also matches things like circled numbers
23:00TimMcYeah, that earlier expression could at *least* be reduced to #"[\d\.,]+", pretty sure
23:01TEttingerno
23:01TEttingerit needed to not match commas
23:01devnamalloy: so, you mentioned wrapping it with a macro. what are you suggesting?
23:02TimMcTEttinger: I see, only the [\d\.] was captured.
23:02TimMcthen why even mention commas?
23:03TimMc,(apply str (remove nil? (map second (re-seq #"(?:([\d\.]))+?" "$1,020.42"))))
23:03clojurebot"1020.42"
23:03TEttingergood point, TimMc
23:03TEttinger,(clojure.string/replace "$1,0໕0.42" #"\p{Nd}" #(Integer/parseInt % 10))
23:03clojurebot#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:04TEttingeraw
23:04TimMc,(apply str (re-seq #"[\d\.]+" "$1,020.42"))
23:04clojurebot"1020.42"
23:04TEttinger,(clojure.string/replace "$1,0໕0.42" #"\p{Nd}" #(str (Integer/parseInt % 10)))
23:04clojurebot"$1,050.42"
23:04TEttingerthat's the Lao digit 5 in there
23:04TimMcI usually use Devanagari. :-)
23:05devnamalloy: 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:05amalloy,(.parse (java.text.NumberFormat/getCurrencyInstance) "$1,0໕0.42")
23:05clojurebot1050.42
23:05TEttinger,(clojure.string/replace "$६६६,0໕0.42" #"\p{Nd}" #(str (Integer/parseInt % 10)))
23:05clojurebot"$666,050.42"
23:05TEttingernice amalloy
23:05TimMcheh
23:05amalloyi didn't actually notice the absurd 5 character
23:05TEttingerha wow
23:05TimMc"absurd"
23:05amalloythe point is just that regexes are the wrong tool for parsing currency
23:06TEttingeryou showed that well, yep
23:06amalloythey work fine, but...
23:06amalloythe currency parser understands locales, too, so you can read euros or whatever
23:07TEttingeramalloy: 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:07TimMcor handle commas vs. periods
23:08TEttinger"Java 9 has been delayed to 2017? the horror... the horror..."
23:18devnheh, no dice eh?
23:19devnIs it as simple as wrapping a doseq in a defmacro, and dropping `(defrecord ~name ~arglist) in there?
23:21devnerr, with an eval wrapper, that is