#clojure log - Dec 30 2014

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

0:00 rritoch: andyf: This is effectively a code generator that generates java code from a .grammar file so it needs to run before javac

0:02 andyf: It is a command line tool, I'm assuming that the maven plugin handles downloading and executing the compilation process for maven projects, and I'd like to do the same from a leiningen project.

0:04 andyf: ok, not aware of anything there. The generation of code sounds similar to the way cljx generates Clojure/Java and ClojureScript code from common source files before the rest of compilation proceeds, but I think in that case you have to enter a separate Leiningen command first -- I believe it is not integrated in the way you describe.

0:08 luxbock: rritoch: creating your own SableCC watching task with https://github.com/boot-clj/boot/wiki might be easier than with Leiningen

0:10 rritoch: luxbock: Thanks for the suggestion. This is my first time seeing that project.

0:12 luxbock: the version 2.0 is rather new, so there might be some rough edges, but I think the ideas behind it are very promising

0:12 I haven't used it myself yet but I plan to

0:12 rritoch: andyf: It sounds like I'd need to make a leiningen plugin myself than. Is there a standard place for dropping executables needed by leiningen plugins? I would think it should go into the .m2 folder, but I don't see anything in my m2 folder thats executable.

0:12 luxbock: the #hoplon channel is very helpful for Boot related problems

0:14 andyf: rritoch: I don't know. If you just needed to hack something up, rather than distribute something others can use, it seems you should be able to put an executable anywhere in your command path.

0:14 rritoch: luxbock: I'm going to need to look into boot more. Leiningen has a lot of issues related to build-order which can be very frustrating to deal with, and if it has a good solution for third party compilers than I may be better off changing the platform.

0:15 andyf: Ok thanks. It sounds like a gray area. I've run into the same issue with phantomjs where there's really no standard place to drop third party command line tools.

0:18 celwell: Does anyone know how I can easily get the client's IP address? I.e., the equivalent of $_SERVER['REMOTE_ADDR'] in PHP. I'm running ring on a Tomcat server.

0:19 rritoch: andyf: If I did make a plugin like this I'd probably want it distributed just to save the next-developer with this issue some time. But there should be some standard "safe" place to drop command line tools. I'll poke around the leiningen script to see if maybe there's something undocumented that's already available.

0:21 andyf: There's also the #leiningen IRC channel, and an email list for Leiningen, where people may know an answer. The IRC channel might be a bit lower populated than usual, and asking here is usually at least a good a place to ask as there, on IRC at least.

0:22 rritoch: calwell: You get all that information from the servlet request http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getRemoteAddr()

0:26 andyf: I'm also in #leiningen, but I don't think technomancy is around. I also prefer IRC since it is much less formal and there's less chance of clients reading it.

0:28 andyf: The last thing I want are my clients to start asking me to build them programming languages for their end users. I'm having a hard enough time doing it for myself. This is nothing more than a proof of concept project.

0:29 andyf: Trying to produce a C language interpreter that can define operators at runtime. Effectively a LISP that uses C syntax.

0:31 andyf: I've run across 1 or 2 interpreters for C-like languages, but not one based on a Lisp before, unless you count the data format I've heard about used within GCC as an intermediate compilation format.

0:37 rritoch: andyf: This is the resurrection of an issue that I ran into using the Pike language which is similar to C. Clojure is the first language I've ever modified, though I've studied compiler design for awhile. I'm trying to go from theoretical to a practical application, and LISP is really an ideal backend since it is so mutable and concepts can be tested and debugged much more quickly from LISP.

0:38 rymndhng: does anyone know in Datomic what the difference is between :db.unique/identity and :db.unique/value -- I'm assuming that for non-ref types, they're the same thing?

0:42 rritoch: andyf: I acctually have a lot of the framework in place for this already, and by extending JCPP I was able to quickly produce a preprocessor with the features I need. SableCC seems to be the best tool for building the compiler so that is where I'm at now.

0:43 andyf: But getting seemless integration between clojure and the SableCC produced code is going to take some effort.

0:44 andyf: you've considered simply having a separate manual step to run SableCC to generate Java, followed later by Leiningen commands for building Java and/or Clojure?

0:44 wrapped up in a bash script or something?

0:45 rritoch: andyf: I have considered compiling the C like language directly to LISP which would be ideal, but that is probably beyond my current capabilities.

0:45 andyf: SableCC compiles the C-like language to Java source code?

0:45 rritoch: andyf: Yes, that is what I'm going to do to get started, but I wanted to ask if any resources were already available so I'm not re-inventing too many wheels.

0:46 andyf: Unless you need that automated within Leiningen itself, seems you could consider making it a separate step to generate the Java first.

0:48 rritoch: SableCC: Not exactly. SableCC produces java source code to do all of the lexical analysis and parsing. Action classes are responsible for generating the final output, which could be anything from bytecode to an interpreter.

0:51 andyf: Once the java classes are produced I would believe I could write all the action classes in clojure

0:52 andyf: Outputing clojure code is probably a possiblity, but I'm starting with the interpreter direction since that should be slightly easier.

0:55 andyf: If I ever make it to the point of outputing clojure code that would have some powerful implications since it would then be possible to compile almost any language into clojure.

0:56 andyf: But that isn't really my goal.

1:06 andyf: Now if I could do the opposite, compile clojure forms into C language, that is something that would be extremly useful when combined with OpenCL, but I've never seen any technology that can do it.

1:07 andyf: I had a client ask for that but it was and still is, beyond my capabilities since there's no JVM in most OpenCL driven hardware.

2:20 fairuz: If I have something like [{:name "foo" :age 22} {:name "bar" :age 44} {:name "meh" :age 22}]. Is there any easy way to know if "foo" is inside this vector?

2:26 akkad: find-if?

2:28 fairuz: akkad: Is this not in core? Which lib can I find find-if?

2:30 justin_smith: ,(some (comp #(= % "foo") :name) [{:name "foo" :age 22} {:name "bar" :age 44} {:name "meh" :age 22}])

2:30 clojurebot: true

2:31 justin_smith: change "some" to "filter" if you want to get all matches, or (comp first filter) if you want to get the first match

2:33 fairuz: neat. Thanks. I'll never find this on my own :)

2:34 Empperi: 'some' is one of those wierdly named functions which has a sensible reason to be named like that

2:34 :)

2:34 justin_smith: fairuz: you know about the cheatsheet right? and grimoire

2:35 http://clojure.org/cheatsheet

2:35 http://conj.io/

2:35 fairuz: justin_smith: Yes. I was looking into conj.io. Did find some but have no idea idea combining it with comp

2:36 justin_smith: fairuz: there is probably a at least 3 useful ways to use comp with just about every clojure function

2:36 Empperi: lol, so true

2:36 clojure is a functional language and those are all about function composition

2:37 which comp does

2:38 jw: is the grimoire up to date?

2:38 theme2: How do I test if a character is upper case?

2:40 justin_smith: ,(Character/isUpperCase \B)

2:40 clojurebot: true

2:40 justin_smith: ,(Character/isUpperCase \b)

2:40 clojurebot: false

2:40 theme2: thanks

2:41 Empperi: ,(map #(Character/isUpperCase %) "asdfBcsd")

2:41 clojurebot: (false false false false true ...)

2:41 justin_smith: ,(Character/isUpperCase \☃)

2:41 clojurebot: false

2:41 theme2: justin_smith: that character looks like a circle pointing up

2:41 justin_smith: theme2: it is a snowman

2:42 theme2: O_o

2:42 doesn't work on tryclj.com

2:42 justin_smith: http://www.utf8-chartable.de/unicode-utf8-table.pl?start=9728

2:43 oh, I think tryclj may be clojurescript?

2:43 theme2: O_o

2:44 justin_smith: wait no, Character/isUpperCase works in tryclj

2:44 Empperi: ,(reduce (every-pred true?) (map #(Character/isUpperCase %) "ASD"))

2:44 justin_smith: or do you mean snowman doesn't work in tryclj?

2:44 clojurebot: true

2:44 Empperi: ,(reduce (every-pred true?) (map #(Character/isUpperCase %) "aASD"))

2:44 clojurebot: false

2:44 theme2: justin_smith: "java.lang.RuntimeException: Unable to resolve symbol: isUpperCase in this context"

2:44 Empperi: ok, got carried away

2:44 jw: would Character/isUpperCase be valid in clojurescript?

2:45 justin_smith: theme2: no

2:45 Empperi: jw: no, it's java call

2:45 justin_smith: err sorry

2:45 jw, no it would not

2:45 jw: ok, yeah that's what I was thinking...

2:45 justin_smith: theme2: what does you call look like? it should work

2:45 theme2: justin_smith: (Character/isUpperCase \b)

2:46 ,(Character/isUpperCase \b)

2:46 clojurebot: false

2:46 theme2: -_-

2:46 wtf

2:46 justin_smith: theme2: that exact call works in tryclj for me

2:46 * theme2 presses f5

2:46 theme2: wtf

2:46 refreshed and doesn't work

2:47 * theme2 hates unreproducible bugs

2:48 Empperi: Give me some Clojure:

2:48 > (Character/isUpperCase \b)

2:48 false

2:48 theme2: ,(print "wtf")

2:48 clojurebot: wtf

2:48 Empperi: straight copy-paste from tryclj

2:48 * theme2 too

2:49 theme2: by any chance, does tryclj use locally installed java?

2:49 > (Character/isUpperCase \b)

2:49 ,(Character/isUpperCase \b)

2:49 clojurebot: false

2:50 theme2: *_*

2:50 orz

2:56 * theme2 couldn't figure out why tryclj hates him

2:58 theme2: ,(str (filter #(Character/isUpperCase %) "abc"))

2:58 clojurebot: "clojure.lang.LazySeq@1"

2:58 theme2: what is that?

2:59 nvm

3:02 Empperi: ,(type (filter true? [true]))

3:02 clojurebot: clojure.lang.LazySeq

3:02 Empperi: it's that :)

3:05 dagda1_: how do I reference clojure 1.7 in my project.clj

3:05 or how can I use transducers is really my question

3:06 Empperi: add clojure 1.7 as a dependency into your project.clj

3:06 [org.clojure/clojure "1.7.0-alpha4"]

3:10 justin_smith: theme2: try apply str

3:11 ,(apply str (filter (Character/isUpperCase %) "aBcD"))

3:11 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: % in this context, compiling:(NO_SOURCE_PATH:0:0)>

3:11 justin_smith: ,(apply str (filter #(Character/isUpperCase %) "aBcD"))

3:11 clojurebot: "BD"

3:21 theme2: ,

3:21 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

3:21 theme2: ,()

3:21 clojurebot: ()

3:21 theme2: ,(())

3:21 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList$EmptyList cannot be cast to clojure.lang.IFn>

3:21 theme2: ,((()))

3:21 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList$EmptyList cannot be cast to clojure.lang.IFn>

3:21 theme2: O_o

3:22 justin_smith: () is unambiguous, so it does not need quoting

3:22 theme2: ,()()

3:22 clojurebot: ()

3:22 theme2: what?

3:22 clojurebot: what is not a bug

3:22 theme2: O_o

3:22 justin_smith: () is always an empty list

3:22 theme2: x?

3:22 wat?

3:22 what?

3:22 clojurebot: what is this

3:23 theme2: -_-

3:23 ,'(1)()

3:23 clojurebot: (1)

3:23 justin_smith: lazybot, is it time for bed???

3:23 lazybot: justin_smith: How could that be wrong?

3:23 justin_smith: seeya

4:11 krat0sprakhar: ,(println "wassap people")

4:11 clojurebot: wassap people\n

4:29 hellofunk: ,(apply str (interpose " " [(apply str (seq (concat "no" "thing"))) "much"]))

4:29 clojurebot: "nothing much"

4:39 tsunny: hello clojurebot

4:40 (+ 1 2)

4:40 clojurebot: 3

4:41 tsunny: (println "Clojure Bot is Cool")

5:03 theme2: ,(println "Clojure Bot is Cool")

5:03 clojurebot: Clojure Bot is Cool\n

5:03 theme2: ,(print "Clojure Bot is Cool")

5:03 clojurebot: Clojure Bot is Cool

5:03 theme2: :)

5:21 hellofunk: (print "no comma")

5:21 (println "no comma")

5:21 theme2: ,(print "no comma")

5:21 :)

5:21 clojurebot: no comma

5:21 hellofunk: (+ 1 3)

5:21 clojurebot: 4

5:21 hellofunk: huh. no comma there

5:22 theme2: (print "no comma")(1)

5:22 (print "no comma") 1

5:22 (print "no comma") '(1)

5:22 ,(print "no comma") '(1)

5:22 clojurebot: no comma

5:22 theme2: -_-

5:22 hellofunk: weirdness

5:22 theme2: weird

5:22 hellofunk: jinx

5:23 theme2: ,(print "Clojure bot is weird")

5:23 clojurebot: Clojure bot is weird

5:23 theme2: ,(println "I am weird")

5:23 clojurebot: I am weird\n

5:24 theme2: ,(println "\\\\\\\\\\\\\\\\\\\")

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

5:24 theme2: ,(println "\\\\\\\\\\\\\\\\\\\\")

5:24 clojurebot: \\\\\\\\\\\n

5:24 theme2: extra n :)

5:24 ,(doc clojurebot)

5:24 clojurebot: Titim gan éirí ort.

5:24 theme2: lol

5:28 hellofunk: clojurebot: explain yourself!

5:28 clojurebot: excusez-moi

5:28 hellofunk: clojurebot: i said, explain yourself!

5:28 clojurebot: It's greek to me.

5:28 hellofunk: clojurebot: explain yourself!

5:28 clojurebot: Titim gan éirí ort.

5:28 theme2: ,(recur)

5:28 clojurebot: eval service is offline

5:28 theme2: whoops

5:29 hellofunk: you broke the bot

5:29 ,(println "we are sorry")

5:29 clojurebot: we are sorry\n

5:29 theme2: ,(fn [] (recur))()

5:29 clojurebot: #<sandbox$eval239$fn__240 sandbox$eval239$fn__240@2d0df534>

5:29 theme2: ,((fn [] (recur)))

5:29 clojurebot: eval service is offline

5:29 theme2: ,(print "test")

5:29 clojurebot: test

5:29 theme2: ,((fn [] (recur)))

5:29 ,(print "test")

5:29 ,(print "test")

5:29 ,(print "test")

5:29 ,(print "test")

5:29 clojurebot: eval service is offline

5:29 test

5:29 test

5:29 test

5:29 test

5:30 theme2: lol

5:40 m1dnight_: Is there an idiomatic way to raise and handle events in clojure?

5:41 Atm I have the idea of writing a function that says "(subscribe :event <fn>)" that will add this function to a list, and when :event happens, trigger all functions in that list

5:41 but I think there is a better way

5:41 brainproxy: m1dnight_: maybe something like https://github.com/clojurewerkz/meltdown

5:42 though, there might be something similar which is based on core.async, not sure

5:42 m1dnight_: hmm, something like that yes

5:47 perhaps channels are an other way to go about it

5:48 brainproxy: sure, you can build little loops and do all sorts of stuff even w/in a single thread

5:48 if you use the (go ...) and (go-loop ...) macros

5:49 m1dnight_: Well the architecture I'm building is a loop that receives messages and I want to subscribe multiple modules to it. Each module should look at each message that is produced by the loop and determine for itself it want sto do something with it or not

5:49 So i'm thinking, each module will create a channel to the loop, and the loop will put each message on each channel it has available

5:49 something like that might do the trick

5:49 brainproxy: have you looked over core.async's API?

5:50 m1dnight_: I've got my cojure book by hand and on that now :)

5:50 brainproxy: there are facilities for pub/sub, etc.

5:50 m1dnight_: hrm, neither books I have contain chapters about core.async (or channels)

5:51 brainproxy: https://github.com/clojure/core.async

5:51 http://clojure.github.io/core.async/

5:52 m1dnight_: I think it might be interesting to go about it with core.async yes

5:53 thanks for the links brainproxy !

5:53 (inc brainproxy)

5:53 lazybot: ⇒ 4

5:53 luxbock: m1dnight_: check out the core.async videos from the Clojure Conj

5:58 m1dnight_: cool :) Looking at a video by Timothy Baldridge

5:58 thanks for the hints

5:58 oh well, it's christmas!

5:58 (inc luxbock)

5:58 lazybot: ⇒ 2

6:06 slipset: core.async has pub/sub as well http://yobriefca.se/blog/2014/06/04/publish-and-subscribe-with-core-dot-asyncs-pub-and-sub/

6:28 I've tried to implement a version of the sleeping barber problem (http://en.wikipedia.org/wiki/Sleeping_barber_problem) using core.async

6:29 code is here: https://gist.github.com/slipset/fb7d2a44303481731d89

6:29 Problem is that the customer never gets to know if he has his hair cut or not.

6:30 Is there any way to know for someone who put! on a dropping-buffer if the value was dropped or not?

6:35 /whois luxbox

6:38 akkad: magic

6:40 slipset: luxbock: re transducers, I think Rich Hickey mentions in either this years conj or strange-loop talk that the transducer impl lets the collections which knows how to step themselves handle the operation internally.

6:42 luxbock: see bottom of this https://gist.github.com/runexec/06b56a9dbd15e43145b9

6:42 luxbock: slipset: thanks

7:03 Frozenlock: Anyone has a link to an example of Stuart Sierra's Component? I found this https://github.com/danielsz/system/tree/master/example/src/example, but there doesn't seem to be dependencies between the components.

7:06 slipset: frozenlock: could be something here http://www.uswitch.com/tech/more-open-source-clojure-systems-please/

7:08 Frozenlock: slipset: thanks!

7:21 mi6x3m: clojure what is the type for Java variadic args?

7:21 X[] ?

7:21 and how can I specify that in gen-class

7:33 SagiCZ1: it is an array yes

7:34 mi6x3m: SagiCZ1: but how do you use it with gen-class? through the [L notation?

7:35 SagiCZ1: mi6x3m: i am not sure, let's wait for someone else

7:35 mi6x3m: good call :)

7:41 KU0N: Hello. Given (let [h {:foo "bar" :foo2 "bar"}]) how can I call function f with each key/val as argument, like (f :foo "bar") (f :foo2 "bar") ?

7:42 SagiCZ1: use map

7:43 ,(map identity {:foo "bar" :a 0})

7:43 clojurebot: ([:foo "bar"] [:a 0])

7:43 SagiCZ1: if you call seq on hash map, it creates a sequence of key value pairs

7:43 map calls seq for you and applies given function on each element of that seq

7:43 KU0N: Hoo, like hash.to_a in ruby. Ok.

7:43 Thanks.

7:44 slipset: (map (fn [[k v]] [(name k) (keyword v)]) h)

7:44 ,(let [h {:foo "bar" :foo2 "bar"}] (map (fn [[k v]] [(name k) (keyword v)]) h))

7:44 clojurebot: (["foo" :bar] ["foo2" :bar])

7:45 SagiCZ1: thats not necessary slipset

7:45 slipset: what's not necessary?

7:47 hyPiRion: ,(let [h {:foo "bar" :foo2 "bar"}] (for [[k v] h] [(name k) (keyword v)]))

7:47 clojurebot: (["foo" :bar] ["foo2" :bar])

7:49 slipset: hyPiRion: cool, haven't used for much

7:49 hyPiRion: You can also go bonkers like me and implement the util fn beside.

7:49 ,(defn beside [& fs] (fn [vs] (mapv #(%1 %2) fs vs)))

7:49 clojurebot: #'sandbox/beside

7:49 hyPiRion: ,(map (beside name keyword) {:foo "bar" :foo2 "bar"})

7:49 clojurebot: (["foo" :bar] ["foo2" :bar])

7:50 KU0N: I've been doing clojure for 1 hour, my head is going to explode:P

7:50 SagiCZ1: KU0N: it sure is intimidating at first

7:50 slipset: hyPiRion: btw really liked your fizzbuzz implementation :)

7:51 https://www.refheap.com/92860

7:51 hyPiRion: slipset: haha, thanks

7:52 Quicksort is also neat: https://www.refheap.com/284a0552a6b69c6037faa2db5

7:52 KU0N: Mmh. (doto req #(map (.setRequestHeader %) headers) (headers being the key/val pairs) I know I'm doing something wrong.

7:53 slipset: hyPiRion: do you write this out manually, or do you have some secret clj-swj function?

7:53 SagiCZ1: KU0N: in interop you need to specify the object you are calling setRequestHeader on first.. and what parameters does the method have?

7:54 KU0N: .setRequestHeader name value

7:54 slipset: KUON: also, I would guess that req.setRequestHeader takes a key and a value as param?

7:54 thheller: KU0N: map is also lazy, so it won't execute since you don't consume the result

7:55 slipset: (map (fn [[k v]] (.setRequestHeader req k v)) header)

7:55 KU0N: (doto req (.setRequestHeader "Content-Type" "application/json")) this workds

7:55 thheller: (doseq [[key value] headers] (.setRequestHeader req key value))

7:55 slipset: would probably do the trick?

7:55 or maybe even mapv, as map is lazy as thheller points out

7:56 hyPiRion: slipset: I'm doing it manually for now, but I go through the same steps every time. I guess it shouldn't be impossible to implement a clj->swj translator

7:56 Only thing I've done was automating number generation, but I don't know where that piece of code is

7:58 thheller: don't use map(v) if you don't need the result, building a collection you don't need is a waste of resources

7:58 KU0N: Yeah I was looking to something like each

7:59 thheller: thats what doseq is for basically

7:59 KU0N: Yeah, it works. Thanks a lot.

7:59 slipset: thheller: thanks

8:02 mi6x3m: can I use a class generated through gen-class with import?

8:02 somehow it's not getting found?

8:09 I need hints as to how to compile a gen-class class only once :)

8:26 slipset: curious, the core.async docs say eg unique is deprecated, use transformer instead.

8:26 should that read "use transducer instead."?

8:26 Bronsa: yeah

9:29 slipset: hmm, here's the answer to getting a message when a put! is dropped http://dev.clojure.org/jira/browse/ASYNC-55

9:30 not that I understood Ghadis answer though.

9:32 bacon1989: anyone know of a good resource on clojure destructors

9:32 like, a crap ton of examples

9:32 slipset: Jay Fields has a blog on it. Hang on...

9:33 http://blog.jayfields.com/2010/07/clojure-destructuring.html

9:33 Bronsa: bacon1989: you mean destructuring, not like OOP destructors right?

9:33 bacon1989: oh yeah, destructuring

9:34 thank you, this should do nicely

9:34 I left my oreilly clojure book at home

9:54 m1dnight_: Is anyone here a beginner-isj clojure dev that would like to help me out with my clojure irc bot thing? Just for fun? I alwyas wanted to co-author something

9:54 never really had the chance

9:54 I dont work on it *that* much, just from time to time

9:55 Empperi: I've already written on ircbot in clojure :P

9:55 one

9:55 just for fun too

9:55 m1dnight_: Yeah, I know there are plenty of them out there but the goal of this tiny project is to build something that has very clean architecture

9:55 some interaction would be nice

9:56 did you write lazybot, Empperi ?

9:56 Empperi: no

9:56 it's my very own bot and no one else uses it

9:56 m1dnight_: github or something?

9:57 Empperi: https://bitbucket.org/niklas_collin/masterbot

9:57 nothing too fancy or beautiful

9:58 m1dnight_: yay, dynamic loading. I want that too

9:58 Atm I have a bot based on the PircBotX framework that used classloading for that purpose but it's not optimal yet

9:58 And I want to replace it with a clojure implementation

9:59 Empperi: m1dnight_: don't get too excited yet https://bitbucket.org/niklas_collin/masterbot/src/7070bbc8d0a26914fe8ad384b931234415905e5b/src/masterbot/core.clj?at=default#cl-10

9:59 m1dnight_: oh snap :p

9:59 Empperi: shouldn't be too hard to implement

9:59 but so far haven't needed it

10:00 m1dnight_: I havent found much when googling for hot swappable code though

10:00 Empperi: anyway, all that is really needed to define a new command is that require

10:00 m1dnight_: Do you have an idea how to go about it?

10:00 Empperi: sure, just evaluate all .clj files in certain directory

10:01 and read them from there

10:01 hiiiighly insecure to do that way but works

10:01 :)

10:01 m1dnight_: https://github.com/m1dnight/infogroep-bot/blob/master/be/christophedetroyer/Main.java#L192

10:01 this is how I do it in java atm

10:01 but I get your point

10:01 might try it out

10:36 slagyr: Anyone datomic developers online?

10:37 llasram: ~anyone

10:37 Bronsa: slagyr: there is a #datomic channel

10:37 clojurebot: anyone is anybody

10:37 slagyr: Bronsa: I’m in #datomic too. It’s a bit slow.

10:38 llasram: slagyr: unless you're trying to get in touch with the developers of datomic, you're probably best off just asking your question

10:39 slagyr: Right. Will datomic behave well with a schema containing hundreds of thousands of attributes?

10:40 I know it can support 2^20 attributes, but at what cost? Will it consume gobs of memory? Will queries slow to a crawl?

10:47 dnolen_: slagyr: probably better to ask your question on the Datomic ML

10:49 slagyr: dnolan_: ok thanks

11:03 dagda1_: why is korks often used as an argument name

11:07 ivan: dagda1_: key or keys

11:07 dagda1_: ivan: now I know!

11:14 visof: i guys

11:14 hi

11:14 what is the best way to send anything to tcp with ip and port?

11:15 llasram: visof: I usually use packets

11:16 visof: llasram: what is packets?

11:17 llasram: visof: Sorry, just me failing to be funny

11:17 visof: I'm actually just not sure what you're asking

11:18 visof: how can you open tcp connection and send something to it?

11:18 luxbock: visof: you could use Aleph: http://paulosuzart.github.io/blog/2012/07/09/tcp-server-with-clojure-aleph-and-gloss/

11:19 visof: i want to make tcp client

11:19 llasram: visof: Just for fun, or to achieve some other goal?

11:19 stuartsierra: visof: java.net.Socket

11:19 mfikes: Clojure Cookbook covers this topic: https://github.com/clojure-cookbook/clojure-cookbook/blob/master/05_network-io/5-09_tcp-client.asciidoc

11:22 stuartsierra: Watch out, folks!

11:22 user=> (.format (SimpleDateFormat. "yyyy-MM-dd") (Date.))

11:22 "2014-12-30"

11:22 user=> (.format (SimpleDateFormat. "YYYY-MM-dd") (Date.))

11:22 "2015-12-30"

11:22 Bronsa: woah wtf

11:22 m1dnight_: Right, I red about that bug

11:22 read*

11:22 stuartsierra: I heard that broke Twitter a few days ago. :)

11:23 m1dnight_: I wonder where it stems from though

11:23 can't find the url immediatly

11:23 visof: stuartsierra: what do you think about this https://github.com/gerritjvv/clj-tcp?

11:23 stuartsierra: It's a legitimate use case: "YYYY" gives you the year for the current *week*

11:23 visof: stuartsierra: what do you think about this https://github.com/gerritjvv/clj-tcp ?

11:24 Bronsa: so it's not a bug

11:24 just weird behaviour, neat

11:24 m1dnight_: http://stackoverflow.com/questions/18228284/java-simpledateformat-bug

11:24 seems to be a fairly old bug?

11:24 oh, nvm "bug" then :p

11:24 tcrayford____: jodatime doesn't support "year for the current week" ;)

11:24 afaik

11:25 stuartsierra: It's not a bug in Java SimpleDateFormat, but it's a common bug in code which uses it.

11:25 visof: I have no basis on which to form an opinion of that link.

11:25 mfikes: Perhaps it is a bug for code to ascribe meaning to YYYY-MM-dd, while it is legit to simply use YYYY in other contexts.

11:26 tcrayford____: stuartsierra: a usability bug if anything. APIs should help prevent their users from fucking up

11:30 visof: i'm in situation which need side-effects, i try to process something, and when i finish i update the status to done in redis, so i need to track status at redis from my clojure code if it done or not

11:30 in imperative language i'm using while loop and check status and status value till status get done

11:31 what is the best practice should do this in clojure or in functional language in general ?

11:31 my think is atom

11:31 and use the same as in imperative language

11:31 but i'm asking about the best and elegant solution for this

11:32 justin_smith: visof: if it only gets done once, use a promise

11:32 or a future or delay, if there is a single expression that is known to deliver the value

11:33 realized? will tell you if it is don (ready for reading) or not

11:33 visof: yeah i got it

11:48 EvanR-work: idiomatic way, while doing a for or map, to "abort" or short-circuit end the computation, resulting in a nil or something

11:48 ?

11:48 exceptions?

11:48 clojurebot: http://paste.lisp.org/display/74305

11:48 justin_smith: EvanR-work: for and map are lazy

11:48 just stop taking more values

11:50 llasram: EvanR-work: You can codify justin_smith's suggestion with `for` using a `:while` condition, and for any lazy sequence by wrapping in a `take-while`

11:50 justin_smith: if you care about the side effects from extra values accidentally produced, you should be using a doseq for the side effects, and using for or map only for the stateless part of the calculation

11:50 EvanR-work: no side effects

11:50 justin_smith: cool

11:51 EvanR-work: ok trying to grok this... so in the event of an error produce nil. then later something will check for an occurrence and return nil instead of the sequence

11:51 at the first nil

11:54 tcrayford____: yeah, you can just use (take-while #(not (nil? %)) stuff) there

11:54 as long as your seqs don't get chunked

11:54 m1dnight_: I think what they mean is just map your function over the list. This produces a lazy sequence. And where you want to abort you make your function return something (e.g., nil). Then you can take the produced part of your map result by using take-while.

11:54 EvanR-work: doesnt that give me the initial part

11:55 i dont want any of it if an error occurs in the middle

11:55 justin_smith: EvanR-work: wait, OK, that's different

11:55 EvanR-work: would the exception be thrown in producing the sequence, or just a state you don't accept?

11:56 m1dnight_: doall, check with some nil, and then return nil or the sequence?

11:56 EvanR-work: producing. doall? why?

11:56 m1dnight_: oh wait no, indeed that would be wrong

11:56 nvm that

11:56 justin_smith: EvanR-work: doall is needed because you need to decide before exiting scope what you are returning

11:56 EvanR-work: i cant just search for the first nil?

11:57 justin_smith: m1dnight_: no, it is perfectly correct, the only way to decide between a sequence and nil is to realize the full sequence

11:57 EvanR-work: the point is im trying to avoid computing the whole thing if an error occurs

11:57 (which might be pointless since it will chunk like 30 items and i have probably less than that items per run)

11:58 justin_smith: (if (some nil? s) nil s)

11:58 that's all you need

11:58 some stops at the first nil

11:59 EvanR-work: yeah

11:59 should work, im luckily not using nil for anything else ;)

11:59 m1dnight_: ooh right because S would be lazy

12:00 you could use :error or something as well, EvanR-work

12:00 justin_smith: more generally you can have (try (test-every s) s (catch Exception e nil)) for exception oriented programming

12:00 EvanR-work: yeah i will need to use [:error "msg"] to explain the problem

12:00 yeah exceptions

12:01 justin_smith: that sounds like you just want an exception then

12:01 once you get messages too, along with short circuiting

12:01 EvanR-work: ive been avoiding them in clojure because it seems i have to define a new module to get a new exception class

12:01 m1dnight_: just use ExceptionInfo

12:01 you can piggyback on it to add data and a message

12:01 EvanR-work: i refuse to to catch all exceptions (unless theres something i dont know)

12:01 ExceptionInfo?

12:02 m1dnight_: http://stackoverflow.com/a/16159584/1225786

12:02 EvanR-work: ^

12:02 EvanR-work: cool

12:02 m1dnight_: Then you can even check if the exception is the type you want, if not, rethrow it

12:03 EvanR-work: ... lovely..

12:03 yeah so i have to do extra checking to differentiate between different uses of this exception

12:04 m1dnight_: I'm afraid so. I'm not sure if ExceptionInfo is used anywhere in clojure though.

12:05 EvanR-work: this would definitely be a control flow mechanism locally using exceptions

12:05 annoying

12:05 ExceptionInfo looks good for when i really want to throw an exception, right now ive been doing asserts

12:06 llasram: EvanR-work: What's your higher-level goal here?

12:06 EvanR-work: its a parser

12:07 take trees of strings as input

12:07 its turning out that i dont seem to be catching the parse failures anywhere inside the parser, so maybe i dont need to do it in a pure way

12:08 i was cautiously thinking that some part of it needs to decide to backtrack if an error happens

12:09 llasram: Are the things you are parsing not arriving in a fashion which makes it convenient to use an off-the-shelf parser like instaparse?

12:13 EvanR-work: looks like it

12:20 (after looking at instaparse, the text-based parser language reminds me of rubyisms, where if your language was based on data structures or s expressions you could more easily build these programs with program)

12:21 (rather)

12:22 in ruby languages usually take the form of a string or a big mutable object where phrases are spoken by using missing method invocations

12:24 llasram: EvanR-work: instaparse also provides a combinator interface

12:25 EvanR-work: The idea (as I understand it, not being the author) is that it provides the same convenience regular expressions provide for regular grammars, just for context-free grammars

12:26 EvanR-work: thats cool

12:27 the patterns describing the top layer of my data are actually regular expressions, just not on streams of letters but streams of trees

12:30 * EvanR-work bites bullets and uses ExceptionInfo

12:31 EvanR-work: ,(:Doc ex-info)

12:31 clojurebot: nil

12:31 EvanR-work: whats the cause argument?

12:31 stuartsierra: EvanR-work: `cause` is another exception you're wrapping.

12:32 Just like the standard java.util.Exception constructors.

12:32 Bronsa: &(doc ex-info)

12:32 lazybot: ⇒ "([msg map] [msg map cause]); Create an instance of ExceptionInfo, a RuntimeException subclass that carries a map of additional data."

12:32 stuartsierra: err, java.lang

12:49 mi6x3m: any experts on gen class around?

12:51 TimMc: Best to just ask your question.

12:52 TEttinger: but probably, yes, mi6x3m

12:52 mi6x3m: I have am preparing a small sample for you guys

12:52 TEttinger: (identity Bronsa)

12:52 lazybot: Bronsa has karma 82.

12:53 mi6x3m: basically my extra constructor argument is being seen in the init function

12:53 but the state is null in an overriden method

12:54 Bronsa: TEttinger I have actually used gen-class only once in my life :P

12:54 TEttinger: heh, lucky

12:54 Bronsa: (in great pain and agony)

12:55 mi6x3m: yes

12:55 it is great pain and agony

12:55 but I will be greatful for any hint :)

12:55 TEttinger: I've never used the state stuff

12:55 Bronsa: I have -- https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader/impl/ExceptionInfo.clj

13:00 mi6x3m: ok everyone, here goes nothing: http://pastebin.com/VnY1huEX

13:00 in the -init method, everything is fine and the factory is != nil

13:00 in the overriden method however, it is nil

13:01 it's probably something with the vector I return in init

13:03 noonian: i've no experience with gen-class, but why are your funciton names prefixed with '-'? it seems weird because in the gen-class form you reference them without the '-'s

13:03 Bronsa: noonian: no, that's the default prefix for gen-class

13:03 noonian: ah cool

13:05 charlespwd: Should lein ring uberwar take 15 minutes+?

13:05 kenrestivo: on a 1ghz atom maybe

13:05 mi6x3m: charlespwd: depends on your internet connection and the number of dependencies

13:06 [blake|: Hey, all: If I have a web app packaged as a WAR, how would I handle uploads? To wit, if this is the sort of thing where I'd normally put files in (say) an "/upload" directory off the root?

13:06 charlespwd: mi6x3m: thanks.

13:07 [blake|: charlespwd: Every now and again, mine takes an inordinate amount of time. I can't really explain it, since everything should already be downloaded.

13:07 TEttinger: decoratorFactory and decorator-factory shouldn't be... it seems like those are different symbols

13:07 Bronsa: TEttinger I don't think that matters at all

13:07 mi6x3m: TEttinger: please explain?

13:07 the one is a java class field, the other a clojure arg

13:07 kenrestivo: [blake|: i usually use s3 in those cases

13:08 TEttinger: I just thought it might be a typo, I don't know how state works here

13:08 Bronsa: mi6x3m: are you sure you don't have stale classes in your classpath?

13:08 TEttinger: lein clean to the rescue

13:08 mi6x3m: Bronsa: what do you mean?

13:08 [blake|: kenrestivo: OK, I think my WAR is actually going to be on S3.

13:10 mi6x3m: Bronsa: i have a file extract-native.dependencies in my stale folder in target

13:11 perhaps it's a garbage collection issue?

13:12 TEttinger: mi6x3m, stale as in from an older compilation of your program

13:13 but not cleaned by lein clean or something that calls lein clean, so your program still sees old non-working class files

13:13 mi6x3m: TEttinger: I am sure, deleted the whole target directory

13:13 TEttinger: ok

13:15 mi6x3m: Bronsa: there is one thing which bothers me

13:16 the superclass takes a variadic argument list

13:16 that "options"

13:16 might be breaking things

13:16 TimMc: As long as you treat that as an array of the appropriate type, that should be fine.

13:16 Bronsa: mi6x3m: I don't think so, you provide an array type, that's how varargs are compiled to

13:17 mi6x3m: than I am sure out of theories :/

13:17 Bronsa: mi6x3m: I'm more concerned about the exposes-method thing, are you sure that's correct?

13:17 mi6x3m: Bronsa: well the method is invoked by the Java code

13:18 so it must be correctly overriden I think

13:18 TimMc: What is evidence that your state is non-nil in init and nil in the method?

13:19 mi6x3m: TimMc: println

13:24 where can one see the code of gen class?

13:25 TimMc: The source for clojure.core/gen-class?

13:26 aperiodic: mi6x3m: I'd try to reproduce the behavior you're seeing in a minimal example w/out other dependencies

13:26 also gen-class is implemented here: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L7218

13:26 good luck

13:27 oh, no, it's not

13:29 this is the meat of it, sorry: https://github.com/clojure/clojure/blob/ae5e679111b3b72e2a8e3d2ebb1439ff0ca695a7/src/clj/clojure/genclass.clj#L124

13:29 it's only 382 lines long

13:30 mi6x3m: jesus christ

13:30 longest let i've seen so far

13:34 aperiodic: anyways, if you have a minimal reproduction it will be easier for others to help you debug, and you may figure out the problem in the course of constructing the minimal reproduction

13:34 it will probably be more productive than trying to understand the implementation

13:35 adu: aperiodic: good ol' min.rep.

13:38 TimMc: ~sscce

13:38 clojurebot: An SSCCE is a Short, Self-Contained, Correct Example <http://sscce.org/&gt;

13:38 TimMc: aperiodic: I bet that would be the case here (discovering the bug while making an sscce).

13:39 aperiodic: Sometimes I ponder making a code bisector that keeps halving your code until the bug is discovered.

13:39 mi6x3m-alt: running the .class file through a decompiler I get: decorator_factory = null;tmp52_36[1] = decorator_factory;return RT.vector(tmp52_36);

13:40 which is quite disturbing

13:40 Yxven1: How difficult is it to learn clojure if you know java and haskell?

13:41 mi6x3m-alt: Yxven1: not hard

13:41 aperiodic: TimMc: how do you remove code without changing the behavior in a way that might obscure the bug?

13:41 TimMc: Dunno.

13:41 Yxven1: It took around 4 months to get proficient at haskell with no previous haskell experience. Would I be looking at the same for clojure mi6x3m-alt?

13:42 TimMc: It would be a neat trick for sure.

13:42 mi6x3m-alt: Yxven1: I'd say 2 months here

13:42 it's a lisp with a lot of JVM mojo

13:42 andyf: I'd say the familiarity with immutable data you got from Haskell will get you a lot of the way there.

13:43 aperiodic: Yxven1: java -> haskell seems like a much bigger paradigm shift than haskell -> clojure. you're already familiary w/immutability & laziness. probably mostly syntax and familiarity with the standard library and idioms that you're missing.

13:44 Yxven1: Would SICP teach me how to write clojure or is scheme very different?

13:45 rgiar: IMO, SICP is great for the lisp aspects of clojure

13:45 mi6x3m-alt: Yxven1: well, I'd take one of the clojure specific books and work my way through the first 200 pages, clojure is not tht difficult really

13:45 AimHere: SICP will teach you programming.

13:45 andyf: Scheme emphasizes lists, whereas typical Clojure code uses vectors, maps, sets, and lists, perhaps even with lists being in the minority.

13:45 rgiar: the tricky parts of thinking in terms of immutability aren't covered

13:45 AimHere: SICP only teaches the basics of scheme anyways

13:46 rgiar: basics of scheme but the deep parts of lisp

13:46 andyf: SICP is a great book, no question, but it won't necessarily make the same kinds of data structure choices that Clojure code would.

13:46 AimHere: rgiar, well SICP teaches immutability by default. It takes about 160 pages before any variable's value is reassigned, and they make a big deal about it

13:46 Bronsa: (inc andyf) ;; thanks for the help on tanal-108

13:46 lazybot: ⇒ 20

13:46 andyf: (inc Bronsa)

13:46 lazybot: ⇒ 83

13:46 rgiar: hmm, i didn't notice it at the time -- they do say very bad things about setcar/setcdr so i guess you're right

13:47 andyf: Thanks for fixing it :)

13:48 Yxven1: I appreciate the advice guys

13:49 AimHere: Anyways, read SICP, even if you can't do the translation and have to do it in scheme!

13:51 TimMc: mi6x3m-alt: A reduced test-case I made does not exhibit the behavior you see.

13:52 mi6x3m-alt: TimMc: can you paste it?

13:53 llasram: mi6x3m-alt: A bit late, but IMHO if you are unable to use reify or even proxy, it is far far simpler to just write a small Java class which can be parameterized with an IFn than to use gen-class

13:53 Java (<8) may not be a great programming language, but it's a pretty decent DSL for defining Java classes

13:53 nullptr: ha!

13:53 TimMc: (inc llasram)

13:53 lazybot: ⇒ 44

13:54 mi6x3m-alt: (inc llasram)

13:54 lazybot: ⇒ 45

13:54 mi6x3m-alt: (inc llasram)

13:54 lazybot: ⇒ 46

13:54 crash_ep: GO BLOCKS

13:54 mi6x3m-alt: I don't know how I wasted a whole day without considering the obvious way

13:54 TimMc: mi6x3m-alt: https://www.refheap.com/95599 I had to strip out some things that might be relevant because they got in my way.

13:54 justin_smith: crash_ep: do they interest you, or are you rooting for your favorite lego themed team?

13:54 TimMc: So it's stripped too far, I guess.

13:55 mi6x3m-alt: TimMc: Object doesn't have a ctor with variadic args :)

13:55 crash_ep: justin_smith: heh

13:55 mi6x3m-alt: anyhow, llasram is fully right, this is non-sense, java is for writing java classes

14:13 clojer: Does Clojurescript eliminate the need for tools such as gulp/grunt and AMD/CommonJS?

14:15 noonian: definitely for AMD/CommonJS since all the modules are loaded and built into a single file at compile time

14:15 and uses google closure

14:15 's module system

14:16 clojer: noonian: I'm just findig the whole JS build tools maze exhausting :(

14:18 mi6x3m-alt: llasram: do you happen to know, my saviour, how to compile java code with lein?

14:18 noonian: clojer: well, with cljs you'll be swapping the js build tools for clojure's build tools; most likely leiningen and lein-cljsbuild

14:18 mi6x3m-alt: I guess I have to modify the task

14:18 craigglennie: Is it okay stylistically to have a “for” in a let block?

14:19 SagiCZ1: how to add an element at the beginning of a vector?

14:19 ,(into [1] [2 3])

14:19 TimMc: craigglennie: Sure, why not?

14:19 clojurebot: [1 2 3]

14:19 noonian: mi6x3m-alt: i think you just need to add a :java-source-paths entry to your project.clj

14:19 craigglennie: TimMc: I couldn’t think of any reason why not, just wondered if it was idiomatic… it certainly works :)

14:19 SagiCZ1: (apply vector 1 [2 3])

14:19 , (apply vector 1 [2 3])

14:19 clojurebot: [1 2 3]

14:19 mi6x3m-alt: noonian: I did, no effect

14:19 TimMc: craigglennie: Especially since a :let clause at the beginnning of a for expr is buggy and doesn't work. :-P

14:19 justin_smith: SagiCZ1: I think into is pretty much your best bet there

14:19 craigglennie: TimMc: It is?

14:19 SagiCZ1: justin_smith: okay thanks

14:20 TimMc: Last I saw.

14:20 coventry: Does anyone have a link to that talk where a leading scala developer flips out about the technical debt in the scala source code?

14:20 TimMc: ,(for [:let [a 5], i (range a)] i)

14:20 clojurebot: #<IllegalStateException java.lang.IllegalStateException: Can't pop empty vector>

14:21 noonian: coventry: I think paul phillips is the guy your thinking of; shouldn't be too hard to find it (i think he has a few of them)

14:21 TimMc: ,(for [i (range 5), :let [a i]] a)

14:21 clojurebot: (0 1 2 3 4)

14:22 TimMc: craigglennie: So if you need to bind something for the entire scope of the for expression, that's really your only option. (And yes, it's idiomatic too.)

14:22 coventry: noonian: Thanks.

14:22

14:22 noonian: either "Scala Collections: Why Not?" or "We're Doing it All Wrong"

14:22 craigglennie: TimMc: Cool, thanks

14:25 coventry: Yes, "we're doing it all wrong" is the one.

14:26 godd2: &(into [] (cons 4 [1 2]))

14:26 lazybot: ⇒ [4 1 2]

14:26 godd2: SagiCZ1 is that what you wanted?

14:26 justin_smith: godd2: that's bad

14:27 godd2: justin_smith bad how? slow? unidiomatic?

14:27 justin_smith: godd2: that turns the whole vector into a list, and then turns it back into a vector again

14:27 which is silly

14:27 tbaldridge: coventry: pretty much every talk by that same guy these days is him flipping out

14:27 justin_smith: (into [4] [1 2]) does a lot less needless work

14:28 godd2: justin_smith yea but the into isn't prepending 4 into [1 2]

14:28 mi6x3m-alt: OK following situation

14:28 using java_source_paths works for compiling the file

14:28 but the file is not being seen by lein run

14:28 Bronsa: ,(into [4] [1 2])

14:28 clojurebot: [4 1 2]

14:28 justin_smith: godd2: right, because you cannot prepend vectors period, but it is the best workaround

14:28 Bronsa: godd2: yes it is

14:28 mi6x3m-alt: I get a classnotfoundexception

14:28 godd2: Bronsa no, it's iteratively appending the elements of [1 2] into [4]

14:29 Bronsa: godd2: and the difference is?

14:30 godd2: [4] is not the same as 4

14:30 justin_smith: godd2: Bronsa: SagiCZ1: the right answer is to use the data structure that can be extended simply and naturally in the direction you need. If you only add on the front use a list, if you need to put things onto both ends use some sort of deque

14:30 tbaldridge: godd2: the point is, that (into [] (cons x [1 2])) is worse than (into [x] [1 2])

14:31 the cons is completely useless

14:31 godd2: tbaldridge it's doing a prepend which is what was asked for

14:31 gfredericks: ~the cons is completely useless

14:31 clojurebot: You don't have to tell me twice.

14:31 Bronsa: godd2: I really don't see your point. (defn foo [x y] (into [x] y)) and you can write (foo 4 [1 2]). who cares how it's implemented? your version does two useless conversions

14:32 tbaldridge: godd2: nope, he said "how to add an element at the beginning of a vector?"

14:32 godd2: Bronsa I didn't say I had a point, you claimed they weren't different.

14:32 SagiCZ1: justin_smith: my vector represents an actual geometric vector and i need to at one place once prepend one to it to increase its dimension.. i dont think i should choose a different data structure just because of that

14:32 Bronsa: whatever.

14:32 godd2: tbaldridge and an element is not the same as a vector containing that element

14:33 llasram: ,(= (into [4] [1 2]) (into [] (cons 4 [1 2])) [4 1 2])

14:33 clojurebot: true

14:33 tbaldridge: true enough

14:33 llasram: Thanks, clojurebot

14:33 godd2: ,(= 4 [4])

14:33 clojurebot: false

14:33 godd2: oh no!

14:34 tbaldridge: so all things considered, SagiCZ1, I would recommend (apply vector x [1 2]) That's most likely going to be the fastest option

14:34 llasram: *plonk*

14:34 SagiCZ1: tbaldridge: really?

14:34 tbaldridge: everything else is going to create extra garbage

14:34 Bronsa: tbaldridge: I would expect into [] to be faster than apply vector TBH

14:35 tbaldridge: Interesting....

14:35 justin_smith: lein do clean, check, eastwood, test

14:35 SagiCZ1: apply vector is almost 3 times faster than into []

14:35 justin_smith: I think I need an alias

14:35 Bronsa: uh, really?

14:35 llasram: mi6x3m-alt: Oh, hey, missed earlier q -- there's a builtin `javac` task

14:35 SagiCZ1: ,(time (dotimes [_ 5000000] (doall (into [5] [1 2]))))

14:35 tbaldridge: Well (into [x] (cons x [1 2])) is completely out, as that both converts to a seq and allocates a cons cell

14:36 mi6x3m-alt: llasram: yeah, the class is generated but I get a ClassNotFoundException

14:36 clojurebot: eval service is offline

14:36 justin_smith: SagiCZ1: how would a clojure vector be more suited for a mathematical vector than a deque would be? just because of the name?

14:36 llasram: mi6x3m-alt: When doing the compile or when trying to load the compiled class?

14:36 mi6x3m-alt: llasram: loading

14:36 tbaldridge: But apply would also convert to a seq, so you may be right Bronsa

14:37 SagiCZ1: justin_smith: havent thought about that honestly, all i know is that when using clojure vector in incanters mathematical matrix operation, it automatically converts it into matrix object correctly

14:37 mi6x3m-alt: llasram: found it, it was a "-" vs "_" issue

14:37 llasram: ah, cool

14:37 Bronsa: tbaldridge: it looks like apply vector is faster for small vectors, but into is faster for bigger ones

14:37 devn: Hmmm, anyone know if anyone has ever discussed passing an assertion message in a :pre or :post condition? Right now it just calls (fn* [c] `(assert ~c))

14:37 I'm looking at you tbaldridge. You think I could sneak that into core? :D

14:37 justin_smith: SagiCZ1: interesting, I would hope that it is using the interfaces and not coding explicitly against the Class, which would mean a deque would work just as nicely

14:37 SagiCZ1: but I don't know incanter so I can't say whether it does

14:38 Bronsa: tbaldridge: not sure if any of this will change with the work for 1.7 though.

14:38 SagiCZ1: list works the same

14:38 idk what deque is or how to make one

14:39 justin_smith: if both vector and list work, deque will. https://github.com/pjstadig/deque-clojure

14:40 SagiCZ1: ,(conj '(4 5) 1)

14:40 clojurebot: (1 4 5)

14:40 justin_smith: a deque is a sequence where insertion and removal from both start and end are efficient

14:40 SagiCZ1: cant i use list?

14:40 justin_smith: I think I mentioned, if you only insert at the beginning, use list, if you only insert at end, use vector, and if you use both use deque

14:40 godd2: SagiCZ1 if you only use list, you cant append efficiently

14:41 SagiCZ1: ok thank you all.. list is sufficient then

14:41 gfredericks: justin_smith: "use deque"?

14:42 godd2: SagiCZ1 it may be a good idea to reverse the meaning of the elements in your list to "convert" it into a vector for design purposes

14:42 aperiodic: though lists are terrible for caches so they can be slower even if they're less work to update

14:42 profile, profile, profile

14:42 SagiCZ1: godd2: i am definitely not reversing anything.. debugging nightmare

14:42 aperiodic: and don't prematurely optimize

14:43 justin_smith: gfredericks: I meant, if you insert or remove at both ends, use a deque

14:43 gfredericks: justin_smith: where would I find one though?

14:43 [blake|: deque-clojure?

14:44 justin_smith: gfredericks: see my link above to deque-clojure, I think that's a good one

14:44 aperiodic: vectors are just as bad for caches as lists in Clojure, and any array that is not a primitive array is nearly as bad, if not as bad as a list

14:44 (on the jvm)

14:45 aperiodic: the jvm isn't very good at the whole "contiguous linear arrangement of data" thing in general

14:46 aperiodic: ah, yeah, chasing pointers is pretty unavoidable on the JVM, ain't it

14:47 stuartsierra: Until we get Value Objects in Java 9 or 10.

14:48 justin_smith: or you could use some wacky ztellman lib, everyone will think you are crazy but your code will be more cache-line friendly

14:48 [blake|: Wow, that Scala talk is =scathing=.

14:49 justin_smith: [blake|: I had to stop watching because I don't like indulging in schadenfreude and was never a scala fan.

14:49 godd2: [blake| link?

14:49 justin_smith: (what I was referring to as a "wacky ztellman lib" above: https://github.com/ztellman/vertigo )

14:50 [blake|: justin_smith: Heh. I have no strong feelings about Scala. Well, I didn't. Now I'm thinking it's the '71 Pinto.

14:50 andyf: justin_smith: I don't understand why you would say that vectors are just as bad as lists. Lists require 2 sequential pointer dereferences for each element, whereas vectors cut it down to about (1+1/32) on average, yes?

14:50 [blake|: godd2: https://www.youtube.com/watch?v=TS1lpKBMkgg

14:50 dnolen_: justin_smith: vectors would be a lot slower if what you said was true

14:51 justin_smith: andyf: but they can't hold primitives, so you still need to chase down the actual Object. So yeah, closer to an array, but still not linear.

14:51 godd2: [blake| thank you

14:51 justin_smith: dnolen_: OK, I should have been a bit more careful in my wording, yes

14:51 tbaldridge: <rant> I found it funny that half the issues mentioned in that scala talk exist due to static typing </rant>

14:52 or improper mapping of common collection operations to static types

14:52 justin_smith: tbaldridge: can you elaborate on the latter?

14:53 [blake|: tbaldridge: Heh. Check out the TypeScript spec some time.

14:54 tbaldridge: Not much to elaborate on, except that I don't think Haskell suffers from these same collection issues (I could be wrong, I don't know Haskell).

14:54 andyf: tbaldridge: seems like the other half are about issues with mutability

14:55 tbaldridge: yeah, that too

14:55 Who on earth unifies a mutable and immutable API?

14:55 stuartsierra: As I recall, a big part of the problem is trying to capture both mutable and immutable collections in a common type hierarchy.

14:55 [blake|: andyf: Yeah, I'm struggling to understand how you combine immutability with object hierarchies.

14:57 tbaldridge: I just remember seeing the "this is how map is defined" and thinking that it was quite ugly compared to the F# version: http://msdn.microsoft.com/en-us/library/vstudio/bb548891(v=vs.100).aspx?cs-save-lang=1&cs-lang=fsharp#code-snippet-1

14:58 romain_: dnolen_: saw your message on twitter about clojurescript low-hanging fruit. Would you be willing to coach a newcomer on working on a CLJS issue, e.g. CLJS-931?

15:02 dnolen_: romain_: sure thing, that is fairly straightforward ticket. We just to need to extend the first comment line to include build options

15:03 romain_: so something like // Compiled by ClojureScript 0.0-2511 : #{:static-fns, :elide-asserts}

15:04 romain_: currently only emitting // Compiled by ClojureScript 0.0-2511

15:04 romain_: dnolen_: OK, actually I tried doing this on a second line

15:04 dnolen_: romain_: lets just keep it on the same line, then we need to helpers in cljs.util for extract this EDN set

15:04 romain_: The thing is, I don't know how to test my patch, I am a bit at a loss with the scripts dir.

15:05 dnolen_: romain_: there's a test directory with compiler and analyzer tests

15:05 romain_: you could make a test .cljs file, compile it, change the settings, compile it again and the modified time should be different

15:05 romain_: one test should not change the setting and the modified time should be the same

15:06 romain_: you can run all tests with `lein test`

15:06 romain_: dnolen_: also, should it output all build options or just the ones that may affect compilation results?

15:07 dnolen_: romain_: only the ones that affect, they are listed on the ticket, there's only 3 for now

15:07 romain_: dnolen_: OK, will try; then submit on JIRA?

15:08 dnolen_: romain_: yes attach a patch to JIRA, make sure to send in your CA

15:08 romain_: http://clojure.org/contributing

15:08 romain_: dnolen_: great

15:16 [blake|: Any pointers for deploying a Clojure WAR to Amazon? Blog post, book, video, whatever?

15:17 justin_smith: [blake|: by the time it's a war, it's just drop-in, identical to deploying a java war

15:17 it's really not even complicated enough to need a book or video

15:17 you tell amazon to deploy your war, and if it's properly packaged, it just works

15:18 [blake|: justin_smith: Yeah, I figured. I'll go that route.

15:20 justin_smith: [blake|: that's a big part of why elasticbeanstalk is expensive, once you have a working war, it's pretty simple

15:23 stuartsierra: Elastic Beanstalk only costs what the underlying compute/storage resources cost.

15:35 justin_smith: stuartsierra: oh? I had a lead claim he was switching from beanstalk to ec2 for a cost savings, but maybe there was another factor being left out

15:36 stuartsierra: http://aws.amazon.com/elasticbeanstalk/pricing/

15:36 Not sure if that was always true.

15:36 justin_smith: oh wow, 100% identical

15:37 so either my lead was misinformed or this is new, clearly, thanks for the correction!

15:37 llasram: I believe you do end up paying for ELB, even for tiny/prototype applications where you don't need it

15:37 stuartsierra: justin_smith: I vaguely recall that there was a small add-on charge for Elastic Beanstalk at some point in the past.

15:40 joobus: i recall beanstalk being more expensive than ec2 last time i looked into it also.

15:40 [blake|: I was also under that impression.

15:41 justin_smith: it's cool to find out it has ec2 pricing now

15:43 romain_: dnolen_: if I invoke "./scripts/repl" I should be able to (cljs.compiler/compile-file f) right? Right now I just get a NPE from "deref-future"...

15:47 dnolen_: romain_: yes because you need to establish a compiler environment

15:48 visof: hi guys

15:48 is there anybody using aleph?

15:48 ticking_: visof: yeah

15:49 visof: how can i send data to tcp connection?

15:49 (aleph.http/tcp-client {:host "example.com", :port 10001})

15:49 ticking_: how can i send data to this connection

15:49 romain_: dnolen_: ah OK, thanks

15:50 dnolen_: romain_: look at the analyzer tests for examples

15:51 ticking_: visof: from the other side of a tcp connection

15:51 visof: it'sbeen a while since I wrote the cod eusing aleph let me check a sec

15:51 visof: ticking_: i'm waiting thanks

15:51 TimMc: netcat? :-)

15:52 ticking_: visof: aleph does not work on its own you also need lamina which handels the channel manipulation

15:52 atratus: @dnolen im trying to setup node repl on windows, self-compile fails, unable to find main class clojure.main

15:52 tried repl.bat too, same

15:52 ticking_: aleph is build on top of lamina which provides channels, and provides different network connections on top of that

15:53 visof: you want lamina.core/enqueue

15:54 visof: ticking_: i guess doing this using java.io.Socket is more simpler

15:54 ticking_: have you tried using java.io.Socket?

15:55 ticking_: visof: not nessecarily

15:56 visof: yeah, but aleph really shines when using it together with gloss

15:56 visof: ticking_: i just want to send data to socket even without waiting to recieve it

15:57 so future + sending to socket are going to be fast enough

15:57 ticking_: ztellmans binary parsing dsl

15:57 makes manipulating bytestreams as pleasant as in erlang

15:57 visof: gloss can encode and decode

15:57 visof: its not about speed but remaining sane when dealing with complex byte formats

15:57 which a tcp connection almost always requires

15:57 visof: .getbytes is enough?

15:58 ticking_: hm?

15:58 llasram: visof: This is just a for-fun project, messing around with sending data over TCP, yes?

15:58 visof: llasram: what do you mean?

15:58 llasram: Oh, nm, you brought up aleph

15:58 I was trying to better-understand what you're trying to do

15:58 visof: clojure docs is down

15:59 is there another way to check clojure docs

15:59 i want to read about reader/writer

15:59 llasram: If you're trying to learn how to do lower-level network programming (at least so far as the JVM allows), then aleph is not going to be helpful :-)

15:59 visof: why always clojuredocs is down

15:59 andyf: visof: Try conj.io

16:00 but clojuredocs.org is up

16:00 romain_: dnolen_: so something like (e/with-compiler-env (e/default-compiler-env) (c/compile-file "hello.cljs"))

16:01 dnolen_: romain_: yep

16:02 visof: andyf: https://clojuredocs.org/clojure.java.io/reader

16:02 andyf: visof: That link works fine for me. You aren't getting anything?

16:03 visof: yeah

16:03 andyf: what browser you are using?

16:03 andyf: i got this http://sprunge.us/XBAG

16:04 andyf: firefox. Also tried Safari with no trouble.

16:04 visof: chrome complain

16:04 guys can any chrome users test this?

16:04 llasram: works fine for me

16:04 tephra: fine for me

16:04 visof: god so what is the problem

16:04 andyf: web proxy between you and there, maybe?

16:05 visof: andyf: every website works for me fine

16:05 atratus: Error code: ERR_SSL_VERSION_OR_CIPHER_MISMATCH

16:06 tephra: visof: are you on XP?

16:06 andyf: perhaps Chrome is more strict in what versions of SSL it allows, to avoid a bug in an older SSL version?

16:08 visof: tephra: i'm using fedora

16:08 andyf: maybe

16:08 i'll try in firefox

16:08 tephra: visof: hmm me to, chrome 40.0

16:08 andyf: freshly installed Google Chrome on Mac OS X 10.9.5 works for that clojuredocs.org location

16:09 visof: firefox complain with this http://sprunge.us/LUIS

16:10 andyf: what country are you in? :)

16:10 visof: andyf: Egypt

16:10 andyf: blocking/intercepting SSL?

16:10 visof: andyf: i don't know

16:12 andyf: visof: Maybe some help here: http://forums.mozillazine.org/viewtopic.php?f=38&t=2301041

16:13 I don't have detailed knowledge here -- just did a search on a keyword in the error message.

16:14 EvanR-work: is there an idiomatic "either" data type

16:14 [:left 3] [:right 3]

16:14 amalloy: EvanR-work: not really

16:14 ticking_: weird when I use the chestnut browser repl to manually transact! on an om cursor, the render loop assertion "Cannot manipulate cursor outside of render phase" will fail, yet the transaction will succeed

16:19 dnolen_: ticking_: that stuff is gone from 0.8.0-betas

16:19 the checks

16:19 ticking_: dnolen_: ah thanks :)

16:20 llasram: EvanR-work: Using a vector like that is the closest you get. There was even a talk at the Conj this year advocating it :-)

16:20 EvanR-work: heh

16:20 i decided against it

16:20 llasram: EvanR-work: Well, in case you change your mind https://www.youtube.com/watch?v=ZQkIWWTygio

16:21 EvanR-work: i did {:left foo} {:right bar} instead, so you cant accidentally ignore the tag

16:22 ticking_: dnolen_: btw, something I never quite got, literals passed to om/root will also be wrapped into a cursor right?

16:22 * EvanR-work watches the video

16:22 dnolen_: ticking_: no

16:23 ticking_: dnolen_: really? hm weird transact! seems to work even though I passed in a literal

16:23 augustl: the function > seems to want to convert things to numbers, it doesn't use comparable. How do I compare two comparables in clojure?

16:23 I happen to be using Joda DateTime instances

16:24 Mosterd: Which ide to use if you are a vim refugee who doesn't understand emacs? Is there a nice editor such as Spyder or python-notebook which I both like to recommend to python users who don't understand vim?

16:24 hyPiRion: hrm, compare?

16:24 ,(compare [1 2] [1 3])

16:24 clojurebot: -1

16:24 romain_: dnolen_: the build options are passed as 'opts' to compile-file right? Or should I also look at the compiler environment...?

16:25 llasram: ,(compare [1 2] [3])

16:25 clojurebot: 1

16:25 atratus_: mosterd: light table integrates ipython pretty well

16:25 dead simple

16:25 llasram: I do think at times that `compare<`, `compare>` etc would be nice

16:26 dnolen_: romain_: opts is the right thing

16:26 augustl: llasram: yeah that would have been nice :)

16:26 scottj: Mosterd: cursive for intellij or gorilla repl maybe

16:26 Mosterd: atratus_, wait that's even written in clojure, that might be great

16:26 hyPiRion: llasram: me too, esp. when working with max-key and min-key

16:26 kenrestivo: so just confirming, async/go-loop will spin of a jvm thread on a jvm, correct?

16:26 romain_: dnolen_: great, so I have a patch but no tests yet. Any ideas or where to put those? And how to design them?

16:27 stuartsierra: Mosterd: perhaps one of Cursive (IntelliJ), Nightcode, Light Table

16:27 atratus_: mosterd: clojurescript but yeah it handles clojure ootb

16:28 it handles ipython just as it does the clojure 'instarepl', with inline graphs and all that

16:28 llasram: hyPiRion, augustl: Sounds like a job for a new tiny library!

16:29 andyf: augustl: (< (compare a b) 0) instead of (< a b), for example. Use <=, >= , or > instead of < as desired.

16:29 Mosterd: It's a desktop program written in javascript?

16:29 atratus_: yep

16:30 hyPiRion: llasram: I'll delegate that work to you

16:30 Mosterd: Hmm, I must have lived under a rock for a while

16:30 augustl: as if date comparisons wasn't hard enough to read as it is :)

16:30 hyPiRion: Although to be fair, it seems to be very little work for rather nice functionality (when you need it).

16:31 atratus_: it uses node webkit & codemirror

16:31 ticking_: dnolen_: yeah they do :P (if (satisfies? IAtom value) value (atom value))

16:31 atratus_: scripted with cljs

16:32 llasram: ,(let [comparize #(%1 (compare %2 %3) 0)] (map (partial comparize < [1 2]) [[1] [1 2] [1 2 3]]))

16:32 clojurebot: (false false true)

16:32 dnolen_: ticking_: that's root, values are not wrapped in cursorss

16:32 ticking_: yes we always wrap the root, but components can take regular values

16:32 ticking_: dnolen_: ah sorry miscommunication then

16:32 dnolen_: they don't need to be cursors

16:33 ticking_: dnolen_: what I meant was when they get wrapped into an atom anyways and thus turned into a cursor, why have atoms in the first place? Changes to the atom won't be send to tx-listen and cause global rerendering which means one should never manipulate the atom anyways

16:33 dnolen_: romain_: put them in tests - make a test dummy .cljs file you check in that the tests run against, the tests can write to a temp directory and check last modified

16:34 ticking_: there are reason to change the atom directly that don't have anything to do w/ components - history stuff etc.

16:35 ticking_: dnolen_: why not expose the cursor directly (def app-state (cursor foo)) this way it is accessible for transact! calls without having to pull it out of a component call

16:35 justin_smith: Mosterd: vim refugee? if you want to still use vim, why not fireplace?

16:36 dnolen_: ticking_: because cursors aren't atoms - I continue to be skeptical

16:36 ticking_: anyways I would use Om on something non-trivial before thinking too much about how to do it differently

16:37 "skeptical that they should act and look like atoms, they hold atoms"

16:37 ticking_: dnolen_: I was just wondering for the reason, because I found myself never accessing the atom directly because it is so incompatible with many om features

16:38 dnolen_: ticking_: changing the app state globally

16:38 ticking_: dnolen_: it should fire a global tx-listen then though :D

16:39 dnolen_: ticking_: there's problems with :tx-listen, likely it will work differently in the future

16:39 mi6x3m-alt: llasram: everything works perfectly, thanks for showing me the one true path =)

16:40 llasram: mi6x3m-alt: np! I keep meaning to write a blog post about it...

16:40 So much time, so little to do

16:40 mi6x3m-alt: well it's so simple it's remarkable

16:40 never use gen-class :D

16:40 llasram: heh

16:40 mi6x3m-alt: when you need a java class

16:40 it will end up in one of these ancient chinese booklets of wisdom, I tell you

16:41 "best DSL for java code is java"

16:41 llasram: I did a short talk for the Atlanta Clojure meetup which included pretty much that -- bullet points of: "reify: when you need this", "proxy: when you need that", "gen-class: NEVAR"

16:41 xemdetia: was that the whole talk?

16:41 Mosterd: justin_smith, perhaps, but I don't know. For some reason I prefer the repl to be in a different window.

16:42 xemdetia: then copious applause?

16:42 gfredericks: llasram: what about for a simple -main? use java instead?

16:42 or some plugin that does that

16:42 mi6x3m-alt: well gfredericks -main is really the only exception

16:42 where this madness actually makes sense

16:42 gfredericks: oh so NEVAR-except

16:43 llasram: gfredericks: that might be the exception, but I've found it very rare that I can make do with just an executable JAR that I don't even use it for that myself

16:43 mi6x3m-alt: well my math prof. defined infinity as "all cases except for finitely many"

16:43 ticking_: dnolen_: I'm intrigued, yet a bit scared as a lot of code I just wrote depends on tx-listen ;)

16:43 mi6x3m-alt: this includes the exceptions

16:43 llasram: mi6x3m-alt: nice

16:43 borkdude: in clojure when I use a library that exposes a BufferedImage, do I need to import this class to be able to work with it?

16:43 gfredericks: mi6x3m-alt: I think that's "almost all"

16:44 dnolen_: ticking_: any changes will be delayed until till 0.9.0 and there will be some sort of upgrade path

16:44 clojurebot: excusez-moi

16:44 Mosterd: justin_smith, I have used tmux before but then I still miss features such as better autocompletion and identation and such, so that's why I'm looking at different editors

16:44 mi6x3m-alt: gfredericks: well now, I do think we both understand what llasram is saying ;)

16:45 llasram: xemdetia: Well, there was a bit more :-) -- I actually still have the slides up http://static.platypope.org/interop/#/

16:45 bacon1989: tmux is an editor now?

16:46 gfredericks: mi6x3m-alt: yes but I'm physically incapable of not being pendantic about infinity

16:46 bacon1989: man, it's gotten featureful

16:46 llasram: Oops meant http://static.platypope.org/interop/#/17 in particular

16:46 mi6x3m-alt: gfredericks: professional condition? :)

16:47 xemdetia: that is a very pretty slide deck

16:47 llasram: xemdetia: It's just a default theme of <digging for link> I can take 0 credit

16:48 Mosterd: bacon1989, nope, but there is a vim plugin that can send code that has been selected in vim to tmux which works if you manually started a lein repl in that tmux session

16:49 llasram: xemdetia: Ah, Reveal.js: http://lab.hakim.se/reveal-js/#/

16:49 xemdetia: v. cool regardless :)

16:51 borkdude: I get an exception Unable to resolve classname: BufferedImage, compiling:(recipes/controllers.clj:14:41) on this line: resized (imagez/resize img (min (.getWidth img) 1024)), imagez is the core namespace from this library https://github.com/mikera/imagez/blob/develop/src/main/clojure/mikera/image/core.clj

16:51 adding (:import [java.awt.image.BufferedImage]) to my ns decl doesn't help

16:52 brb

16:52 devn: Asked this earlier, but I'd be curious to know if anyone knows anything before I look into it any further

16:52 has anyone discussed passing an assertion message in a :pre or :post condition? Right now it just calls (fn* [c] `(assert ~c))

16:53 borkdude: that sounds familiar actually

16:56 tephra: visof: did you resolve the issue?

16:56 stuartsierra: devn: I know it's been discussed somewhere, maybe on a mailing list.

16:56 devn: stuartsierra: any idea whether it's out of the question, or if it's worth making a patch for it?

16:56 stuartsierra: devn: I don't know.

16:57 justin_smith: devn: I would use :pre much more if it allowed custom messages

16:57 devn: stuartsierra: fair enough. thanks for the reply either way. i'll try and hunt it down.

16:57 EvanR-work: llasram: well that was refreshing and convinced me to go with my original idea, and somehow to ignore my original worry that someone will just do let [[_ x] foo] and bypass the safety

16:58 (mainly me)

17:01 andyf: devn: Maybe this discussion: https://groups.google.com/forum/#!searchin/clojure-dev/precondition/clojure-dev/i7pijgFaa0I/MPVOCgeRO4YJ

17:02 SagiCZ1: hi, i need to achieve something like this

17:02 ,(let [data [:a :b :c]] (for [e data] [e (remove #{e} data)]))

17:02 but... not using set

17:02 clojurebot: ([:a (:b :c)] [:b (:a :c)] [:c (:a :b)])

17:03 EvanR-work: apply dissoc?

17:03 SagiCZ1: EvanR-work: i would rather just use the index

17:03 because set operations need to compare the things but the elements could be very expensive to compare

17:04 devn: andyf: ah, yes

17:04 that's better than what i found. thank you!

17:04 andyf: Th-inc nothing of it :)

17:05 devn: seems like this has been brought up on several occasions

17:05 all of the right people were on these ML discussions

17:05 just looks like nothing ever happened with it

17:07 https://groups.google.com/forum/#!msg/clojure-dev/eNK9UZ5HklI/BDa6CDHenWkJ

17:07 andyf: Preconditions are easy to replace with assert's and custom messages on your own. Postconditions not so much.

17:07 devn: *nod*, which I've done

17:07 but it felt kind of odd to me

17:07 im *not* complaining about error messages, to be clear :D

17:08 it would be nice to give myself a nice message in pre/post though

17:08 andyf: A modification of Shantanu's approach looks straightforward to achieve that?

17:08 devn: they feel like a natural place for it, but maybe im overloading them

17:09 agreed, but it also doesn't seem like it'd be that much trouble to work it into fn

17:09 i may be underestimating the work involved, but... it looks like a fair number of people have been interested in this

17:09 borkdude: devn I'm back

17:10 devn: borkdude: i spoke too soon, im not remembering what it was, but did you try (:import (java.awt.image BufferedImage))?

17:10 andyf: Backwards compatibility would be important, I assume. Agreed that coding up a change shouldn't be a lot of work. Go for a ticket, if you feel so moved.

17:11 devn: andyf: yeah of course

17:11 it's smack dab in the middle of fn

17:11 borkdude: devn that was it... syntax

17:12 but still I don't get why I need this import

17:15 anyway, thanks :)

17:18 devn: yw

17:22 ticking_: SagiCZ1: not pretty but it's what you described plus indexes

17:22 ,(let [data [:a :b :c] indexed-data (map vector data (range))] (for [[e i] indexed-data] [e (map first (remove (comp #{i} second) indexed-data))]))

17:22 clojurebot: ([:a (:b :c)] [:b (:a :c)] [:c (:a :b)])

17:23 ticking_: vectors don't have efficient dissoc afaik so this is a lot harder

17:23 SagiCZ1: i did this in the end

17:23 (let [data [:a :b :c]]

17:23 (for [[e i] (map list data (range (count data)))]

17:23 [e (remove-elem data i)]))

17:24 where remove-elem removes the element at index i in vector data

17:24 justin_smith: ticking_: there is no dissoc for vectors

17:24 gagangowda10: I am really new to clojure

17:24 amalloy: SagiCZ1: that sounds pretty expensive. you are iterating over the list a lot of times

17:25 SagiCZ1: amalloy: over the data list? how so?

17:25 gagangowda10: in fact I was going through the website and found this line

17:25 reactive Agent system that ensure clean, correct, multithreaded designs

17:25 ticking_: justin_smith: yeah, pitty, but I suppose the trie thing doesn't really lend itself to it

17:25 amalloy: i mean, remove-elem walks over the entire list of N elements, and you call it N times

17:25 justin_smith: ticking_: finger-trees do it nicely though

17:25 gagangowda10: I understand the concept of reactive agents, but how is it implemented in clojure, any insight about this?

17:26 SagiCZ1: amalloy: remove-elem concatenates two subvectors .. before and after the remove element

17:26 gagangowda10: like conceptual information on how clojure uses this

17:26 justin_smith: SagiCZ1: this is something that exists?

17:26 SagiCZ1: no

17:26 its something that.. hellofunk wrote for me the other day i think

17:27 (fn [v i] (vec (concat (subvec v 0 i) (subvec v (inc i)))))

17:28 gagangowda10: nvm got it

17:28 justin_smith: yeah, that walks the whole vector - a finger tree would handle that much better

17:28 gagangowda10: what was the answer?

17:29 "Clojure's Agents are reactive, not autonomous - there is no imperative message loop and no blocking receive. The state of an Agent should be itself immutable (preferably an instance of one of Clojure's persistent collections), and the state of an Agent is always immediately available for reading by any thread (using the deref function or reader macro @) without any messages, i.e. observation does not require cooperation or coordination."

17:29 http://clojure.org/agents

17:29 SagiCZ1: never heard of finger tree.. anyways.. although clojure is very data oriented.. i feel like its very hard to manipulate data in it in some ways i needed lately.. so strange

17:30 justin_smith: SagiCZ1: the function specified above works, it's just that as amalloy notes it is doing more work than would be optimal.

17:31 SagiCZ1: i understand that and i am not going to optimize it, because it works on a very small number of elements.. (dozens at most)

17:31 maybe the feeling i have is because i naturally started to avoid manipulating indexes, but sometimes it feels like there is no other way.. for example the thing i needed couple minutes ago

17:33 ticking_: SagiCZ1: whats the data that you have so little of it, yet a comparison operation is too expensive, if I may ask :)?

17:34 SagiCZ1: ticking_: clusters of points.. so i have lets say five clusters.. each with hundreds of thousands points

17:35 ticking_: SagiCZ1: ah yeah point clouds suck

17:36 arohner: I remember someone proposing adding :let [foo bar] to the inside of a cond clause a while back. Did that macro ever get written in a public place?

17:37 jcromartie: error in process sentinel: Could not start nREPL server: /bin/bash: lein: command not found

17:37 but it definitely should be found

17:37 arohner: aha: http://clj-me.cgrand.net/2011/06/17/a-flatter-cond/

17:38 ticking_: jcromartie: needs more input

17:38 jcromartie: I just updated to Yosemite, and cider-jack-in fails with that error

17:38 I've set my exec-path

17:38 ticking_: jcromartie: have you tried reinstalling leiningen?

17:38 jcromartie: to include /usr/local/bin, where lein lives

17:39 I can run lein from the terminal

17:39 no problem

17:39 ticking_: brew install lein

17:39 arohner: jcromartie: are you starting Emacs from the dock?

17:39 nullptr: yeah, your PATH is probably messed up -- they change the way that works every release, seemingly

17:39 it's infuriating

17:40 arohner: jcromartie: Emac's path is goofy, because the OSX 'window manager' doesn't use .bashrc, .profile, etc stuff

17:40 nullptr: i've given up and start Emacs exclusively from terminal now

17:40 jcromartie: yeah, I understand that

17:40 ticking_: reinstalling command line utils after os x upgrades can also sometimes do the trick

17:40 jcromartie: but I've explicitly put /usr/local/bin on the Emacs PATH and exec-path

17:40 but yeah

17:41 probably some weird OSXism

17:41 yeah

17:41 I'm reainstalling homebrew right now to start with

17:41 (somewhat unrelated... BTW I had not removed /usr/local/bin before trying cider-jack-in)

17:47 justin_smith: jcromartie: how have you explicitly put those in the Emacs PATH?

17:48 jcromartie: (add-to-list 'exec-path "/usr/local/bin")

17:48 (setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH")))

17:49 derp

17:49 just added that ":" to the (setenv "PATH" ...) and that was it

17:49 justin_smith: that fixed it?

17:49 jcromartie: it wasn't there before

17:49 yeah

17:49 justin_smith: hah, there you go

17:50 jcromartie: I hadn't used (setenv "PATH" ...) at all before Yosemite

17:50 justin_smith: I had never heard of this "exec-path" var, I always used setenv

17:50 jcromartie: but yeah

17:51 every time OS X is updated, the PATH setting method changes :P

17:51 justin_smith: ahh, exec-path is just for subprocesses, I don't know if cider uses the proper "subprocess" infrastructure or not...

17:51 nullptr: i don't believe so -- setting exec-path has not been sufficient in the past

17:52 justin_smith: yet another weird thing about cider I guess

17:53 [blake|: I've got this uuencoded PNG passed back from the front end of my app and I'd like to save it as a PNG on the server. I was trying to use clojure.data.code.base64, but it wants a byte-array.

17:56 nullptr: (inc jcromartie)

17:56 lazybot: ⇒ 8

17:56 justin_smith: [blake|: and you have what, a string?

17:56 ,(.getBytes "hello")

17:56 clojurebot: #<byte[] [B@20b2d772>

17:56 amalloy: uuencoded? i didn't know uuencode was still much used

17:56 [blake|: justin_smith: Yeah. I can map it to a byte array but...I'm concerned I'm doing something fundamentally wrong.

17:57 amalloy: HTML5's canvas.toDataURL() returns a base64 uuencoded PNG. (I think.)

17:57 justin_smith: [blake|: .getBytes is O(1) afaik, it is a data cast not a transform iirc

17:57 EvanR-work: i usually use md5 for encoding

17:57 Frozenlock: Interesting... I wasn't aware there were plans to 'replace' cljx https://groups.google.com/forum/#!topic/clojure-dev/6pnIeXFRwnI

17:57 justin_smith: [blake|: that is not the same as uuencoding

17:57 amalloy: [blake|: base64 uuencoded sounds bizarre

17:57 it's like an english spanish sentence

17:57 justin_smith: yeah, I suspect it is just base64

17:58 amalloy: justin_smith: i would be quite surprised if getBytes were O(1)

17:58 justin_smith: oh? doesn't it just return the underlying bytes of the string?

17:59 amalloy: no. even if you call it with the same character encoding as the string actually uses internally, it copies

17:59 [blake|: OK, so there's the first problem. I added UUEncode. =P

17:59 justin_smith: aha

17:59 amalloy: because strings are immutable

17:59 and you can't just hand out pointers to their internals like candy

17:59 justin_smith: right, and it returns something mutable, of course

17:59 stuartsierra: And Java Strings are UTF-16.

18:00 justin_smith: the world of mutability is so strange to me when I get lost in clojure land...

18:00 stuartsierra: ish

18:00 amalloy: and anyway strings actually store a char[], not a byte[]

18:00 justin_smith: right

18:00 amalloy: [blake|: yeah, step 1 is to not involve uuencode at all

18:01 justin_smith: [blake|: you may be able to circumvent your handler and get the bytes from the incoming data directly, but there is always .getBytes as a fallback I guess

18:01 [blake|: amalloy: OK, since I was using clojure.data.codec.base64, I probably didn't actually put any UUEncode in my code.

18:02 I could write out the file as a text and use base64...but that seems cheesy. Might not work on Amazon, either, come to think of it.

18:06 justin_smith: there is no reason to write it to disk before generating the png

18:07 [blake|: justin_smith: It's not my preference.

18:10 justin_smith: whatever drawbacks there are to .getBytes on a String (rather than using the bytes you just got over the network), putting the string in a file in order to get the bytes is worse

18:11 [blake|: I assume I'll be able to work it out without doing that.

18:12 amalloy: it's kinda lame that data.codec requires a byte[]

18:12 jcromartie: [blake| decoding-transfer

18:12 clojure.data.codec.base64/decoding-transfer

18:13 amalloy: jcromartie: he doesn't have streams either

18:13 jcromartie: oh

18:13 it's a request param?

18:13 [blake|: Yeah. It's coming back from the client side.

18:13 justin_smith: yeah, which is why I suggested getting the jump on the default handler in order to get that raw body stream

18:14 that should be possible with a middleware in the right place in the stack

18:14 or did I articulate that? I meant to

18:14 [blake|: justin_smith: You did, and I missed it.

18:15 jcromartie: is there a memory issue or something?

18:15 [blake|: justin_smith: But I'm not sure how it helps.

18:15 jcromartie: because .getBytes should be fine

18:15 justin_smith: [blake|: it gets the body stream, which will directly give you the bytes

18:16 that's a good point too, jcromartie, but I think if what you want is bytes, and that is the initial form coming in, it is silly to let the double conversion happen

18:16 [blake|: justin_smith: Which...oh, okay, so you're saying something on the server side is turning this into a string from bytes?

18:16 jcromartie: if the body of the request is the base64-encoded string, then sure

18:17 [blake|: how is the base64-encoded image being passed to the server?

18:17 POST?

18:17 as a form encoded param?

18:17 or as the entire request body?

18:19 [blake|: As part of the "data" in a JQuery ajax POST.

18:20 jcromartie: as a part of it, or as the whole thing?

18:20 because you can send an object or a strign

18:20 string

18:21 in the former case the JS obj will be sent as form encoded params

18:21 [blake|: It's not the only part, no. There are two parts. So it's &field1=whatever&field2=whatever...&screencap=toDataUrl()

18:21 jcromartie: in the latter it will be the literal POST body

18:21 ah ha

18:21 then I would skip worrying about intercepting the raw request body stream and just decode the (.getBytes (:screencap params))

18:21 well

18:22 the part after "base64,"

18:22 [blake|: jcromartie: Thanks. I'll give that a try.

18:22 justin_smith: jcromartie: yeah, that's actually right, I forgot other stuff would likely be in the body

18:22 (inc jcromartie)

18:22 lazybot: ⇒ 9

18:22 [blake|: I may try later different configurations.

18:22 (inc jcromartie)

18:22 lazybot: ⇒ 10

18:22 jcromartie: you'll need to pull apart the dataURL scheme

18:23 or you can do that in JS

18:35 SagiCZ1: how can i find out if a predicate is true for exactly one element

18:35 amalloy: filter the list with the pred, and check that its count is one via (and (seq xs) (not (next xs)))

18:36 SagiCZ1: amalloy: cool, thanks

18:37 jcromartie: amalloy: nice, works for lazy seqs :)

18:37 amalloy: jcromartie: yes, calling count is a sin

18:37 SagiCZ1: amalloy: wait and what if i dont to return that one elment

18:37 thsi would return true/false

18:38 amalloy: SagiCZ1: who cares? wrap it in boolean if that really matters

18:38 SagiCZ1: *what if i WANT to return that one elment

18:38 amalloy: SagiCZ1: you probably don't

18:38 SagiCZ1: [:a :a :b :a :a :a :a] -- > there is only one :b so return :b

18:38 amalloy: what if the thing for which the predicate passes is falsey?

18:39 SagiCZ1: then idk.. gosh this is hard :(

18:39 amalloy: eg, (one-matches? nil? [1 2 3 nil])

18:39 will return nil, just like (one-matches? nil? [1 2 3])

18:39 SagiCZ1: ok then let it return nil.. thats cool

18:40 TEttinger: but nil is the "value not found" there

18:40 it can't also be "value found" and still be usable

18:40 (for collections containing nil that you want to find nil in)

18:40 SagiCZ1: wait but how do i get to the element still?

18:40 TEttinger: first xs

18:41 SagiCZ1: i need to return the element if there is only one passing that predicate, otherwise return nil

18:42 ,(filter pos? [5 5 6 -1 -2 6 5])

18:42 clojurebot: (5 5 6 6 5)

18:42 TEttinger: ,(let [coll [1 2 3] pred #(= (mod % 2) 0) xs (filter pred coll)] (if (and (seq xs) (not (next xs))) xs))

18:43 clojurebot: (2)

18:43 TEttinger: ,(let [coll [1 2 3] pred #(= (mod % 2) 0) xs (filter pred coll)] (if (and (seq xs) (not (next xs))) (first xs)))

18:43 clojurebot: 2

18:43 TEttinger: ,(let [coll [1 2 3] pred #(= (mod % 2) 1) xs (filter pred coll)] (if (and (seq xs) (not (next xs))) (first xs))) ;; if more than one matches the pred....

18:43 clojurebot: nil

18:44 SagiCZ1: ,(let [coll [1 2 3] pred #(= (mod % 2) 1) xs (filter pred coll)] (if (and (seq xs) (not (next xs))) (first xs)))

18:44 clojurebot: nil

18:45 SagiCZ1: i think this works great

18:45 thank you very much both

18:45 TEttinger: (inc amalloy)

18:45 lazybot: ⇒ 210

18:45 SagiCZ1: (inc TEttinger)

18:45 lazybot: ⇒ 36

18:46 TEttinger: slowly improving that thar karma

18:52 [blake|: What makes "spit" only suitable for small amounts of data?

18:52 tcrayford____: it buffers all the data into a string at once (iirc)

18:53 [blake|: tcrayford____: So, if I had all the data in a string already, I'd have two copies?

18:53 tcrayford____: or potentially you could exhaust the memory of the system

18:53 [blake|: fair 'nuff

18:54 tcrayford____: and the JVM GC doesn't cope all that well with huge objects

18:54 [blake|: tcrayford____: Cool, thx.

18:54 (inc tcrayford____)

18:54 lazybot: ⇒ 1

18:56 TEttinger: (inc tcrayford)

18:56 lazybot: ⇒ 1

18:57 tcrayford____: haha, I've only recently come back to this channel

18:57 last time I was here heavily there wasn't a lazybot

19:00 TEttinger: lazybot's a good one. clojurebot has a better eval though, usually

19:00 amalloy: tcrayford____: lazybot used to be called sexpbot until like...two or three years ago

19:00 TEttinger: ,(def something (map * (range) (range)))

19:00 clojurebot: #'sandbox/something

19:00 TEttinger: ,(take 10 something)

19:00 clojurebot: (0 1 4 9 16 ...)

19:01 amalloy: &(take 10 (map * (range) (range)))

19:01 lazybot: ⇒ (0 1 4 9 16 25 36 49 64 81)

19:01 amalloy: i can see why you'd like clojurebot's better :P

19:01 TEttinger: hehe

19:21 [blake|: bytes are signed?

19:21 gfredericks: so signed

19:22 justin_smith: [blake|: in java, everything is signed

19:22 mfikes: Except for char?

19:22 augustl: -127 is 0, yay

19:22 justin_smith: mfikes: char is not numeric

19:22 hyPiRion: except for the jars themselves

19:22 justin_smith: haha

19:22 gfredericks: ~badum

19:22 clojurebot: Pardon?

19:22 gfredericks: ~goards

19:22 clojurebot: Huh?

19:22 justin_smith: augustl: surely you mean -128

19:23 gfredericks: ~guards

19:23 clojurebot: SEIZE HIM!

19:23 gfredericks: oh thank goodness

19:23 justin_smith: ~gourds

19:23 clojurebot: SQUEEZE HIM!

19:23 gfredericks: yeah speling

19:23 augustl: justin_smith: I must have problems with my cache invalidation and/or naming things

19:24 justin_smith: augustl: the best version of that joke involves blurting "concurrency" in the middle of someone else telling the joke

19:24 gfredericks: there are only fifteen hard problems in computer science: naming things.

19:25 there are only 10 hard problems in THIS IS A JOKE ABOUT BINARY NUMBERS

19:26 justin_smith: gfredericks: aka bumbers

19:27 [blake|: Well, dammit. I was afraid of this. I get my data decoded and written to disk and I can't read the resultant PNG. =(

19:29 gfredericks: (inc bumbers)

19:29 lazybot: ⇒ 1

19:31 dbaston: does anyone know if I can cancel nREPL execution initiated from vim-fireplace? In my attempts to do elegant recursion I seem to be starting lots of infinite loops instead...

19:33 justin_smith: dbaston: https://github.com/tpope/vim-fireplace/commit/286a1f6c47fc0efe017e69c8e862e1433a4b6189 looks like it is supported as of this commit, dunno the keybinding though

19:40 dbaston: justin_smith: Thanks, you're right, and Ctrl-C seems to do the trick. I swear it didn't before now!

19:44 EvanR-work: make sure your elegant recursion includes evidence that it will either terminate or at least continue to produce useful results forever ;)

19:44 elegant evidence* ;)

19:49 dbaston: my mistake is accidentally executing an "iterate" form

19:49 justin_smith: yeah, you usually want to put that inside a take-while or nth

20:03 [blake|: Well, okay, looks like I've been going about this all wrong. I need to render a web-page to disk from the server. Is that a thing? Seems like it should be a thing.

20:08 munderwo: So if I want to build a vector of maps where each element from another sequece is one of the values… how do I do that?

20:08 I tried something like (map #({:foo %1}) list-of-values)

20:09 tolstoy: (map :foo list-of-hashmaps)?

20:09 amalloy: munderwo: try writing it with (fn ...) instead of the #() shorthand

20:09 and then look at what the #() shorthand expands to, noticing the difference

20:09 munderwo: yeah… just worked that out. Its always hard working out when #() will work and when it wont

20:10 amalloy: ,'#({:foo %})

20:10 clojurebot: (fn* [p1__25#] ({:foo p1__25#}))

20:10 amalloy: see how that's different from (fn [x] {:foo x})?

20:10 munderwo: so this does what I want

20:10 (map (fn [x] {:value x}) lines)

20:10 ahh, because the map is in a list so it gets executed… I see

20:11 which doesnt make sense because you cant execute a map..

20:11 justin_smith: munderwo: the easy way (I think) is to remember that #() always invokes its first arg, the first arg to #({}) is {}

20:11 amalloy: #() *always* has parens as the outermost thing

20:11 SagiCZ1: munderwo: you can do #(hash-map :foo %) but its not exactly the same as {:foo .. }

20:11 munderwo: yeah. that makes sense… Its just finding that out :)

20:11 justin_smith: ,({:a 0} :a) ; munderwo

20:11 amalloy: munderwo: well, actually you can call a map as a function, but it doesn't do what you want

20:11 clojurebot: 0

20:11 munderwo: thanks!

20:12 justin_smith: silly way to get {:foo %1}: #({:thing {:foo %1}} :thing)

20:15 amalloy: justin_smith: #(do {:foo %})

20:15 justin_smith: amalloy: that's not nearly as silly

20:15 amalloy: true

20:17 hyPiRion: "#() *always* has parens as the outermost thing" – ahem

20:17 ,((->> :ten #()))

20:17 clojurebot: :ten

20:18 justin_smith: hyPiRion: the parens that follow #

20:18 hyPiRion: ah, alright then

20:19 justin_smith: though I guess that macro displaces what eventually becomes its body...

21:38 charlesgiii: Is there a common way that people connect to the browser repl? I'd like to use vim (+vim-fireplace) to live code like Light Table provides

21:42 scottj: charlesgiii: austin https://cognitect.wufoo.com/reports/state-of-clojurescript-2014-results/

21:50 charlesgiii: scottj, thanks!

22:07 paomian: I have a problem,when i use the core.async,how to get the length of items which in chan

22:07 justin_smith: paomian: take them all and count while you are taking

22:10 paomian: justin_smith: Ok,i means that i don't know the consumer is to many or producer

22:11 justin_smith: I don't understand what you just said

22:11 amalloy: you can't inspect channels except by taking things from them

22:12 paomian: justin_smith: my englist is poor

22:12 I means that i take the chan like a queue

22:13 justin_smith: right, and you can't read or count the values without removing them from the channel

22:14 paomian: justin_smith: ok,i get it

22:14 thank you

22:45 DanielWu:

22:45 (def postgres-db "postgresql://postgres:oracle@localhost:5432/example")

22:45 (j/update! (j/db-find-connection postgres-db) :connector_files {:message_create 1} ["file_id = ?" 10])

22:45 IllegalArgumentException db-spec false is missing a required parameter clojure.java.jdbc/get-connection (jdbc.clj:289)

22:45 What is missing?

22:45 use the same parameter I could run j/query function witout any issue, but if with update, then it failed.

23:06 justin_smith: DanielWu: so it works with no password?

Logging service provided by n01se.net