#clojure log - Jan 03 2013

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

0:00 technomancy: postgres 9.1 with c.j.j 0.2.1

0:00 app is here: https://github.com/heroku/buildkits/blob/master/project.clj

0:00 tufflax: Are there any clojure/conj 2012 videos out? I feel like watching some :P

0:06 ihodes: technomancy: hah, using jdbc:postgresql:database-name works…except that it says that a relation i know exists does not exist.

0:06 yeah this is wild. huh.

0:19 okay

0:19 i figured it out

0:19 needed the right combinations of versions

0:19 and for some reason, can't connect to one of my DBs. not sure yet why.

0:27 Sgeo: technomancy, you know what keeps getting me

0:27 The [ thing

0:27 There's no place where you have to use [ or anything, but stylistically it's suggested

0:27 But I'm still a bit iffy on where it's good style

0:28 [] is (almost. macros can detect the difference if they wish) the same as (), so there's no enforcement of whatever Racket style is

0:29 technomancy: Sgeo: do you see it much in code you read

0:29 ?

0:29 Sgeo: Hm? Yeah, Racket examples are always using []

0:29 Like:

0:29 (let ([a 1] [b 2]) (+ a b)) might be an example

0:30 That's completely equivalent to (let ((a 1) (b 2)) (+ a b))

0:30 technomancy: IIRC allowing [] to be interchangable with () is part of RNRS, right?

0:30 but from what I gather it's not that common in other schemes?

0:30 Sgeo: I'm under the impression that it is Racket specific

0:31 I could be wrong, I guess

0:31 Oh, r6rs does have [] interchangable

0:31 But r6rs is somewhat widely disliked

0:31 technomancy: mostly for pushing racketisms on the wider scheme community from what I gather

0:32 which is understandable; the renaming was probably the only way to keep them from blows

0:33 Sgeo: Huh, wasn't aware of that

0:33 Of pushing Racketisms on the community

0:33 technomancy: r6rs had just been ratified when I was playing with implementing scheme

0:34 from an implementor's perspective it was annoying; more junk I didn't care about

0:34 but from the perspective of "I want to use Scheme to build useful stuff" it's understandable

0:43 Deece: The docs for deliver say that it will throw an exception if i deliver twice to the same promise, but doing so in my repl just returns nil. is this because it's an alpha thing?

0:43 technomancy: ,(doto (promise) (deliver 1) (deliver 2))

0:43 clojurebot: #<core$promise$reify__3678@29b473e2: 1>

0:44 technomancy: huh

0:44 I guess so

0:44 err--I mean it's a bug

0:46 bbloom: ,@(doto (promise) (deliver 1) (deliver 2))

0:46 clojurebot: 1

0:47 bbloom: ,(macroexpand '(doto (promise) (deliver 1) (deliver 2)))

0:47 clojurebot: (let* [G__86 (promise)] (deliver G__86 1) (deliver G__86 2) G__86)

0:47 bbloom: yup seems bugged to me :-)

0:50 amalloy: i think there's a jira issue to update the docs

0:50 the behavior changed in, i think, 1.3? it now returns false if deliver failed, rather than throwing

0:59 ivan: fixed post-1.4 http://dev.clojure.org/jira/browse/CLJ-1038

1:03 was changed to get rid of locks, I assume https://github.com/clojure/clojure/commit/57c5186972c9c0f03d4bb5d2445309f14405e098

1:03 ihodes: technomancy: bam: working. http://copperthoughts.herokuapp.com/ thanks so much :) it looks like i needed to not use korma, and use a particular combination of versions. i'll investigate further later. got a rails app to finish now…

1:04 i think i may be one of the few devs who went clojure -> ruby

1:04 :\

1:04 technomancy: I maintain a big pile o ruby at work

1:05 ihodes: what's your day-to-day like nowadays? if you don't mine my asking

1:05 sounds like a cool place to work!

1:05 technomancy: I work on the git push pipeline at heroku primarily

1:06 I work on lein maybe 20-25% of the time

1:06 problem is the adapter between lein and the heroku runtime is so small it's not enough to keep me busy

1:06 ihodes: ah, interesting

1:06 i use your work a lot…

1:07 actually, for the past 3 or 4 years

1:07 i'm either using lein

1:07 or pushing to heroku

1:07 so, thanks, a lot

1:07 technomancy: well I didn't write much of the git stuff; just keeping it running and experimenting with ways to replace some of the legacy bits

1:09 ihodes: how big is that codebase?

1:09 if you don't mind my asking

1:10 technomancy: looks like around 3kloc

1:10 that's not including the individual buildpacks for each language, but I don't have to touch those that often

1:10 ihodes: yeah

1:11 technomancy: so just a bit bigger than lein =)

1:12 ihodes: haha

1:12 amazing how so little code can keep people so busy

1:13 but considering how long i've spent on a few lines of code before

1:18 miql: Just barely started using lein and heroku, so thanks, too!

1:20 Raynes: technomancy is singularly responsible for the 10 hour downtime refheap had recently.

1:20 That's the way I see it.

1:21 technomancy: (when (= (System/getenv "USER") "Raynes") (System/exit 255))

1:22 Raynes: !

1:24 ivan: [hickory.zip :refer [hickory-zip]]

1:24 [clojure.zip :as zip]

1:24 [me.raynes.laser.zip :as lzip]

1:24 that's a lot of zips

1:25 Raynes: Bahahaha

1:25 Laser is pretty zippy, for sure.

1:25 bbloom: zippy? or is it ZAPpy!?

1:25 * bbloom is pleased with his pun

1:26 Raynes: hickory-zip gets me a zipper over a hickory representation of HTML, zip gets me normal zip functions (obviously) and lzip is stuff for post-order zipper walking.

1:27 I like zippers, you see.

1:27 I'm just sad I can't find undergarments with zippers.

1:33 aphyr: Is it just me, or is incanter's API... weird?

1:33 technomancy: aphyr: it's weird

1:33 Raynes: I heard it sing White and Nerdy recently.

1:33 It's pretty weird.

1:33 aphyr: OK. After 8 hours of trying to wrap my brain around it everything is looking a little questionable.

1:34 actually eight nested maps involved in turning... a few integer arrays into a chart

1:36 Raynes: aphyr: http://cdn.memegenerator.net/instances/400x/32826812.jpg

1:36 I was going to do that and be all smug, but it covered up half of his face.

1:36 :(

1:37 aphyr: https://www.refheap.com/paste/8050

1:38 it's like wandering through a mansion with a flashlight... whenever I look at a function's docs it makes sense, but I have no idea if there are giant rooms full of the stuff I need

1:41 Raynes: aphyr: We should go haunted house touring together.

1:41 You sound like the kind of guy I could take a liking to.

1:43 aphyr: haha well I'm really excited about getting graphs out of it! :)

1:43 just a little puzzled on the way there

1:44 building a tool to do things like "tell me the difference in performance between two git commits of a project"

1:44 basho-bench in erlang, kinda

1:45 technomancy: I kept meaning to write a lein plugin that would record that kind of data during CI runs back when I was working on a large project on a daily basis

1:48 aphyr: ... wait there's such a thing as haunted house touring?

1:48 if so I am totally in

1:49 aaelony: aphyr: do you prefer incanter charting to d3 and (clj)js? what about stuff like this… http://bl.ocks.org/mbostock ...

1:49 Raynes: aphyr: They give tours of some places. Others are existing hotels or bed and breakfasts that we could just stay at.

1:50 aphyr: mbo is cool! Doesn't really matter to me, I just want to get some pngs out of it

1:50 Raynes: curiosity piqued

1:51 Do we have to stay long enough for the furnace fumes to cause us to hallucinate?

1:51 Raynes: I think we do.

2:14 aphyr: (record {:name "sleep 10" :f #(Thread/sleep 10) :n 1000 :threads 10}))

2:14 http://aphyr.com/media/latency.png

2:15 muhoo: i suspect this code is hideous: https://www.refheap.com/paste/8051

2:16 so i'm offering it here for amalloy to point that out.

2:16 amalloy: what the hell is this?

2:17 muhoo: hahahaa

2:17 amalloy: trans-fifo is some kind of mutable holder for dates, and you're spin-polling it?

2:17 muhoo: it's my miserable attempt at trying to block waiting for a new thing to be added to a queue

2:18 new, meaning after the "bench" date.

2:18 amalloy: https://github.com/flatland/useful/blob/develop/src/flatland/useful/state.clj#L54

2:19 aphyr: ahem: OOOH

2:19 squirreling that away, can't count how many times I've written something like this

2:19 muhoo: the top level is: there's a callback in another thread dumping stuff into that fifo. there are multiple threads each waiting for something "new", which locally means after they ask, to be added

2:19 amalloy: wow, that's cool, thanks

2:20 * muhoo rewrites

2:22 amalloy: that code is the one time i've used promises for a good reason

2:23 Raynes: muhoo: I recorded Over My Head by The Fray earlier. I'm in windows or I'd throw it at you.

2:23 Ember-: muhoo: also if you have a slightly easier situation you could just use seque http://clojuredocs.org/clojure_core/clojure.core/seque

2:26 ejackson: still hating on us old folks, eh Raynes ?

2:27 Raynes: ejackson: Speak up, gramps, can't hear you.

2:28 amalloy: i think usually it goes the other way

2:29 ejackson: what's that sonny, into my good ear !

2:29 Raynes: amalloy: That was kind of the joke. I suck at humor.

2:30 amalloy: We were making jokes about how me turning 19 = one foot in the grave this morning.

2:30 amalloy: i remember you having a brief bout with ejackson but i must have missed that part

2:32 muhoo: Raynes: kewl, i should set up my lurking irssi again so you can

2:32 Ember-: i started up with sequeu, but this wait-until is perfect

2:33 https://www.refheap.com/paste/8052 ... i'ma see if i can get it down to 3 lines

2:35 https://www.refheap.com/paste/8053 close enough

2:36 amalloy: muhoo: well, there's an easy one-line shrink that would also improve your correctness. instead of (wait-until ...) (dw @x), write (dw (wait-until ...))

2:36 muhoo: amalloy: cool, will try. thanks again. this is just fantastic

3:24 ebaxt: I'm moving my application off webnoir (since it's deprecated), is ring.middleware.reload the preferred way to reload without restarting?

3:29 bbloom: do protocols support type hints? or do i need to use definterface?

3:31 Sgeo_: Protocols create interfaces, don't they?

3:32 bbloom: Sgeo_: I'd assume so

3:33 i guess it doesn't matter... since a protocol compiles to a cast, followed by an interface dispatch

3:34 i'm experimenting with some opengl stuff and i really wish i could just generate specialized code paths for every different type of vertex that i want to pump through the system

3:35 but then i'd need to write pretty much my whole library inside some giant macros.... which may actually make sense

3:35 i basically want multi-type-hints

3:35 "recompile this function once for each of these types"

3:36 which i suppose java does under the hood

3:36 but i don't trust it at this level

3:39 dbushenko: is there a way to ahead-of-time compile records and protocols?

3:39 bbloom: hm, i don't know much about ahead-of-time compilation in clojure... i guess i should read up on it

3:40 i kinda always equated that with generating named classes for use by java interop

3:40 dbushenko: that's not an answer for your question, that's just my question too :-)

3:40 I would appreciate if there was a way to aot-compile my records

3:41 bbloom: heh

4:00 tsdh: Is there a way to use multimethods dispatching on type if the type of an objects isn't manifested in its class? Basically, I need something like (defmulti foo class), but with my own class and isa? functions.

4:06 I mean, I could use `make-hierarchy' and `derive' to convert the custom type hierarchy of the objects to a hierarchy suitable for isa?, but it doesn't feel right to duplicate that information...

4:06 ejackson: tsdh: sounds doable. Just use your the guts of your isa as the dispatch fn in your multi.

4:07 so long as you have a fn that can descriminate your types, you're golden.

4:10 tsdh: ejackson: Well, I have a function (has-type? obj type), but I don't see how that helps me.

4:11 ejackson: you have a function that given an instance of your type returns a value that identifies it ?

4:12 tomoj: but you also need to set up a hierarchy?

4:12 tsdh: ejackson: Well, yes. But if it returned Foo, a method defined for SuperTypeOfFoo should trigger if there's no method for Foo itself.

4:13 tomoj: where is the information of the type hierarchy now?

4:13 ejackson: i see, trickier.

4:13 tsdh: tomoj: The hierarchy is basically there. For every object, (.getType o) returns its type and for these types I have (.isSuperType t1 t2) and friends.

4:14 tomoj: but where? in java code?

4:14 tsdh: tomoj: Yes.

4:14 tomoj: my condolences

4:15 tsdh: So if I could replace isa? with my own function, it'd be very easy.

4:15 ejackson: can you expose a method in those java objects that returns their type/super-type ?

4:15 tomoj: I guess you could write a macro to which the input is a list of all the types

4:16 if the number of types squared is not very large, the macro could go through every pair and check .isSuperType

4:16 then emit the necessary derives

4:16 not sure why you'd want to do that though..

4:17 tsdh: tomoj: Yes, that would be possible, but I don't want to convert an existing hierarchy to another one. So probably I take the multimethods implementation and change it to my needs.

4:18 ejackson: As said, they already have these methods.

4:19 ejackson: why can't you use them to dispatch ? (sorry if that's a stupid question)

4:21 (defmulti mm [x] (.my-type-or-super-type x))

4:21 * ejackson clearly missed something

4:22 tsdh: ejackson: Because multimethods use the function isa? to compare the defmethod dispatch-val with the value returned by the dispatch function. Instead of isa?, I'd need my own isa? that known about the type hierarchy of the objects.

4:22 ejackson: that way you can get the java hierarchy to do the inheritance dance for you

4:23 bbloom: tsdh: you could patch my use my dispatch-map project to support custom isa?

4:23 tsdh: https://github.com/brandonbloom/dispatch-map

4:24 https://github.com/brandonbloom/dispatch-map/blob/master/src/dispatch_map/core.clj#L102

4:24 and line 106 just a few down

4:24 those could become (.isa? dm x y)

4:24 if you add an isa? member to dispatch-map

4:24 tsdh: ejackson: But the inheritance dance is not reflected in the classes. Just because (.isSuperType (.getType o1) (.getType o2)) is true doesn't imply that (class (.getType o1)) is a superclass of (class (.getType o2))). In fact, both classes are the same.

4:25 bbloom: Thanks, I'll have a look at it.

4:25 ejackson: ok, gotcha. Could you get a java method to return a vector of the type and supertypes going back to Object ?

4:25 bbloom: tsdh: i don't have an implementation of multimethods yet, but they are trivial

4:26 ejackson: then you could recursively dispatch the multimethod on those until you get a hit ?

4:26 that might just be crazy talk though

4:26 bbloom: ejackson: the better thing to do is to use a pluggable implementation... which is what i'm offering he make out of mine :-)

4:26 ejackson: hehehe, alrighty :)

4:26 bbloom: tsdh: i need a break from this other project, maybe i'll add the multimethod functions too... shouldn't take me long

4:31 tsdh: bbloom: That looks good. `dispatch-map' could then accept an additional isa?-fn to override the standard behavior?

4:31 bbloom: tsdh: yeah

4:31 i'd take a pull request for that

4:32 tsdh: actually, i can probably just do it for you, it's really quick

4:32 i won't even invoice you :-)

4:33 tsdh: :-)

4:36 ejackson: bbloom: that's an interesting lib

4:36 cool !

4:36 muhoo: clojurebot: java logging

4:36 clojurebot: java logging is clown shoes

4:37 muhoo: http://www.slf4j.org/images/concrete-bindings.png hell yeh it is.

4:41 bbloom: ejackson: thanks :-)

4:53 borkdude: Is there already something like this "scopes" thing that Stuart Sierra mentions here? https://groups.google.com/forum/?fromgroups=#!topic/clojure/2JDLF9E934o

4:55 bbloom: i havent seen anything like it... rich released some stuff on streams a while back but it didn't seem to go anywhere. i think chunked sequences got most of the perf benefits and the resource management stuff wasn't big enough a problem to justify new features

4:57 tsdh: i'm definitely going to do the features you need, but you may just want to check back tomorrow :-)

4:57 tsdh: bbloom: No problem, I'm not in a hurry.

4:57 bbloom: tsdh: easiest thing to do is to star the project :-)

4:58 tsdh: bbloom: Done.

4:59 Raynes: tomoj: Don't know if you noticed, but I released a new version of laser with the select changes we talked about. Haven't done anyting with the attr= function and such though.

4:59 * Raynes is also just leaving, so allow some time for any comments on it to be processed and shipped.

5:15 grayzone: hello to anyone : i've a problem with sqlite3 & org.clojure/java.jdbc "0.2.3" : IllegalStateException I/O in transaction clojure.java.jdbc/transaction* (jdbc.clj:369) : suggestions for a sample with create table on db sqlite3 ?

5:38 svedubois: (new topic) I have created a vector:

5:38 (def idx (org.itk.simple.VectorUInt32.))

5:38 And I would like to print and modify the vector, but I it doesn't work.

5:38 When I do this:

5:38 (println idx)

5:38 I obtain this:

5:38 #<VectorUInt32 org.itk.simple.VectorUInt32@54ee4346>

5:38 The javadoc of the class VectorUInt32 is here:

5:38 http://jsfiddle.net/svedubois/WBvEt/

5:38 Can you give me some advice?

5:39 tomoj: Do `(<= level conf)` and "Confidence is <= level." mean the same thing?

5:45 bbloom: tsdh: is your custom hierarchy immutable?

5:45 with java, if you redefine a type, it's a new type

5:45 tsdh: tsdh: Yes.

5:45 bbloom: tsdh: ok b/c i've got polymorphic isa? working (i think) with an IHierarchy protocol

5:45 but you need to make sure that the result of your -isa protocol definition would be memoizable

5:46 tsdh: bbloom: Cool, I'll have a look later.

5:46 bbloom: not published yet

5:46 still writing test cases

5:46 tsdh: issue here: https://github.com/brandonbloom/dispatch-map/issues/1

5:46 tsdh: bbloom: Watching.

5:50 augustl: is there a small in-process document database for the JVM I can use for storing small things like user settings?

5:52 svedubois: Any advice about how to print/modify a vector using org.itk.simple.VectorUInt32 ?

5:52 noidi: augustl, if you don't need anything fancy, you could `pprint` the settings into a file and `read` them back

5:53 augustl: noidi: ah, cool

5:53 noidi: ,(require 'clojure.pprint)

5:53 clojurebot: nil

5:54 noidi: ,(pprint "{:foo 123}")

5:54 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: pprint in this context, compiling:(NO_SOURCE_PATH:0)>

5:54 noidi: ,(clojure.pprint/pprint {:foo 123})

5:54 clojurebot: {:foo 123}

5:54 noidi: ,(with-out-str (clojure.pprint/pprint {:foo 123}))

5:54 clojurebot: "{:foo 123}\n"

5:57 bbloom: i apparently suck at spelling hierarchy

6:01 grc: I'm missing something obvious here: (def my-map {:a 1 :b 2}), (def my-list '(my-map)), (map? (first my-list)) => false

6:03 Anonny: Go ahead and call my-list.

6:05 grc: Anonny: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn

6:05 which seems reasonable: invoked as (my-list)

6:05 Anonny: I had it show up (my-map)

6:06 (def my-list (list my-map)) works however

6:06 svedubois: I have created a java array called idx, when I write: (alength idx) I obtain an error. What I am doing wrong?

6:07 grc: Anonny: That's working here too. I have no idea why

6:08 Anonny: grc: I think '(my-map) isn't actually capturing the value of the variable.

6:08 grc: It might just be capturing the literal name for the var.

6:09 grc: Anonny: You're right and I need to go and read up on quote again. Thanks

6:09 Anonny: grc: But that's just a guess. I'm sure somebody has a real answer

6:09 grc: My pleasure.

6:09 andrewmcveigh|wo: grc: the symbol is not evaluated because you quoted it ##(symbol? (first '(my-map)))

6:09 lazybot: ⇒ true

6:11 grc: andrewmcveigh|wo: Thanks.

6:12 Anonny: svedubois: (.length idx)?

6:13 svedubois: Anonny: java.lang.IllegalArgumentException: No matching field found: length for class org.itk.simple.VectorUInt32

6:14 The javadoc of the class VectorUInt32 is here: http://jsfiddle.net/svedubois/WBvEt/

6:17 Anonny: svedubois: Neither capacity or size do what you're looking for?

6:18 nor size*

6:19 svedubois: Anonny: Yes, (.capacity idx)

6:19 (.size idx)

6:19 print without error 0

6:20 How I can set a vector for this java array?

6:28 I have created and image called imgx

6:28 (def imgx (org.itk.simple.Image. 256 256 PixelIDValueEnum/sitkFloat32))

6:28 I am not sure that this is the Size:

6:28 (.getSize imgx) ;-> #<VectorUInt32 org.itk.simple.VectorUInt32@23a647ea>

6:28 (.size(.getSize imgx)) ;-> 2

6:28 The javadoc of Image is here http://jsfiddle.net/svedubois/MdPWz/

6:31 llasram: svedubois: So, .getSize is returning an array then? What's the problem?

6:32 svedubois: llasram: I would like to (.getPixel imgx 0 0 0)

6:32 (.setPixel imgx 0 0 0 1)

6:33 But I don't know which method I have to use and how.

6:34 There is not getPixel, there are different getPixels.

6:34 For example, (.getPixelIDValue imgx 0 0 0)

6:34 And it gives and error

6:35 llasram: Well yeah -- your javadoc there says the getPixelIDValue method doesn't take any arguments

6:36 It seems like you're having issues figuring out how to use this library at all vs using it in Clojure. I'd suggest getting help getting it working in Java, and asking further here if you have trouble translating what works in Java into Clojure

6:41 svedubois: (.getPixelIDValue imgx)

6:41 ;-> 6

6:46 callen: hugod: debugging. How do I get a debugging experience in Clojure like http://pypi.python.org/pypi/ipdb

7:13 bbloom: what do i do license-wise if i want to copy paste a big chunk of code out of clojure.core?

7:13 do i just put an inline attribution and assign copyrights to rich hickey? or what?

7:14 callen: bbloom: just wondering...why?

7:15 bbloom: i implemented multimethods on top of my dispatch-map and i want to copy 10+ tests over wholesale

7:27 callen: bbloom: why did you implement multimethods?

7:27 bbloom: callen: because https://github.com/brandonbloom/dispatch-map made it easy & it seemed like fun? :-)

7:27 also tsdh needed custom isa?

7:28 callen: sometimes I wonder if anybody here makes things that aren't experiments.

7:30 bbloom: dispatch-map isn't an experiment, i'm using it for a real project :-P

7:55 tsdh: ok that took much longer than i expected... but it's done :-P

7:55 tsdh: bbloom: Thank you, I'll give it a try. :-)

7:55 bbloom: tsdh: if you have any issues, please report them on github

7:55 tsdh: I'll do if I find one.

7:56 callen: bbloom: you wouldn't happen to be aware of any good debuggers for Clojure, would you?

7:57 bbloom: callen: no, but i haven't really felt the need for one since i can pprint any intermediate value. i generally prefer printf debugging anyway, but i'm a crazy person

7:58 callen: bbloom: I'm accustomed to having first-class in-langauge debugger/REPL combos from Common Lisp and Python

7:58 bbloom: that I can't find one for a Lisp (Clojure) is appalling.

7:58 algernon: callen: I've had reasonable success with yourkit's stuff. (but I mostly used it for profiling, for debugging, I usually abuse robert.hooke and pprint to my heart's content)

7:59 callen: algernon: I don't really want to use software other people control.

7:59 bbloom: lolwut

7:59 callen: and I don't want a profiler, I want a native Clojure debugger/REPL.

8:00 my impression has been that YourKit is commercial but donates to open source projects.

8:00 bbloom: it's a profiler, you're not taking a dependency on it

8:00 algernon: callen: you might want to have a look at https://github.com/pallet/ritz then

8:00 dpwright: hello -- sure I must be doing something stupid here, but a project I've made which runs fine when I run "lein repl" and then (-main) fails with "No such namespace: goshiki" (where goshiki is a namespace defined in another file in my project) when I do "lein run"

8:00 callen: algernon: I already have, or I wouldn't be asking

8:00 I don't want a java debugger

8:00 I want a Clojure debugger

8:00 https://github.com/georgejahad/debug-repl <--- this is closer to my intent.

8:01 bbloom: dpwright: refheap your ns forms

8:02 dpwright: (more precisely, I have a namespace hotel-scraper.goshiki which is required thus '[hotel-scraper.goshiki :as goshiki]'

8:02 hugod: callen: what didn't you like in ritz?

8:02 dpwright: bbloom -- thank you, I will look up what that means and then try it ;-)

8:02 bbloom: ~refheap

8:02 clojurebot: refheap is gist

8:02 bbloom: ~gist

8:02 clojurebot: gist is forget ~paste

8:02 bbloom: ~paste

8:02 clojurebot: paste is not gist.github.com

8:02 bbloom: LOL

8:02 callen: hugod: I can't figure out how to make it behave like a native Clojure REPL

8:02 bbloom: http://www.refheap.com

8:02 dpwright: oh I see

8:03 hugod: callen: in what way?

8:03 callen: hugod: if you can point to documentation that will let me do what I want, do so

8:03 hugod: but when I looked, all I could find was shitty auto-generated crap.

8:04 I don't use any java IDEs or any of that crap, so if using JPDA requires that, I'm out.

8:04 hugod: callen: most of http://common-lisp.net/project/slime/doc/html/Debugger.html applies to ritz

8:04 callen: hugod: that is such a cop out. never mind then.

8:05 hugod: I'm asking how to use *ritz*, not slime/swank.

8:05 If I use swank, I'm just going to use CDT.

8:05 I'd rather use nREPL though.

8:05 hugod: callen: it applies to ritz-nrepl too

8:05 callen: hugod: where's the documentation?

8:06 algernon: https://github.com/pallet/ritz/tree/develop/nrepl got me started, fwiw.

8:06 (linked from the main ritz readme)

8:07 dpwright: bbloom https://www.refheap.com/paste/8059

8:07 callen: algernon: I've seen that, I didn't see anything for dropping a REPL inline at runtime.

8:07 bbloom: dpwright: the filename must match the ns name

8:08 dpwright: are those in a hotel_scraper directory ?

8:08 dpwright: bbloom, yes -- core.clj was generated by leiningen, and I just added goshiki.clj next to it

8:08 bbloom: do you have a hotel-scraper.util ?

8:08 hotel_scraper/util.clj

8:09 dpwright: yes, defined inside util.clj in the same directory

8:09 bbloom: and it's ns form ?

8:10 its*

8:10 dpwright: https://www.refheap.com/paste/8060

8:10 just noticed, my project.clj doesn't specify a src directory

8:11 the sources are in src/hotel_scraper, which I thought was the default, but..

8:11 bbloom: it is the default

8:11 hm i'm not sure

8:11 but i'm also exhausted, so my eyes might be useless

8:12 sorry man, good luck! i'm off to bed

8:12 dpwright: thanks for taking a look!

8:12 night

8:15 ah -- figured it out! I was doing an eval inside the code, running something read in from a config file. I guess when I ran it from the repl the namespaces were set up ok, but using "lein run" they weren't. At any rate, using the full namespace name in the config file rather than the shortened one I specified in the :require statement fixed it.

8:15 thanks again for your time bbloom

8:16 time for me to head bedward too

8:20 hugod: callen: the nearest is to set a breakpoint, and then use 'e' to evaluate arbitrary expressions within the context of any stack frame

8:24 callen: hugod: okay let me provide some contrast. first step: `pip install ipdb`

8:25 hugod: second step: drop `ipdb.set_trace()` wherever you want a debugger/REPL to pop up. There is no third step.

8:31 hugod: callen: sure, it is not super smooth to set up. Contributions welcome...

8:32 callen: hugod: is there a way to use it just from a running process?

8:33 I'd rather experiment with it before shitting up my Emacs config.

8:34 hugod: callen: it requires a jvm running with debug flags. At the moment it does that by controlling the process startup (with lein-ritz). Attaching to a running process is on the todo list.

8:35 * callen scrunches faces

9:22 TimMc: technomancy: The lein-newnew changes will invalidate the leiningen.new tests -- perhaps those should live on newnew in the first place...

9:26 marianoguerra: I want to filter a map by some field on the value and then build a new map, I'm doing something like (apply hash-map (flatten (filter filter-fn (seq the-map))))

9:26 (of course not as a one liner)

9:26 is there another way?

9:51 llasram: marianoguerra: ##(let [input {:a 1, :b 2, :c 3, :d 4}] (into {} (filter (comp odd? second) input)))

9:51 lazybot: ⇒ {:a 1, :c 3}

9:52 marianoguerra: llasram: thanks

10:04 bosie: so, i am reading on macros in Clojure Programming and i enter the first macro they have in my REPL. it seems to work, i get #'user/reverse-it back. calling the macro though results in "unable to resolve symbol: nltnirp)

10:05 https://gist.github.com/4444022

10:06 nDuff: bosie: well, of course -- println reversed isn't something valid.

10:07 jeremyheiler: I think you're supposed to call it (reverse-it (nltnirp "foo"))

10:08 nDuff: bosie: ...it's not a macro that's expected to actually be very _useful_, but is a demonstration of the power/flexibility.

10:08 bosie: nDuff: at this point it doesn't demonstrate anything to me

10:08 nDuff: if i call the function walk/postwalk manually it works

10:08 nDuff: bosie: it demonstrates that a macro can rewrite the symbol "println" to be its reverse -- "nltnirp"

10:08 bosie: if i call it through the macro, it doesn't

10:08 nDuff: no?

10:09 nDuff: bosie: so, the error itself demonstrates that the macro is working.

10:09 bosie: because the code within the macro is rewritten according to its instructions.

10:09 noidi: here's a better demonstration of the power of lisp macros https://www.hackerschool.com/blog/13-list-comprehensions-in-eight-lines-of-clojure

10:09 bosie: ah

10:09 so symbol executes/evaluates the method?

10:10 nDuff: no

10:10 bosie: no

10:10 (walk/postwalk #(if (symbol? %)

10:10 (symbol (str/reverse (name %)))

10:10 %)sorry

10:10 again, i don't get it

10:10 nDuff: when you use a non-special name, that's a symbol

10:10 for instance, in (println "foo"), println is a symbol

10:10 noidi: bosie, the symbol println is turned into string "println", reversed into "nltnirp", and turned into symbol nltnirp

10:11 bosie: noidi: i get that. i don't get the error part

10:11 nDuff: so, the macro is creating a symbol "nltnirp", akin to the symbol "println" but not actually pointing to anything valid.

10:11 noidi: after that the code is executed, as if you had written nltnirp instead of println

10:11 nDuff: and because "nltnirp" isn't valid, you get an error.

10:11 bosie: https://gist.github.com/4444089

10:11 executed by whom?

10:11 nDuff: Executed?

10:11 This is a compile-time error.

10:11 There's no execution happening yet.

10:11 bosie: ok

10:12 noidi: sorry, s/executed/evaluated/

10:12 bosie: ok

10:13 noidi: ,(ntlirp "foo")

10:13 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ntlirp in this context, compiling:(NO_SOURCE_PATH:0)>

10:13 bosie: yup

10:14 but i am not sure

10:14 why calling the method directly vs calling it through the macro results in 2 different results

10:14 jonasen: cemerick: is this by design, or a bug in nrepl: https://www.refheap.com/paste/8057 ?

10:14 nDuff: bosie: well, you're not calling the same code through the macro

10:14 bosie: macros rewrite their contents

10:15 bosie: ...rewrite their contents at compile time, even. that's what they _do_, and what makes them fundamentally different from functions.

10:15 bosie: so, the macro rewrites the code to replace all symbols with reversed versions of their names

10:15 s/the/that particular/

10:15 bosie: so it's no surprise that the rewritten code won't compile.

10:16 bosie: nDuff: oh, so when i call the macro, it actually gets recompiled?

10:16 and rewritten

10:16 ?

10:16 i thought only the macro itself gets rewritten

10:17 nDuff: bosie: well, when you enter _anything_ at the REPL, that thing gets compiled before it's executed. When you compile code that contains a macro call, though, the macro rewrites the code within it.

10:17 noidi: bosie, the macro takes a data structure representing code that's read but not evaluated. it then transforms it into another data structure, which is then evaluated.

10:17 bosie: i see

10:17 got it, thank you

10:17 noidi: ,(read-string "(println \"foo\"")

10:17 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

10:18 noidi: ,(read-string "(println \"foo\")")

10:18 clojurebot: (println "foo")

10:18 noidi: that's the read phase

10:18 it transforms your source code into a data structure

10:18 ,(eval (read-string "(println \"foo\")"))

10:18 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

10:19 noidi: okay, that would've resulted in a println call if clojurebot would allow it :)

10:19 bosie: thanks a lot guys, really appreciated

10:19 jkkramer: you are henceforth initiated into macro club

10:19 the first rule of macro club is: don't write macros

10:20 ohpauleez: is the second rule about hygenic macros?

10:20 nDuff: ohpauleez: that's the third rule. The second rule is also "don't write macros".

10:21 ohpauleez: ahh right right :)

10:21 ejackson: you're not supposed to use because they're made from fat people, or something... i don't fully grok it.

10:22 nDuff: ejackson: More about composability. Can't use macros as arguments to higher-order functions.

10:23 ejackson: indeed, and they make your brains leak out your ears; upsets the cubicle-mates.

10:25 nDuff: bosie: ...by the way, you may have already gotten this, but just to amplify a bit re "when I call the macro" -- macros only take effect at compile time; there's no invocation/recompilation happening after that point.

10:32 bosie: jkkramer: why not?

10:32 ok

10:33 yogthos: bosie: macros are considered to be more difficult to understand than regular functions

10:33 jkkramer: bosie: for the reason nDuff gave. Also, macros hijack evaluation and can make your code confusing to read if not used with care

10:33 bosie: yogthos: and i guess composability as mentioned by nDuff doesn't help either ;)

10:33 yogthos: bosie: so if you can just do it with a function it's probably more maintainable in the long run

10:34 bosie: right :)

10:34 nDuff: ...so, there are cases where macros _are_ appropriate -- but basically, those come down to "language features".

10:34 Anything with short-circuiting evaluation, for instance.

10:34 bosie: why oculdn't i rewrite "for" as a function?

10:34 jkkramer: macros are good at removing syntactic boilerplate

10:35 yogthos: I like to think of macros as templating, if you have have some repeating code which is hard to abstract otherwise then macro is appropriate

10:35 also good for deferring evaluation

10:35 nDuff: ...and there are also cases where functions would have more overhead (though there are hybrid approaches to that -- see ie. definline)

10:35 dnolen: the list of things that macros are good at ... long list

10:36 my rule of thumb is if I can't interact w/ the basic api w/o macros - there's probably a problem.

10:36 cemerick: jonasen: a bit of a bug; keywords are just name'd upon serialization to bencode (which only supports strings, integers, lists (vectors), and maps)

10:36 nDuff: dnolen++

10:36 jkkramer: bosie: you can, but it wouldn't be pretty

10:37 &(macroexpand '(for [i (range 3)] (inc i)))

10:37 lazybot: ⇒ (let* [iter__4468__auto__ (clojure.core/fn iter__141314 [s__141315] (clojure.core/lazy-seq (clojure.core/loop [s__141315 s__141315] (clojure.core/when-let [s__141315 (clojure.core/seq s__141315)] (if (clojure.core/chunked-seq? s__141315) (clojure.core/let [c__44... https://www.refheap.com/paste/8062

10:37 cemerick: jonasen: side effect of using the stringify and keywordize stuff in clojure.walk

10:39 Some people have suggested the development of an edn transport, though that will leave out e.g. vim

10:41 jonasen: cemerick: ok. How about a fressian transport? Anyone attempted that? I'd guess it would be a great fit

10:41 cemerick: jonasen: no, no one's done that one either

10:46 silasdavis: i'm using the lein ring plugin to start a server, could someone tell me how it goes about finding what file/code to run?

10:46 weavejester: silasdavis: It should be in the README. It expects a key in your project.clj file telling it where the Ring handler function is.

10:48 brainproxy: weavejester: have you run into weirdness w/ lein-ring, auto-reload and clojure 1.5.0-RC1

10:48 ?

10:48 weavejester: brainproxy: No, but I haven't used Clojure 1.5.0-RC1 with Ring yet. However, there is a pull request for ns-tracker that I'll merge tonight that I think some people were saying they needed

10:49 brainproxy: sure, that might be related

10:49 weavejester: btw, with respect to lein-ring / ring, where is the source code that drives the behavior of auto-refresh

10:50 i went hunting for it the other day and couldn't find it

10:50 weavejester: brainproxy: https://github.com/weavejester/ring-refresh

10:51 brainproxy: sure, I'm aware of that repo, but ... how is that getting pulled in by lein-ring / ring

10:51 didn't see the dep in project.clj

10:51 silasdavis: weavejester: ah yes it's in the install section, thanks

10:52 weavejester: brainproxy: Plugins operate in a separate classloader than the actual project itself

10:52 brainproxy: So if you want a plugin to use library X in your project, it needs to be in the project's dependencies, not the plugin's

10:53 brainproxy: well i have auto-refresh working

10:53 but I'm not using that plugin

10:53 just lein-ring

10:53 weavejester: brainproxy: lein-ring is injecting that dependency into your project map when "lein ring server" runs

10:54 brainproxy: makes sense, but what drives that functionalit w/in lein-ring, hunted in the source for it, must have missed something

10:56 jcrossley3: weavejester: i saw your comment on kognate's PR about :path-info. any chance of getting that and :context into the Ring spec?

10:56 weavejester: brainproxy: It's easy to miss. Let me find the line

10:57 jcrossley3: Why should it be in the Ring spec?

10:57 brainproxy: https://github.com/weavejester/lein-ring/blob/master/src/leiningen/ring/server.clj#L17

10:58 And ring-server has the dependencies:

10:58 https://github.com/weavejester/ring-server/blob/master/project.clj

10:58 brainproxy: weavejester: ah, thanks

10:58 jcrossley3: weavejester: i figured it made sense if "official" ring middleware is referring to it.

10:59 brainproxy: weavejester: i don't think I ever made the connection between lein-ring and your ring-server thing

11:00 i was just bouncing back and forth between sources for lein-ring and ring proper

11:00 weavejester: jcrossley3: The SPEC defines how to transform a HTTP request and response into Clojure maps

11:00 But path-info and context are not part of HTTP

11:01 Strictly speaking, nor are URL-encoded parameters, cookies, sessions, and a lot of other things

11:01 jcrossley3: weavejester: sure, but i think it'd be useful to have a canonical list of what keys i can expect in the request. where is that if not the spec?

11:02 weavejester: So even though official Ring middleware will use these keys, they still shouldn't be part of the spec, because they're not something an adapter-writer should worry about.

11:02 It's possible we could create a list of keys that the various Ring middleware adds

11:02 yogthos: I think at least the context needs to be in the spec, as it's something that's part of the servlet spec

11:02 weavejester: But this would be documentation, not specification.

11:03 yogthos: this was a long time bug in noir where, it redirects ignored the context and if you deployed on something like tomcat your app would be broken

11:03 weavejester: The Ring spec is unrelated to the servlet spec.

11:03 The Ring spec defines the mapping between HTTP and Clojure

11:03 One of the problems with Java servlets is that it attempts to put too much in the same specification

11:04 jcrossley3: weavejester: the majority of the spec is a listing of the keys available in the request and response maps. :)

11:04 yogthos: true

11:04 weavejester: HTTP, cookies, parameters, sessions, long polling and so forth

11:04 The Ring spec is *just* about HTTP and nothing more

11:04 yogthos: but since ring runs on top of servlets, it's something that you do have to be aware of when working with ring

11:04 weavejester: yogthos: Well, no, not really. Only if you deploy Ring to a legacy servlet container

11:05 yogthos: weavejester: well any container, like glassfish, jboss, tomcat, etc

11:05 weavejester: If you're just using Ring with the adapter, there shouldn't be anything you need to know about the underlying implementation

11:05 yogthos: I think most people run jetty standalone where it's not an issue

11:05 jcrossley3: i don't think ring necessarily runs on top of servlets, but it does concede inspiration from Rack and WSGI, both of which support :context and :path-info in addition to :uri, the latter being in the spec.

11:06 weavejester: jcrossley3: It is inspired by those, but path-info and context shouldn't be in a spec that deals with HTTP

11:06 jcrossley3: weavejester: i gather you feel pretty strongly about this. :)

11:06 yogthos: hehe

11:07 what about making context part of the implementation?

11:07 not expose it as a key, but if it is present it's probably should be part of any relative urls

11:07 weavejester: Well, once upon a time I asked Mark the same thing: I wanted :context and :path-info in the SPEC

11:07 yogthos: then it wouldn't be exposed to the user, but you'd still have correct behavior in case it is present

11:07 weavejester: But after some discussion I've changed my mind

11:08 For Ring 1.2, middleware that used to access the :uri is now going to use the ring.util.request/path-info function

11:08 Which is just (or (:path-info request) (:uri request))

11:09 So the code will be aware of the :path-info key

11:09 And having documentation on all the keys that Ring middleware adds is a good idea

11:09 But there's a difference between documentation and specification

11:09 yogthos: yeah that's a good point

11:10 weavejester: The former describes the code, and the latter is something from which code is derived

11:10 So for the SPEC, that's a specification because you want all the adapters to share a common interface

11:10 But for things like the :cookies key, there's no need for a specification

11:10 Because we only need one wrap-cookies middleware

11:11 yogthos: right, it's not a common protocol that needs to be shared by different adapters

11:11 weavejester: Exactly :)

11:11 yogthos: yeah that's a good separation

11:11 weavejester: But *documenting* all the keys is definitely a good idea.

11:11 yogthos: :)

11:11 weavejester: It just shouldn't be a spec, because that's kinda like the tail wagging the dog.

11:12 jcrossley3: weavejester: i agree with all of that. i really just want all the ring middleware to work correctly with context paths. i still feel, as you once did, contexts should be a part of a spec that maps a "hypertext transport protocol" to what we now know as the "interwebs" but i respect your perspective there.

11:13 weavejester: Well, there are two possibilities: create a spec which defines how :context and :path-info work, or create code that defines how they work

11:14 yogthos: but is there any value in exposing the context to the user in the first place?

11:14 jcrossley3: weavejester: imagine how pissed you'd be if rack, wsgi, and servlets took the code approach. :)

11:15 weavejester: yogthos: It's useful for links.

11:15 Seba51: Hi yogthos, nice to meet you.

11:15 yogthos: weavejester: a link to a different context on the same app server?

11:15 Seba51: hello :)

11:16 jcrossley3: weavejester: folks will end up in the same place i am right now: debating whether to copy/rewrite/monkey-patch ring middleware until it catches up. if we're going to be data-driven, let's spec out the available data.

11:16 weavejester: jcrossley3: I didn't mean have the definition scattered throughout the code

11:16 silasdavis: why does ((fn [] "string message")) work but (#("string message")) does not?

11:16 weavejester: I mean, like wrap-cookies, you only need a single function to do that

11:16 So you have a middleare function, wrap-context, that adds a :context and :path-info key

11:16 And the docstring describes how it works

11:17 jlewis: silasdavis: because #() anonymous functions try to apply the first exp inside of them as a function to the rest

11:17 weavejester: So effectively we constrain the definition of context to a single middleware

11:17 yogthos: I think that's fairly reasonable, and templates can be used to set it up correctly :)

11:18 that definitely provides a lot of granularity, you want context handling you wrap the middleware, you don't then you don't

11:18 jcrossley3: weavejester: yeah, i retract my last comment. i think making ring fully context-aware, whether spec'd or not is fine.

11:18 silasdavis: jlewis: and the rest in this context is? could you expand the #(...) to (fn ...)?

11:18 jlewis: #(...) is the same as (fn [] (...))

11:19 well, it might have arguments, but you get the picture

11:19 weavejester: jcrossley3: The only thing I'm a little worried about is whether that approach will work for everything.

11:19 silasdavis: jlewis: um so I feel like my two expressions are the same, but the fn one works as expected

11:19 jcrossley3: weavejester: dammit! i was banking on YOUR confidence it will! don't make me worry about these things! ;)

11:19 weavejester: jcrossley3: It might be that, for instance, it doesn't make sense for servlets to use wrap-context, but to get the context and path info from the servlet.

11:19 silasdavis: the shorthand ones throws: ClassCastException java.lang.String cannot be cast to clojure.lang.IFn

11:20 jlewis: yes - note that the one you wrote with fn doesn't have any inner parens, like my example

11:20 weavejester: jcrossley3: The only way to be sure is to implement it, and then see if we need multiple implementations.

11:20 terom: silasdavis: they're not the same, (fn [] (...)) vs (fn [] ...)

11:20 weavejester: jcrossley3: If we do, then it's time for a spec

11:20 matthavener: silasdavis: the #("string") becomes (fn [] ("string")) and tries to execute "string"

11:20 weavejester: jcrossley3: But only if we need multiple implementations. If we only have one, then there's not much point in writing a spec :)

11:20 silasdavis: oh right yes

11:21 yogthos: silasdavis: it's because #( ) expects a function name as the first item

11:21 jcrossley3: weavejester: true, but please just s/:uri/:path-info/ before your next release, k? :)

11:21 hyPiRion: ,#([0] 0)

11:21 matthavener: silasdavis: you can always do #(identity "string"), but thats longer than (fn [] "string") :)

11:21 yogthos: silasdavis: in case of #("foo") first item is a string, it tries to execute it as a function and fails

11:21 clojurebot: #<sandbox$eval27$fn__28 sandbox$eval27$fn__28@292d45ad>

11:21 hyPiRion: ,(#([0] 0))

11:21 clojurebot: 0

11:22 weavejester: jcrossley3: That's the plan. It's worked well in Compojure for the past couple of years, so it makes sense to integrate it into Ring.

11:23 silasdavis: or (#(str "string))

11:23 jcrossley3: weavejester: agree. what release version of ring are you targetting?

11:23 Seba51: Being nosy: what is the context thing you are talking about?

11:24 yogthos: Seba51: in Java servlet spec you can have a context string, which specifies the context relative to the application server you're deploying on

11:24 Seba51: I know

11:25 yogthos: Seba51: ok so the problem is that if you don't specify the context in the url, then it won't work correctly in those situations

11:25 Seba51: for example if you're doing a redirect

11:26 Seba51: Even worse, you can have a mod_jk or mod_proxy receiving a request on www.example.com and calling your jetty server on http://localhost:8080/myapp

11:26 yogthos: Seba51: right same problem ;)

11:26 Seba51: although shouldn't apache rewrite the urls at that point?

11:27 jcrossley3: Seba51: yogthos: or mapping a uri path component to a file system or class path, in the case of wrap-file or wrap-resource.

11:28 silasdavis: more basic clojure non-understanding... when using moustache why does (app [""] "string") produce a working handler but (app [""] ((fn [] "string"))) does not?

11:29 I'm guessing because app is a macro it is able to not evaluate the function argument as I expect

11:29 creese: did moustache development start up again?

11:29 Seba51: No

11:29 silasdavis: is moustache dead?

11:30 creese: last I heard, it was suggested to use Compojure

11:30 Seba51: You would have to filter the html, analyse the Javascript, patch whatever is building a URL to finally have a correct HTML

11:30 You will receive the context with different request parameters.

11:31 Out of my mind, something like x_context

11:31 silasdavis: I actually was using compojure, but thought I try moustache for the hell of it. I see the last commit was a year ago. I'll switch back

11:31 Seba51: Only redirects are fixed

11:33 See here: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#request-bodies

11:34 yogthos: silasdavis: shameless plug :P http://luminus.herokuapp.com/

11:34 silasdavis: trying to make a one stop shop for clojure web dev :)

11:35 Seba51: @yogthos Any reading is mod_jk: 3. Some applications might contain hard coded absolute links. In this case check, whether you find a configuration item for your web framework to configure the base URL. If not, your only chance is to parse all response content bodies and do search and replace. This is fragile and very resource intensive. If you really need to do this, you can use http://apache.webthing.com/mod_proxy_html/, http://httpd.ap

11:36 silasdavis: yogthos: that looks really useful thanks

11:36 yogthos: silasdavis: good to hear, and any feedback is welcome as I'm still working out long term direction for it

11:37 silasdavis: I started of with noir and then someone told me (in a pub surprisingly) that that was deprecated

11:37 yogthos: Seba51: yeah so long story short stay away from mod_jk if possible ;)

11:37 systemfault: Hmm, if noir is deprecated then what is the cool framework to use nowadays?

11:37 yogthos: silasdavis: yup, building on top of compojure is the recommended approach nowadays

11:37 silasdavis: so then I found a compojure/hiccup template, which was ok, then I read about moustache and enlive so tried all combinations therein

11:38 systemfault: Thanks

11:38 silasdavis: at some point I need to stop framework hoping and write some code :0

11:38 creese: yogthos: why do you use hiccup as the default?

11:38 silasdavis: pp*

11:38 Ember-: ooh dear

11:38 4clojure admins here?

11:38 504 Gateway Time-out

11:38 yogthos: creese: it doesn't require learning new syntax

11:38 silasdavis: Any thoughts on https://github.com/clojure-liberator/liberator ?

11:39 yogthos: creese: with something like enlive you have to learn how enlive works, with hiccup it's just standard clojure data structures, I figure it's more beginner friendly

11:39 creese: yoghos: for a designer, it does. a designer won't know clojure

11:39 yogthos: creese: arguably the designer shouldn't touch the markup and use css for styling

11:39 silasdavis: what I am building is a restful api, with some light templating for convenience, not sure whether I should work more directly with compojure or use that

11:40 yogthos: silasdavis: luminus primarily just sets up a good compojure template

11:40 silasdavis: yogthos: that's often pretty hard to do, particulary supporting many browsers...

11:40 creese: yogthos: I'll have to think on that. Most of the designers in our shop do markup

11:40 silasdavis: yogthos: that is what I've been after. I think I can use both if I wish

11:41 yogthos: creese: well the beauty of the whole scheme is that you can rip out hiccup very easily

11:41 creese: just dump the dependency and use any templating you like, but my experience is that it is a good practice to not mix markup and design

11:41 jcrossley3: yogthos: was recommending java.jdbc a deliberate decision, over something like korma?

11:42 yogthos: jcrossley3: I always found java.jdbc to be simple enough to use, but if there's interest in korma I could certainly add it in as a module

11:43 jcrossley3: korma did recently get a maintainer :)

11:43 silasdavis: i'm planning on using monger

11:43 jcrossley3: yogthos: indeed, a good thing

11:43 Seba51: yogthos: I am not sure, if the persistence layer should be included.

11:44 yogthos: Seba51: it's not by default

11:44 Seba51: basically if you do lein new luminus myapp you get barebones compojure app

11:44 Seba51: We will end up in a big fat framework where people struggle to rip out things.

11:44 yogthos: Seba51: if you add stuff like +postgres you get the db dependencies basic setup

11:44 Seba51: I mean there is mongo/couchdb/jdbc/JPA/in memory dbs etc

11:45 yogthos: Seba51: for most apps you'll need some sort of persistence at some point though, so I think it's better to template that than to have to roll it from scratch every time

11:46 Seba51: There is a german diction: You cannot see the forest because there are so many trees.

11:46 yogthos: Seba51: all of those can be added in as separate modules, so if you want mongo you do +mongo, you want couch you do +couch, etc

11:46 Seba51: Every option will make other stuff less visible.

11:46 yogthos: Seba51: how so?

11:47 silasdavis: it's appealing to have a minimal base that actually works, particularly for somone like me who is learning the language and the frameworks at the same time

11:47 Seba51: If I introduce a framework having 500 options and you are a struggling learner, you have to look through all of them.

11:47 silasdavis: Seba51: it should just default to something like sqlite

11:47 yogthos: Seba51: well you can organize them logically and provide sane defaults right

11:48 Seba51: options aren't there so that you have to use them, they're there to override the default behavior if it's not working for you

11:48 silasdavis: yogthos: does your server.clj essentially provide a standalone alternative to lein ring server?

11:48 yogthos: silasdavis: yup

11:49 silasdavis: you can just do lein run with it

11:49 silasdavis: also setup for heroku :)

11:49 silasdavis: I couldn't decide whether to separate handlers in to separate 'controller' files

11:50 not sure how much that pattern applies. I see you have a single handler to start with

11:50 yogthos: silasdavis: I find it's better to think in terms of routes

11:50 silasdavis: for example say you have all your authentication routes such as register, login, logout

11:50 silasdavis: I'd group those into a single namespace and then have all the logic around that workflow in one spot

11:51 Seba51: IMHO: less can sometimes be more. Because you will easily learn the frameworks and get a clear overview. But this is a matter of preference. There are many big frameworks like JEE, Ruby on Rails, which took the choice to provide all layers. Others are succesful to focus on something.

11:51 silasdavis: that's essentially an authentication controller I suppose

11:51 yogthos: silasdavis: right

11:52 Seba51: I do want to keep it somewhat minimalistic, but I also want to capture all the common tasks

11:52 Seba51: part of it is also to make it easy for beginners to get bootstrapped

11:53 silasdavis: Seba51: I quite like the loosely coupled clojure web stack from what I've seen, so I'm not sure you'd want something like RoR, but having a fully working, if not fully functional setup is very useful

11:53 yogthos: Seba51: it can be frustrating having to hunt for how to do this or that, or having to figure out which library is the one people use for example

11:53 silasdavis: for bootstrapping, yes

11:53 Seba51: I think you have been quite successful with this. ;-) (Leaving, children are waiting for dinner)

11:54 silasdavis: midn you I suppose you could leave persistence out of that. I just wanted to be able to do 'lein ring server' or similar and then start breaking things

11:54 yogthos: Seba51: thanks ;)

11:54 silasdavis: that's the base template then :)

11:55 silasdavis: if you just do lein new luminus myapp it won't put any persistence stuff in

11:55 silasdavis: and it's ready to break out of the box ;)

11:57 silasdavis: actually it's not quite for me, I'm getting a class not found exeception for server

11:58 Exception in thread "main" java.lang.ClassNotFoundException: crosstalk.luminus.server

11:59 lein 2

12:00 yogthos: silasdavis: oh interesting

12:00 silasdavis: it's the dots

12:00 yogthos: how are you running it?

12:00 silasdavis: I called my app crosstalk.luminus

12:00 yogthos: ah

12:00 yeah I think the app name has to be just letters

12:01 silasdavis: I don't think the templating handles the dots, might be something to fix in lein :)

12:01 silasdavis: not sure how new works but it would be good if it could capture that, bit of an edge case though

12:01 hyPiRion: it's lein-newnew in that case

12:01 yogthos: yup

12:02 yeah just tried it the template doesn't sanitize the .

12:02 hyPiRion: https://github.com/Raynes/lein-newnew/issues/57

12:02 I suppose that's kind-of relevant

12:04 yogthos: yeah looks related

12:06 silasdavis: yogthos: will you keep the template update with the latest version of dependent libraries?

12:06 updated*

12:06 yogthos: silasdavis: that's the plan :)

12:06 silasdavis: I'm kind of invested in it, as I use it for work as well

12:07 silasdavis: might want to see if you can get it linked from: http://www.webnoir.org/

12:07 there really should be a note on that site saying it is deprecated by the author

12:07 it's the top hit for 'clojure web framework'

12:07 yogthos: silasdavis: yeah next time Chris is on I could ask him about that

12:18 callen: yogthos: what?

12:19 yogthos: callen: hey what's up

12:19 callen: yogthos: you must've meant ibdknox, n/m

12:19 yogthos: callen: ah yes

12:19 callen: about the noir being deprecated :)

12:20 callen: Right.

12:20 yogthos: silasdavis: callen: so this should help keep the template up to date :) https://gist.github.com/4445009

12:22 can't really autoupdate them though, as there could be breaking stuff

12:27 silasdavis: you could always maintain an auto-synced testing branch

12:27 other people could track that if they wanted

12:27 yogthos: silasdavis: yeah might be an idea, if nothing else this way I can easily check if stuff looks out of date

12:28 callen: oh yeah you want to add those env scripts?

12:28 callen: yogthos: no

12:30 ppppaul: can someone give me a suggestion as to how i would write a test that mocks out rabbitMQ?

12:32 anyone?

12:32 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

12:32 ppppaul: hmm

12:33 llasram: ppppaul: By using with-redefs...?

12:33 yogthos: ppppaul: what are you trying to do with ti?

12:33 technomancy: yeah, with-redefs

12:33 ppppaul: i understand that

12:33 i'm just not very experienced with doing async stuff with clojure

12:33 joegallo: ppppaul: are you using a library to interact with rabbitmq? if so, which one?

12:34 * nDuff is surprised that Clojure 1.5 doesn't have a way to set the executor pool to which futures are dispatched

12:34 llasram: ppppaul: If you're testing something which depends on exactly how your rabbitmq communication is async, then I'd suggest *not* mocking rabbitmq

12:34 nDuff: ...btw, anyone know why futures are dispatched to a bounded pool?

12:34 ppppaul: http://clojurerabbitmq.info/

12:34 llasram: nDuff: You do. It's the same as the send-off pool?

12:34 nDuff: llasram: Ahh; that makes sense, then.

12:35 llasram: ...though I don't understand _why_, as futures aren't typically going to be IO-bound. To prevent deadlocks if they call other futures, I suppose?

12:37 llasram: ppppaul: If you're doing something straightforward which e.g. turns a sequence of received messages into a seq, then you can just mock there. Or do both for different tests!

12:37 nDuff: I definitely uses futures for IO-bound stuff

12:37 use, even

12:38 nDuff: Fair 'nuff.

12:38 svedubois: (New topic) I would like to print the origin of an image. With this line:

12:38 (. image getOrigin)

12:38 I obtain this:

12:38 #<VectorDouble org.itk.simple.VectorDouble@295f7c4b>

12:38 But the real origin is [0.283453, 0.283453, 0.283453]

12:38 I obtain the origin from a long list using:

12:38 (println image)

12:38 * nDuff ponders future vs future-off :)

12:38 svedubois: How I can print the origin? And the origin in the x axe?

12:38 The javadoc of Image http://jsfiddle.net/svedubois/MdPWz/

12:38 The javadoc of the VectorUInt32 http://jsfiddle.net/svedubois/WBvEt/

12:39 nDuff: svedubois: The first thing I'd try, without looking at those docs: (vec (. image getOrigin) )

12:40 svedubois: nDuff: java.lang.RuntimeException: Unable to convert: class org.itk.simple.VectorDouble to Object[]

12:40 nDuff: ...yeah, gathered that looking at the docs. A "container class" that doesn't implement any Java standard container interfaces? WTF?

12:41 llasram: It's some sort of SWIG-generated cruft

12:43 svedubois: llasram: Yes it is swig generated

12:43 nDuff: svedubois: Huh. Well, you can extend Seqable to know how to handle it, if you want.

12:43 llasram: nDuff: Did Seqable become a protocol when I wasn't looking...?

12:45 nDuff: llasram: Oof -- my bad.

12:53 ppppaul: thanks llasram

12:54 svedubois: (defn seqable? [x] (instance? clojure.lang.Seqable x))

12:54 (seqable? (. image getOrigin))

12:54 ;-> false

12:55 hyPiRion: eh

12:56 ,(instance? clojure.lang.Seqable "foobar")

12:56 clojurebot: false

12:56 hyPiRion: ,(seq "foobar")

12:56 clojurebot: (\f \o \o \b \a ...)

12:57 mattyw: why does (lazy-seq (slurp "some-large-file")) take much less time than (slurp "some-large-file")?

12:58 hiredman: 1/win 15

13:01 svedubois: (seqable? (seq (. image getOrigin)))

13:01 java.lang.IllegalArgumentException: Don't know how to create ISeq from: org.itk.simple.VectorDouble

13:01 hyPiRion: ,(macroexpand-1 '(lazy-seq (slurp "some-large-file")))

13:01 clojurebot: (new clojure.lang.LazySeq (fn* [] (slurp "some-large-file")))

13:01 nDuff: svedubois: I think you kinda' missed the point there.

13:02 svedubois: How I can print the origin and not the name vector ?

13:02 nDuff: svedubois: ...well, you need to write code that describes how to decode the object, since it's not a type that Clojure knows anything about, and it doesn't implement any common Java interfaces Clojure could use to know what it is.

13:02 hyPiRion: mattyw: That's your reason - whenever creating a lazy-seq, you're not evaluating the contents until needed

13:03 mattyw: so it really doesn't slurp the entire file until needed?

13:03 silasdavis: yogthos: not sure if the util.clj module belongs in luminus given that it's not used by the base pages and the functions are a bit arbitrary

13:04 hyPiRion: mattyw: exactly

13:04 mattyw: hyPiRion, that's cool! Thanks very much, I had a feeling that's what it was doing but wasn't too sure - it's cool

13:04 nDuff: svedubois: one approach would be to build a wrapper that extends ASeq.

13:05 svedubois: ...but no matter what, you're going to be writing code.

13:05 hyPiRion: mattyw: you're welcome :)

13:05 svedubois: nDuff: Perhaps it is possible to decode the result #<VectorDouble org.itk.simple.VectorDouble@295f7c4b> with some method from the VectorDouble class http://jsfiddle.net/svedubois/RH5Mc/

13:05 nDuff: ...

13:06 svedubois: No.

13:06 yogthos: silasdavis: yeah that could probably go

13:06 nDuff: svedubois: No method in that class implements standard Java collection types.

13:06 svedubois: You are going to have to write code. You.

13:06 s/implements/returns something that implements/

13:06 svedubois: nDuff: With get(int i)?

13:07 * nDuff does an eyeroll.

13:07 jkkramer: svedubois: (mapv #(.get vd %) (range (.capacity vd)))

13:08 or .size or whatever

13:08 svedubois: jkkramer: Thanks, that's work

13:08 (mapv #(.get (. image getOrigin) %) (range (.capacity (. image getOrigin))))

13:08 ;-> [0.28345292806625366 0.28345292806625366 0.28345292806625366]

13:13 marianoguerra: is there a way to build a promise passing a list of promises and get it resolved as soon as the first one is resolved?

13:14 yogthos: svedubois: you can make it a bit cleaner with .. notation (mapv #(.. image getOrigin (get %)) (range (.. image getOrigin capacity)))

13:16 silasdavis: yogthos: is the timbre dependency being used (is any logging set up)?

13:17 yogthos: silasdavis: yeah http://luminus.herokuapp.com/docs/logging.md

13:17 it logs to standard out by default

13:18 technomancy: :use?

13:18 llasram: marianoguerra: Why not have just one promise?

13:20 silasdavis: yogthos: ah so should I add that manually?

13:21 yogthos: silasdavis: yeah sprinkle logs in as needed ;)

13:21 technomancy: you mean in the example? :)

13:22 technomancy: based it off the official docs ;)

13:24 silasdavis: If I wanted default debug logging everywhere do I need to add the use directive to every file?

13:24 marianoguerra: llasram: because the other function is returning a promise for each item, but I can modify that to use one I pass as an optional param, thanks :)

13:33 llasram: marianoguerra: Cool beans. Do be aware that different versions of Clojure react differently to re-`deliver`ing. The docstring still says it throws an exception, but starting with 1.[34]? it actually just silently does nothing

13:33 yogthos: silasdavis: as far as I know you do have to reference the libraries in each namespace

13:35 llasram: silasdavis: You can use the fully-qualified name for a var once it's been loaded, but it isn't good practice, as you can't know if it's been loaded yet unless you do so in each using namespace

13:35 ppppaul: i'm trying to use java.net.URI with (file) but it's giving me an exception saying that i don't have an absolute path

13:35 technomancy: can someone explain to me the point of git tags that have messages?

13:35 ppppaul: how do i get an absolute path from a rel path

13:37 joegallo: ppppaul: http://docs.oracle.com/javase/6/docs/api/java/io/File.html#getAbsolutePath%28%29

13:37 ppppaul: :D thanks

13:37 llasram: ppppaul: Or (.toURI (clojure.java.io/file "example.txt"))

13:38 svedubois: jkkramer: The Direction of an image is a matrix like this:

13:38 1 0 0

13:38 0 1 0

13:38 0 0 1

13:38 So I would like to obtain this vector so I write:

13:38 (. image getDirection)

13:38 ;-> #<VectorDouble org.itk.simple.VectorDouble@6645add0>

13:38 (mapv #(.. image getDirection (get %)) (range (.. image getOrigin capacity)))

13:38 ;-> [1.0 0.0 0.0]

13:38 Is there any kind of function like mapv to obtain the matrix and not the vector?

13:38 hiredman: svedubois: read the docs for the library you are using

13:39 jkkramer: svedubois: see hiredman's response. if there's a way to get it out of the java api, you can use that to generate a clojure data structure

13:39 hiredman: org.itk.simple.VectorDouble is not a from clojure, so there are no clojure functions for doing anything with it, if you want to do anything with it you need to read the documentation

13:40 hornairs: anyone have any experience with giving ring an InputStream as a response body? i'm trying to get it to send data to the client as it gets written to the stream but it seems to wait until the stream is closed to send any

13:41 thanks for any help anyone can give!

13:50 jkkramer: hornairs: in the past I've followed the pattern seen here: https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/util/io.clj#L10

13:50 i.e., create piped streams, start a thread to write to the output stream, return the input stream as the ring body

13:56 llasram: Weird though, it looks like if you're using ring's servlet wrapper, which is used by the jetty adapter, then it will read the entire stream before responding: https://github.com/ring-clojure/ring/blob/master/ring-servlet/src/ring/util/servlet.clj#L95

13:56 yedi: does a clojure map have the same time characteristics as a conventional hashmap? (with constant time access)

13:57 weavejester: llasram: What do you mean?

13:57 yedi: In theory, no. In practise, yes.

13:58 yedi: The Clojure map is effectively a tree of constant-time hash tables

13:58 yedi: even though clojure's immutable data structure implementation makes maps basically al inked list of other maps?

13:58 oh it's a tree?

13:58 weavejester: yedi: But the tree isn't that deep, so it's almost the same thing as a hashtable in practise

13:58 llasram: weavejester: Oh hey! I was have some similar issues to hornairs getting chunked encoding responses working recently, so just dove into the ring code

13:59 weavejester: llasram: Could you explain the problem in more detail?

14:00 hornairs: does io/copy block on a read until the stream is closed?

14:00 llasram: weavejester: Oh, I see -- the response object isn't returned. It pre-exists, so the response can begin as soon as one begins writing to the response's output stream

14:00 weavejester: hornairs: Yes, it's blocking I/O.

14:00 llasram: Right

14:01 llasram: Ok, just injecting confusion then :-)

14:02 hornairs: llasram thanks for investigating though! my current symptom is an empty response with the content length header set to 0 which makes the client close the connection, so im not sure if my stream writes later ever make it out

14:05 adu_: technomancy: r7rs is better

14:31 andrewmcveigh: Using cemerik's friend, I want to keep track of all login attempts. Where would be the best place to do this? Create a wrapper fn for a workflow (currently using interactive-form)? Make my own workflow? Something in middleware?

14:34 gtrak: it depends on how folks log in... I ended up not using workflows at all, just a manual merge-authentication

14:36 in a compojure route handler

14:37 andrewmcveigh: I'm currently using the interactive form workflow, and it's working pretty well for me at the moment, so ideally I'm not wanting to write too much code to deal with this.

14:38 gtrak: the docs say a workflow is a ring-handler except it may return an authentication map instead of a ring response, so a 'middleware' might do the trick

14:39 andrewmcveigh: I mean I could write a little middleware, but it seems like it would be trivial to have it in friend itself.

14:39 hmm...

14:44 gtrak: thanks for the input :), I'll think about it a bit more.

14:44 gtrak: no prob, I'm sure I'll need to learn workflows at some point :-)

14:48 ppppaul: if anyone here uses clutch, i would be very greatful to get a link with an example of (put-attachment) using a inputstream. :)

14:48 i'm looking at the source code and i can't seem to figure out how to use the function :(

14:59 muhoo: does 126Kb sound normal/accepted for :advanced compilation of a cljs hello world?

14:59 also, is it normal for :advanced mode to pretty-print the output?

15:00 nDuff: muhoo: No, it's not.

15:00 muhoo: Are you sure it's actually being run through Google Closure?

15:01 muhoo: nDuff: how would i determine that for certain?

15:01 Raynes: tpope: http://stackoverflow.com/questions/14145425/vim-foreplay-is-really-slow-with-ruby-1-9-but-fast-with-ruby-1-8-on-windows

15:01 nDuff: muhoo: ...well, if it's pretty-printed, it's definitely not. :)

15:01 muhoo: right. here's the project: https://www.refheap.com/paste/8070

15:02 nDuff: and here's the minimal i need to get it to 130K https://www.refheap.com/paste/8071

15:04 pulling XhrIo out gets it down to 99k

15:06 tpope: Raynes: geez, tufflax is everywhere :p

15:06 Raynes: tpope: Did you see my comments on foreplay a little while ago? I pinged you, but I'm on the road so my internet probably dvanished.

15:06 vanished*

15:07 tpope: Raynes: did not see them

15:07 Raynes: [13:28:14] <Raynes> tpope: vim-foreplay uses Ruby?

15:07 [13:28:55] <Raynes> I don't understand how you do it, man. I wrote like 20 lines of Ruby for a Vim plugin for refheap and even I couldn't get it to work on OS X and half the time on Linux boxes. Vim hates Ruby. Never had problems with Python support.

15:07 muhoo: so the problem appears to be, no matter what i do, either google closure or lein-cljsbuild insists, despite all reason, to pretty print the output

15:08 callen: Raynes: you know the Red Bull Flugtag?

15:08 Raynes: No.

15:08 callen: Raynes: google it for two seconds so I can make the reference.

15:08 muhoo: it's definitely munging variable and object names though, so that part is working

15:08 tpope: Raynes: it does hate ruby, and I've had other issues with python

15:09 * muhoo shrugs and looks blankly at closure

15:09 tpope: Raynes: I did the absolute minimum necessary. just a socket connection

15:09 Raynes: and I fall back to shelling out, if necessary

15:09 Raynes: callen: Got it.

15:09 tpope: You're a good person.

15:09 callen: Raynes: the "vehicles" you see in the Flugtag? That's most Ruby software I've run into.

15:10 tpope: my bencode implemention is pure viml

15:10 Raynes: Yay language bashing!

15:10 * Raynes runs around dancing

15:10 tpope: I'm fine with ruby, just not the vim interface to it

15:11 * muhoo is still chuckling about rhickey saying "gem install hairball"

15:11 tpope: plus, it's basically a money printing machine

15:15 muhoo: yay, :pretty-print false is required, not default. ok, no prob. hello world now 72k

15:22 dnolen: muhoo: yeah, I will say I don't think I've ever seen trivial CLJS programs smaller than 30k-40k after adv. compilation.

15:23 systemfault: Not that bad.

15:24 You will get about 50% compression with gzip

15:24 So a 20k file isn't that bad.

15:25 ejackson: dnolen: don't tempt me with your devil words !

15:25 callen: isn't that 2/3s the size of Google's entire landing page?

15:26 systemfault: You're speaking as if there was a lot of content on it...

15:26 An empty page is even lighter than google.com

15:26 callen: the ideal Zen state.

15:27 ibdknox: there needs to be a separable advanced compilation mode

15:28 then this could be largely done away with

15:29 make cljs.core and the goog.* libs a CDN'd common dependency and call it a day

15:29 first load you eat the 20k gzipped

15:29 any cljs site thereafter? the tiny bit of code actually related to your project is all you'll eat

15:31 we actually need to do something like that for nodejs module sharing anyways.

15:40 Raynes: ibdknox: Can I enable paren matching in lt?

15:44 TimMc: &(Double/parseDouble "-Infinity")

15:44 lazybot: ⇒ -Infinity

15:44 zilti: What can be the reasons for a "IllegalArgumentException: Parameter declaration when-not should be a vector"? I have that in one of my namespaces, and only there. Even when creating a (defn foo (when-not false 1)) I get that message. I eval'd each form separately and only get the message at the foo fn.

15:45 TimMc: zilti: It's saying that it's expecting a parameter declaration.

15:46 and that it should be a vector, but instead it has this "when-not" thing.

15:46 ttimvisher: zilti: you need to add a parameter declaration, like: (defn foo [] (when-not

15:46 false 1))

15:47 zilti: ttimvisher: Yes, sure. It does not change anything. Hm... Maybe I should restart the REPL, could help.

15:48 ttimvisher: zilti: you shouldn't have to but maybe

15:48 i just did it at the REPL here

15:49 zilti: Well it helped.

15:49 ibdknox: Raynes: it should be enabled already

15:51 ttimvisher: zilti: rockin

15:52 ibdknox: Raynes: depending on the theme, it may not be particularly visible, at some point I need to go through all the themes and set the match colors

15:55 Raynes: ibdknox: In that case, my theme doesn't work with it.

15:55 ibdknox: Sorry for the suckage. ;)

15:56 ibdknox: haha

15:56 Raynes: I'll take a look. I'm working on a major refactor and a *big* set of experience improvements right now. 0.3.0 is going to be an awesome release. :)

15:57 Raynes: ibdknox: Refactor? How many times are you going to rewrite that thing?

15:57 ibdknox: same way of writing it, just fixing some of the stupid mistakes as I was learning how this methodology would work

15:58 nDuff: Whoa.

15:58 hyPiRion: (constantly :refactoring)

15:58 nDuff: Some shiny stuff going on in Incanter 1.5.

15:59 llasram: I just got the name: in-cant-R

15:59 hyPiRion: more like I-can't-R

16:00 ibdknox: nDuff: like what?

16:00 ejackson: blas backend for the matrix stuff !

16:01 woot

16:01 llasram: Doesn't it already use parallel colt, which can use a blas backend if available?

16:02 ejackson: sortof. The idea was to build incanter w/o native deps.

16:03 so I'm not sure how easy it would be to get the PC going the native BLAS.

16:03 llasram: Ah, gotcha

16:03 ejackson: the 1.5 stuff uses jblas, which keeps most of the numeric ops in java

16:03 but farms out any non-linear time stuff (inversion etc) to fortran

16:04 llasram: Neat!

16:04 ejackson: llasram: also, the name is a play on a Neal Stephenson novel

16:04 Anathem :)

16:05 yogthos: that was a good book :)

16:05 ejackson: indeed !

16:05 yogthos: anybody read his latest one?

16:05 ejackson: meh

16:05 yogthos: reamde?

16:05 not as epic?

16:06 ejackson: too epic, not as brilliant

16:06 yogthos: ah

16:06 reading this right now http://en.wikipedia.org/wiki/Quarantine_(Greg_Egan_novel) it's fantastic :)

16:06 in a similar headspace as anathem

16:06 ejackson: thanks.

16:13 technomancy: bbloom: hey, did you want to meet up for dinner before seajure?

16:13 my other friend isn't going to mke it

16:13 make

16:20 TimMc: "Other friend"? HEY LOOK THIS GUY HAS > 1 FRIENDS

16:20 Seba51: Can I do something like (let [{:keys [[x :as foo] y] } point] to extract key :x but bind it to foo?

16:21 technomancy: heh

16:21 pjstadig: technomancy: you know i'd totally do dinner with you if I didn't live 3,000 mi away

16:21 hyPiRion: TimMc: Other clojure friend within driving distance

16:21 technomancy: pjstadig: it's mongolian BBQ; totally worth the trip.

16:21 amalloy: Seba51: yes, but not with the keys shorthand

16:22 TimMc: ,(let [{foo :x, y :y} {:x 1 :y 2}] [foo y])

16:22 clojurebot: [1 2]

16:23 Seba51: Thanks, I knew the other but are still learning ;-)

16:23 hyPiRion: ,(let [{foo :x, :keys [y]} {:x 1, :y 2}] [foo y])

16:23 clojurebot: [1 2]

16:23 dhm_: technomancy: what place? not that i would crash, just love mongolian bbq

16:24 Seba51: This community is amazing. Thankfully, I do not have to pay a beer for every response. :-D

16:24 ihodes: actually, Seba51, you do

16:24 technomancy: dhm_: Ruzhen on University Way: https://plus.google.com/101916490585616946067/about?gl=us&hl=en

16:24 dhm_: technomancy: cool, thx

16:24 TimMc: ihodes: Incorrect, I accept chocolate as an alternative.

16:25 technomancy: dhm_: happy to have you at seajure if you're local

16:25 ihodes: TimMc: chocolate stout. i understand.

16:25 dhm_: technomancy: thanks, been a few times and loved it (darren)

16:25 technomancy: ah, cool

16:26 hornairs: i am struggling to get streamed output working with ring, if anyone has any pointers I would super appreciate it! https://gist.github.com/4447300

16:27 i get a 0 content length output immediately instead of seeing my two stream writes

16:28 justincampbell: is there a way to async/background something in clojure?

16:28 hyPiRion: agents?

16:28 justincampbell: like, i just want a form that executes and returns right away

16:28 maybe?

16:28 ill look them up

16:28 technomancy: probably futures for that

16:30 justincampbell: (future …) is perfect, thanks!

16:30 amalloy: huh, i didn't know about ring.util.io/piped-input-stream

16:31 TimMc: &(nth (nth (destructure '[{:keys {b a}} 1]) 5) 2)

16:31 lazybot: ⇒ :[b a]

16:31 TimMc: I'm not really sure how it came up with that.

16:32 I suppose ##(-> '{b a} first str keyword).

16:32 lazybot: ⇒ :[b a]

16:32 amalloy: hornairs: i bet the outputstream doesn't have a .write(String) method

16:32 output streams generally don't

16:33 hornairs: amalloy: wouldn't i get loud complaints if that was the case?

16:34 amalloy: yes and no. you'll get an exception in the thread where that writing is happening

16:34 llasram: (inc amolloy)

16:34 lazybot: ⇒ 1

16:34 llasram: hah

16:34 (inc amalloy)

16:34 lazybot: ⇒ 38

16:34 amalloy: and exceptions on another thread vanish into nothing unless you ask for them

16:34 hornairs: do you have to do something special to get exceptions from threads spawned by futures?

16:34 aha!

16:34 gtrak: hornairs: when you deref it, the exception will propagate

16:35 amalloy: he doesn't have access to the future object, though. it's created and managed by someone else

16:35 gtrak: oh, nevermind

16:36 hornairs: maybe ill do my own try/catch and log em?

16:38 thanks amalloy, that was silly of me

16:46 mpan: is there an easier way to have a function that takes either [x y z] or [x z] than to specify it as [& xs] and counting them?

16:47 dhm_: mpan: you can supply an ([x z] ...) version and invoke the ([x y z] ...) version with the default value of z

16:49 mpan: does just fn support that? or is that something that defn does for you?

16:49 terom: mpan: (defn f ([x z] ...) ([x y z] ...))

16:50 dhm_: yeah what terom said

16:50 hornairs: so I still can't get ring to flush the first part of the stream, it seems to wait until the stream has been closed to send anything to the client https://gist.github.com/4447544#file-core-clj

16:50 terom: mpan: yeah, fn supports it also

16:50 mpan: thank you all

16:50 hornairs: i have a sneaking suspicion it might be because ring wants to calculate the length of the response for the Content-Length header

16:51 nDuff: ibdknox: Matrix types (via clatrix) that are both fast (native BLAS types) and seq-able.

16:53 hiredman: hornairs: piped streams have a buffer size, your test almost certainly doesn't fill the buffer

16:53 also your paren placement is bad

16:55 Seba51: Green bar, beer and chocolate is fine. Are there any Clojure conferences where people meet?

16:58 TimMc: ihodes: I'd prefer a stout chocolate, really.

17:02 nDuff: Seba51: there's the conj and Clojure/west every year.

17:15 loganlinn: are there any good open-source tools for inspecting/visualizing JVM stats?

17:16 nDuff: Hrm. Free-of-cost, maybe, but nothing open-source that I know of.

17:16 loganlinn: free will do

17:16 nDuff: Free for production use, or is free for development use good enough?

17:17 If the latter, I've been pretty happy with the tools that ship with JRockit

17:17 loganlinn: development use for now

17:17 * nDuff hasn't tracked how/whether they've changed their licensing over the last several years, though

17:17 loganlinn: ok, cool. ill check it out — thanks!

17:18 nDuff: ...it at least used to be that JRockit's advanced tooling was free-to-use with the restriction that it would require JVM shutdown after 30 minutes to prevent production use without buying a license.

17:18 yogthos: loganlinn: have you tried jvisualvm?

17:18 nDuff: (production use of the advanced tooling, that is, not the base VM)

17:19 mich2: VisualVM?

17:19 yogthos: mich2: yeah, I've used it for profiling before

17:20 mich2: it can check threads, memory usage, etc. can also connect to remote vms which is nice

17:20 mich2: Ah my mistake

17:20 * nDuff 's employer pays the $$$$ for YourKit, so he hasn't looked into lower-cost options for a while.

17:33 hiredman: ob

17:35 zoldar: Hello. Is there a way in Clojurescript to mock a function (from a different, required namespace) in a away similar to with-redefs-fn?

17:38 loganlinn: mich2: VisualVM is exactly what I wanted. Thanks

17:39 jjl__: what's best practice on config files for web apps? obviously i need to have something outside of the jar file. but shouldn't i have some sort of hook that installs a default one if there isn't one? and where should i place it?

17:40 XPherior: jjl__, Are you using Immutant, Noir, or something like that?

17:41 jjl__: no, i'm using compojure

17:41 hiredman: https://github.com/sonian/carica

17:41 merges maps of configurations found on the classpath

17:42 jjl__: sorry, i'm quite new to jvm things. i thought the classpath was purely for code?

17:43 XPherior: Classpath can be for any files.

17:45 jjl__: sorry if i sound a bit thick, but how do i reference non-code files that are on the classpath?

17:46 weavejester: jjl__: clojure.java.io/resource

17:46 XPherior: jjl__, I don't have a lot of experience with this either. But seems like either through Carica (above) or Java resources.

17:46 Yeah, that one. ^

17:47 weavejester: Be aware that resources do *not* have a beginning /

17:47 So if you have a file resources/public/css/foo.css

17:47 You'd get the URL of it with (io/resource "public/css/foo.css")

17:48 Which you could then read with clojure.core/slurp or any one of the clojure.java.io functions

17:48 jjl__: okay, so that could be in my jar file or if i had an entry in the classpath that was just a directory, relative to there too?

17:49 and carioca would merge them so i could provide defaults?

17:49 weavejester: Right

17:49 jjl__: sweet

17:49 is this a typical way of doing config in jvm languages?

17:49 weavejester: Well……..

17:49 jjl__: (i come from a dynamic language background, so much of this is new to me)

17:50 weavejester: Some Java libraries, particularly older ones, tend to favor XML

17:50 Which you obviously want to avoid ;)

17:50 jjl__: like the plauge

17:50 plague(

17:50 arrdem: hahaha

17:51 jjl__: i've yet to find a satisfactory xml library in any language. i suspect it's not possible

17:51 weavejester: The Heroku guys put forward a suggestion at 12factor.net that server-side apps should be configured via environment variables

17:51 XPherior: It's not the library that's the problem, jjl__.

17:51 weavejester: Which is the approach I currently favour

17:51 jjl__: weavejester: haha. and when you have a complex app that has nested sections, that's going to go down well

17:52 nDuff: jjl__: I'm pretty happy with lxml.etree (Python).

17:52 weavejester: jjl__: True, but it does force you to simplify your config

17:52 jjl__: nDuff: thanks for the pointer. if i have to do xml stuff in python again, i'll take a look. i think i used one of the core things last time

17:52 nDuff: ...not that human-generated configuration is anywhere remotely close to XML's sweet spot...

17:53 weavejester: Another option is to look for a config file. I guess really it depends on what your app does.

17:53 nDuff: jjl__: FYI, the Python standard library now contains ElementTree, which lxml.etree is an extension of.

17:53 weavejester: Terminal apps usually have config files in their home directory

17:53 jjl__: nDuff: elementtree rings a bell

17:53 nDuff: jjl__: ...but yes, the several other options in core besides that one all suck.

17:53 weavejester: Server side apps often have an argument or environment variable you can set to point to a config file

17:53 jjl__: nDuff: i think elementtree is what i ended up using last time

17:53 nDuff: jjl__: ...and ElementTree isn't that great either (doesn't support real XPath, for instance)

17:54 jjl__: nDuff: my needs were simple. xpath has a habit of complicating things unless the xml is silly complex

17:54 nDuff: Eh? XPath is simple. XQuery is where things get interesting. :)

17:54 * nDuff grouses about libxml2 being back in the dark ages...

17:55 jjl__: xpath is sufficiently complicated. most of the time i'd be happier writing css-style selectors, which some libraries handily provide

17:55 weavejester: In Clojure zippers are a more generic alternative to XPath

17:55 nDuff: jjl__: ...yes, lxml.etree does provide css-style selectors.

17:55 jjl__: i don't do much python anymore, but i'll note it down. thanks for the tip

17:56 i have a more obscure question too...

17:56 nDuff: weavejester: I'm not sure how I feel about zippers. XQuery and XPath are amenable to high-performance processing with pre-indexed documents. Zippers feel like they preclude that.

17:56 weavejester: nDuff: I guess it depends on how big your XML document is.

17:57 nDuff: If it's large enough that you need a lot of indexing, then maybe you need to load it into a proper DB

17:57 nDuff: weavejester: well, yes. I'm talking about this in the context of an XML-aware database. :)

17:57 jjl__: i'm building a webapp i want to be extensible with plugins. i'm assuming most users of it won't be clueful enough with clojure and will want something more java-esque, but i want to preserve all the handy thread local stuff clojure does for me and manage access to shared data with STM. as a result i'm going to write a compiler for some other language that compiles down into clojure, and then turn that into class files. is there some nice api for driving the cloj

17:57 nDuff: s/database/datastore/

17:58 weavejester: ...or, to clarify: I'd rather be writing my queries in a way that can port over to a high-performance datastore.

17:58 weavejester: ...given that I do actually have and use one. :)

17:59 weavejester: jjl__: Why not just create a Java interface that talks to Clojure underneath?

17:59 nDuff: I wonder how easily one could turn Datomic into an an XML indexer

18:00 jjl__: weavejester: hrm. i'm wondering what i'd need to provide through that and if it may turn out to be a lot of work. i presume that would allow people to use scala etc. as well though?

18:00 nDuff: weavejester: *nod*; it's an interesting thought.

18:01 jjl__: weavejester: i'm guessing i'd have to make wrappers over everything i wanted them to have access to?

18:01 weavejester: jjl__: Sure. I mean, it depends on what you want to do, but every (most?) JVM languages can create an object that implements an interface.

18:02 nDuff: ...even Jython can do that, and its integration with the JVM's object system is otherwise awful.

18:02 weavejester: jjl__: Yes… but are there that many things you need to do that for?

18:03 jjl__: weavejester: it's going to be a big app. but i suppose it's worth the effort

18:03 weavejester: jjl__: Another option is have the plugins interact through a web service.

18:03 jjl__: that sounds terribly inefficient. not at all something i'd do in a dynamic language

18:04 i suppose i have the luxury in that case of mandating people use that language though, hrm...

18:05 weavejester: jjl__: If you look at apps for systems like Facebook, that's how they operate.

18:05 jjl__: part of the thing is that i'm designing it so that the core of the application is utterly minimal and most of the code that ships with the app is distributed in plugins as well

18:05 kovas: is there a good clojure lib for manipulating sql schemas? looking at lobos, wondering if theres others

18:05 jjl__: facebook doesn't exactly have a choice :)

18:06 kovas: lobos + korma was the best i found. but it seems to lack a lot of things :/

18:06 kovas: jjl__: anything in particular that sucks?

18:06 jjl__: well, i wanted to use postgis columns and i couldn't figure out how

18:07 kovas: jjl__: ok. I'm gonna be working with mysql so maybe ill be ok

18:07 jjl__: mysql is much less complicated in general

18:07 nDuff: *shudder*

18:08 * nDuff associates MySQL with data loss and major features missing for no good reason, and his more recent experiences have done nothing to change that.

18:08 XPherior: Haha

18:08 War story, nDuff!

18:09 jjl__: i can go several steps further than that, but this isn't really a channel for hating on poor technology is it?

18:09 kovas: sometimes we gotta do data analysis on the databases we have, not the ones we want..

18:09 nDuff: XPherior: Which one do you want? My MySQL war stories go back to the one in the mid-90s about a car dealership running their finances with no relational integrity...

18:10 jjl__: but mysql is nothing compared to what people try and make it do that it can't ;)

18:10 XPherior: nDuff: Any of them result in limb loss?

18:10 nDuff: XPherior: None that good, no.

18:11 snowylike: but i want to hear about that car dealership

18:11 jjl__: nDuff: that's boring compared to the 3 table database i used to work with. an EAV store with values in blob columns. that could be foreign keys. and 3 joins sent it into exponential time

18:11 XPherior: nDuff: You're not a *real* software engineer until you've lost a digit or two on the job.

18:11 snowylike: XPherior: does RSI count as limb loss?

18:12 XPherior: Only if it turned blue, snowylike

18:12 yogthos: my question is why use mysql when postgres exists

18:12 :)

18:12 jjl__: yogthos: and a good one to ask the boss when they insist on mysql

18:12 ibdknox: I've seen some "amazing" things done with mysql databases lol

18:12 yogthos: jjl__: ha!

18:13 jjl__: next week i shall mostly be fixing mysql performance problems ;)

18:14 ibdknox: once upon a time ago, I was asked to fix the slowness of a company's PHP website. Turns out they were executing over 2400 queries per page load.. these queries joined on *regular expressions*

18:14 technomancy: kovas: I would avoid lobos; they appear to be working under the misconception that it's possible to abstract over the differences between DBs

18:14 * arrdem shudders

18:14 yogthos: oh my

18:14 kovas: technomancy: yeah, so it seems :/

18:14 technomancy: clojurebot: clojars migrations?

18:14 clojurebot: next-gen clojars is a proposal for a revamped Clojars repository with higher standards: http://groups.google.com/group/clojars-maintainers/browse_thread/thread/77c1cd77e478bb0f

18:14 XPherior: technomancy: It's gotta get solved someday.

18:14 arrdem: technomancy: idk... I managed to abstract away my transiton from ibdknox's SimpleDB to Mongo...

18:15 kovas: all i want is to get the mysql schema as a reasonable clojure data structure.

18:15 jjl__: technomancy: for the most part, it is. DBIx::Class (perl) manages except for really complex stuff

18:15 nDuff: ibdknox: Been there, done that... though it was Django, not PHP.

18:15 technomancy: arrdem: it's possible, for trivial programs

18:15 and lucky programs

18:15 kovas: I recommend just writing the SQL

18:15 here's what clojars does: this is

18:15 err--https://github.com/ato/clojars-web/blob/master/src/clojars/db/migrate.clj

18:15 jjl__: ibdknox: how about some php that generated 101 queries and unioned them together?

18:15 Foxboron: technomancy, any plans fixing lein for windows?

18:16 technomancy: Foxboron: not really, but I'll take a patch

18:16 kovas: technomancy: thnx

18:16 Foxboron: technomancy, but batch is so ugly ._.

18:16 ibdknox: jjl__: heh I've seen it all ;) My PHP days were darker times.

18:16 yogthos: haha I worked on the opposite end of the stick from that, had an overactive oracle dba once :)

18:16 jjl__: ibdknox: apparently i have some queries that do full table scans to look at next week. that should be fun

18:16 yogthos: half the application lived in stored procs

18:17 which he managed with notepad more or less

18:17 ibdknox: lol

18:17 yogthos: no source control nothing

18:17 it was fast, but completely and utterly unmaintainable by anybody but him

18:17 technomancy: clojurebot: clojars migration is done simply with a bunch of sql defns in a single namespace: https://github.com/ato/clojars-web/blob/master/src/clojars/db/migrate.clj

18:17 clojurebot: Ok.

18:17 ibdknox: job security!

18:17 yogthos: indeed :)

18:17 maybe he knew what he was doing after all :P

18:18 ibdknox: the most ridiculous db I worked with was for wines

18:18 jjl__: you'd be surprised how often "write more stored procs" is a good answer

18:18 ibdknox: to my knowledge it was the single largest data collection on wines in existence

18:18 jjl__: particularly if you have a lot of apps in different technologies

18:18 yogthos: jjl__: oh stored procs can be very handy

18:19 ibdknox: to get the information for a single wine its entirety required a query that was a couple pages long

18:19 yogthos: jjl__: but there is a line you cross somewhere when they start outgrowing the actual application :)

18:19 ibdknox: in its*

18:19 jjl__: if you've got complex validation logic, for example, across several apps, sometimes it's good to get the database to do it

18:20 yogthos: ibdknox: people do some weird stuff with dbs ;)

18:20 jjl__: that said, these days i'd probably shove a webservice in front of it instead

18:20 yogthos: jjl__: that would be my preference as well, db should worry about the actual storage

18:20 zoldar: sorry for repeating myself, but how to approach function mocking in cljs? I've seen somebody using goog.testing/createMethodMock, however I couldn't sort out how it actually works.

18:21 yogthos: jjl__: it also makes it pretty tricky to figure out what the actual business logic is when some of it is sprinkled in db and some in the app

18:21 mpan: is it possible to evaluate arbitrary clojurescript determined at runtime? does the compiler being in clojure prevent that?

18:21 jjl__: yogthos: you also have to love when the only place the stored procs are is the database and you can't see the code

18:22 mpan: as in, I would like the user to specify some code at runtime, and then eval that

18:22 callen: ibdknox: why was it so complicated?

18:22 ibdknox: callen: outsourced to a team of idiots

18:23 jjl__: mpan: i don't know if it's the 'right' answer as i don't use clojurescript, but you could ship the compiler source?

18:23 ibdknox: their naming strategy was comical

18:23 there were 3 wine tables

18:23 Wine

18:23 mpan: basically, my use-case is that I want people to be able to just run this in their browser without setup

18:23 ibdknox: _wine and __Wine

18:23 mpan: preferably without resorting to a server-side compiling service

18:24 callen: ibdknox: Right. right. Figures.

18:24 yogthos: ibdknox: this is shaping up great already :P

18:24 jjl__: ibdknox: a crappy attempt at sharding?

18:24 mpan: (because honestly I'm not even sure how that would fit in)

18:24 yogthos: ibdknox: does the number of underscores signify some perverted naming convention?

18:24 jjl__: mpan: compile clojurescript with clojurescript?

18:25 ibdknox: yogthos: that would be giving them too much credit. I'm pretty sure this was their attempt at doing something like wine2 and wine3

18:25 yogthos: ibdknox: brilliant!

18:25 ibdknox: all the tables contained wildly different information and used different kinds of keys

18:25 mpan: wait, you can compile cljs in cljs now?

18:25 ibdknox: mpan: not reliably

18:26 mpan: and no, there's no way to do what you want (yet) without a server

18:26 kanaka is the closest

18:26 mpan: https://github.com/kanaka/clojurescript

18:26 mpan: thanks

18:27 ibdknox: but that has a good ways to go

18:27 mpan: so, my specific use-case is to create something resembling netlogo ( http://ccl.northwestern.edu/netlogo/ ) but on top of a general-purpose language

18:27 ibdknox: yogthos: but yeah, just joining those 3 tables together required the use of 4 other tables.

18:28 mpan: major part of that is to eval user-supplied code to determine what the turtles do

18:28 ibdknox: mpan: just use the compiler as a service

18:28 yogthos: ibdknox: that's something alright, I imagine that ran at blazing speeds :)

18:28 zilti: "Today I learned that a function called init without any arguments gets executed each time the ns gets required or used."

18:29 mpan: is that doable even if I need the user-supplied code to be able to reference code from the library and code supplied earlier?

18:29 ibdknox: mpan: yeah, that's fine

18:29 mpan: is himera the example I should be looking at?

18:29 ibdknox: mpan: as long as the compiled JS is already on the client it won't matter

18:30 mpan: you can only do simple optimization for that though

18:30 mpan: himera is a good start, yeah

18:30 mpan: that's great

18:30 thanks!

18:31 ibdknox: yogthos: if I remember correctly a full query joined on 25 tables. So yeah - blazing ;)

18:31 yogthos: ibdknox: rofl

18:31 ibdknox: this is when I learned to hate SQL

18:32 kovas: i think i started hating SQL when i learned of the join table concept

18:32 ibdknox: thousands upon thousands of lines were devoted just to handwritten SQL queries (ORM's didn't really exist then)

18:32 even if they had, I don't think they could've handled what we were doing lol

18:33 yogthos: yeah that's one thing that happens with orms often, you start out with small data sets and it's all peachy

18:33 then you get close to production time and start testing with some real data and find out the the orm generated queries are... not optimal

18:33 ibdknox: I've written 3 :) and then whatever Korma is

18:33 yogthos: my primary experience is with hibernate

18:34 the things I've seen done with hibernate *shudder*

18:34 ibdknox: haha

18:34 Korma was intentionally not an ORM

18:34 rather an efficient means to generate SQL

18:34 yogthos: yup

18:34 ibdknox: the ORM abstraction *always* broke down

18:34 nDuff: Eh.

18:35 * nDuff is happy with SQLAlchemy.

18:35 yogthos: well there's a fundamental mismatch between object trees and relational tables

18:35 nDuff: ...mind you, that's the _only_ ORM I've ever been happy with

18:35 jjl__: ibdknox: oh korma is yours?

18:35 nDuff: ...and it has a very extensive "SQL builder" layer that has nothing to do with object mapping...

18:35 ...and it's a huge, insane amount of code and trouble...

18:35 but it's an existence proof that such things can be done well, even so.

18:36 (err, trouble for its maintainer, who does a very good job)

18:36 ibdknox: jjl__: originally, Alex Baranosky is driving it now

18:36 jjl__: nDuff: there's an awesome new perl library that does this properly. any day now

18:36 nDuff: jjl__: You expect _anything_ to be well-designed in Perl?!

18:37 jjl__: nDuff: quite a lot of things are actually. just nothing older than the last 5 years.

18:37 nDuff: perl has the best ORM of any language i've worked with

18:38 nDuff: and it now has a library for implementing a CLOS-like object system

18:40 * nDuff hasn't been in the Perl ecosystem for much, much longer than that, but is... surprised... that it's seeing uptake amongst folks acquainted with formalism, completeness, robustness, &c.

18:41 ibdknox: it's a different language these days

18:41 jjl__: it's a really nice language these days

18:43 if it weren't for silly enormous scaling problems on the project i'm working on, i wouldn't have bothered learning clojure and just done it all in perl

18:43 technomancy: good perl people do have a way of just quietly getting stuff done

18:45 jjl__: cpan is fantastic too. there are only two areas where the libraries are better in other languages IMO (rabbitmq and soap client). both of which are better in python (libamqp, suds)

18:45 technomancy: heh; suds

18:45 snowylike: perl has changed much since they started work on perl 6

18:45 jjl__: perl 6 has been great for getting new shiny into perl 5

18:45 nDuff: Is suds actually decent these days?

18:46 jjl__: but i do hope they never finish it

18:46 snowylike: why?

18:46 * nDuff wasn't happy with the state of SOAP libraries in Python at all last time he looked.

18:46 clojurebot: snowylike: because you can't handle the truth!

18:46 snowylike: now that was not the response i expected

18:46 jjl__: perl6 made the same mistakes perl5 did, only a thousand times worse

18:46 snowylike: for example?

18:47 nDuff: Isn't perl6 the one that finally has a formally defined syntax?

18:47 jjl__: minor things can make big differences

18:47 groovy has done this to some extent as well

18:47 nDuff: I mean, that's a hard prerequisite before I consider a language worth even thinking about potentially learning.

18:47 (and became one after prior experience with Perl).

18:47 jjl__: in practice it's not a big problem, actually

18:47 it was a major problem when me and a friend tried to port perl to the jvm

18:48 snowylike: oh, well

18:48 jjl__: but other than that, it's of no consequence

18:48 snowylike: perl and the jvm aren't on friendly terms

18:48 * nDuff also used to be at an embedded-systems house, and was tasked with making Perl cross-compile. It was... a surprisingly interesting project.

18:48 jjl__: nDuff: much better these days

18:49 nDuff: they've really sorted out the compile process. in fact installing a new perl these days is so easy it's been automated by perlbrew

18:52 nDuff: jjl__: As of which releases? I'm seeing reports as recent as 5.14.2 that miniperl is still used to run tests that are intended to apply to the target on the host.

18:53 jjl__: nDuff: hrm, that's possible. i'm not a core hacker. i know around 5.15 they made some changes to reduce the amount that miniperl did

18:53 nDuff: irc.perl.org#p5p would be the place to ask

18:53 aphyr: So... Incanter's (scatter-plot) is a *macro* which takes variable argument options, like (scatter-plot ... :x-label "hi" :y-label "sup")

18:54 SegFaultAX: Does riemann use an in-memory database for its index?

18:54 Or does it use eg redis as the storage mechanism?

18:54 aphyr: So if I want to call scatter-plot and change those options, am I forced to use a macro as well?

18:54 obviously you can't apply a macro :(

18:54 SegFaultAX: the index protocol is pluggable, default implementation is Cliff Click's nonblockinghashmap

18:56 hiredman: aphyr: have you looked at using jfreecharts directly? incanter's charting is a fairly limiting wrapper around it

18:56 gtrak: has anyone ever done parallel builds in clojure?

18:56 aphyr: Yeah I probably should, just... so much boilerplate

18:57 SegFaultAX: if you wanted to use redis it is possible, though you might have an interesting time compiling queries for it.

18:57 Maintaining inverted index consistency can be tricky

18:58 hiredman: aphyr: https://gist.github.com/3949532 is an example of creating a live (updating) time series chart, which isn't too bad

18:59 aphyr: Thanks for the sample, hiredman. Pretty close to dropping incanter and just doing that.

19:00 hiredman: I had trouble getting incanter to create a time series chart and just ended up having unix timestamps as numbers on the axis instead of dates

19:00 SegFaultAX: aphyr: Is Riemann applicable to generic real-time analytics? statsd/gaug.es/etc.

19:00 aphyr: SegFaultAX: short answer, yes. If you want to talk over in #riemann I can explain at a little more length.

19:03 jjl__: any reason why i should stick with lein 1.x instead of upgrading to 2?

19:04 hyPiRion: jjl__: There's no reason to no move to lein2 now

19:04 technomancy: jjl__: none whatsoever

19:04 hyPiRion: not moce*

19:11 tufflax: jjl__: I like to have both, save lein 1.7 as `lein1` because some projects out there use it

19:12 jjl__: technomancy: is there a reason i shouldn't bump lein to 2.x in homebrew?

19:12 technomancy: jjl__: I don't know much about homebrew. there is still one breaking change in the plan before the final 2.0.0 release

19:12 jjl__: aha

19:12 it has a devel version available. (2.0.0-preview10)

19:12 technomancy: https://github.com/technomancy/leiningen/issues/241

19:13 hyPiRion: technomancy: Actually, there's two

19:13 technomancy: hyPiRion: remind me of the other?

19:13 hyPiRion: https://github.com/technomancy/leiningen/issues/885

19:14 You cannot upload the jar without fixing that one

19:14 technomancy: ah, true

19:14 hyPiRion: Which means bash script updates etc.

19:14 technomancy: though it shouldn't be relevant to downstream packagers

19:15 hyPiRion: True

19:15 jjl__: i'll leave it for now

19:16 technomancy: I hope to get preview11 out soon, but I'm stuck debugging a segfault in the horrible sqlite jdbc drivers that clojars is using

19:19 TimMc: technomancy: xerial?

19:19 technomancy: TimMc: ayup

19:20 https://github.com/ato/clojars-web/issues/115

20:01 AimHere: Hmm, how do I tell if an object out of Javaland is a member of a subclass of some particular set X?

20:01 *particular class X

20:01 tomoj: &(let [bar 3] `(foo ~`(bar ~bar)))

20:01 lazybot: ⇒ (clojure.core/foo (clojure.core/bar 3))

20:02 tomoj: I always thought bindings only went 1 level deep in nested `/~

20:02 maybe I'm confused

20:02 TimMc: AimHere: instance?, I think

20:03 tomoj: I don't htink bindings have anything to do with it.

20:03 Each symbol is either quoted or evaluated.

20:04 tomoj: when building macros in the past I've avoided nesting `/~ in some cases where it seemed convenient, thinking that if I nested too far I'd lose access to the local bindings above

20:04 AimHere: instance? looks like it does the trick. Thanks, TimMc

20:04 tomoj: crazy, must have just assumed that to be the case due to unrelated errors on some broken macro I was writing

20:05 technomancy: tomoj: the only thing you lose is gensym consistency

20:05 TimMc: tomoj: You can run into issues with gensyms.

20:05 technomancy: jinx

20:05 tomoj: oh, hopefully that's what I was thinking of..

20:24 bbloom: ibdknox: when you did some of your game stuff, how did you find perf with small vectors?

20:26 i'm considering doing an implementation of gvec for small vectors: ie 2, 3, or 4 elements. it would be nice to generate generate types for vectors, simple shapes, colors, etc, and have them all implement IPersistentVector and friends

20:26 tomoj: I've wondered why there isn't an analogue to PersistentArrayMap for vectors

20:26 hiredman: https://github.com/hiredman/tuples

20:27 bbloom: tomoj: isn't there tho? VectorChunk or something?

20:27 hiredman: ah cool, let me peek at it

20:27 hiredman: there is an open design question in tuples about caching the hash code

20:27 it is a big digusting macro

20:27 bbloom: hiredman: yeah, it would have to be lol

20:28 tuples is definitely the word my brain was searching for tho

20:28 hiredman: it would be interesting to do a vector impl that was all classes and fields instead of arrays in fields

20:28 tomoj: bbloom: well, I dunno, it's not an analogue exactly the way I was thinking, since (vector 1) is a PersistentVector, not a PersistentArrayVector or whatever

20:29 bbloom: tomoj: i think the reason is that it wouldn't yield significant performance improvement

20:29 basically PersistentVector's Node inner class could also be a persistent vector

20:29 tomoj: yeah, I figured if I understood how PersistentVector worked, I'd see why

20:29 bbloom: but it would save you only 3 or 4 words of overhead

20:30 probably not worth doing while PersistentVector is still defined in java

20:30 hiredman: you have 2 design axes, element access speed, and size of structure in memory

20:30 bbloom: hiredman: what are you using your tuples library for?

20:30 hiredman: nothing

20:30 bbloom: heh

20:31 hiredman: so i want a little more flexibility than get12 etc

20:31 hiredman: bbloom: flexibility in what way?

20:32 the gets all provide the fastest possible access, while nth is fast for tuples, it is not as fast as the gets

20:32 bbloom: hmmm i guess extend-protocol would do what i want

20:32 basically, i want to be able to do something like:

20:32 (defvector RectangleF [left right top bottom])

20:32 hiredman: :(

20:32 just use a deftype

20:33 or defrecord

20:33 bbloom: but then i'd also need to (extend-protocol Rectangle RectangleF ...)

20:33 yeah, but i want fast field access

20:33 hiredman: uh

20:33 bbloom: generically, if possible :-)

20:33 hiredman: both defrecord and deftype give you that

20:33 bbloom: well and a persistent vector implementation lol

20:33 hiredman: named tuple types are gross

20:34 bbloom: they are gross for most use cases, but a 3d graphics library needs fast Vector2f, Rectangle, Circle, etc

20:34 hiredman: bbloom: deftype and defrecord will do that

20:35 bbloom: it would also be nice if i could somehow make it so that (= Vector3f (conj (Vector2f. 5 10) 15))

20:35 ie define a range of small vectors

20:35 hiredman: tuples does that, but not super well

20:36 actually, it might do it ok, the call to tuples make get inlined in to a direct constructor call by the clojure compiler

20:38 bbloom: ok, thanks for showing me this

20:38 tomoj: wonder if there is some reason not to make vars named https://www.refheap.com/paste/a5545e10e63a1fa688fd9276a

20:38 bbloom: hiredman: do you mind if i chop it up and adapt it for my needs and publish my changes?

20:39 hiredman: bbloom: sure, enjoy

20:39 bbloom: hiredman: thanks

20:39 hiredman: tomoj: not all vars have names

20:39 it is possible to have "anonymous" vars

20:39 tomoj: not all symbols have namespaces

20:40 I noticed that --unnamed-- case, but how do you create them?

20:40 technomancy: what always weirded me out was that namespaces aren't named

20:40 tomoj: it's weird maybe that Named includes getNamespace

20:40 hiredman: you have to interop on the Var class

20:41 the compiler uses lots of anonymous vars, it is very gross

20:41 tomoj: ..or for a Namespace, would (= (name ns) (namespace ns))?

20:41 karpov: hi all. (newbie question warning!) - would anyone be willing to take a quick look at a 4-line long gist, and tell me why does it throw? https://gist.github.com/4449117

20:41 hiredman: the namespace for a namespace is obviously the classloader that loaded it, not a symbol, so it cannot use the Named interface anyway

20:41 bbloom: karpov: laziness

20:41 karpov: try mapv

20:41 hyPiRion: karpov: You're opening a file, making a lazy list, then close the file

20:42 By making the list lazy, you're trying to read from a closed stream.

20:42 karpov: oooh. so it's closed by the time I attempt to actually read from it during realization?

20:42 hyPiRion: yup

20:42 tomoj: hiredman: :)

20:42 karpov: lol... well that's good to know, thank you all

20:43 hiredman: you should, of course, be using reducers for io instead of lazy seqs https://gist.github.com/4075459

20:44 I guess that is not technically a reducer? it is jsut using coll-reduce

20:44 karpov: funny, I was *just* thinking that maybe reducing would be a better option... but my toolkit is just starting to grow. thanks, will check it out

20:45 tomoj: 'reducer' to me means 'something that implements CollReduce'

20:45 hiredman: karpov: I am sort of joking, no one actually does that, but I think it is sort of a chicken and egg problem, no one has written a library for it because no one does it, because no one has a library …

20:46 karpov: ok then, checking out mapv )

20:47 bbloom: karpov: mapv is just (comp vec map)

20:47 karpov: vectors are not lazy

20:48 you can use vec any time you have a sequence and want to force it to be realized completely

20:48 technomancy: eh

20:48 if you are just interested in forcing a seq it's clearer to use doall

20:48 karpov: hiredman: I do wonder though - why is it that doing something 'inside' the scope of with-open is running into a closed file? that doesn't sound very intuitive...

20:48 technomancy: vec does more than just force the seq

20:49 hiredman: karpov: map is produces a sequence of lazily computed results (a lazy-seq)

20:49 karpov: so until you force the sequence the actually mapping has not happened

20:49 http://clojure.org/sequences

20:50 karpov: oh.. so it's not the 1st lazy sequence (of lines from file), but 2nd one (of map results), that causes a problem?

20:50 hiredman: I dunno, I haven't looked at your code, I am just going by the general reaction to it

20:50 karpov: hm no, based on exception, it's the file ones alright..

20:51 mpan: I added a resource path to my project.clj and I can see it if I launch a new repl with "lein repl" but new repls launched inside eclipse ccw still can't see this change

20:51 karpov: like, double-laziness

20:51 mpan: how can I force eclipse ccw or the relevant parts to reload project.clj?

20:52 hiredman: instead of mapping over the values you returned a closure that called .read on the reader

20:52 it is sort of like the upwards funarg problem

20:52 karpov: yeah that's what I am thinking now, right

20:54 mpan: even restarting eclipse doesn't seem to work, so I'm confused what I'm doing wrong

20:54 technomancy: mpan: :resource-paths ["something"]?

20:54 mpan: if I start a new repl with "lein repl" then it works

20:55 yes, I added a new resource-paths declaration to project.clj

20:55 but nothing I've tried so far has gotten the repls I start inside eclipse ccw to pick up on this

20:55 tomoj: #(if-let [v (resolve %)] (symbol (name (ns-name (.ns v))) (name (.sym v))) %)

20:55 :/

20:56 mpan: so I test this by evaluating (clojure.java.io/resource "favicon.ico"), which works properly if I start a repl with "lein repl", but fails if I start a repl inside eclipse ccw (even though I just closed and restarted eclipse)

20:57 karpov: technomancy: oh, thanks for the doall tip too (and for leiningen =P)

20:57 mpan: oh, hm that's confusing

20:57 I have no idea why, but refreshing eclipse w/ f5 fixed it

20:58 technomancy: karpov: np =)

20:58 marcellus1: Anyone know of any decent guides or advice to help me better understand how/when to use agents?

20:58 Just read the section in Clojure Programming on them, and I sense that I need them in a problem I'm working on, but yet still don't "get" them enough to get any code written

20:59 technomancy: marcellus1: agents are a reference type, so you would use them when you need a stable identity whose value changes over time. but also they're asynchronous, so that plays into it too.

21:00 aaelony: marcellus1: +1 for me as well. I'm starting to use agents for distibuted writing to files, see http://lethain.com/a-couple-of-clojure-agent-examples/

21:01 also: http://stackoverflow.com/questions/8741514/maintaining-multiple-open-files-for-writing-clojure

21:01 marcellus1: sweet thanks guys

21:04 aaelony: there's also a few new functions for agents in 1.5 i think

21:18 ppppaul: i have a (println) in a thread that i want to have printing to my repl, how would i do so?

21:27 jballanc: *sigh* I feel like I've asked this before, but I think I'm still not clear: defrecord vs deftype?

21:27 ppppaul: map

21:27 jballanc: is there more than "deftype can have mutable fields" and "defrecord gets free intefaces"

21:27 ppppaul: records have brought me much pain

21:27 jballanc: interfaces

21:27 ppppaul: how so?

21:28 ppppaul: hard to do transformations on them or something

21:28 i wrote my first clojure program using them, and near the end i removed all of the records completely

21:28 xeqi: http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/

21:28 ppppaul: it was years ago, though

21:29 jballanc: xeqi: thanks! I knew I had read something like that in the past

21:30 ppppaul: if anyone can help me figure out how to get my threads writing to the same emacs repl i would be able to die happy :D

21:31 xeqi: ppppaul: ##(doc bound-fn) ?

21:31 lazybot: ⇒ "Macro ([& fntail]); Returns a function defined by the given fntail, which will install the same bindings in effect as in the thread at the time bound-fn was called. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place."

21:32 ppppaul: :D

21:33 i'm doing this:

21:33 (Thread. (bound-fn (fn []

21:33 (lc/subscribe ch queue-name message-handler :auto-ack true))))

21:33 xeqi: &(doto (Thread. (bound-fn [] (println "hi")) .start)

21:33 lazybot: java.lang.RuntimeException: EOF while reading, starting at line 1

21:33 xeqi: &(doto (Thread. (bound-fn [] (println "hi"))) .start)

21:33 ppppaul: ooooh

21:34 lazybot: ⇒ hi #<Thread Thread[Thread-44305,5,sandbox]>

21:34 ppppaul: ^_^

21:35 xeqi: given it looks like you're doing a pub/sub thing, still might not be sufficient

21:35 ppppaul: yeah, it isn't working

21:35 :(

21:35 xeqi: might need to wrap message-handler

21:35 ppppaul: in a bound-fn or binding ?

21:36 hyPiRion: Since when did lazybot accept threads? I thought it didn't

21:36 xeqi: hyPiRion: I think its just direct Thread interaction. Though I did try to get Raynes to block it

21:37 hyPiRion: hm,

21:38 amalloy: hyPiRion: clojurebot successfully blocks threads; lazybot doesn't, partly because it's hard and partly because that makes him less useful

21:38 hyPiRion: I see

21:38 ppppaul: https://gist.github.com/4449412

21:42 how would i change message-handler to get it to print to my repl?

21:42 xeqi: ppppaul: I'm surprised to see the thread started for the consumer, I would have thought the mq would do the callback in a thread

21:43 ppppaul: this is an example right off the site for this lib

21:43 i'm surprised too

21:43 xeqi: ah, the "hello world" example

21:44 ppppaul: have a better way to do this? please enlighten me (i haven't done concurrency with clojure cept for future and a tiny bit with refs)

21:45 xeqi: ah, subscribe is a blocking call

21:45 ppppaul: blocking sexiness

21:46 maybe i do a bound-fn with &args and apply args to message-handler

21:46 xeqi: could try (bound-fn [& args] (apply message-handler args)) ... I'm almost tempted to say the bound-fn is needed in both places

21:46 ppppaul: ^_^

21:48 thanks xeqi. it works

21:48 xeqi: hurray

21:49 ppppaul: i guess their hello world example is meant to run via lein run

21:49 mpan: thinking of trying an alternate approach: does someone know if you can ask quil to draw on arbitrary buffers e.g. the innards of some swing component?

21:50 devn: fastest way to get a clojure blog that runs on heroku by forking an existing project?

21:50 mpan: since if I can use a java applet then I can work with clojure-jvm and it would be taking on fewer unfamiliar things at once

21:50 xeqi: devn: https://github.com/yogthos/yuggoth ?

21:51 not that I can vouch for the project, I just know it exists

21:51 devn: xeqi: appreciated. i guess i may as well just make this quick. i don't want one that uses noir

21:52 just a simple skeleton with lib-noir, hiccup, etc.

21:54 xeqi: devn: http://www.luminusweb.net/docs ?

21:54 devn: where'd you find this?

21:54 xeqi: well, that has a few more things.. and not postgres

21:55 devn: I feel like I fell off the bus. I used to follow disclojure.org and planet clojure pretty closely

21:55 i'm still on the list, just curious how you found that repo

21:55 xeqi: heh, I think I saw that on r/clojure, which I've just started following a couple weeks ago

21:56 devn: man, reddit has never been in my daily visits list

21:56 xeqi: http://www.reddit.com/r/clojure

21:56 devn: i know of r/clojure -- just have never been able to open it

21:56 i think i was scarred by digg

21:56 and slashdot before it

21:56 xeqi: heh, just ignore the rest of the site

21:56 devn: hacker news is the only thing i can stomach, but even that i go to sparingly nowadays

21:57 probably due to me working with and being around nerds all the time -- no reason to spend time filtering when other people do it for me

21:58 used to the be the case that someone who was into clojure and followed the list, etc. was like a unicorn to me

21:58 xeqi: I null hosted hn to try and be more productive. when I view it every couple days I realize I haven't really missed anything

21:58 devn: xeqi: surprising eh?

21:58 you missed the pre-order for a kinect-controlled gyrocopter

21:59 or some shit like that

22:00 xeqi: think the rails vuln was the only one recently... but really just missed the drama and saw the good explination

22:00 devn: there's some cool stuff on there, though. i miss having the time to read literally everything on it over the course of a day. i learned a lot there.

22:00 The "Every NFL play for the past 10 years in CSV format" was kind of cool

22:01 I'm always in the market for some large data sets

22:09 bobajett: noob question: Im trying to use a math library (https://github.com/clojure/math.numeric-tower). I've added to my lein dependencies [org.clojure/math.numeric-tower "0.0.2"]

22:09 is there something I have to tell lein to do to fetch that library so I can use it at the repl?

22:10 at the reply I get this: (require '[math.numeric-tower :as math]) |[1 of 1] Compiling Main ( foo.hs, interpreted )

22:10 FileNotFoundException Could not locate math/numeric_tower__init.class

22:11 jkkramer: bobajett: the namespace is clojure.math.numeric-tower - you're missing the "clojure." prefix

22:13 bobajett: (:require [clojure.math.numeric-tower :as math]))

22:13 FileNotFoundException Could not locate clojure/math/numeric_tower__init.class

22:14 jkkramer: will the repl automatically fetch/pull in the library or do I have to tell that before I fire up the repl?

22:16 jkkramer: bobajett: pretty sure lein repl pulls them in for you. are you using lein 2?

22:16 hyPiRion: bobajett: should fire up automatically for both lein1 and 2

22:16 bobajett: user=> user=> Bye for now![07:06P]basic$ lein version

22:16 Leiningen 2.0.0-preview10 on Java 1.6.0_37

22:19 jkkramer: bobajett: do you see numeric tower when you run `lein deps :tree`?

22:21 karpov: I just tried adding that dependency, and it seems to work... I did start a fresh repl after adding it though.

22:23 you may want to check it got pulled into your .m2/repository/org/clojure, perhaps?

22:41 bobajett: jkkramer: karpov: thanks guys! (face-palm with-meta {:embarrased "red"} "I was in the stupid wrong project directory")

22:55 Sgeo_: Would it be trolling to have a blog post comparing Clojure and Racket show up on Planet Racket?

22:55 erm, Planet Clojure

22:55 Planet Racket isn't a blog aggregator

22:58 jyfl987: oop, found it,http://en.wikipedia.org/wiki/Scheme_Requests_for_Implementation

22:59 http://srfi.schemers.org/srfi-49/srfi-49.html

23:35 tomoj: user> (into {} (map #fn[% %] (range 5)))

23:35 {0 0, 1 1, 2 2, 3 3, 4 4}

23:36 i.e. (into {} (map (fn [x] [x x]) (range 5))) or (into {} (map #(vector % %) (range 5)))

23:46 callen: tomoj: Clojure needs the LOOP macro.

23:48 tomoj: meh

Logging service provided by n01se.net