#clojure logs

2011-06-05

01:28offby1"No Dazed and Confused"
01:44disappearedngwhat 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
01:45disappearedng!book
01:46halfprogrammer`disappearedng: Right now there are not too many options "Programming clojure" and "Practical clojure" are the others available
01:47halfprogrammer`both are good. Programming clojure is the older of the two
01:47disappearedngwhich one is more code
01:47disappearedngI can't stand reading theoretical stuff
01:47halfprogrammer`Certainly Programming clojure has more examples
01:48halfprogrammer`Think you will change your mind abt Joy of clojure in a few days
01:48disappearedngok thx
01:48disappearedngI read 50 pages and haven't even started writing code yet
01:48disappearedngI am literally falling asleep
01:48halfprogrammer`That is probably the best book around. Extremely high quality
01:48halfprogrammer`:)
01:48halfprogrammer`You don't read K&R for C to learn how to code in C from, do you
01:49halfprogrammer`Joy of clojure tells you why certain things work the way they do
01:49disappearedngI read source code
01:49disappearedngand then I read k & r
01:49disappearedngI have ADHD i can't sit still but I can code really focused
01:50halfprogrammer`hmmm
01:50halfprogrammer`IMHO Joy of clojure probably the best one out there. Of course, opinions differ...
01:51disappearedngok i will try to stick to it till page 60
01:51disappearedngI am literally not being able to focus cause it's so boring
01:51halfprogrammer`hmmm
06:09Night-hackshi guys
06:09Night-hacksis there any book about language desing, implementations and .... ?
06:10Night-hacksof course i dont mean end user books
06:11Vinzentmaybe SICP will be helpful
06:11Night-hacksSICP stands for ... ?
06:12Vinzentstructure and interpretation of computer progrmas
06:12Night-hacksVinzent: MIT press one ?
06:12Vinzentyep
06:12Night-hacksVinzent: thanks
06:13morphlingNight-hacks: 'lisp in small pieces' might suit you
06:13Night-hacksmorphling: yeah thats in my list also
06:15VinzentIn enlive, if I have 2 identical html-pieces excluding one tag. how can I use one snippet to generate both pieces?
06:16raekVinzent: 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
06:17raekNight-hacks: book recommendations: Compilers: Principles, Techniques, and Tools ("The Dragon Book" http://dragonbook.stanford.edu/)
06:18raekNight-hacks: and also Semantics with Applications (now available for free: http://www.daimi.au.dk/~bra8130/Wiley_book/wiley.html)
06:19Night-hacksraek: both looks intersting
06:56djpowellI can't get wrap-file to work properly in ring...
06:57djpowellI do (wrap-file "public"), but this seems to map the requests from /public/a.txt to the file public/public/file.txt
06:59raekdjpowell: that's strange. the string "public" isn
06:59raek'n even in the source
07:00raekoh, wait.
07:00raekdjpowell: the path you give to wrap-file is the root directory where you will serve files from
07:01raekdjpowell: and the url is simply concatenated onto that, hence the double "public"
07:01raekso (wrap-file "public") will serve the URL /a.txt from public/file.txt
07:03raekdjpowell: with moustache, you can strip off one segment of the url: (app ["public" &] [(wrap-file "public") not-found-handler])
07:06djpowellyeah - i guess that is how it is supposed to work. wrap-resource is the same
07:06djpowellseems a bit odd
07:07raekthe URL prefix does not have to have the same name as the root directory
07:07raeke.g. you might want to have /static/ in the URL, but call the static root directory public/
07:08djpowellyeah
07:09djpowellthe clojure web stack has quite a learning curve, but it looks like it might be worth it
07:10raekwhat 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)
07:16Vinzentbut compojure has the context macro that does the same
07:56quizmeI would just like to announce that slime.vim is awesome. It gets CTRL-C CTRL-C to send code from vim to your REPL.
07:56quizmesuper easy to set up too.
08:19Vinzentis 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)
08:21greghhttp://richhickey.github.com/clojure-contrib/combinatorics-api.html
08:22Vinzentoh. ok, thanks
10:10fliebelAny 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:37schaf_hi all. whats wrong about this: (.isDirectory file)? it get "No matching field found: isDirectory for class [Ljava.io.File;"
10:40fliebelschaf_: Looks like you have a file array
10:42schaf_thank you fliebel. i just did not see it
11:06schaf_hmmm. now (.isDirectory file) works but (.getName file) gives me "java.lang.IllegalArgumentException: No matching field found: name for class java.io.File"
11:12teromHmm, works her3e
11:13schaf_yes, here too. my mistake... sorry terom
15:53JohnnyLhi
15:57offby1
15:57offby1"No Dazed and Confused"
16:05JohnnyLthats nice!
16:08offby1A "Dazed And Confused"-free zone is indeed nice.
16:33JohnnyLoffby1: oh right, that led zep quote.
16:33JohnnyLhahaha, duh, silly me, i had no idea what you were talking about.
16:49krumholtis there a way to print a deftype or a defrecord nicely? like overriding a print mehtod somewhere?
16:52dnolenkrumholt: you can implement print-method for your type/record
16:54krumholtdnolen, thanks
18:02MoominpapaI know this is slightly off-topic, but is there really no callback-orientated way to run a JDBC query in Java?
18:03MoominpapaI couldn't figure out why clojure.contrib.sql didn't seem to have the functionality, and then I looked at the Java API...
18:03seancorfieldcan you give an example of what you're trying to envisage?
18:06MoominpapaWell, in C#, you can call a function asynchronously, and give a function to be called when it's finished
18:06MoominpapaNode has that as the only model.
18:06MoominpapaSo
18:07Moominpapa(execute-query connection "select * from Users" do-something-with-users)
18:07Moominpapa(I appreciate that looks like with-query-results.)
18:07MoominpapaBut as far as I can tell, with-query-results waits for the DB to return.
18:11iceySo you just want to make your db call asynchronously and have a callback handle the response?
18:11MoominpapaYes, well, in particular, I'd rather not have a thread waiting for the response.
18:12MoominpapaTbh, it probably doesn't matter, but I've been thinking in node style for a month or two.
18:12iceyEh, I'm a clojure noob, but couldn't you use an agent for that?
18:12mrBliss`,(doc future)
18:12clojurebot"([& 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:14MoominpapaYou 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:14MoominpapaProbably doesn't matter for my purposes, but I was surprised that Java didn't seem to have a way to do it.
18:15lucianMoominpapa: that's something you have to live with on the jvm, sometimes
18:15MoominpapaYeah, I guess :)
18:16MoominpapaI probably overthink resource utilisation anyway. :)
18:16luciana thread pool just for async io is silly, but it's often something you have to live with, sadly
18:17lucianI hope whoever first thought sync IO is a good idea died a bad death
18:30brehautMoominpapa: you might find https://github.com/hiredman/die-geister useful?
18:31brehautMoominpapa: you can make any expression a 'task' that is run async, merge tasks together and declare join points.
19:02JohnnyLü
19:02JohnnyL:)
20:57gstampexit
20:57gstampoops
21:23offby1passwd offby1 frotz
21:23offby1oops
21:31Ownatikfail
22:08wastreli did an ok job
22:39lawfulfalafelI 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:40lawfulfalafelbut 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:41lawfulfalafelI think paredit is causing this, but I'm not sure at all
22:56offby1lawfulfalafel: you should ask on #emacs
22:56offby1in the meantime, it sounds like you're using paredit
22:56offby1... which just does that
23:26TimMclawfulfalafel: so you have |(% number 3) where | is the cursor...
23:27TimMctype left-paren and then Ctrl right arrow
23:28TimMcgiven (eq 0|) (% number 3), Ctrl-right jumps the innermost possible close-paren to the right to enclose another form.
23:30zakwilsonIs Postal the One True Way for sending mail from Clojure?
23:37lawfulfalafelTimMC: thanks! I never new that Ctrl-right arrow trick
23:45lawfulfalafelin the clojure repl, how do you go to previous commands?
23:45lawfulfalafelthe up arrow just prints the keyboard character
23:45lawfulfalafel^[[A
23:45lawfulfalafelwhatever that is :P
23:48zakwilsonlawfulfalafel: most people don't use the ordinary repl; they use lein, or slime/swank or labrepl
23:49zakwilsonTo directly answer your question, I don't think the basic repl can do that.
23:50dnolenalso cake ... best repl.
23:59TimMclawfulfalafel: Check out the "Paredit cheat sheet", by the way. Lots of tricks.