#clojure log - Oct 08 2009

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

0:00 hiredman: dunno

0:01 generally if you get disconnected and reconnect, but your ghost is still hanging around, irc servers give you nick_

0:01 itistoday: ah gotcha

0:02 well thanks, gotta go

0:04 hecktor: Is there a command from within the repl to reset the state of the repl?

0:32 rongenre: so if I have a hash-map. eg {:a 1, :b 2}

0:33 ,{:a 1 :b 2}

0:33 clojurebot: {:a 1, :b 2}

0:33 rongenre: I can turn it into pairs with seq

0:33 ,(seq {:a 1 :b 2})

0:33 clojurebot: ([:a 1] [:b 2])

0:33 rongenre: how do I turn it back (easily, I can use reduce, but I don't think that's the right way)

0:35 arbscht: ,(apply merge {} (seq {:a 1 :b 2}))

0:35 clojurebot: {:b 2, :a 1}

0:35 rongenre: Nice, I like it. Thanks.

0:35 arbscht: ,(into {} (seq {:a 1 :b 2}))

0:35 clojurebot: {:a 1, :b 2}

0:36 arbscht: ,(reduce conj {} (seq {:a 1 :b 2}))

0:36 clojurebot: {:b 2, :a 1}

0:37 arbscht: into is probably the best way

2:01 Raynes: Wouldn't it be a good idea to have a separate Google Group for job postings? Or some other means of getting job offers to the Clojure community that isn't the primary Google Group?

2:41 ztellman: just wrote a mandelbrot viewer, if anyone's into that sort of thing

2:41 http://ideolalia.com/exploring-the-mandelbrot-set-with-your-gpu

3:00 LauJensen: Morning gents

3:05 Fossi: hi

3:06 tomoj: LauJensen: are you the clojureql person?

3:06 LauJensen: Yes sir

3:06 tomoj: so, is it true that I need to put jars for mysql/postgres/derby/... in lib/ in order to compile clojureql?

3:07 Fossi: hi

3:08 tomoj: ah well just got a BUILD SUCCESSFUL so, even if I really didn't need all of them, it's OK :)

3:08 LauJensen: tomoj, kotarak has almost exclusively set up the build environment - I don't think you need to put them there before running ant, Ivy should fetch whatever is necessary

3:08 tomoj: wasn't using Ivy, was just doing `ant -Dclojure.jar=...`

3:09 LauJensen: k, you shouldn't need it for building, it's not nitted in anywhere, you do need your jdbc adapter on the classpath when you actually start interacting with the database

3:09 tomoj: strange, I got compile errors until I dumped in jars for mysql, postgres, and derby

3:10 oh well, it appears to have worked

3:13 LauJensen: I should look into that

3:24 1: public LabeledComponentGroup(String labelString, JComponent... components) {

3:24 2: public LabeledComponentGroup(String labelString, List<JComponent> components) {

3:24 I haven't seen the ... notation before, what's going on here?

3:28 tomoj: I believe that just means a variable number of arguments

3:29 cgrand: the last arg is just an array of JComponent

3:29 LauJensen: Ok, that would be my guess, but the weird thing is that I cannot instantiate this class ... maybe I'm not getting JComponents...

3:29 I'll get back to you guys

3:32 tomoj: LauJensen: so you pass a connection info map to clojureql every time you want to run a query. does it keep an active connection alive in the background, or does it make a new connection on every query?

3:32 LauJensen: tomoj, You can review our progress on lighthouseapp.com, so far it's a connection that opens and closes which easy body of code, but that's of course unecessary in most cases, so we're trying to agree on a method of resolution

3:35 tomoj: ah, I see, thanks

3:36 LauJensen: ,(javax.swing.JComponent.)

3:36 clojurebot: java.lang.InstantiationError: javax.swing.JComponent

3:37 LauJensen: http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JComponent.html#JComponent()

3:37 Am I missing something here?

3:42 Chousuke: LauJensen: I don't think you're supposed to instantiate that

3:43 it's an abstract class :P

3:44 jaiganesh: hi

3:44 LauJensen: So whats the use? When I need to pass it to a constructor like LabeledComponentGroup, is it (#^JComponent (JTextField. x y z)) ?

3:44 hi

3:44 Chousuke: LauJensen: Without the extra parens :P

3:45 LauJensen: No dice

3:45 I can't instantiate the Labeledgroup

3:45 'no matching ctor'

3:46 jaiganesh: i am reading a file one line at a time using this function

3:46 (defn file-lines

3:46 [file-name]

3:46 (line-seq (BufferedReader. (FileReader. file-name))))

3:46 is there an alternate way in clojure?

3:46 LauJensen: (map #(do-stuff-to-line %) (.split (slurp "filename") "\n"))

3:47 Chousuke: LauJensen: it takes a List or an Array of JComponents apparently

3:47 jaiganesh: LauJensen: thanks a lot

3:48 LauJensen: Chousuke, aaaah, into-array is my friend, thanks

3:48 jaiganesh, np

3:48 Chousuke: LauJensen: or you can just use a plain clojure list

3:48 since there's a List<JComponent> constructor as well

3:48 LauJensen: wow

3:48 jaiganesh: .split can you explain that?

3:49 oh ok got it

3:49 splitting on newline character

3:49 Chousuke: slurp doesn't read the file one line at a time though.

3:49 LauJensen: Chousuke, I gave up when I saw that Vector wasn't unified with []

3:49 jaiganesh: yeash slurp read the whole file into a string

3:50 Chousuke: jaiganesh: if you're using contrib there's the duck-streams library

3:50 jaiganesh: chousuke:thks will check it out

3:51 how to know what functions defined in a library?

3:51 LauJensen: read the source?

3:51 tomoj: jeez, I'm getting a segfault with clojureql

3:51 jaiganesh: yeah thats one way

3:52 Chousuke: jaiganesh: contrib has documentation accessible via github

3:52 ~contrib

3:52 clojurebot: contrib is http://github.com/richhickey/clojure-contrib/tree/master

3:52 LauJensen: segfault?!

3:53 tomoj: LauJensen: that's what I thought! didn't even know those could happen in java

3:53 LauJensen: That has to be something in the jdbc driver you're using

3:53 Chousuke: it can't :)

3:53 you're accessing some non-java code.

3:53 LauJensen: What we do is make AST's and compile those into text, passing that to your driver

3:53 tomoj: ah, yes, my sqlite JDBC driver

3:53 LauJensen: That will never give you a segfault

3:55 tomoj: jaiganesh: you can also do like (ns-interns 'clojure.contrib.duck-streams)

3:55 though the docs on the the gh-pages are easier to read :)

3:59 jaiganesh: Chousuke:ok

3:59 tomoj: guess I will just try with postgres

4:00 jaiganesh: i wana find if a string contains a substring , like "hello" contains "h".. how to do it?

4:03 tomoj: ,(.contains "hello" "h")

4:03 clojurebot: true

4:04 liwp: how do I get to the namespace doc string in the repl. (doc contrib.walk) prints out nil

4:08 LauJensen: tomoj, in our daily work I use postgres/mysql and kota is more on Derby, those 3 work well

4:09 We are working on literal strings for the predicate clause to queries, until that's up, there are situations where you need to use 'raw'

4:09 at least one I can think of anyway

4:10 (query table [date name value] (> date (- (Date.) (Date. 14 0 0))) or something similar, to pull up dates from the last 14 days, in that case you'd use (raw "SELECT... WHERE >= date(now() - INTERVAL 14 DAY);")

4:14 tomoj: LauJensen: yay, it works. thanks for making this!

4:14 clojurebot: for is not used often enough.

4:15 LauJensen: cool, np

4:49 tomoj: LauJensen: have you had problems with :auto-inc in postgres?

4:50 LauJensen: We had a create-table for postgres contributed, which was fundamentally flawed, I rewrote it a few commits ago and it's worked since, also with :auto-inc

4:51 tomoj: is there something special you have to do to tell create-table to use postgres?

4:51 my tables are created fine but :not-null and :auto-inc seem to be ignored

5:04 LauJensen: tomoj, sorry, didn't catch your msg before now - You should run the demo, it demonstrates all facets of clojureql

5:19 tomoj: LauJensen: feel free to ignore me, don't want to bug you. trying to run the demo now but I can't figure out how to. it looks like the demo classes didn't get compiled into the jar, are they supposed to be?

5:21 LauJensen: I start up a repl, then load clojureql/src/dk/bestinclass/clojureql/demos/mysql.clj for instance, making sure that I have the appropriate user created in the dbms, then eval (-main)

5:22 That will then execute some 20 operations giving you the output, reading through the code, seeing the output will teach you just about everything you need to know about clojureql

5:24 crios_: hello. can anyone clear me the monad-expr documentation? http://github.com/richhickey/clojure-contrib/blob/master/src/clojure/contrib/monads.clj

5:25 :bind and :result should be m-bind and m-result ?

5:25 I mean, :m-bind and :m-result

5:25 tomoj: LauJensen: thanks, that worked. and the demo successfully make a table with a primary key/serial

5:25 so I must have been doing something wrong

5:26 LauJensen: Good, then at least now you have some working code to look at

5:26 tomoj: yep :)

5:28 crios_: no Leibniz friend here :) ?

5:29 tomoj: LauJensen: aha. I simply forgot to require dk.bestinclass.clojureql.backend.postgres

5:29 thanks for your help

5:29 LauJensen: aah :) np

5:32 liwp: crios_: yeah, I think you're right

5:33 crios_: or possible m-bind and m-return

5:38 crios_: but I don't think you need to worry about that with monad-expr, you simply pass in the steps as a binding vector and monad-expr will do the right thing for you

5:41 crios_: liwp: thanks. I was trying to understand how domonad works

5:41 The first part in http://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure-programmers-part-1/ is really obscure

5:41 (for me)

5:43 I understood that stuff as simply adding what in Java / OO would be a decorator pattern

5:43 with a known interface

5:44 LauJensen: Am I the only one here who thinks that monads are a complete waste of time?

5:44 tomoj: I don't understand them yet :(

5:45 crios_: Well, I could add, if just could understand their purpose :D

5:47 Its purpose should be adding behaviour to existing functions, so that they can be chained together

5:47 at least, this is my feeling

5:47 what do you think?

5:47 LauJensen: From what I understood, researchers worked for years on monads, primarily in Haskell, extending, adapting, improving and when they we're done they looked up and saw that Excel had the same properties... ?

5:48 liwp: ,(use clojure.walk)

5:48 clojurebot: java.lang.ClassNotFoundException: clojure.walk

5:48 liwp: ,(use 'clojure.walk)

5:48 clojurebot: nil

5:48 liwp: ,(doc clojure.walk)

5:48 clojurebot: java.lang.ClassNotFoundException: clojure.walk

5:49 liwp: huh?

5:49 (use 'clojure.contrib.base64)

5:49 ,(use 'clojure.contrib.base64)

5:49 clojurebot: nil

5:49 liwp: ,(doc clojure.contrib.base64)

5:49 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.base64

5:49 liwp: ,(doc map)

5:49 clojurebot: "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."

5:50 LauJensen: liwp, you can query clojurebot directly and play with him there, or alternatively, open a REPL locally and experiment

5:51 G0SUB: LauJensen: btw, where can I get the code of Clojurebot?

5:51 LauJensen: clojurebot, where are you?

5:51 G0SUB: whoops!

5:51 LauJensen: ~where are you?

5:51 clojurebot: http://github.com/hiredman/clojurebot/tree/master

5:52 G0SUB: nice

5:56 crios_: still regarding http://github.com/richhickey/clojure-contrib/blob/master/src/clojure/contrib/monads.clj , I don't understand what the let in 'add-monad-step' do

5:57 let [[bform expr] step]

5:57 What does it do?

5:59 the parameter mexpr is splitted in [bform expr] , correct?

6:03 liwp: LauJensen: I've done the playing locally, I just wanted to verify that clojure bot shows the same problem

6:03 LauJensen: try (doc clojure.walk) in your repl

6:03 do you get a doc string?

6:04 tomoj: is there a good way to define methods for multimethods in namespaces out of your control?

6:05 liwp: crios_: yeah, the let binding destructures a vector and binds the first element to bform and the second element to expr

6:05 LauJensen: liwp, I have no clojure.walk

6:06 liwp: LauJensen: you don't? are you on HEAD? I think it might have been clojure.contrib.walk in earlier

6:06 arbscht: crios_: step is destructured, not mexpr

6:07 liwp: LauJensen: anyhow, doc does not return a doc string for the name space even though one exists

6:07 LauJensen: I'm in a 2 weeks old snapshot

6:07 ~def walk

6:07 clojurebot: Excuse me?

6:07 LauJensen: ~def println

6:08 liwp, it's not in core

6:09 liwp: LauJensen: hmm, mine is src/clj/clojure/walk.clj

6:09 LauJensen: aaah, I see the problem

6:09 look in the top of that file :author "Stuart Sierra" :D

6:09 liwp: LauJensen: but back to the namespace doc string: I can see a doc string for example for clojure.contrib.base64 and I'm trying to figure out why it doesn't work for clojure.walk

6:10 LauJensen: why is that a problem?

6:10 LauJensen: (use 'clojure.walk)

6:10 ,(use 'clojure.walk)

6:10 clojurebot: nil

6:10 LauJensen: ,(doc walk)

6:10 clojurebot: "([inner outer form]); Traverses form, an arbitrary data structure. inner and outer are functions. Applies inner to each element of form, building up a data structure of the same type, then applies outer to the result. Recognizes all Clojure data structures except sorted-map-by. Consumes seqs as with doall."

6:11 liwp: that works for me too, but (doc clojure.walk) does not return the docstring for the namespace

6:13 LauJensen: Weird

6:14 cgrand: LauJensen: clojure.walk is more than 2 weeks old

6:14 LauJensen: cgrand, can you fetch the doc string for it from your repl?

6:17 cgrand: LauJensen: yes. Are you running a compiled clojure?

6:18 StartsWithK: liwp: you didn't compile your clojure-contrib but you have compiled version of clojure.walk? aot removes namespace metadata, i think its a known bug

6:19 liwp: StartsWithK: I think I've got compiled versions of both, but I might be wrong

6:19 anyhow, that would explain it

6:19 thanks

6:19 LauJensen: good catch

6:20 tomoj: is this a bad idea? https://gist.github.com/05542a0687e908fe2042

6:20 Chousuke: there's a macro like that in contrib

6:20 (doc with-ns)

6:20 clojurebot: "clojure.contrib.with-ns/with-ns;[[ns & body]]; Evaluates body in another namespace. ns is either a namespace object or a symbol. This makes it possible to define functions in namespaces other than the current one."

6:21 Chousuke: tomoj: also, you don't need the # for bindings outside the syntax-quote :P

6:22 tomoj: ah, yes

6:22 well since it's in contrib I guess it's not evil?

6:22 Chousuke: I dunno

6:22 tomoj: I just want to define extra methods for multimethods in some other namespace

6:22 Chousuke: you should be able to do (defmethod othernamespace/multi ...)

6:23 liwp: I've got clojure-contrib/src and clojure-contrib/classes in my classpath before clojure-contrib.jar so that might explain it

6:23 maybe I should only have the jar file in my classpath...

6:27 tomoj: Chousuke: great, thanks

6:27 I tried (defn othernamespace/foo ...) (where foo wasn't in the other namespace) and got an error, and for some reason assumed that meant I couldn't (defmethod othernamespace/bar ...) (where bar IS in the other namespace)

6:36 LauJensen: shouldn't compile-sql-alter dispatch on the class of db, like compile-sql does?

7:29 LauJensen: alter is currently being reworked completely

7:29 @ tomoj

7:59 AWizzArd: ~max people

7:59 clojurebot: max people is 182

8:10 tomoj: LauJensen: ah, ok. I'll check out the logs

8:33 ambient: anyone know what tech Penumbra uses? seems that it doesn't use CUDA or any of that.

8:44 liwp: ambient: OpenCL?

9:06 ambient: doubtful, because opencl doesn't seem to have even C libraries yet for most platforms

9:09 jdz: ambient: you could as well go check the source code on github instead of guessing

9:10 ambient: well i already read through the code, but seems i have to read opengl api now also

9:30 Dawgmatix: whats used to write the documentation available on clojure.org ? and whats used to do the syntax highlighting of the examples ?

9:56 chouser: clojure.org is a wikispaces site, so it uses their markup. The coloring is done by a javascript file I believe.

10:07 ffailla: do clojure sets maintain insertion order?

10:08 liwp: no

10:08 you can use ordered sets for that

10:08 I think they maintain insertion order

10:08 chouser: sorted sets maintain sorted order

10:09 ,(sorted-set 4 2 5 3 1 3 2)

10:09 clojurebot: #{1 2 3 4 5}

10:09 ffailla: sorted sets incur the cost of sorting per insertion correct?

10:09 liwp: chouser: so there is no set that maintains insertion order?

10:10 chouser: liwp: nothing it Clojure anyway -- dunno if Java has something like that. You can use a vector or a list of course, if you don't mind the O(n) search time.

10:11 ffailla: sure, it's a red-black tree.

10:11 Chousuke: is that possible in the first place? :/

10:11 chouser: probably. you might be able to cook up some combination of a map and a vector or something

10:12 actually, finger trees would do it I think.

10:12 Chousuke: how's your implementation doing?

10:12 chouser: O(1) insert keeping insertion order, O(log n) lookup.

10:13 tomoj: how fast are clojure sets at lookup?

10:13 crios_: liwp: in Java you can use LinkedHashSet

10:13 liwp: crios_: thanks

10:13 crios_: http://java.sun.com/j2se/1.4.2/docs/api/java/util/LinkedHashSet.html

10:14 chouser: Chousuke: not bad -- pretty much all working, just needs some performance improvements.

10:14 liwp: chouser: your impl relies on newnew?

10:15 chouser: liwp: yes

10:15 tomoj: hash-sets are essentially O(1) lookup. sorted-sets are O(log n)

10:23 tomoj: anyone done migrations in clojure?

10:23 by that I mean database schema migrations

11:43 andysp: how to restart nagios?

11:51 replaca_: ztellman: are you lurking?

11:51 ztellman: replaca_, yeah

11:52 trouble running the mandelbrot demo?

11:52 replaca_: sick of c#, eh? :-)

11:52 ztellman: do you know who replaca_ is?

11:52 ztellman: replaca_, no

11:53 replaca_: ztellman: clue: I wrote the clojure pretty printer

11:53 ztellman: ah, gotcha

11:53 replaca_: so I just wanted to give you some grief when I saw you in channel after I heard you were sick

11:54 ztellman: yeah, I'm trying to figure out whether to come into work today

11:54 replaca_: don't - we don't want to share our germs this year

11:54 plus you're about to have vacation

11:54 ztellman: yeah

12:32 technomancy: so it looks like the JDK is has primitives for reading zip files, but it doesn't seem to have any actually useful "unzip this file into this location" methods...

12:32 is there anything like that for Clojure? maybe in contrib?

12:33 tomoj: LauJensen: is there supposed to be a way to make multiple columns NOT NULL?

12:33 technomancy: probably should be in contrib if it's not already

12:43 cow-orker: inconsistent? on a sorted-map I'm allowed to run first and rest, but not destructure in let. (let [[x & xs] (sorted-map 1 2 3 4)] nil)

12:43 java.lang.UnsupportedOperationException: nth not supported on this type: PersistentTreeMap

12:43 clojurebot:

12:46 corruptmemory: deploying latest devastator to QA

12:46 oops, wrong window

12:46 carry on

12:52 rsynnott: clearly, corruptmemory works for a company which makes weapons for bad scifi books

12:53 corruptmemory: Alas, not far from the truth, although no weapons. Merely the other engineers here like to name things after Transformers, perhaps just as bad.

12:54 rsynnott: (happily, in the real world weapons either have non-threatening names, like Polaris, or meaningless names, like SS-18)

12:55 ambient: Carebear stare V9

12:56 cow-orker: or maybe not "inconsistent" as there is no reader syntax for sorted-map. But it would have been nice anyway... some destructuring syntax that works with first/rest? anyway...no big deal :)

12:56 rsynnott: or downright deceptive names; Blue Peacock is a nuclear landmine filled with chickens, not peacocks, presumably for cost reasons

13:01 JAS415: anyone have experience with pneumbra?

13:01 i'm trying to get it set upand having trouble

13:01 not sure what i'm doing wrong

13:02 replaca_: JAS415: ztellman is your guy. He's around here sometimes

13:02 JAS415: ok

13:02 ztellman: yeah, I'm here

13:02 what kind of problem are you having?

13:03 JAS415: well i'm on linux, and i'm getting an 'unsatisfied link error'

13:03 that my nativewindow_jvm isn't on the library path

13:03 interesting thing is all of the things in my library path have lib prepended to them

13:03 ztellman: are you using the startup script from the wiki?

13:04 JAS415: so its libnativewindow_jvm

13:04 trying to

13:04 ztellman: hmm

13:04 ambient: i do -Djava.library.path=c:\path\to\penumbra\lib\windows

13:05 JAS415: oh

13:05 maybe the ~ is screwing it up

13:05 ztellman: yeah, you generally have to give the full path

13:06 seems like you shouldn't need to, but you do

13:08 JAS415: it is literally supposed to be something like "/home/jon/pneumbra/lib/linux" ?

13:09 ztellman: yeah, though you transposed some characters in "penumbra"

13:09 in case that was a copy/paste

13:10 JAS415: well there's a problem

13:12 thanks, now it works

13:12 ztellman: great

13:12 let me know if you have any other issues

13:23 tomoj: is it bad that I want to call a function whose namespace is known only at runtime?

13:24 I guess I can just eval it, but it seems wrong :(

13:27 hiredman: ,((resolve (symbol "clojure.core" "+")) 1 2)

13:27 clojurebot: 3

13:27 tomoj: ah, thanks

13:28 I was trying stuff like #'(symbol ...) and realized that was idiotic, then gave up

13:30 ngoc: How to start REPL and evaluate something right after (or before) REPL is started? I want to both run a .clj file and hava REPL at the same time

13:35 ambient: i use emacs for that

13:35 or some other ide

13:36 Chousuke: ngoc: java -cp clojure.jar clojure.main --help :)

13:36 ngoc: I want to design a "make start" target that starts the program, and still gives REPL so that the user can interact with the program

13:37 Chousuke: you can start a repl with a startup script

13:40 ambient: anyone have tips for fast buffer switching in emacs?

13:41 funkenblatt: C-x <right>?

13:41 or left

13:41 ambient: well i got like 40 buffers open but want to just switch between 4 or 5

13:41 funkenblatt: oh

13:41 well for that i usually just open up 4 or 5 windows

13:42 ambient: some kind of a keybind/tab-bar system would be highly useful

13:43 M-x bind-buffer M-1 foo.clj M-2 bar.clj etc..

13:43 funkenblatt: it might exist already

13:43 rdd: check out iswitchb-mode or ido-mode

13:45 hm, they're not like what you suggested, but better than the default buffer switching function imo

13:46 tomoj: ido and friends are great

13:50 funkenblatt: well anyway it wouldn't be hard to write something like what ambient said

13:51 technomancy: ambient: yeah, ido is the way to go

13:51 ambient: somekind of a priority list for autobinding would be kinda sweet also, the most used files bubbling onto the top, or manually defining the priorities

13:51 ok, thx. i shall read about ido then

13:52 technomancy: ido puts the most recently accessed at the front

14:05 danlei: I use a mix of ido-switch-to-buffer, winner-undo, and C-x r w / C-x r j

14:07 (C-x r w is especially helpful if I want to preserve a split of file+repl, when using different languages)

14:07 * technomancy is still learning that last one

14:08 danlei: bookmarks are nice too, but another story

14:18 drewr: I use elscreen

14:18 konr: Are there other screencasts besides Rich's?

14:18 drewr: each "screen" is a different window config

14:18 keeps me sane switching between emacs and the terminal

14:19 C-z always does what I expect

14:19 technomancy: konr: there's PeepCode (not free)

14:19 konr: and there's a few very introductory ones on youtube

14:20 konr: technomancy: hmm, is peepcode worth it?

14:20 technomancy: konr: I think so, but since I wrote it I just might be biased. =)

14:20 konr: technomancy: haha

14:20 technomancy: most reviews were pretty positive though.

14:32 danlei: drewr: what's the difference to C-x r w then?

14:47 mrsolo: knor: this is new http://channel9.msdn.com/shows/Going+Deep/Expert-to-Expert-Rich-Hickey-and-Brian-Beckman-Inside-Clojure/

14:55 savanni: Hey, I have a really simple JDBC question.

14:56 As far as I can tell, I'm supposed to create a connection using the getConnection() method on java.sql.DriverManager. The problem is that when I call (. java.sql.DriverManager (getConnection)), it says that getConnection does not even exist, and I am expecting it to say that getConnection requires more parameters.

14:56 Am I going in totally the wrong direction?

14:58 mrsolo: svanni: i juse clojure.contrib.sql instead of jdbc directly...

14:59 konr: technomancy: I'm downloading your screencast! Sounds nice!

14:59 Chousuke: savanni: when it says it doesn't exist it means that it doesn't exist for the parameters you called it with :P

14:59 technomancy: konr: cool; thanks

15:00 kotarak: savanni: there is also clojureql

15:01 savanni: Actually, i'm going to jdbc because there's at least one function, getMetaData, which isn't strictly an SQL function.

15:02 Chousuke: does that apply only to java methods?

15:02 Chousuke: savanni: yeah

15:02 savanni: Aaaahhhhh.

15:02 Chousuke: ,(identity 3 4)

15:02 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$identity

15:02 savanni: Yeah, that's what I was expecting.

15:03 Chousuke: ,(Math/sqrt 2 3 4 5)

15:03 clojurebot: java.lang.IllegalArgumentException: No matching method: sqrt

15:03 rstehwien:  konr: is that the Mire screencast from peepcode? It is awesome.

15:03 konr: rstehwien: yes! There are several interesting screencasts on it. I hope more clojure-related ones show up

15:04 rstehwien: konr: me too, the more clojure screencasts the better

15:05 slashus2: Chousuke: You working on writing the reader in clojure? How is that going?

15:05 savanni: Booya! Access denied!

15:05 Thanks, Chousuke.

15:09 Chousuke: slashus2: stalled right now, studies interfere. :P

15:11 kotarak: savanni: you might want to look into show from clojure.contrib.repl-utils

15:12 savanni: Okay, I'll look at that, too.

15:12 I've got access, but it's a deep tree to traverse.

15:14 wooby: is use of test metadata idiomatic, or should one prefer test-is?

15:15 Chousuke: wooby: test-is is clojure.test nowadays, so use it :)

15:16 though you need a git version of clojure for it :/

15:16 danlarkin: stuartsierra: got a minute? I'm getting weird behavior with duck-streams/copy

15:17 wooby: Chousuke: thanks

15:17 drewr: danlei: elscreen probably uses it underneath

15:17 danlarkin: stuartsierra: the output file is larger than the input file

15:17 drewr: danlei: less to keep in my head

15:18 just scroll through the tabs at top with C-z C-n

15:18 danlei: ah, ok

15:33 dermarius: hello everyone

15:33 LauJensen: Gents - I'm working on a single namespace little app, where I want to use a few images, how can I avoid using fully qualified paths ? (user.dir = "/home/")

15:33 hi dermarius

15:33 dermarius: I'm just trying to get along with emacs and clojure-mode.... but somehow the keystrokes are still a mystery for me

15:34 is there a command to eval the whole buffer?

15:34 C-x C-e seems not to compete with line breaks

15:35 danlei: dermarius: C-c C-l, C-c C-k the first one loads, the second one loads and compiles. besides, try C-h m in a blojure-mode buffer

15:35 Marius: ok, thanks... will give it a try

15:35 danlei: welcome

15:40 hiredman: LauJensen: if you don't put a '/' as the first element in the path it will not be fully qualified, and that is how you can avoid using fully qualified paths

15:40

15:41 LauJensen: hiredman, does it then guarantee to set user.dir to the directory where java is launched from ?

15:42 hamza: hey guys, i am building xml from a set using reduce (reduce f [] data) but i get everything wrapped in a vector and that produces empty tag. is there a way to overcome this?

15:42 hiredman: LauJensen: if you want a nonspecific answer it's best to ask specific questions

15:43 hamza: [] is an emtpy vector, and you are using it as the init value to reduce

15:44 it is hard to say if that is the problem without looking at teh function, but that would be my guess

15:44 LauJensen: by user.dir you mean the java property?

15:45 and you want user.dir to be a relative path or something?

15:46 LauJensen: hiredman, yea - I just want to be sure, that when I ask people to run the app with java -cp . clojure.main proggy.clj - that it will always find the images in that folder

15:46 hamza: yeah thats the case function is (reduce (fn [f v] (conj f [:item [:desc (:desc v)]])) [] data) how would you produce an xml? or do i have to call first on the result

15:46 hiredman: LauJensen: uh

15:46 LauJensen: that folder means the directory java is launched from?

15:46 LauJensen: yes

15:47 hiredman: so just user (System/getProperty "user.dir")

15:47 use

15:48 hamza: I've never produceded xml, just consumed it

15:49 but your result is a bunch of xml fragments, I imagine you need to stick them in some kind of containing tag/element/whatever

15:50 what are you using to produce the xml?

15:50 I was thinking clojure.xml/emit or some such, but your format is completely different

15:57 stuartsierra: danlarkin: I'm back; what's the problem?

15:57 danlarkin: stuartsierra: the output file is larger than the input file

15:58 stuartsierra: oooo-kay

15:58 What are you copying? File to File?

15:59 danlarkin: InputStream to Writer

15:59 stuartsierra: Might be an encoding issue.

16:00 danlarkin: it's binary data

16:01 stuartsierra: Then you should be writing to an OutputStream, no?

16:03 danlarkin: heh, I did not know that

16:04 stuartsierra: Yes, Reader & Writer are only for character data; InputStream and OutputStream are for binary data.

16:04 (copy InputStream Writer) will first convert the content of the input stream to a string using the default encoding.

16:04 danlarkin: well that would explain it

16:05 stuartsierra: If you just want to read from an input stream and write to disk, you can use (copy InputStream File)

16:06 danlarkin: Yep, just made the change and now the tests pass, thanks :)

16:06 stuartsierra: no problem

16:12 zakwilson: So let's say I want to use Clojure to make a decent cross-platform GUI that's easy to distribute, and I don't want to tear out my hair. What tools should I be looking at?

16:12 stuartsierra: zakwilson: a magic lamp?

16:14 dermarius: :-D

16:15 triyo: is that like magic pony?

16:16 dermarius: its like the holy grail, but brighter

16:16 Chousuke: zakwilson: maybe Qt? :/

16:16 dermarius: zakwilson: one could say java already contains a cross-platform GUI... what will be special with the GUI you're thinking about?

16:17 zakwilson: Qt seems like it would make distribution significantly harder. I was hoping for something that makes Swing nicer to work with.

16:17 But I didn't phrase the question that way because I don't want to limit my options.

16:18 fyuryu\: who "owns" the the Clojure tshirts on zazzle.com?

16:18 dermarius: one thing which annoys me at swing is how the layout is managed

16:18 hiredman: Chouser maybe?

16:18 dermarius: i guess that's why ibm choose to develop SWT

16:19 hiredman: zakwilson: the #java regulars all seem to swear by swing

16:19 fyuryu\: hiredman: thanks. That's what I thought.

16:19 rstehwien: zakwilson: There is a discussion at the following link that talks about guis. I like the idea of soemthing like the last declarative form or a groovy like gui builder http://stackoverflow.com/questions/233171/what-is-the-best-way-to-do-gui-in-clojure .... I don't like swing much either

16:19 fyuryu\: chouser: ping

16:20 zakwilson: Swing seems like the obvious choice, but using it directly is pretty verbose.

16:20 Chousuke: contrib also has that miglayout wrapper thing but I don't know if it's any good.

16:20 rstehwien: zakwilson: mostly I liked swing until I wanted to do a tree or grid.

16:20 hiredman: rstehwien: the highest voted answer there is bs

16:21 chouser: fyuryu\: hi

16:21 rstehwien: hiredman: yeah, I actually liked the lowest voted item

16:22 fyuryu\: chouser: hi, does any money from stuff on zazzle.com go to rhickey or is it all sold without any margins?

16:22 rstehwien: hiredman: my prefs were gui code that is declarative like "(form {:title :on-close dispose :x-size 500 :y-size 450}", a builder, maybe cells, or just straight swing

16:22 zakwilson: Short answer: write a macro?

16:23 Ok. I guess I was hoping somebody already had, and tested it well and put it on github or some such.

16:24 chouser: fyuryu\: none of the profit that zazzle shares has gone anywhere yet. I believe I've promised in the past that it would all go to rich.

16:24 danlei: rstehwien: yes, cells-gtk for example is a breeze to work with

16:25 rstehwien: if you meant a sorta reactive approach with "cells"

16:25 chouser: fyuryu\: there's hardly been enought to bother about yet.

16:25 fyuryu\: chouser: I bought a something at a similar shop, but haven't made the shop itself public. I'm thinking about it. And I guess some cash for rhickey to pay for the servers etc would be nice

16:26 rstehwien: danlei: do you know if the cells-gtk for CL is similar to the Clojure neman.cells lib http://bitbucket.org/ksojat/neman/ ?

16:27 fyuryu\: I don't care about the money anyway, I just wanted something to wear ;-)

16:27 http://dl.getdropbox.com/u/820389/clj02.png

16:28 hiredman: oooh

16:28 clojure track suits

16:29 danlei: rstehwien: I never used it, but from what I read in the description, it looks alike, yes

16:30 rstehwien: danlei: thanks! the neman.cells has moved up on the list of things to look at then... to bad that list is really long ;)

16:30 danlei: rstehwien: in my opinion this is one of the best approaches to gui programming (at least the nicest I've ever worked with)

16:32 ambient: there's something for clojure/swing?

16:35 lisppaste8: danlei pasted "cells<->fahrenheit" at http://paste.lisp.org/display/88401

16:35 danlei: rstehwien: that's for example a fahrenheit celsius converter I did when learning cells-gtk

16:36 rstehwien: btw. thanks for to pointer at neman.cells, I'll check it out

16:37 lisppaste8: danlei annotated #88401 "correct version" at http://paste.lisp.org/display/88401#1

16:37 zakwilson: Paste is Cells-GTK?

16:37 * danlei pastet wrong :)

16:37 danlei: yes

16:37 *pasted

16:38 rstehwien: daneli: no problem newman.cells (there is a google groups thread on cells) and miglayout in clojure.contrib might be something close to what I'd like. I'd love a declarative framework for gui but using doto is pretty close

16:39 danlei: hm ... I don't think so about doto :)

16:40 technomancy: wouldn't it be handy if file-seq took a string?

16:40 rstehwien: I'd like a dsl that takes something like this and makes the Swing for me

16:40 (form {:title :on-close dispose :x-size 500 :y-size 450}

16:40   [(button {:text "Close" :id 5 :on-click #(System/exit 0) :align :bottom})

16:40    (text-field {:text "" :on-change #(.println System/out (:value %)) :align :center})

16:40    (combo-box {:text "Chose background colour" :on-change background-update-function

16:40                :items valid-colours})])

16:41 daneli: code pasted not mine or my ideal, just snagged for example. I've been spoiled by declaritive frameworks in Adobe Flex (sucks in its own way but nice to declare a gui)

16:45 danlei: rstehwien: I think cells-gtk (and maybe neman.cells) comes close. what I find most convenient is that you don't have to handle callbacks and such, just say what something contains and it updates automagically, that's the big win

16:46 as far as kt's cells is concerned, he describes it as "spread cheet" like approach

16:47 so, there would be no "on change", for example

16:47 just say what goes there, and if it changes, it's not your problem :)

16:48 (as in my pasted example)

16:48 rstehwien: danlei: That does sound nice. Flex has the ability to bind data in a similar fashion so that when the data changes the UI is updated and vice versa

16:48 danlei: yes, that's exactly what I mean

16:48 rstehwien: danlei: and data binding is a big win

16:48 StartsWithK: neman.cells is broken :/ never updated it to new watchers

16:48 danlei: I think that's THE way to handle guis (at least for a great part)

16:49 StartsWithK: is there a interest in more feature rich (and working) version of cells?

16:49 danlei: I still have to look at it, but generally: sure

16:49 rstehwien: danlei: I agree. Once you have that level of data binding it is hard to go back to having to do it yourself

16:49 danlei: (look at neman, that is)

Logging service provided by n01se.net