#clojure log - Jun 05 2011

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

1:28 * offby1 points to the sign

1:28 offby1: "No Dazed and Confused"

1:44 disappearedng: what is shortest and most practical book for clojure? I am reading the joy of clojure and it's super long winded and I can't stand it

1:45 !book

1:46 halfprogrammer`: disappearedng: Right now there are not too many options "Programming clojure" and "Practical clojure" are the others available

1:47 both are good. Programming clojure is the older of the two

1:47 disappearedng: which one is more code

1:47 I can't stand reading theoretical stuff

1:47 halfprogrammer`: Certainly Programming clojure has more examples

1:48 Think you will change your mind abt Joy of clojure in a few days

1:48 disappearedng: ok thx

1:48 I read 50 pages and haven't even started writing code yet

1:48 I am literally falling asleep

1:48 halfprogrammer`: That is probably the best book around. Extremely high quality

1:48 :)

1:48 You don't read K&R for C to learn how to code in C from, do you

1:49 Joy of clojure tells you why certain things work the way they do

1:49 disappearedng: I read source code

1:49 and then I read k & r

1:49 I have ADHD i can't sit still but I can code really focused

1:50 halfprogrammer`: hmmm

1:50 IMHO Joy of clojure probably the best one out there. Of course, opinions differ...

1:51 disappearedng: ok i will try to stick to it till page 60

1:51 I am literally not being able to focus cause it's so boring

1:51 halfprogrammer`: hmmm

1:56 * halfprogrammer learning couchdb

6:09 Night-hacks: hi guys

6:09 is there any book about language desing, implementations and .... ?

6:10 of course i dont mean end user books

6:11 Vinzent: maybe SICP will be helpful

6:11 Night-hacks: SICP stands for ... ?

6:12 Vinzent: structure and interpretation of computer progrmas

6:12 Night-hacks: Vinzent: MIT press one ?

6:12 Vinzent: yep

6:12 Night-hacks: Vinzent: thanks

6:13 morphling: Night-hacks: 'lisp in small pieces' might suit you

6:13 Night-hacks: morphling: yeah thats in my list also

6:15 Vinzent: In enlive, if I have 2 identical html-pieces excluding one tag. how can I use one snippet to generate both pieces?

6:16 raek: Vinzent: you can define a var to contain one of them, and then define another var to contain the result of an at-call on the first

6:17 Night-hacks: book recommendations: Compilers: Principles, Techniques, and Tools ("The Dragon Book" http://dragonbook.stanford.edu/)

6:18 Night-hacks: and also Semantics with Applications (now available for free: http://www.daimi.au.dk/~bra8130/Wiley_book/wiley.html)

6:19 Night-hacks: raek: both looks intersting

6:56 djpowell: I can't get wrap-file to work properly in ring...

6:57 I do (wrap-file "public"), but this seems to map the requests from /public/a.txt to the file public/public/file.txt

6:59 raek: djpowell: that's strange. the string "public" isn

6:59 'n even in the source

7:00 oh, wait.

7:00 djpowell: the path you give to wrap-file is the root directory where you will serve files from

7:01 djpowell: and the url is simply concatenated onto that, hence the double "public"

7:01 so (wrap-file "public") will serve the URL /a.txt from public/file.txt

7:03 djpowell: with moustache, you can strip off one segment of the url: (app ["public" &] [(wrap-file "public") not-found-handler])

7:06 djpowell: yeah - i guess that is how it is supposed to work. wrap-resource is the same

7:06 seems a bit odd

7:07 raek: the URL prefix does not have to have the same name as the root directory

7:07 e.g. you might want to have /static/ in the URL, but call the static root directory public/

7:08 djpowell: yeah

7:09 the clojure web stack has quite a learning curve, but it looks like it might be worth it

7:10 raek: what I really like about Moustache is that it is very simple to arrange ones handlers hierarchially (since the routing middlware can strip off matched segments of the URL)

7:16 Vinzent: but compojure has the context macro that does the same

7:56 quizme: I would just like to announce that slime.vim is awesome. It gets CTRL-C CTRL-C to send code from vim to your REPL.

7:56 super easy to set up too.

8:19 Vinzent: is there a built-in fn to get all the permutations of the given seq? e.g. (f [1 2 3 4]) => ([1 2 3 4] [2 3 4 1] [3 1 4 2] etc)

8:21 gregh: http://richhickey.github.com/clojure-contrib/combinatorics-api.html

8:22 Vinzent: oh. ok, thanks

10:10 fliebel: Any math people around who could tell me what would be the name(or any other means of finding guidance to a solution) of a problem similar to the traveling salesman problem. Namely, the cheapest way to connect a set of nodes in a weighted graph.

10:37 schaf_: hi all. whats wrong about this: (.isDirectory file)? it get "No matching field found: isDirectory for class [Ljava.io.File;"

10:40 fliebel: schaf_: Looks like you have a file array

10:42 schaf_: thank you fliebel. i just did not see it

11:06 hmmm. now (.isDirectory file) works but (.getName file) gives me "java.lang.IllegalArgumentException: No matching field found: name for class java.io.File"

11:12 terom: Hmm, works her3e

11:13 schaf_: yes, here too. my mistake... sorry terom

15:53 JohnnyL: hi

15:57 offby1:

15:57 * offby1 points to the sign

15:57 offby1: "No Dazed and Confused"

15:57 * offby1 nods gravely

16:05 JohnnyL: thats nice!

16:08 offby1: A "Dazed And Confused"-free zone is indeed nice.

16:08 * offby1 dimly recalls a couple of other tracks on LZI that were worth skipping

16:33 JohnnyL: offby1: oh right, that led zep quote.

16:33 hahaha, duh, silly me, i had no idea what you were talking about.

16:49 krumholt: is there a way to print a deftype or a defrecord nicely? like overriding a print mehtod somewhere?

16:52 dnolen: krumholt: you can implement print-method for your type/record

16:54 krumholt: dnolen, thanks

18:02 Moominpapa: I know this is slightly off-topic, but is there really no callback-orientated way to run a JDBC query in Java?

18:03 I couldn't figure out why clojure.contrib.sql didn't seem to have the functionality, and then I looked at the Java API...

18:03 seancorfield: can you give an example of what you're trying to envisage?

18:06 Moominpapa: Well, in C#, you can call a function asynchronously, and give a function to be called when it's finished

18:06 Node has that as the only model.

18:06 So

18:07 (execute-query connection "select * from Users" do-something-with-users)

18:07 (I appreciate that looks like with-query-results.)

18:07 But as far as I can tell, with-query-results waits for the DB to return.

18:11 icey: So you just want to make your db call asynchronously and have a callback handle the response?

18:11 Moominpapa: Yes, well, in particular, I'd rather not have a thread waiting for the response.

18:12 Tbh, it probably doesn't matter, but I've been thinking in node style for a month or two.

18:12 icey: Eh, I'm a clojure noob, but couldn't you use an agent for that?

18:12 mrBliss`: ,(doc future)

18:12 clojurebot: "([& body]); Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block."

18:14 Moominpapa: You can certainly use an agent (future does, for instance), but you're still taking up a thread in a thread pool just to wait for something that's executing on another machine.

18:14 Probably doesn't matter for my purposes, but I was surprised that Java didn't seem to have a way to do it.

18:15 lucian: Moominpapa: that's something you have to live with on the jvm, sometimes

18:15 Moominpapa: Yeah, I guess :)

18:16 I probably overthink resource utilisation anyway. :)

18:16 lucian: a thread pool just for async io is silly, but it's often something you have to live with, sadly

18:17 I hope whoever first thought sync IO is a good idea died a bad death

18:30 brehaut: Moominpapa: you might find https://github.com/hiredman/die-geister useful?

18:31 Moominpapa: you can make any expression a 'task' that is run async, merge tasks together and declare join points.

19:02 JohnnyL: ΓΌ

19:02 :)

20:57 gstamp: exit

20:57 oops

21:23 offby1: passwd offby1 frotz

21:23 oops

21:31 Ownatik: fail

22:08 wastrel: i did an ok job

22:39 lawfulfalafel: I have this weird problem in emacs; for some reason when I create a left paren key, the right one is automatically created right next to it

22:40 but I don't get how I am supposed to enclose an existing function like (% number 3) and turn it into (eq 0 (% number 3))

22:41 I think paredit is causing this, but I'm not sure at all

22:56 offby1: lawfulfalafel: you should ask on #emacs

22:56 in the meantime, it sounds like you're using paredit

22:56 ... which just does that

23:26 TimMc: lawfulfalafel: so you have |(% number 3) where | is the cursor...

23:27 type left-paren and then Ctrl right arrow

23:28 given (eq 0|) (% number 3), Ctrl-right jumps the innermost possible close-paren to the right to enclose another form.

23:30 zakwilson: Is Postal the One True Way for sending mail from Clojure?

23:37 lawfulfalafel: TimMC: thanks! I never new that Ctrl-right arrow trick

23:45 in the clojure repl, how do you go to previous commands?

23:45 the up arrow just prints the keyboard character

23:45 ^[[A

23:45 whatever that is :P

23:48 zakwilson: lawfulfalafel: most people don't use the ordinary repl; they use lein, or slime/swank or labrepl

23:49 To directly answer your question, I don't think the basic repl can do that.

23:50 dnolen: also cake ... best repl.

23:52 * zakwilson is a slime guy with little use for a standalone repl, but cake has a good reputation.

23:59 TimMc: lawfulfalafel: Check out the "Paredit cheat sheet", by the way. Lots of tricks.

Logging service provided by n01se.net