#clojure log - Aug 26 2011

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

0:08 gstamp: is there any way to pass JVM arguments to the lein swank subprocess? I'm trying to setup profiling

1:11 technomancy: gstamp: :jvm-opts in project.clj

1:19 polypus74: trying out clj-redis. there is no select command available, anybody know anything about it?

1:22 gstamp: technomancy: it seemed like those options were not being passed down to the JVM spawned by lein-swank

1:24 amalloy: polypus74: aleph-redis surely supports select

1:25 duck1123: yeah, Aleph's redis support has all the commands

1:27 amalloy: at least in the sense that it has none of them, and will happily send any old junk. the protocol is self-documented enough that aleph can parse the right "answer" without knowing what the command means

1:27 technomancy: gstamp: just confirmed it works here

1:28 polypus74: amalloy: ty, i'll have a look, although i just read that having > 1 db is discouraged and may even be deprecated, so i may go another route

1:28 technomancy: gstamp: it should be a vector of strings

1:29 duck1123: polypus74: Where did you hear that? If anything, I've been hearing more and more about people clustering redis

1:29 polypus74: not more than one instance, more than one indexable db, which is different

1:30 gstamp: technomany: okay, strange. that's what I've I'm using. I'll double check

1:32 polypus74: duck1123: https://github.com/xetorthio/jedis/issues/85, fourth comment from bottom

1:33 amalloy: polypus74: deprecated on jedis, maybe, but i don't see anyone saying you shouldn't do it with redis in general

1:51 gstamp: technomancy: Looks like I was mistaken. It seems to work fine. Sorry about that.

1:52 scottj: amalloy: where's your utils repo ago?

1:52 again

1:52 amalloy: scottj: github.com/amalloy/amalloy-utils - but most of it's been absorbed into ninjudd's useful

1:52 github.com/flatland/useful

1:55 scottj: amalloy: ty

2:14 ibdknox: for those following along, I updated the pinot readme with all sorts of goodness, including the visualization stuff:

2:14 https://github.com/ibdknox/pinot

2:17 amalloy: scottj: just for my vanity, what function were you looking for in amalloy-utils?

2:18 ibdknox: amalloy: the one that spits out my entire program... I can't seem to find it in there though.

2:18 amalloy: ibdknox: lazy-loop is usually pretty close, in my experience

2:19 ibdknox: haha

2:21 scottj: amalloy: actually I misremembered I was looking for readable dates

2:25 amalloy: ah, excellent. now i'll be moderately humble for at least a week or two

2:27 scottj: anyone else keep a directory of clojure project they don't use around just for grepping through when wondering about an idiom or util?

6:41 marms: hi

6:41 if I use gen-class to extend a Java class, is it possible to access private fields of the super class ?

6:43 oh dear I just discovered the exposes-method arg

6:43 nevermind

6:47 tsdh: Why does (let [^java.awt.Image i (java.awt.image.BufferedImage. 10 10 java.awt.image.BufferedImage/TYPE_INT_RGB)] (.getHeight i)) give a warning that getHeight cannot be resolved? BufferedImage is a subclass of Image...

6:50 And, yes, I know that I can omit the hint in the example. My real use is something is (let [^java.awt.Image (.getImage myImageIcon)] (.getHeight i)).

6:54 And how do I import a nested class in a ns? :import (foo.bar Baz.InnerBaz) doesn't do the trick...

6:56 Ah, Baz$InnerBaz. :-)

6:56 khaliG: hm i'd like to launch fleetdb at the start of my clojure app. is there a nice way to do this?

7:35 McOmghall: could someone provide info on constructing a lazy string from a reader without using line-seq?

7:36 that function seems to fail when I use it for composing a huge webpage from URL

8:07 noone?

8:08 raek: McOmghall: how does it fail?

8:09 McOmghall: raek: java.lang.RuntimeException: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn (repl-1:2)

8:10 with this code:

8:10 (defn fetch-url [url]

8:10 "Retrieves the web page specified by the url."

8:10 (with-open [the-stream (.openStream (java.net.URL. url))]

8:10 (let [reader (new BufferedReader (new InputStreamReader the-stream))]

8:10 (repeatedly (str (.read reader))))))

8:10 when I try to take the ``first'' or any seq operator on the result

8:11 raek: there are multiple things I would like to comment on:

8:11 repeatedly takes a function, so you need to write something like (repeatedly #(str (.read reader)))

8:12 repeatedly is lazy, so the .read calls will happen outside the scope of with-open

8:12 that can be solved by wrapping the repeatedly call with doall

8:13 a lot of the code can be simplified by using clojure.java.io

8:13 (with-open [reader (io/reader (io/to-url url))] ...)

8:14 but one inmportant question is what unit of data do you want to read? lines? bytes?

8:14 characters?

8:15 McOmghall: it must be bytes or characters because of 2 reasons

8:16 the web page I try to fetch is very big, so a line analysis is not really adequate

8:16 and I am writing a parser for it, so it is more easily done with a character stream

8:18 line-seq doesn't work because, I think, the page lasts too much on being loaded

8:19 raek: anyway, if you want a lazy sequence of characters of the stream, I recommend something like (defn char-seq [reader] (lazy-seq (let [x (.read reader)] (when-not (neg? x) (cons (char x) (char-seq reader))))))

8:20 McOmghall: ok, thanks raek

8:20 raek: (defn do-stuff [url] (with-open [reader (-> url io/to-url io/reader)] (do-stuff-with-lazy-seq (char-seq reader))))

8:20 McOmghall: i'll try that

8:21 raek: laziness and with-open does not really mix well, so I believe that trying to encapsulate them together is not going to work

8:22 what do you mean by "lasts too much on being loaded"?

8:22 char-seq does pretty much what line-seq does, but with .read instead of .readLine

8:22 McOmghall: i've worked a previous version with line-seq and printed the results

8:23 mprentice: c.c.zip-filter.xml/xml-> is a function, not a macro like ->. that threw me off for a while.

8:23 McOmghall: the last element of the sequence was not the last element of the page

8:24 so I thought it was because it was not fully loaded when the lazy sequence was created

8:24 raek: was the page chopped off at the end?

8:24 McOmghall: yes

8:24 raek: it might be possible that the server closed the connection before the client consumed the whole thing

8:25 McOmghall: does wrapping the line-seq call in a doall make any difference?

8:25 (warning: that will load the whole page into memory)

8:27 McOmghall: I think you shoould investigate exactly where the problem is before abandoning line-seq and/or laziness.

8:27 McOmghall: yeah, I need lazyness because the page is too big to have a copy in-memory

8:28 raek: (also: if the server closes the connection before reaching the end of the file, I would expect something to throw an exception)

8:28 so to repeat: gather more information on what actually happens

8:30 McOmghall: thank you, this was useful

8:30 i'll investigate

8:41 timvisher: hey all

8:41 does anyone know how to make ring send utf-8 encoded documents?

8:42 i.e. setting the Content-Type on the response?

8:44 raek: timvisher: ring will send the data encoded in UTF-8, but you have to include a Content-Type header with the charset parameter set to UTF-8

8:45 {:status 200, :headers {"Content-Type" "text/html; charset=UTF-8"}, :body "<blink>Hello Web!</blink>"}

8:45 timvisher: raek: I'm trying to avoid having to create a response map every time

8:45 but that is certainly an option. :)

8:45 ring.middleware.content-type

8:45 also found that

8:45 raek: timvisher: what do you mean? in ring you always have an response map

8:45 yes, you can use function to factor out common code, as usual... :-)

8:46 timvisher: i'm sorry, i'm using ring through compojure

8:46 compojure at least guesses a good response map from your data

8:46 or you can return one manually

8:46 true true re using a function

8:46 raek: I usually make a html-response function that takes a body and returns the map the way I want it

8:48 timvisher: do you use compojure?

8:48 raek: I prefer Moustache myself, but I have used compojure too

8:50 with moustache I tend to write each handler as a separate defn and then use the moustache app macro to dispatch them

8:54 timvisher: thanks for the pointer

8:54 that works, even if it's not exactly what I was hoping for

8:54 thanks

8:55 robbe-: How should I interpret errors like

8:55 java.lang.NullPointerException (NO_SOURCE_FILE:0)

8:56 When the file loaded allright, it seems.

9:17 dnolen: robbe-: it almost always mean the file did not load right.

9:19 robbe-: Wel, it did. :-)

9:19 Error goes away if I uncomment the line causing the error.

9:42 I've traced it back to (.hashCode nil) by the way.

9:43 raek: robbe-: if you call (require 'your-ns :reload), do you get an exception directly, or only when you call something from that namespace?

9:50 robbe-: Only when I called the function, ultimately to calling what I described above.

9:51 I suppose the answer to my original question is "generally, you're probably doing something with nil while you shouldn't - or file didn't properly load." - At least that's how I interpret it now.

9:51 dnolen: robbe-: sorry it wasn't clear to me when the error was happening, or what you mean by the "file loaded". yes, null pointer exceptions don't give line numbers.

9:51 not sure why.

9:52 robbe-: It wasn't all really clear for me either, leading me to asking rather unclear questions probably. ;-)

9:53 dnolen: robbe-: actually that's not true, they do give line numbers, but not if the code error happens during compilation.

9:56 robbe-: That's odd, it was during runtime and I didn't get a line number.

9:56 Furtermore, that line was executed once, before being executed with nil.

9:57 Furthermore*

10:03 raek: robbe-: but you should be able to see the line number of the function where it happens in the stack trace, right?

10:03 robbe-: There's no stack trace.

10:04 raek: robbe-: what do you mean? are you using an IDE or a bare REPL in a terminal?

10:04 robbe-: http://pastebin.com/CBxCGSdB

10:05 raek: robbe-: call (.printStackTrace *e) to get the stack trace in a bare REPL

10:06 robbe-: Ah, now that's a good one to know.

10:06 I was hating clojure for throwing me errors and not saying where they come from.

10:06 :)

10:07 Also (completely unrelated) there seems to be somthing wrong with my awk print command there. :P

10:09 raek: yeah, the bare REPL is a bit akward to develop in...

10:09 robbe-: (There, forgot that $ has to be escaped in the makefile.)

10:10 Any recommended IDEs for Clojure for a vim enthousiast?

10:10 I also irrationally hate eclipse.

10:10 Just saying.

10:10 :P

10:11 gtrak: emacs

10:11 MasseR: robbe-: vim

10:11 gtrak: there's a vimclojure

10:11 tsdh: I'm toying around with chouser's lazy qsort for The Joy of Clojure, but using it, I get an StackOverflowError. http://pastebin.com/MxrBHRRx

10:11 MasseR: And slimv

10:11 robbe-: Well, I still have the bare REPL thing to fight with then. :P

10:12 raek: I know that people are using vim for clojure dev, and that there exists something similar to what slime/swank does in emacs, but not much more than that

10:12 MasseR: robbe-: slimv handles that for you (in theory)

10:12 I use it mainly for paredit

10:12 tsdh: Could someone check if it works with clojure 1.2? (I'm using a 1.3 snapshot...)

10:12 robbe-: I'll google slimv then. Thanks for the tip.

10:13 gtrak: is there a decent guide to refactoring? moving function defs around, etc..?

10:15 coopernurse: robbe-: I always suggest IntelliJ. zero tooling issues since I switched to it from slime

10:16 gtrak: does intellij do good leiningen integration

10:17 sjl: robbe-: I use SLIMV with a few files from VimClojure and rarely deal with the REPL

10:17 robbe-: I mostly use <localleader>ee to just veal the top-level form I'm in. Quick and painless.

10:18 *eval

10:26 zoldar: hello, I have a java interop problem. I'm defining a bunch or records based on interfaces defined in java. After compilation record's methods have proper type hints in java IDE. However, constructor still has Object arg0, Object arg*.. as arguments - is there any way to expose type hints for java env? Or is some sort of factory interface the only way to go ?

10:27 gtrak`: Object arg0 etc.. is not a typing issue, eclipse uses the source of the interfaces to name the args, you'd have to output source code for it to know what to do

10:27 maybe the 'Object' part is a typing issue

10:30 zoldar: gtrak`, so, how could I expose that information to eclipse/other java ide?

10:30 st3fan: how would i translate python's if foo in ('cheese', 'bacon') to clojure?

10:30 gtrak`: some kind of plugin that uses a clojure AST

10:30 st3fan: i now have (if (or (= ..) (= ...))) but i an wondering if there is a shortcut

10:30 sjl: st3fan: (if (#{"cheese" "bacon"} foo) …)

10:31 st3fan: hm nice

10:31 sjl: st3fan: Yeah, Clojure Sets are functions too.

10:31 manutter: ,(let [foo "cheese"] (if (#{"cheese" "bacon"} foo) :contains-fat :fat-free)

10:31 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

10:31 manutter: ,(let [foo "cheese"] (if (#{"cheese" "bacon"} foo) :contains-fat :fat-free))

10:31 clojurebot: :contains-fat

10:32 zoldar: gtrak`, a plugin for IDE? I guess I will stick to some kind of factory then...

10:32 gtrak`: zoldar, or maybe the opposite, write some clojure that outputs java source for ide's to pick up

10:33 or just forget java

10:33 ;-)

10:33 zoldar: gtrak`, not an option unfortunately

10:33 but thanks for pointers anyway

10:35 gtrak`: private constructor and a factory method solves the problem? then that's easiest

10:45 zoldar: gtrak`, but you intrigued me with clojure writing java - do you mean that I would explicitly output some java source code to files which would be later compiled?

10:45 gtrak`: you could, yea, say with stringtemplate or something

10:46 zoldar: that's an idea..

10:46 gtrak`: just another layer of abstraction

10:47 but there might be a simpler way, I haven't had to deal with that stuff really

11:11 irrumator_: anyone work with kawa (a scheme on the jvm) here before? can you compare it to clojure?

11:12 kawa: http://www.gnu.org/s/kawa/

11:13 duck1123: Ok, I've never really figured this part out. What do I need to do if c.t.logging isn't showing the right namespace?

11:14 I have one project where it's working right, but then another where all I get is clojure.tools.logging$eval129$fn__130

11:33 stuartsierra: duck1123: It's probably an issue of when c.t.logging is resolving *ns*, e.g. at macroexpansion time.

11:36 upwardindex: Is there some kind of style guide for clojure code?

11:37 triyo_: I have cljs code spread over multiple modules. When I run a cljs.closure/build I get a `nth not supported on this type: PersistentArrayMap`. If I move all the code `as is` in to a single module, all works fine. Seems strange

11:37 manutter: triyo_: sounds like a syntax error in a :use or :require clause

11:39 duck1123: stuartsierra: would that be because I have a macro that does logging? If I moved the logging call to an internal fn, would that fix this?

11:39 stuartsierra: possible

11:40 triyo_: manutter: hmm, doesn't seem like it. (ns blog.validation.form (:require [blog.validation.preds :as preds] [blog.validation.core :as core]))

11:40 stuartsierra: A macro probably shouldn't log directly, though it may expand to code which does logging.

11:40 duck1123: that's what I meant

11:41 triyo_: If I remove the `:require` though, all works

11:41 so one would think its a syntax error, but it seems well formed.

11:42 manutter: triyo_: try extra square brackets around the whole list: (:require[[blog.validation.preds :as preds][blog.validation.core :as core]]))

11:42 duck1123: I have a "spy" macro that logs the code and pprints the data https://github.com/duck1123/ciste/blob/master/src/main/clojure/ciste/debug.clj

11:42 triyo_: manutter: Assert failed: Only [lib.ns :as alias] form supported (and alias (= :as as))

11:43 manutter: triyo_: hmm, never mind then :/

11:43 triyo_: manutter: this is clojure script btw

11:43 *clojurescript

11:44 manutter: doh, missed the "cljs"

11:44 triyo_: thought so :)

11:44 manutter: some day I'll break down and visit the eye doctor again

11:45 triyo_: I think it might be a bug. I'll have a look at the source and issue db

12:04 TimMc: ,(-> " foo" (.trim) (.length))

12:04 clojurebot: 4

12:04 TimMc: Oh, Java.

12:05 manutter: wow, really?

12:05 jarel: ,(.trim "foo")

12:05 clojurebot: "foo"

12:05 manutter: ,(macroexpand '(-> "foo" (.trim) (.length))

12:05 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

12:06 manutter: ,(macroexpand '(-> "foo" (.trim) (.length)))

12:06 clojurebot: (. (clojure.core/-> "foo" (.trim)) length)

12:06 TimMc: manutter: It's a nbsp

12:06 manutter: Ah

12:06 ,(macroexpand-all '(-> "foo" (.trim) (.length))

12:06 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

12:06 manutter: ,(macroexpand-all '(-> "foo" (.trim) (.length)))

12:06 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: macroexpand-all in this context, compiling:(NO_SOURCE_PATH:0)>

12:06 manutter: I should just give up.

12:06 TimMc: Is clojurebot shitting itself again?

12:07 ,(macroexpand '(-> "foo" (.trim) (.length)))

12:07 clojurebot: (. (clojure.core/-> "foo" (.trim)) length)

12:07 jarel: ,(.length "foo")

12:07 clojurebot: 3

12:07 jarel: huh

12:08 TimMc: ,(macroexpand `(-> "foo" (.trim) (.length)))

12:08 clojurebot: (. (clojure.core/-> "foo" (.trim)) length)

12:09 scgilardi: ~botsnack

12:09 clojurebot: Thanks, but I prefer chocolate

12:09 TimMc: ,(-> "\u00a0foo" (.trim) (.length)) ; to be clear

12:09 clojurebot: 4

12:09 jarel: oic

12:09 TimMc: Apparently, String.trim is not to be trusted.

12:09 hiredman: stop calling .length

12:10 use count

12:10 jarel: http://en.wikipedia.org/wiki/Nbsp

12:10 manutter: TimMc: but if it's a non-breaking space, isn't the correct behavior to treat it like a non-space?

12:10 TimMc: hiredman: Ah, right.

12:10 manutter: It's whitespace.

12:11 Actually, I just found a good discussion of this: http://closingbraces.net/2008/11/11/javastringtrim/

12:11 manutter: ok, I can see that, since comma is also whitespace (in clojure)

12:12 TimMc: What does that have to do with trimming?

12:14 manutter: nothing really, just thinking out loud about the difference between "visible appearance" and "should be trimmed" (or ignored)

12:14 carry on. :)

12:15 robbe-: I like how Clojure internally translates '!' to 'BANG'. :-)

12:20 coopernurse: hey folks. I'm using noir with hiccup to build up some html

12:20 and I'd like to make part of my response conditional

12:20 fbru02: hey all... stupid question.. where did clojure.contrib.string end up going after the contrib split??

12:20 lazybot: fbru02: What are you, crazy? Of course not!

12:21 fbru02: lazybot: snack

12:21 coopernurse: so, for example: [:tr [:th "Ballot name"] [:th "Vote"] [:th "View Results"] [:th "Edit"] [:th "Delete"] ]

12:21 manutter: lol, good one lazybot

12:21 coopernurse: I'd like to make the last two [:th ] elements conditional based on a variable

12:21 manutter: isn't it just clojure.string now?

12:21 coopernurse: is there a simple way to inline that expression?

12:21 concat perhaps?

12:21 fbru02: manutter: didn't know that , let me check

12:22 arohner: coopernurse: if

12:22 coopernurse: arohner: yeah, I've been fiddling with if

12:22 arohner: (if foo [:th "Edit"] [:th "Delete"])

12:22 coopernurse: but I don't have the syntax right

12:23 arohner: how so?

12:23 manutter: ,(let [x [:tr (if true [:th "Vote"]) ]] x)

12:23 clojurebot: [:tr [:th "Vote"]]

12:23 TimMc: ,[:tr (if true [:th "Vote"]) ]

12:24 clojurebot: [:tr [:th "Vote"]]

12:24 TimMc: ,[:tr (if false [:th "Vote"]) ]

12:24 clojurebot: [:tr nil]

12:24 manutter: hmm, wonder how hiccup renders [:tr nil]

12:24 coopernurse: manutter: good question

12:24 this is a good start.. I'll try these

12:24 arohner: hiccup ignores nils

12:25 that would become <tr /> or <tr></tr>

12:25 depending on whether it's a self-closing tag

12:25 TimMc: Anyway, use when instead of if.

12:25 duck1123: aside from setting a ref and then reading it later, is there any good way to make my function return the results of my try block when a finally is in use?

12:26 manutter: ,(let [x [:tr (when false [:td])]] x)

12:26 clojurebot: [:tr nil]

12:26 TimMc: manutter: What's with the let?

12:26 coopernurse: ,[:tr [:th "Ballot name"] [:th "Vote"] [:th "View Results"] (if true [:th "Edit"] [:th "Delete"]) ]

12:26 clojurebot: [:tr [:th "Ballot name"] [:th "Vote"] [:th "View Results"] [:th "Edit"]]

12:26 coopernurse: so [:th "Delete"] is ignored, as that's the "else" value

12:27 manutter: TimMc: wasn't sure if clojurebot understood ,[ or not

12:27 TimMc: ,"hi"

12:27 clojurebot: "hi"

12:27 manutter: cool :)

12:27 TimMc: Yeah, it just goes for it.

12:27 , so if you accidentally start with a comma...

12:27 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: so in this context, compiling:(NO_SOURCE_PATH:0)>

12:28 arohner: duck1123: you could use an atom in a let

12:28 coopernurse: how do I destructure this list? (concat) and (cons) don't seem to do it

12:28 ,[:tr [:th "Ballot name"] [:th "Vote"] [:th "View Results"] (if true (concat [:th "Edit"] [:th "Delete"])) ]

12:28 clojurebot: [:tr [:th "Ballot name"] [:th "Vote"] [:th "View Results"] (:th "Edit" :th "Delete")]

12:28 arohner: (let [result (atom nil)] (try (swap! result (constantly body))) (finally blah) @result)

12:28 hiredman: duck1123: what?

12:29 a finally doesn't change the result of an expression

12:29 duck1123: arohner: I guess you're right, atom would be better for this. Just wondering if there was something I was misiing

12:29 hiredman: ,(try 1 (finally 2))

12:29 clojurebot: hiredman: Titim gan éirí ort.

12:29 hiredman: clojurebot: what?

12:29 clojurebot: what is wrong with you

12:29 TimMc: haha

12:29 hiredman: oh, right

12:29 TimMc: Is try disallowed?

12:30 duck1123: hiredman's example returns 1

12:30 manutter: coopernurse: you don't need the concat, just put the [:th "Edit"] directly, as the "then" clause of your if statement.

12:31 coopernurse: manutter: but I want both edit and delete if the case is true

12:31 duck1123: ok, it seems I was going down the wrong path here. I wasn't getting the result I expected. I now see why

12:31 manutter: coopernurse: oh ah, just a sec

12:31 coopernurse: this works, but is silly

12:31 ,[:tr [:th "Ballot name"] [:th "Vote"] [:th "View Results"] (if true [:th "Edit"] nil) (if true [:th "Delete"] nil) ]

12:31 clojurebot: [:tr [:th "Ballot name"] [:th "Vote"] [:th "View Results"] [:th "Edit"] ...]

12:31 hiredman: duck1123: (finally ...) is the closest thing clojure has to a statement, it has no result

12:33 manutter: ,[:tr [:th "Ballot"][:th "Vote"] (when true [:th "Edit"] [:th "Delete"])]

12:33 clojurebot: [:tr [:th "Ballot"] [:th "Vote"] [:th "Delete"]]

12:33 manutter: coopernurse: ^^^

12:33 tufflax: that didnt work manutter

12:33 duck1123: manutter: wrap them in a list

12:33 arohner: you need a (list) in there

12:33 coopernurse: manutter: hmm.. what happened to edit?

12:33 manutter: oh wait, miscounted

12:33 TimMc: manutter: when returns the last expression's value

12:34 manutter: Yeah

12:34 tufflax: I think duck1123 is right, a list is what you need

12:34 that's how prxml works at least

12:35 coopernurse: yeah, just not sure how to clobber the list container that wraps around it when I do this

12:35 duck1123: just don't be tempted to try to use a vector. That causes problems

12:35 coopernurse: ,[:tr [:th "Ballot"][:th "Vote"] (when true (list [:th "Edit"] [:th "Delete"]))]

12:35 clojurebot: [:tr [:th "Ballot"] [:th "Vote"] ([:th "Edit"] [:th "Delete"])]

12:36 fbru02: manutter: thank that worked

12:36 arohner: coopernurse: the ([]) is fine, hiccup ignores it

12:36 coopernurse: oh really?

12:36 lemme try that

12:36 manutter: heh, at least I got one thing right today

12:36 arohner: manutter: that's better than most people :-)

12:37 coopernurse: arohner: ah, so it does. thank you!

12:37 manutter: Wait, no wonder, it's Friday the 26th -- that's TWICE Friday the 13th! Augh!

12:39 TimMc: a.k.a. FridayFriday the 13th :-P

12:39 duck1123: double friday all the way

12:46 grios: hello, I'm new on clojure and I'm studying compojure's code. I cannot understand how file-path is evaluated in this function: http://pastebin.com/EAFn859D Any hint?

12:49 bsteuber: grios: well it must have been defined before

12:49 or what do you mean "how it is evaluated"?

12:51 grios: it is not defined before (imho): https://github.com/weavejester/compojure/blob/master/src/compojure/route.clj

12:51 i cannot understand why it works :)

12:51 coopernurse: grios: it's scoped in by the use block. it comes from ring.middleware.file-info

12:52 grios: oops.. I'm wrong.. one sec

12:52 but I think it's one of the libs in the use block

12:52 duck1123: I wasn't able to find it

12:53 coopernurse: hmm me either

12:54 raek: grios: if you have a repl with compojure ready, you can find out with (in-ns 'compojure.route) (resolve 'file-path)

12:54 bsteuber: that's weird indeed :)

12:54 coopernurse: just did it..

12:54 grios: raek: compojure.test.route=> (in-ns 'compojure.route) (resolve 'file-path) #<Namespace compojure.route> nil

12:54 coopernurse: nil

12:54 grios: ops

12:54 wait...

12:55 raek: grios: ah, now I see it. it's not a var, it's part of a destructuring form

12:55 {{file-path :*} :route-params}

12:55 grios: what?

12:55 clojurebot: what is short for ,(doc ...)

12:56 bsteuber: lol

12:56 raek: if there is a map like {:route-params {:* <foo>}}, file-path will be bound to <foo>

12:56 bsteuber: silly me

12:56 overlooked the let

12:56 raek: ,(let [{{file-path :*} :route-params} {:route-params {:* "/mystery"}}] file-path)

12:56 clojurebot: "/mystery"

12:57 coopernurse: heh, nice

12:57 bsteuber: ah not that silly, it's hidden in the get

12:58 grios: ah okay, thank you raek; I spent my two hours without success, now I know why :)

12:59 so , let [{{file-path :*} :route-params} {:route-params {:* "/mystery"}}] file-path) < === > {:route-params {:* <foo>}}

13:01 raek: it has two parts. the right side is a map value (like the one you wrote to the right of < === >) and the left side is a destructuring form to "reach into" the map and bind a value in it to the symbol "file-path"

13:02 mattmitchell_: How do I insert a value to a list, at a specific position?

13:02 raek: grios: (let [{{file-path :*} :route-params} {:route-params {:* "/mystery"}}] ...) = (let [{file-path :*} {:* "/mystery"}] ...) = (let [file-path "/mystery"] ...)

13:03 mattmitchell_: (concat left-half [element] right-half)

13:03 mattmitchell_: raek: OK simple enough, thanks

13:04 grios: raek: ok; but the let is after the destructuring form, isn'it?

13:04 arohner: mattmitchell: there's not a direct way to do it because it can't be done efficiently on that datastructure

13:04 grios: I'm looking here: http://pastebin.com/EAFn859D

13:05 raek: grios: the GET macro expands into, among other things, another let form

13:05 mattmitchell_: arohner: ok so nothing like (insert-aftert 2 '(0 1 3) 1) => '(0 1 2 3) etc.?

13:06 arohner: mattmitchell_: you can write that, but it will require something that looks like raek's suggestion, with a take and a drop

13:06 mattmitchell_: err, that example is messed up but you know what i mean :)

13:06 arohner: ok cool

13:06 grios: raek: ah ok, compile-route calls in the last let-request

13:07 raek: grios: when you write (GET ...path... foo ...body...) it will become something like (... (let [foo ...request-map...] ... ...body... ...) ...)

13:07 grios: ok

13:07 TimMc: manutter: Looks like whitespace recognition in Java is best accomplished this way: [\p{javaWhitespace}\p{Zs}]+

13:07 grios: do you have discovered it expanding macros?

13:07 raek: grios: you can run macroexpand or macroexpand-1 on the code to see what it expands to

13:08 ,(macroexpand-1 '(if-let [x y] z))

13:08 clojurebot: (clojure.core/if-let [x y] z nil)

13:08 raek: ,(macroexpand '(if-let [x y] z))

13:08 clojurebot: (let* [temp__3723__auto__ y] (if temp__3723__auto__ (clojure.core/let [x temp__3723__auto__] z) nil))

13:10 grios: thanks raek

13:10 manutter: TImMc: I'll have to bookmark that...

13:10 now, where's the "Save Bookmark" command in irc...?

13:11 raek: grios: it's possible that the destructuring happens in something else than a let, though. function parameters support destructuring too, for example.

13:13 grios: reak: "file-path" example works because GET is a macro; if it would be a function it had not worked, correct?

13:13 raek: grios: exactly

13:14 macros are powerful (and trickyto read!) because the change the rules of evaluation

13:14 grios: I can see :)

13:14 okay, I'm feeling enough smart, and I can go home

13:14 bye

13:14 and thank you

13:19 di-csuehs: I feel an approaching enlightment....or at least a learning experience...just need help getting over the edge.

13:22 I'm using an API which uses the the with- idiom, but by the time my function calls the api's function which refers to the configuration var, it is unbound.

13:22 This must mean I am not understanding the binding order.

13:22 raek: laziness combined with 'binding' often yields this problem

13:34 TimMc: Man, I would never have thought of that.

13:37 di-csuehs: unintended laziness...only there is no such thing...it is all supposed to be lazy.

13:39 map returns a lazy sequence...so by the time it gets eval'd, the config var has gone away

13:39 raek: ,(binding [*out* 123] (lazy-seq [*out*]))

13:39 clojurebot: (#<StringWriter (#<StringWriter >)

13:39 hiredman: that came out odd

13:39 icey: Have any of you had good luck with hiring Clojure devs? I'd love to start using it more seriously for a few things, but I don't know anything about how many people out there can write it well, and I would hate to have to rewrite stuff later because I can't find anyone to help maintain / work on it

13:42 hiredman: they are out there

13:43 TimMc: manutter: Here's what I ended up writing as a utility: https://gist.github.com/1173941

13:44 Convert to Clojure as needed/desired.

13:44 arohner: icey: a good place to start is with people already in the clojure community

13:44 bloggers, OSS contributors, etc

13:44 technomancy: icey: it's pretty good if you can hire remote workers

13:44 we haven't had any trouble finding qualified candidates

13:45 if you limit yourself by locality you put yourself in a much harder place.

13:46 icey: technomancy: yeah, remote would be an option; this is something that's a bit down the road anyways. I guess my biggest worry comes from the fact that a lot of the problem space I work in is pretty boring :)

13:46 arohner: icey: what is the problem space?

13:47 icey: arohner: for what i'm working at the moment - health insurance rate comparisons / rating engines

13:47 technomancy: using clojure could be a good way to spice it up a bit

13:48 kzar: How do you tell emacs to kill a clojure thread again? C-c C-b I thought but it's not working

13:48 arohner: C-c C-c, doesn't always work

13:48 that kills the repl

13:48 icey: clojure is definitely a good fit for the problem space

13:48 kzar: C-c C-c ran the closest s-exp for me

13:49 arohner: in the repl buffer

13:49 icey: i've been watching the language for years and it seems amazingly stable for how young it is. now i'm just at the point of having fears related to switching away from one platform (.net) and onto something significantly more exotic (clojure, not the jvm)

13:50 TimMc: icey: Sounds like an *important* problem space, though -- there's not enough consumer information/empowerment in the insurance market.

13:53 icey: there is a lot of domain knowledge required, so i am looking for whatever weapons i can use to increase developer productivity as much as possible

13:54 actually, it's not even a domain knowledge problem as much as it is a "every company does shit totally differently" problem :)

13:54 TimMc: haha

13:54 I can already see that you'll need dynamically scoped binding.

13:55 (with [*company-does-weird-stuff* true] (process-things))

13:56 icey: my current solution uses c# and is scriptable with ironpython... i thought i'd be able to take it to the carriers and say "hey here's the api, just fill in the blanks to hook in to this system"; but python was too much of a stretch so we ended up writing all the scripts ourself

13:56 i figure if i'm going to write all the guts & gear code then it might as well be in something that provides more flexibility

14:01 lol, i guess no questions are original; just found a really great thread on the mailinglist that features someone with a lot of my concerns... from 2009 :) (thanks again everyone)

14:04 tcepsa: When defining a namespace with hyphens in it, is it true that you

14:04 should name the corresponding directories and file with underscores

14:04 where the hyphens go?

14:04 e.g. test.record-types would be in test/record_types.clj ?

14:05 Vinzent: tcepsa, yes

14:06 tcepsa: Okay, so then if I define some records (using defrecord) in that

14:06 namespace, what's the correct way to access them from another namespace?

14:07 Because test.record-type.TestRecord gives me a "class not found" exception

14:07 But test.record_types.TestRecord works

14:07 raek: tcepsa: you need to import the record types like java classes

14:07 tcepsa: Oh! Okay, I'll give that a try

14:08 (I had been using :use and :require)

14:08 raek: so, you end up needing both use/require and import...

14:09 tcepsa: raek: Okay, what should that look like?

14:10 raek: (ns ... (:require your-ns) (:import your-ns.TheRecordType))

14:12 tcepsa: raek: Thanks, I'll see if I can get that to work

14:14 raek: but it sounds a bit weird that test.record_types.TestRecord worked but not test.record-type.TestRecord

14:14 tcepsa: which clojure version are you running? I vagely recall that something like this was fixed in clojure 1.2.1

14:15 http://dev.clojure.org/jira/browse/CLJ-432

14:16 tcepsa: anyway, it's often simpler to expose a "constructor function" instead

14:17 tcepsa: raek: Ah, thanks, I'll double check that

14:17 * raek read the issue and becomed even more confused

14:18 raek: looks like test.record_types.TestRecord is the "correct way" in some sense. yuck.

14:18 tcepsa: raek: Hmmm, okay. That would explain why it's still not working

14:19 * tcepsa grins wryly

14:19 tcepsa: Okay, yeah, if I do

14:19 (ns ... (:require scratch.record-types) (:import scratch.record_types.Example))

14:19 then it works

14:20 But if I use a dash in the :import then it fails

14:21 (It looks like I am using version 1.2.1)

14:22 Is there a way to check the Clojure version from within the REPL?

14:23 raek: ,(clojure-version)

14:23 clojurebot: "1.3.0-master-SNAPSHOT"

14:23 tcepsa: Thanks, yes, I am using 1.2.1

14:25 TimMc: tcepsa: You had an "s" at the end of record_types, but not record-type. Probably just a transcription typo, but I thought I should mention it.

14:25 Vinzent: hm, samething here

14:25 (but not with 1.2.0)

14:26 tcepsa: TimMc: Good catch! That was a transcription error this time (but would

14:26 have been very frustrating if it were the actual problem!)

14:28 Vinzent: http://paste.org.ru/?c3yyiv - and in the 1.2.0 defrecord returns foo-bar.Foo. Interesting

14:31 tcepsa: Is there some way to submit this as an issue?

14:33 TimMc: &findfn "a-b" "a_b"

14:33 $findfn "a-b" "a_b"

14:35 stuartsierra: tcepsa: In 1.3 defrecords create real constructor functions.

14:36 tcepsa: stuartsierra: Ah, okay, then I'll switch to that. Thanks!

14:36 scottj: ibdknox: have you tested output-to and output-dir on cljs-watch? I tried them last night and they didn't seem to work

14:36 ibdknox: scottj: are you using zsh?

14:36 scottj: ibdknox: yes and escaped {

14:37 I think I ran it under bash though too to test

14:37 cljs-watch src \{:output-to "public/cljs/bootstrap.js" :output-dir "public/cljs/"\}

14:37 ibdknox: scottj: it works on bash for me, zsh doesn't get any args at all

14:37 ever

14:37 scottj: that's the line I used, I ended up editing cljs-watch

14:38 ibdknox: scottj: I also tried with cljsc and that had the same issue

14:38 scottj: ok I'll retest in bash

14:38 ibdknox: you shouldn't need to escape in bash

14:39 srid: fyi - we just released a new version of Stackato with support for Clojure; invite codes here - http://www.reddit.com/r/programming/comments/jv8uo/activestate_adds_python_django_support_to/

14:39 ibdknox: srid: congrats

14:40 scottj: ibdknox: might want to ignore .#foo.cljs files (emacs autosaves I think)

14:40 ibdknox: hm, I thought I did that

14:40 scottj: or probably any .foo.cljs

14:40 ibdknox: I think I lost one of my commits somewhere

14:41 yeah, vim does the same thing

14:41 amalloy: $findfn "a-b" "a_b"

14:41 lazybot: [clojure.core/munge clojure.core/namespace-munge]

14:41 amalloy: TimMc: sorry for the inconvenience, he's back

14:42 scottj: ibdknox: just tried under bash and it doesn't work

14:42 ibdknox: hm

14:42 btw

14:42 it does ignore . files...

14:43 scottj: but still shows exception on them? :: watcher :: Building ClojureScript files in :: src/java.io.FileNotFoundException: The file src/emailatask/cljs/.#frontend.cljs does not exist.

14:44 ibdknox: are you sure you have my latest?

14:44 Vinzent: ->MyRecord looks strange

14:45 scottj: "fix bug that causes bootstrap.js to be created as a dir." latest commit

14:45 ibdknox: scottj: k, I can repro the options not taking

14:45 scottj: there's no build process to create a new cljs-watch is there? it looked like the script had the source inline

14:46 ibdknox: gtg

14:47 ibdknox: scottj: thanks, I'll get it fixed up

14:49 hiredman: Vinzent: reads as "to MyRecord"

14:49 tcepsa: stuartsierra: As it stands, I am having the same problem (with

14:49 defrecord and hyphenated namespaces) in 1.3.0-master-SNAPSHOT as in 1.2.1

14:50 Vinzent: hiredman, I understand, but still looks strange

14:51 cemerick: Funny that ->Foo comes up just now. http://dev.clojure.org/jira/browse/CLJ-833

14:52 TimMc: srid: The article has a broken link to Stackato

14:52 tcepsa: http://pastebin.com/G3yhyjUq

14:53 srid: TimMc: ah ok, here's the link - http://www.activestate.com/cloud

14:53 TimMc: Yeah, it's just missing a "/" to make it an absolute path.

14:54 looks like it escaped into the last link in your reddit comment

14:55 tcepsa: Now with more documentation: http://pastebin.com/Mr5atT21

14:55 Defrecord doesn't play nicely with hyphenated namespaces

14:56 Vinzent: I'm curious why defrecord should create a function? Why not (new-from-map Foo {:a 1}), or something similar?

14:58 stuartsierra: Dunno. It was a long-thought discussion on the dev.clojure.org wiki.

15:07 Vinzent: (record MyRecord 1 2) and (record-map MyRecord :a 1 :b 2) seems ideal, imo

15:07 (as described here http://groups.google.com/group/clojure-dev/browse_thread/thread/4a0447939ebed7c4)

15:08 cemerick: Vinzent: record and record-map would have to be macros, and thus couldn't be used with HOFs

15:08 hiredman: I've noticed http://dev.clojure.org/display/design/JIRA+workflow doesn't seem to address assigning, should assign issues to yourself?

15:08 cemerick: macros or use reflection

15:09 both are distasteful

15:09 cemerick: Right; neither of which are kosher

15:09 Vinzent: cemerick, ah, so it's done for speed

15:09 arohner: is it possible to create a class with several constructors, using gen-class? I have (defn -init ([] (...)) ([foo] ...) ([foo bar] ...)), but (show) only lists the first constructor

15:09 cemerick: Thus, the implicit fn definitions — which I'm not a fan of, but… *shrug*

15:10 coopernurse: anyone know of a function in ring / compojure / noir that given a relative url returns a full url with host/port/context prepended?

15:10 cemerick: Vinzent: Seems like a reasonable expectation.

15:10 arohner: coopernurse: I'm pretty sure that doesn't exist

15:11 coopernurse: arohner: ok.. servlet api has some stuff that can help with that, but a convenience function would be nice

15:11 ooh.. maybe hiccup.core/with-base-url

15:14 hmm, nope

15:15 looks like that's just a macro that takes the base url

15:15 amalloy: coopernurse: doesn't java.net.URL do something like that?

15:17 coopernurse: amalloy: I don't believe so. you need the host/port from the HttpServletRequest

15:21 something along these lines. I'll see about porting it. http://www.java2s.com/Code/Java/Servlets/GetRelativeUrlforservlet.htm

15:32 LauJensen: Do we have any examples of scraping webpages behind logins? ie. negotiating cookies and all that

15:32 coopernurse: LauJensen: the apache HttpClient lib will automatically store/send cookies. not sure if there's a clojure wrapper for it yet

15:33 perhaps: http://clojars.org/diamondap/clj-apache-https

15:33 LauJensen: coopernurse: Excellent, thanks

15:34 coopernurse: you bet. docs are at github: https://github.com/rnewman/clj-apache-http

15:34 or is that a different lib? http vs https. author looks different

15:35 sorry, yeah those two links are different libs

15:35 but they appear to wrap the same HTTPClient lib under the hood, so both probably do what you need

15:37 I'm not seeing an obvious way to access the HttpServletRequest in noir.. anyone know if defpage exposes it? or do I have to write middleware

15:51 Somelauw: What would be the best way to implement a datastructure in clojure? I know clojure likes to use dicts for everything, but dicts are slow, you can't overwrite the way that for iterates over them and you can't decide how to should be printed. So I think that would be one of the cases in which you should use genclass.

15:52 amalloy: Somelauw: noooo, not genclass

15:52 deftype please

15:52 hiredman: gen-class is slow

15:53 amalloy: really?

15:53 hiredman: yes

15:53 stuarthalloway: slow/fast doesn't mean much without a requirement

15:53 but +1 hiredman

15:54 hiredman: "gen-class just adds another layer of dispatch"

15:54 stuarthalloway: if you are writing a datastructure, deftype is your friend

15:54 amalloy: Somelauw: https://github.com/flatland/ordered/blob/develop/src/ordered/map.clj is an example of mine, implementing maps that retain insertion order

15:54 hiredman: deftype removes one

15:54 amalloy: the final version is kinda unreadable due to performance optimizations, but you can probably see sorta what's going on?

15:56 Somelauw: https://github.com/flatland/ordered/blob/1ed7e95d093c9de74701a7239d7ba04c9f7464d0/src/ordered/set.clj is a less messy implementation of ordered sets

15:59 Somelauw: amalloy: Thanks, I will look at them.

15:59 stuarthalloway: anybody here use the clojure maven plugin and have context on http://dev.clojure.org/jira/browse/CLJ-822?

16:05 Mike|home: I saw a function that looked like this: (fn [[a b]] [b (+ a b)]) Is the inner [a b] destructuring?

16:05 amalloy: yes

16:05 Bronsa: yes

16:05 Mike|home: Radical.

16:06 Bronsa: i'd say awesome

16:06 amalloy: Mike|home: i smell fibonacci

16:06 ibdknox: lol

16:06 coopernurse: there's a technique noir is using in cookies.clj that I may want to emulate, but I want to make sure I understand what's going on

16:06 Mike|home: Indeed, amalloy :)

16:06 coopernurse: looking at: https://github.com/ibdknox/noir/blob/master/src/noir/cookies.clj

16:06 arohner: anyone have ideas on why (future (+ 1 1)) would fail, even on in a clean repl session?

16:06 coopernurse: specifically, I want to make sure I understand (binding ) that happens in noir-cookies

16:07 Mike|home: I still feel pretty stupid because I can't do much with Clojure, even though I've been at it for a few weeks. Haha.

16:07 ibdknox: coopernurse: it creates a threadlevel binding

16:07 coopernurse: ibdknox: ok, great. that's what it appears

16:07 ibdknox: coopernurse: which means, in this case, that it will have that value for that specific request

16:07 coopernurse: so all calls to other cookie funcs by that thread will use those local bindings

16:07 ibdknox: coopernurse: during that request, yes

16:08 coopernurse: ibdknox: that's what I figured - otherwise noir would be broken with concurrency > 1

16:08 ibdknox: ibdknox: yep :)

16:08 lol

16:08 I like talking to myself

16:08 coopernurse: heh

16:08 ibdknox: coopernurse: what are you trying to do?

16:09 coopernurse: ibdknox: well, I'm still puzzling over how to build a full URL based on the current request context

16:09 so I'm planning on writing a lib that might pull a similar trick

16:09 manutter: arohner: odd, if I try (future (+ 1 1)) I get java.util.concurrent.RejectedExecutionException

16:09 coopernurse: use (binding) to make the request thread local, and expose functions that operate on that binding

16:09 ibdknox: coopernurse: wait, you just want the requested uri?

16:09 manutter: arohner: is that what you're seeing?

16:09 arohner: manutter: yeah

16:10 (.isTerminated clojure.lang.Agent/soloExecutor) => true

16:10 coopernurse: ibdknox: no, I want to create an url relative to the base url of the current request

16:10 manutter: arohner: that's weird, I'm sure I played with future before, without issues.

16:10 ibdknox: coopernurse: by default any url missing the root slash will be relative

16:11 arohner: manutter: https://github.com/technomancy/leiningen/issues/265

16:11 coopernurse: ibdknox: so, for example, if the current request is: http://example.com:2913/foo/bar

16:11 ibdknox: and the context root is /foo (which I have no way of knowning in advance)

16:11 ibdknox: and I ask for a relative url of: "/baz", then I expect: http://example.com:2913/foo/baz

16:12 Mike|home: Agh. I'm packing to move, but I ran out of boxes.

16:12 manutter: arohner: ah

16:12 Mike|home: Better start making piles.

16:12 ibdknox: I see

16:12 coopernurse: ibdknox: I'm trying to construct the absolute url, without having to know how the WAR was deployed, which the servlet api provides hooks for, but you need the HttpServletRequest

16:12 ibdknox: coopernurse: gotcha. Sounds like that would be reasonable

16:12 Bronsa: user=> (future (+ 1 1))

16:12 #<core$future_call$reify__5508@2586b11c: 2>

16:12 user=> @*1

16:12 2

16:13 coopernurse: ibdknox: but noir doesn't appear to expose the request, and even if it did, passing it around seems crufty.. so this (binding) trick looks good

16:13 Bronsa: for me it works

16:13 ibdknox: coopernurse: well, you can easily create a middleware that adds the uri to the params passed to defpage, but I think your solution sounds more robust

16:14 amalloy: coopernurse: yeah, that's one of the things binding is for. i have a middleware that binds *url* to the uri of the request

16:14 hugod: stuarthalloway: for adding clojure.test to zi, I ended up writing a macro that used binding in 1.2 and with-redefs in 1.3

16:14 coopernurse: amalloy: ibdknox: cool, thanks. I will explore. definitely the sort of code you want to make sure you get right, lest wires get crossed

16:14 stuarthalloway: hugod: the dynamic binding fix is now pushed

16:16 ibdknox: stuarthalloway: shot in the dark, but do you happen to know when speakers will get notified for the conj? We want to buy our tickets soon.

16:16 amalloy: (inc ibdknox)

16:16 lazybot: ⟹ 2

16:17 hugod: stuarthalloway: thanks

16:17 stuarthalloway: ibdknox: we hope to announce before early bird is over

16:17 but if we don't ...

16:18 amalloy: though, ibdknox, i wouldn't be surprised if they could arrange a refund if it turns out you get to speak :P

16:18 stuarthalloway: (1) anybody who buys now will get refunded if they are a speaker

16:18 ibdknox: stuarthalloway: great, that works

16:18 mwillhite: hey all, brand new to clojure and java…trying to set up my dependencies w/ leiningen, but I'm not sure how to request the correct package: http://pastie.org/2435373

16:19 starting with the java.awt stuff, where can I find the resource?

16:19 amalloy: mwillhite: those are all packages included in the jre, so you don't have any special dependencies

16:20 mwillhite: well I get this error: Exception in thread "main" java.lang.ClassNotFoundException: quote.(java.awt AWTException Robot Rectangle Toolkit) (core.clj:1)

16:20 so maybe one of those don't actually exist…

16:20 obviously I'm just copying and pasting code here…

16:21 amalloy: they should exist, and they do when i try it. are you sure what you pasted is your actual code?

16:21 mwillhite: yep

16:21 weird…

16:21 coopernurse: mwillhite: what JDK are you using, and what OS?

16:22 mwillhite: I'm on Lion

16:22 not sure how to find the JDK

16:22 amalloy: coopernurse: i doubt it matters. the exception indicates his clojure syntax is broken, not anything class-related

16:22 niko22: when using emacs/slime i get a "byte-code: Failed to download Clojure jars" - any suggestions?

16:23 amalloy: mwillhite: there are two many close parens at the end of your import. this makes me strongly suspect that your actual code is (ns (import ...))

16:24 mwillhite: it is…

16:24 let me paste the entire file

16:24 its small

16:24 amalloy: ugh. that's why i asked you if you pasted your actual code

16:24 mwillhite: I deeply apologize

16:24 amalloy: what you pasted would be correct in isolation; being wrapped in (ns) slightly alters the meaning

16:24 coopernurse: mwillhite: yeah, you could start a REPL and just try: (import '(java.awt AWTException Robot Rectangle Toolkit))

16:25 mwillhite: http://pastie.org/2435398

16:25 ah, so my whole code should be wrapped in the namespace

16:25 amalloy: you want more like (ns (:import (java.awt AWTException ...) (java.awt.image ...)))

16:25 mwillhite: yeah that makes sense

16:25 Exception in thread "main" java.lang.IllegalArgumentException: Parameter declaration quote should be a vector (core.clj:1)

16:25 amalloy: this is a confusing distinction, i'm aware. basicalle, (import) is a function, so needs its arguments quoted. (ns) is a macro, which doesn't need quoting

16:26 tcepsa: mwillhite: Not your whole code; only the imports should be in the

16:26 ns form.

16:26 amalloy: and it uses :import instead of import to clarify the difference

16:26 mwillhite: oh

16:27 okay, so updating to the syntax amalloy suggested gets it to compile

16:27 lancepantz: amalloy: hi

16:27 mwillhite: thanks people

16:27 tcepsa: Sweet

16:31 mwillhite: given the code in this pastie: http://pastie.org/2435398

16:31 shouldn't I be able to do this from the repl:

16:31 (screen-grab "screen.jpg")

16:32 tcepsa: mwillhite: You need to be in the correct namespace in the REPL

16:32 coopernurse: mwillhite: you need to namespace qualify it, or use (in-ns) to switch to the screencap.core ns

16:32 mwillhite: I'm using the lein repl…

16:32 coopernurse: so this should work: (screencap.core/screen-grab "screen.jpg")

16:32 mwillhite: I thought that put me in the right namespace

16:32 okay

16:32 coopernurse: if the prompt says: user=>

16:32 then you're in the user namespace, which is the default

16:32 mwillhite: it does

16:33 oh right okay

16:33 coopernurse: if you do this: (in-ns 'screencap.core)

16:33 then the prompt will change

16:33 mwillhite: screencap.core=> (screen-grab "screen.jpg")

16:33 java.lang.Exception: Unable to resolve symbol: screen-grab in this context (NO_SOURCE_FILE:6)

16:34 coopernurse: have you loaded the file into the repl?

16:34 mwillhite: whats interesting too, is when I tried the first method (from user=>) including the namescape, it said it couldn't find the namespace

16:34 I just typed 'lein repl' from the project root

16:34 coopernurse: ah

16:34 try: (load-file "yourfile.clj")

16:35 tcepsa: What's the path (including filename) of that file?

16:35 (It has to be in a specific location relative to your project

16:35 root for lein repl to find it and load it for you)

16:35 coopernurse: right, so absolute path is best for now

16:36 tcepsa: Should be in src/screencap/core.clj

16:36 mwillhite: /Users/mwillhite/apps/clojure_hacks/screencap/core.clj

16:36 coopernurse: yeah, pass that to load-file

16:36 mwillhite: I was digging into clojure a few months back and I never had to load my file before, maybe thats new?

16:36 will try

16:37 getting a file not found exception

16:37 tcepsa: What coopernurse suggested should work. To get it to load

16:37 automatically, you need to put your screencap directory in a directory

16:37 named src

16:37 mwillhite: (load-file "/Users/mwillhite/apps/clojure_hacks/screencap/core.clj")

16:37 oh I missed a dir

16:38 k, got it loaded…

16:38 coopernurse: great, so you should be able to call screen-grab now

16:38 mwillhite: well that seemed to work…not sure where it put my file tho :P

16:38 oh, same dir

16:39 coopernurse: nice

16:40 mwillhite: I have to say, I've always been super impressed by the help received from this channel (and the seemingly inifinite patience), thank you so much for helping me out

16:40 coopernurse: mwillhite: totally welcome.. happy to have a question I actually can answer

16:40 mwillhite: :)

16:40 coopernurse: yeah, I found the tooling a little hard to wrap my head around at first

16:41 but once you learn the basic handful of tricks to eval files and whatnot, then it's a very productive platform imho

16:41 mwillhite: yeah, especially having been completely immersed in javascript and ruby for the past 5 months…my clojure mind has withered a bit

16:42 I'm really excited about learning it, just need to find the right application so my employer will let me do it during the day

16:42 coopernurse: yeah, I have to keep a doc in evernote for each lang/platform I use to remind me of the incantations like these

16:42 heh, yeah I know what you mean

16:43 ordnungswidrig: anybody using emacs from emacsformacosx.com? I have problems with german keyboard and keybindings

16:43 mwillhite: I need to start documenting the tricks as I learn, I think that will help a lot

16:44 coopernurse: mwillhite: yeah, I'm inconsistent with it. I found using something like evernote, where you don't have to think about naming a file, you can just paste stuff in and organize it later, has helped

16:44 mwillhite: anything to eliminate any barriers to taking notes

16:44 mwillhite: yeah totally, I'm a fan of evernote…thanks again for your help

16:44 coopernurse: you bet

16:44 have fun

16:44 * amalloy needs to attend some kind of training session for org-mode. i'm sure if i learned to use it i would instantly become twice as productive

16:45 tcepsa: amalloy: Same here!

16:47 hiredman: we had a sonian meetup, where it was discovered one of my cowokers has an org-mode were he lists the topics and his agreement/disagreement with another coworker, so we he is accurately able to say "I agree with so-and-so 40% of the time"

16:47 ibdknox: lol

16:48 tcepsa: Nice!

16:48 technomancy: needs a web frontend though. http://iagreewithdanlarkin.com

16:49 you could get achievement badges, etc.

16:49 hiredman: it needs some kind of crowd sourcing statistical backing, so you just answer a few questions and it gives you a good guess at your agreement percentage with danlarkin

16:49 danlarkin: oh boy

16:50 what is this I don't even

16:52 scottj: cemerick: both your theories apply to me, I had no clue about ->Blah and it definitely didn't look like a constructor to me, I thought of threading too.

16:52 cemerick: damn, fogus is never around when I have an opportunity to gloat! ;-)

16:53 scottj: I've no doubt some docs will get in, eventually. Hopefully for 1.3.0, but we'll see how that goes.

16:57 icey: Do people lean one way or the other on clojureql vs clojure.contrib.sql?

16:58 stuartsierra: cemerick: I'll gloat for you the next time I see him.

16:59 cemerick: stuartsierra: ha, much obliged.

16:59 stuartsierra: 'later.

16:59 scottj: icey: both are used quite a bit, I don't have a large enough sample to say one is more popular than the other

16:59 amalloy: icey: hasn't c.c.sql been put down in favor of c.j.jdbc?

16:59 icey: amalloy: entirely possible; i'm a noob :)

17:00 scottj: good enough for me, thanks... just making sure i'm not looking at using a solution that nobody uses or has flaws that i haven't found in google yet

17:10 kzar: Is there a function you can use a predicate that just returns the argument? I want to use not-any?, watching out for non-nil values

17:11 scottj: kzar: example of inputs and output?

17:12 raek: kzar: identity

17:12 kzar: raek: aha thanks

17:14 amalloy: kzar: though (every? nil? xs) seems clearer for your actual goal

17:14 kzar: amalloy: oh yea, good point

17:27 coopernurse: ok, this appears to work for concurrency=1. but if someone has a moment to check my use of (binding) here I would be grateful. https://gist.github.com/1174475

17:29 amalloy: coopernurse: the semantics are the same, but i'd use declare instead of def

17:30 coopernurse: amalloy: thanks, changing..

17:30 zoldar: I have a defrecord refering to vars (functions, atoms etc.) in the same namespace. When I aot compile the namespace and try to use the record class in java code, it ends up with "Var some.ns/some-var is unbound" pointing to a reference to that var in the defrecord. What may I be missing?

17:31 amalloy: anyway, you certainly don't have any binding-related problems

17:32 i'd write your port test as (when-not (#{80 443} port) (str ":" port))

17:32 coopernurse: amalloy: love it, thanks

17:33 amalloy: though i guess that could cause silent failure if, say, port is an int and 80 is a long. though i think that's fixed in 1.3

17:33 coopernurse: ooh

17:33 let me try that

17:34 getPort() is an int

17:34 literal numbers are ints right, depending on their size?

17:34 ,(type 80)

17:34 clojurebot: java.lang.Long

17:34 coopernurse: oh

17:34 in my repl is says Integer

17:35 amalloy: coopernurse: right, that changed in 1.3

17:35 coopernurse: ok, interesting

17:35 amalloy: &(class 90)

17:35 lazybot: ⇒ java.lang.Integer

17:36 amalloy: &*clojure-version*

17:36 lazybot: ⇒ {:major 1, :minor 2, :incremental 0, :qualifier ""}

17:36 amalloy: ,*clojure-version*

17:36 clojurebot: {:interim true, :major 1, :minor 3, :incremental 0, :qualifier "master"}

17:36 coopernurse: ah, good to know

17:37 so = tests will work between int and long, but not set membership

17:37 amalloy: right

17:37 coopernurse: is that a bug or feature?

17:37 hiredman: the hoops you have to jump through to get a boxed integer in 1.3 are kind of a drag

17:38 I mean, maybe it's good for performance, but if a java method requires an Integer you have to do something like (Integer/valueOf (int 10))

17:38 coopernurse: yeah, that particular case is very subtle

17:39 hiredman: that is one word you could use to describe it

17:39 amalloy: haha

17:39 coopernurse: so is that how 1.3 is going to stay? or is there talk of changing it?

17:39 amalloy: ,(Integer. (int 10))

17:40 clojurebot: 10

17:40 amalloy: hiredman: that's simpler, at least?

17:40 dnolen: hiredman: eh? (Integer. 10) works

17:40 amalloy: ,(Integer. 10)

17:40 clojurebot: 10

17:40 dnolen: ,(type (Integer. 10)

17:40 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

17:40 dnolen: ,(type (Integer. 10))

17:40 clojurebot: java.lang.Integer

17:40 hiredman: ah, no kinding

17:41 "autoboxing, unless you're an int or float"

17:43 what really through me was (int 10) was throwing an exception

17:43 (Long cannot be cast to Integer or something)

17:47 dnolen: hiredman: ? I haven't seen anything like that.

17:50 hiredman: ,(type (int 10))

17:50 clojurebot: java.lang.Long

17:51 hiredman: you cannot pass that to a method that takes an Integer

17:51 zoldar: I've put together the minimal example describing my problem: http://pastebin.com/P4C3FxXM

17:52 hiredman: you need to load the namespace from java

17:52 paul__: hey, I'm trying to apply a function with side effects to a collection, that also updates the collection, and (dorun (map (fn... dosnt seem to be working

17:52 any ideas?

17:52 hiredman: ,(doc dorun)

17:52 clojurebot: "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil."

17:52 hiredman: ^- "returns nil."

17:53 ,(doc doall)

17:53 clojurebot: "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."

17:53 paul__: ah, Ill try that

17:53 thanks

17:54 OK, it looks like that'll work

18:07 chewbranca: anyone have any recommendations for coercing a String to an InputStream?

18:08 basically I'm trying to save an attachment to a couchdb document, the method in clutch I'm using expects either a File or an InputStream, but I need to save from a string, and created a temporary file on the disk just seems like a bad way to accomplish it

18:09 s/created/creating/

18:09 lazybot: <chewbranca> basically I'm trying to save an attachment to a couchdb document, the method in clutch I'm using expects either a File or an InputStream, but I need to save from a string, and creating a temporary file on the disk just seems like a bad way to accomplish it

18:09 manutter: Try (StringReader. the-str)

18:09 hmm, that's probably not sufficient

18:09 coopernurse: (ByteArrayInputStream. (.getBytes the-str))

18:10 chewbranca: manutter: yeah actually tried that but didn't work

18:10 manutter: doh, I was just about to say that

18:10 my google-fu is too slow

18:12 chewbranca: coopernurse: excellent! thanks that did the trick

18:12 coopernurse: chewbranca: sweet

18:13 amalloy: you should really make sure you write it with the character encoding you intend to

18:13 coopernurse: amalloy: heh, was just writing that

18:13 ordnungswidrig: I just thought of that

18:13 coopernurse: (ByteArrayInputStream. (.getBytes the-str "utf-8"))

18:13 for example

18:14 chewbranca: ok cool, thanks, adding that in

18:15 also, what's the clojure idiomatic way of naming conversion functions? right now I'm going with string-to-input-stream

18:15 amalloy: meh

18:16 there are people who will like that, or will like str->input-stream. i like stream-from-string, personally

18:17 chewbranca: amalloy: ok, so more of a style preference, I'm not a huge fan of string-to-input-stream

18:34 scottj: how about input-stream?

18:35 and use protocols or multimethods

18:35 amalloy: scottj: clojure.java.io already does that

18:37 scottj: chewbranca: so I think the idiomatic way is just it after the result type

18:43 chewbranca: scottj: I tried using input stream but it treats the string as a file path, rather than a raw string. ByteArrayInputStream is working well though

18:45 tomoj: input-stream should accept a byte array

18:45 like (input-stream (.getBytes "foo"))

18:51 chewbranca: tomoj: ahhh nice, that's a bit cleaner that directly using ByteArrayInputStream

19:10 justicefries: clojure is absolutely ruining ruby for me.

19:11 tomoj: :D

19:11 technomancy: justicefries: yeah, there needs to be a warning label for that

19:11 justicefries: yeah....

19:12 think I'm okay with it. ;)

19:12 the one thing I'm not sure of, and maybe this is because I just haven't done it...

19:12 but how it fares organizationally against large codebases a la Rails.

19:15 scottj: justicefries: I think the conventions aren't there so each project is going to look different, it's up to your to organize them well

19:16 justicefries: ah sure.

19:55 Somelauw: Hi, does anyone remember the command to shutdown cake?

20:01 Nevermind, I already killed it using top.

20:04 amalloy: cake kill

20:07 Somelauw: That works

21:26 tnks: I don't know Clojure at all, but a friend was curious if Clojure had a currrying facility.

21:27 amalloy: well. because it has first-class functions, it is possible to curry. but it doesn't happen automatically like in haskell

21:27 hiredman: sort of depends what you mean by that

21:27 tnks: or maybe a more appropriate question is "how does Clojure solve problems other languages would use currying or partial eval to solve?"

21:27 amalloy: (instead, it allows functions to have a variable number of arguments)

21:27 danlarkin: it doesn't have currying like haskell has currying

21:27 hiredman: but sure you can create functions that are the partial application of another function

21:27 ,((partial + 1) 2)

21:27 clojurebot: 3

21:28 tnks: awesome.

21:28 partial is really half the battle.

21:28 I'm going to send him here.

21:28 hiredman: a lot of people just function literals

21:28 ,(#(+ 1 %) 2) ; this sort of thing

21:28 clojurebot: 3

21:29 hiredman: partial is prettier though

21:29 dnolen: red-black tree balance checking, https://gist.github.com/1174834 (yes I know, syntax needs to improve, working on it)

21:29 tnks: yeah, I'm not sure how to parse the latter.

21:29 amalloy: debatable. partial is more elegant, i think, but neither is pretty

21:29 tnks: what's the "%"?⇧

21:30 amalloy: &'#(inc %)

21:30 lazybot: ⇒ (fn* [p1__12654#] (inc p1__12654#))

21:30 amalloy: &(#(inc %) 2)

21:30 lazybot: ⇒ 3

21:30 hiredman: ,'#(+ % 1)

21:30 clojurebot: (fn* [p1__10191#] (+ p1__10191# 1))

21:30 hiredman: % is the argument

21:31 amalloy: "prettier"

21:31 partial also doesn't generate more classes

21:31 tnks: okay, this feels very similar to the _ partial eval Scala has.

21:32 where % feels like _

21:39 dnolen: will probably let vector patterns take [], and seqs will match with ([] :seq).

21:45 amalloy: aw, hiredman, generating more classes is fun! who doesn't love classnames like sandbox10558$eval12677$foo__12678$fn__12679$bar__12680?

22:34 mbac: is there an unless primitive in clojure?

22:34 amalloy: &(doc when-not)

22:34 lazybot: ⇒ "Macro ([test & body]); Evaluates test. If logical false, evaluates body in an implicit do."

22:35 mbac: cool!

22:36 amalloy: mbac: of course, it's easy to write your own

22:37 mbac: sure

23:17 dnolen: gotta love open source, https://gist.github.com/1174909

23:26 srid: is it possible to register custom type convertors for clojure's json library? at the minimum, i want to convert timestamp number in the JSON to java.sql.Timestamp objects automatically.

23:27 technomancy: srid: clojure has lots of json libs.

23:27 cheshire allows that

23:27 as does clojure-json

23:28 srid: i am using org.clojure/data.json, but I can switch to one of those

23:28 technomancy: oh, hm... well, it allows for customization on encoding. I don't know about decoding.

23:34 srid: whenever I add a new dependency via `lein install` or `lein deps`, is it mandatory to kill *slime-repl* and do clojure-jack-in again? all of this takes time. jvm is slow

23:34 * hiredman needs a project name

23:35 srid: how about jambojure?

23:35 technomancy: lupus yonderboy

23:36 srid: it appears i can't use (use ...) alone in the repl. it must be wrapped in (ns foo ...). that sucks

23:36 hiredman: I decided I wanted a persistent map as a service, running on my laptop to be available for other little bits of code (like my irc->sqs notifcation stuff)

23:36 srid: you need to quote the form

23:37 ,(use 'clojure.zip)

23:37 clojurebot: WARNING: next already refers to: #'clojure.core/next in namespace: sandbox, being replaced by: #'clojure.zip/next

23:37 WARNING: replace already refers to: #'clojure.core/replace in namespace: sandbox, being replaced by: #'clojure.zip/replace

23:37 WARNING: remove already refers to: #'clojure.core/remove in namespace: sandbox, being replaced by: #'clojure.zip/remove

23:37 nil

23:37 srid: right, thanks

23:37 hiredman: whoops, that must have broke a lot of things

23:37 technomancy: clojurebot: ABORT, ABORT

23:38 clojurebot: No entiendo

23:38 srid: chesire doesn't see to have custom decoders (only encoders)

23:39 * srid is thinking of map'ing the read json for transformation

23:39 hiredman: so I wrote this thing on top of infinispan that I can run via launchd to provide persistent key/value storage

23:39 technomancy: srid: update-in?

23:39 hiredman: and I need a name for it

23:39 technomancy: hiredman: army-of-one?

23:40 hiredman: ah!

23:40 entrepot

23:40 technomancy: because seriously, do you have a data center under your desk?

23:41 hiredman: no? that would be ridiculous...

23:42 it's totally sweet, I store a map of irc nicks to email addresses in entrepot so now my sqs thing can use gravatars

23:42 amalloy: dnolen: that's more like a bean than a pojo, fwiw

23:42 dnolen: amalloy: forgive my total Java ignorance, how so?

23:43 srid: technomancy: (update-in foo [1 :last_updated] f) <- here update-it only updates index 1, so i need to it multiple times passing 2 3 etc... I suppose.

23:43 call it*

23:43 technomancy: srid: sure; a combination of map and update-in, I guess

23:43 amalloy: dnolen: well, pojo is Plain Old Java Object: conforms to no special specifications or conventions. beans were introduced so that property inspectors could manipuate properties by calling conventional get/set/is methods

23:45 dnolen: amalloy: open to better names, tho clearly this is not really a bean a either.

23:45 amalloy: and there's a reasonably well-tested camelCase->dash-case function at https://github.com/flatland/useful/blob/develop/src/useful/string.clj

23:45 feel free to steal it

23:46 * technomancy alerts the CA police

23:46 amalloy: technomancy: hey, i have a CA and i wrote that

23:46 i think. *checks blame*

23:47 technomancy: but your CA only covers contributions to clojure and contrib!!1eleven

23:47 amalloy: that's probably true. funny if it weren't so sad :P

23:48 dnolen: amalloy: thx, sent it along to darevay.

23:48 srid: (map (fn [q] (update-in q [:creation_date] #(Timestamp. %))) json)

23:48 beauty.

23:51 amalloy: pretty cool, though, dnolen

23:51 `(. ~this ~(symbol n)) should probably be `(. ~this (~(symbol n)))

23:52 but i guess since this isn't your code i won't bother you with it :)

23:52 dnolen: amalloy: always feel free to send corrections via pull requests :)

23:53 amalloy: dnolen: i sure will. let me know when you add this to match and i'll have a look then

23:54 dnolen: amalloy: that'd be great. will do.

Logging service provided by n01se.net