2010-02-13
| 00:01 | underdev | qed: do you have those clojure yasnippets? |
| 00:20 | joshua-choi | Question: I'm looking at some undocumented reader macros. What do #< and #= do? |
| 00:30 | qed | ,(doc #<) |
| 00:30 | clojurebot | Unreadable form |
| 00:30 | qed | ,(doc #=) |
| 00:30 | clojurebot | EvalReader not allowed when *read-eval* is false. |
| 00:39 | somnium | b |
| 00:52 | gstratton | How do I persuade Leiningen to use my version of a jar instead of downloading its own? |
| 01:05 | gstratton | Ah, name it correctly |
| 01:18 | no_mind | how do I calculate the memory consumed by a clojure app |
| 01:25 | technomancy | no_mind: JMX is one way to do it |
| 01:26 | danlarkin | PIRANHAMOOOOOOOOOOOOOOOOOOOOOSE |
| 01:27 | qed | can anyone help me troubleshoot why my paredit is flaking out? I can't use C-) when I'm [|] to slurp |
| 01:27 | qed | {} are behaving irregularly as well |
| 01:34 | qed | *sigh* -- what could have changed to screw this up so badly? |
| 01:40 | qed | i give up |
| 01:51 | piccolino | Is there some way to indicat directly that a function should be in a specific namespace? |
| 02:53 | LauJensen | Does anybody know of a catch-all location paramter you can pass to nginx, in order to trap all urls under a certain domain ? like md.dk, md.dk/one/two etc |
| 02:58 | LauJensen | Nvm, faked it |
| 03:33 | defn | hello |
| 03:33 | kmurph79 | how is a hash map different from a hash? |
| 03:38 | defn | a hash map refers to key/value pairs, whereas a hash generally refers to the value alone within the context of a hash map |
| 03:39 | defn | err im sorry that's not right |
| 03:39 | defn | well, it sort of is |
| 03:41 | defn | kmurph79: does that make sense? |
| 03:41 | defn | you have a key, you run it through a hash function -- in a hash map you store the value in the container the key points to |
| 03:42 | defn | like :fred -> [Fred's phone number] -- The hash is Fred's phone number |
| 03:42 | kmurph79 | yeah |
| 03:43 | noidi | that's not quite right |
| 03:43 | noidi | http://en.wikipedia.org/wiki/Hash_map |
| 03:43 | kmurph79 | and a hash-map would the value and the number? |
| 03:43 | defn | yes |
| 03:43 | defn | errr, the key and the number |
| 03:43 | kmurph79 | yeah |
| 03:43 | defn | :a -> "A", :b -> "B", and so on |
| 03:43 | defn | :a is a key, "A" is a value |
| 03:44 | defn | "A" is the hash, the whole thing is a hash map |
| 03:44 | morphling | kmurph79: do you come from ruby? they use "hash" short for hash map |
| 03:44 | defn | yes i was just going to say, many people use the two terms interchangeably |
| 03:44 | kmurph79 | morphling: yes :) |
| 03:44 | defn | kmurph79: you may also hear someone talking about a "map" -- which can often refer to a hash map |
| 03:45 | defn | in clojure "map" could also refer to (map #(+ 1 %) [1 2 3]) |
| 03:45 | defn | namely, the function map |
| 03:45 | defn | ,(doc map) |
| 03:45 | 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." |
| 03:46 | defn | thats a whole lot of mumbo jumbo which means you apply some partial function to each element in a collection |
| 03:47 | defn | kmurph79: in clojure there are two ways that i know of to represent "partials" -- think of partials like half a function |
| 03:47 | defn | ,(partial + 1) |
| 03:47 | clojurebot | #<core$partial__5034$fn__5036 clojure.core$partial__5034$fn__5036@f74015> |
| 03:47 | defn | ,((partial + 1) 1) |
| 03:47 | clojurebot | 2 |
| 03:47 | kmurph79 | ya, i understand map. i was listening to rhickey's talk on clojure, and he was throwing around the 'map' term a lot, so that clears that up |
| 03:48 | defn | ,(map #(+ 1 %) [1]) |
| 03:48 | clojurebot | (2) |
| 03:48 | defn | kmurph79: stop me if im droning on :) |
| 03:48 | kmurph79 | defn: no, it's much appreciated |
| 03:50 | defn | kmurph79: lots of functions will use partials like #(function %1 %2 %3) |
| 03:50 | defn | % is just a placeholder for the value it's taking from the collection you're applying the function to |
| 03:51 | kmurph79 | understood |
| 03:52 | defn | specicially %1 and %2 etc. are used when you have multiple collections |
| 03:52 | defn | like: |
| 03:52 | defn | ,(map #(+ %1 %2) [1 2 3] [4 5 6]) |
| 03:52 | clojurebot | (5 7 9) |
| 03:54 | kmurph79 | yeah, i digested the map function awhile ago |
| 03:55 | Chousuke | defn: (map + ...) is enough :) |
| 03:55 | defn | Chousuke: sure -- I think they both demonstrate different things |
| 03:55 | kmurph79 | so, a hash-map is just more efficient than a hash? |
| 03:55 | Chousuke | not really. |
| 03:56 | defn | one of them demonstrates #(fn %) (that syntax) |
| 03:56 | defn | the other demonstrates to pay attention to functions which takes multiple args |
| 03:56 | defn | take* |
| 03:56 | Chousuke | But #(+ %1 %2) is completely redundant since + already takes multiple parameters |
| 03:56 | defn | right, but the + in that example is completely unimportant |
| 03:57 | defn | Chousuke: i see what you're saying, though |
| 03:59 | Chousuke | more accurately, the %n symbol just refers to the nth parameter of the function, and map just feeds the function as many parameters as there are collections to map over. |
| 04:00 | defn | Chousuke: you're more right than me, but that doesn't stop me from being right as well |
| 04:00 | Chousuke | I thought you just made it sounds more complicated than it is :) |
| 04:00 | Chousuke | sound* |
| 04:01 | defn | i always feel like my explanations are pretty stupid sounding |
| 04:02 | defn | im a very visual learner though -- i learned #(fn %) before i learned how partials worked, because i thought partials seemed sort of scary at first |
| 04:02 | defn | then i learned they're the same thing -- then i learned how fns which take multiple args work in partials |
| 04:03 | kmurph79 | is #() a partial? |
| 04:03 | Chousuke | the #() syntax is one way to construct a partial but it's not so limited. also, #() always creates a new function |
| 04:03 | Chousuke | a new Class, I should say |
| 04:03 | Chousuke | a call to partial does not. |
| 04:05 | Chousuke | I think the most common use for #() is (map #(.javaMethod %) ...) |
| 04:05 | Chousuke | or filter |
| 04:06 | defn | what about remove? |
| 04:06 | Chousuke | consider map a representative of the whole class of functions :) |
| 04:06 | defn | ah nvm, you said most common |
| 04:06 | defn | morning cgrand-rec |
| 04:07 | Chousuke | However, with clojure functions, #(foo %) is an anti-idiom because it creates a function that is pretty much equivalent to foo. |
| 04:07 | Chousuke | but if you need to fixate one of multiple args, #(foo % bar) or #(foo bar %) is pretty common as well |
| 04:07 | defn | fixate? |
| 04:08 | defn | to place within the context of a function's arguments? to place in a specific argument position? |
| 04:08 | defn | is that a fair definition? |
| 04:08 | Chousuke | I meant just "predetermine" |
| 04:09 | Chousuke | ie, make a "partial" |
| 04:09 | defn | ah ok |
| 04:09 | Chousuke | I guess just "fix" would have been more correct :P |
| 04:09 | defn | Chousuke: as long as I've got you in M-x teach-mode, could I ask for some help with refs, atoms, agents? |
| 04:10 | Chousuke | Sure. :P |
| 04:10 | defn | I understand (i think) how refs work, but there is a disconnect for me between real world application and what they are capable of |
| 04:11 | defn | do you have any examples for refs, atoms, or agents in a very simple real world context? |
| 04:11 | Chousuke | Heh. They are the construct you're supposed to use to make clojure to do real-world things. :) |
| 04:11 | defn | haha -- I realize what i'm saying is flawed as I'm saying it -- let me just shut up and say: "I don't really get refs/atoms/agents. Can you help me understand them better?" |
| 04:12 | Chousuke | if ignoring java interop, Clojure is purely functional and without refs, you *can't* mutate anything. You can't have state. |
| 04:12 | Chousuke | and most interesting programs require some state |
| 04:12 | Chousuke | so, Clojure provides you with managed constructs for it. |
| 04:13 | defn | i've heard the term mutate, and im not sure what that means in this discussion |
| 04:13 | defn | (sorry if this is remedial) |
| 04:14 | Chousuke | defn: Well, the reference types are really mutable. You can change them, unlike vectors or maps, which are values. |
| 04:14 | Chousuke | unlike traditional variables, however, the mutation semantics are well-defined |
| 04:15 | defn | so is my ref like my "int x=4;"? |
| 04:15 | defn | and then "print x" => 4, is that sort of like dereferencing? |
| 04:15 | Chousuke | it's closer to int *x = &four; where four is immutable |
| 04:15 | defn | ah-ha! |
| 04:17 | Chousuke | of course, C pointers have no concurrency semantics for mutation, which is the point of all the different ref types in Clojure. |
| 04:17 | defn | ,(def x (ref 4)) |
| 04:17 | clojurebot | DENIED |
| 04:17 | defn | :( clojurebot, be nice to me! |
| 04:18 | piccolino | Is there some easy way to take a Java Map<k,v> and turn it into a Clojure map? I must be missing something. |
| 04:19 | Chousuke | defn: atoms are uncoordinated but synchronous and mutable accross threads, while refs are coordinated and mutable accross threads. Agents are asynchronous, and Vars are only thread-locally mutable. |
| 04:19 | Chousuke | across* |
| 04:19 | Chousuke | meh, I'm making many mistakes today :P |
| 04:19 | Chousuke | piccolino: I think just (into {} java-map) should work |
| 04:20 | piccolino | Aha! |
| 04:20 | piccolino | Never thought to look for that. |
| 04:20 | defn | Chousuke: do you know of a good set of examples for each ref type? |
| 04:20 | Chousuke | hmm, not really. |
| 04:20 | defn | im just looking for something barebones which gets the point across |
| 04:20 | defn | damn.. |
| 04:21 | defn | wanna write a few for me? ;) |
| 04:21 | defn | ,(ref x) |
| 04:21 | clojurebot | java.lang.Exception: Unable to resolve symbol: x in this context |
| 04:21 | Chousuke | defn: there's this though http://github.com/technomancy/mire |
| 04:21 | defn | oh right -- i forgot about that... |
| 04:22 | zab | Anyone here successfully deployed a Compojure app to App Engine? I am about to give up. :/ |
| 04:22 | defn | zab: not to app engine, sorry |
| 04:23 | Chousuke | well, atoms are simple: (def x (atom 1)); @x -> 1; (swap! x inc) -> 2; @x -> most likely 2, unless some other thread changed the atom between the swap! and deref |
| 04:24 | Chousuke | I think You might use an atom for eg. game state in a single-threaded game. |
| 04:25 | defn | Chousuke: if it was (def x (ref 1)); @x -> 1; (swap! x inc) -> 2; we could be sure that it is 2, simply because we used a coordinated mutable state reftype? |
| 04:25 | Chousuke | defn: refs don't support swap! at all. :) |
| 04:25 | defn | d'oh |
| 04:25 | defn | is swap part of the new transients stuff or am i way off? |
| 04:26 | Chousuke | nah, swap! is an atom thing |
| 04:26 | defn | ,(doc swap) |
| 04:26 | clojurebot | Pardon? |
| 04:26 | defn | ,(doc swap!) |
| 04:26 | clojurebot | "([atom f] [atom f x] [atom f x y] [atom f x y & args]); Atomically swaps the value of atom to be: (apply f current-value-of-atom args). Note that f may be called multiple times, and thus should be free of side effects. Returns the value that was swapped in." |
| 04:26 | defn | that sounds kind of like reduce? |
| 04:27 | Chousuke | It's nothing like reduce :/ |
| 04:27 | Chousuke | it just changes the value of the atom |
| 04:27 | Chousuke | by applying a function to its current value |
| 04:27 | Chousuke | there's also reset! which sets an atom to a given value |
| 04:29 | Chousuke | With refs you would have a (def x (ref 1)) (dosync (let [a (ensure x)] (if (= a 1) (alter x inc) (ref-set! a 2)))) |
| 04:30 | Chousuke | that would ensure that @x is 2 at the end of the transaction |
| 04:30 | Chousuke | oops. ref-set! x, not a. |
| 04:31 | Chousuke | using ensure instead of @ is probably not necessary in this case but it shouldn't hurt either |
| 04:33 | Chousuke | it's basically saying "I depend on the value of x in the transaction" so the transaction will restart if other transactions that have touched x finish first. |
| 04:37 | defn | sorry, stepped away for a second |
| 04:37 | defn | damned telcos... |
| 05:46 | djanatyn | Umm, sorry if I already said this, but does anybody know how to install clojure on Debian? |
| 06:06 | hoeck | djanatyn: I don't think its worth installing clojure via apt, as clojure consists only of a single jar, but it seems that there is a clojure.deb available |
| 06:11 | djanatyn | Ah. |
| 06:11 | djanatyn | Thanks. |
| 06:23 | zab | I have a question related to VimClojure. When I send my current file to the Clojure server, the preview buffer displays a list of all the defined macros. |
| 06:24 | zab | Then when I visit the locally running web server in my browser, my request times out and nailgun reports java.lang.OutOfMemoryError almost instantly. |
| 06:30 | cgrand | defn: morning :-) |
| 06:31 | zab | Oh right. I think it's because I don't know how to serve my servlet as a War file? |
| 06:33 | zab | Hmm. Confused. This is an App Engine app. How do people develop GAE apps without recompiling everytime? |
| 06:39 | konr | What do you use to generate pdf files? |
| 07:03 | LauJensen | Clojure has been #1 on DZone this morning, currently #2 :) |
| 07:05 | zab | LauJensen: Heh, your post is also on the front page of HN |
| 07:05 | LauJensen | aah right, cool |
| 07:13 | hoeck | konr: you can use iText (http://itextpdf.com/), but you basically have to buy a book describing it and author your documents in a pdf-oriented way |
| 07:14 | hoeck | konr: or use http://www.allcolor.org/YaHPConverter, a java-based html2pdf renderer and use some html-templating language from clojure |
| 07:16 | hoeck | konr: and then there are lots of other libs which let you basically write pdf source in java |
| 07:17 | StartsWithK | and batik can convert svg to pdf using apache fop |
| 07:21 | bsteuber | I used iText for some small project, you can more or less do it without a book if you're willing to google around and have a look at the javadocs |
| 07:22 | bsteuber | actually, I have built a small clojure wrapper around it for my purposes |
| 07:24 | hoeck | bsteuber: yes, I wouldn't mind buying the book, but at the time I looked at it there was only a book about an old iText version available :/ |
| 07:24 | bsteuber | hm, then maybe it wasn't so bad I just used online resources |
| 07:52 | konr | hoeck: thanks! haha that's what I was considering too... the pdf libraries are so insanely verbose, that it's better to write html and convert |
| 08:16 | scode | technomancy|away: I'm looking at making leiningen support system dependencies. Do you have any opinions on how? Mainly I'm considering having :jar-dependencies, but otherwise supporting some different syntax to :dependencies, such as "[:system name path/to/file". The latter seems cleaner. |
| 09:13 | yuuki | Can *in* be rebound with dynamic scope? |
| 09:20 | StartsWithK | yuuki, yes; see with-in-str or you can do it with binding |
| 09:21 | yuuki | sweet, with-bindings is what I was looking for |
| 09:55 | qed | Is there any interest in Clojure being a mentoring organization in the Google Summer of Code? |
| 09:57 | konr | it would be awesome |
| 09:59 | qed | the only thing I have to worry about is how many people want to play with clojure who beat me with their proposals |
| 10:04 | no_mind | qed, you will be surprised how many people lurk for GSoC |
| 10:07 | qed | no_mind: in here? |
| 10:07 | no_mind | qed yes, let google announce the names of organizations |
| 10:08 | no_mind | qed, I had been GSoC mentor twice and and both times more than one kid has beaten my expectation |
| 10:09 | qed | no_mind: so you think there's a good chance for Clojure in the GSoC this year? |
| 10:10 | no_mind | qed, clojure is getting popular and there is no restrictions on number of students. To start with you can take only one or two students for first year |
| 10:10 | no_mind | err |
| 10:10 | no_mind | I mean no restriction on the minimum number of students an organization intakes |
| 10:11 | qed | no_mind: well, I certainly hope clojure is one of the organizations. I'd kill to write Clojure for the summer. |
| 10:12 | no_mind | qed, sure. So who is going to be the admin ? |
| 10:12 | no_mind | qed, also Google has changed the format for organization signup this year. They are asking more questions upfront |
| 10:12 | qed | no_mind: i have no idea -- i think it's time to post to the list |
| 10:13 | no_mind | qed, yeah and if we want to be in GSoC we have to create an ideas page before applying |
| 10:13 | qed | if everyone puts their heads together in a few threads on the list I bet we could get it done |
| 10:14 | no_mind | qed, sure |
| 10:14 | qed | no_mind: since you've been a mentor you probably know a lot more than me. would you post something to the list about it? |
| 10:14 | qed | ill do anything i can to help |
| 10:14 | no_mind | qed, you start the thread and I will follow |
| 10:14 | qed | k |
| 10:15 | no_mind | qed, firs thing we have to decide is, whether we want to accept proposals for core clojure or for clojure contribs |
| 10:20 | qed | no_mind: I tossed something very basic up there to gauge interest. Feel free to reply with any information you might have on the topic. |
| 10:20 | no_mind | sure |
| 10:22 | no_mind | qed, which mailing list you had posted to ? google group ? |
| 10:23 | pdk | are gsoc applications open yet |
| 10:24 | qed | no_mind: yes the clojure google group |
| 10:24 | qed | pdk: mentoring organizations can apply Mar 8th => 12th |
| 10:25 | pdk | and students apply after then? |
| 10:25 | no_mind | pdk, no |
| 10:26 | no_mind | pdk, once google announces the list of orgs, there will be a 2 week period for students to interact with orgs |
| 10:26 | no_mind | then student applications open on march 29th |
| 10:28 | no_mind | qed, I dont see the post yet |
| 10:37 | triyo | LauJensen: you there? |
| 10:40 | triyo | Your post "My tribute to Steve Ballmer" was the best one so far. I used it to produce a ascii art of pic of "my wife, daughter and I" and got a nice frame to go with it and gave it to my wife for Valentines. ;-) thx for the idea. All that weighing in at $8 with pic frame. |
| 10:56 | LauJensen | trio - I'm glad you liked it - Hope the Mrs. and the little one are pleased :) |
| 11:00 | triyo | LauJensen: yup, indeed. Had to go with something different than the generic valentines gifts. On the serious note, good article. Keep it up. |
| 11:00 | qed | ditto. thanks Lau |
| 11:04 | LauJensen | np guys - great with some positive feedback, thanks |
| 11:06 | LauJensen | its actually been overwhelming well received, I thought I'd get some sucker punches because of the association with MS, but its been on the frontpage of HN all day, top of DZone and it just his reddit/r/programming/new |
| 11:06 | triyo | LauJensen: here is the result btw: https://dl.dropbox.com/u/2146210/aisha_and_alen_ascii_art.html |
| 11:06 | LauJensen | Thats great :) |
| 11:06 | triyo | LauJensen: this is fine, just don't do "x" VS "y" ;-) |
| 11:07 | triyo | then you get flamed |
| 11:08 | LauJensen | triyo, after I did the Ruby Scala post, Rich said "Its time to kick butt and chew bubble gum, and I'm aaallll outta gum", then I knew it was time to quit |
| 11:08 | triyo | LauJensen: the ascii pic came out nicely to on the actual print too |
| 11:08 | LauJensen | cool - Though I feel a little cheated that you didn't give her a picture of Steve Ballmer :) |
| 11:09 | LauJensen | (kidding) |
| 11:09 | triyo | hehehe, well if I wanted to share the shit our of my wife, it would have been my first choice |
| 11:10 | triyo | *share=scrar |
| 11:10 | triyo | e |
| 11:10 | triyo | scare |
| 11:10 | triyo | ;) |
| 11:11 | triyo | Oh btw, anyone in the mood for a "your mother is so fat" joke? CS style that is? |
| 11:11 | LauJensen | alright - I gotta jet I'm in the middle of a very complicated project, so catch you all later and again, thanks for the feedback |
| 11:11 | triyo | cool |
| 11:11 | triyo | http://i.imgur.com/pPw3p.jpg |
| 12:33 | technomancy | how do you check for OS X in a shell script? |
| 12:33 | triyo | one sec I have it somewhere |
| 12:34 | triyo | I think I checked darwin on uname or something.. |
| 12:34 | triyo | one sec |
| 12:36 | technomancy | anyone know what might be causing this kind of error when using Xbootclasspath on OS X? http://gist.github.com/303481 |
| 12:36 | technomancy | putting clojure.jar on Xbootclasspath works great on Linux, but it bails when running tests on OS X |
| 12:36 | triyo | echo $OSTYPE |
| 12:37 | technomancy | triyo: what's that value on OS X? |
| 12:37 | technomancy | which makes debugging that much more annoying |
| 12:37 | triyo | if [[ $OSTYPE == 'darwin10.0' ]]; then |
| 12:37 | triyo | :) |
| 12:38 | triyo | not exactly perfect though... I'm trying to find my script that I have that actually only checks part of it as far as I can recall |
| 12:39 | triyo | actually its better to check on uname |
| 12:40 | triyo | like so: |
| 12:40 | triyo | uname=`uname` |
| 12:40 | technomancy | yeah, so that should be "Darwin" |
| 12:40 | technomancy | ? |
| 12:40 | triyo | if [[ "$uname" == 'Darwin ]]; then |
| 12:40 | triyo | always |
| 12:40 | technomancy | cool |
| 12:40 | technomancy | thanks |
| 12:40 | triyo | np |
| 12:41 | triyo | then you can have your elif's for "Linux" "Cygwin", etc. |
| 12:49 | dabd | how do you refer to a Java inner class? I am trying Class$InnerClass but it is not working |
| 12:55 | chouser | dabd: that should work, but note you have to import that whole name |
| 12:55 | chouser | (import 'the.package.Class$InnerClass) ...then you can use just Class$InnerClass |
| 12:55 | dabd | chouser: I was just about to try that |
| 14:14 | rrc7cz-hm | what's the best way to recursively search a nested map structure? I know clojure.walk does something similar, but it appears to be more like a recursive map. I don't want to replace anything, just return the first matching node. Basically like seq-utils/find-first but recursive |
| 14:19 | hiredman | you can use find-first with tree-seq |
| 14:20 | hiredman | ,(doc tree-seq) |
| 14:20 | clojurebot | "([branch? children root]); Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may not). children must be a fn of one arg that returns a sequence of the children. Will only be called on nodes for which branch? returns true. Root is the root node of the tree." |
| 14:20 | hiredman | ,(tree-seq map? vals {:a {:b :c}}) |
| 14:20 | clojurebot | ({:a {:b :c}} {:b :c} :c) |
| 14:25 | rrc7cz-hm | hiredman: thanks, I'm playing with it now. In reality I have something like [{:a {:b :c}} {:a {:b :c}} {:a {:b :c}} |
| 14:27 | hiredman | rrc7cz-hm: output from clojure.xml/parse? |
| 14:28 | rrc7cz-hm | hiredman: when I find a match, I actually have to return a sibling's value. For example, if I search for :id=3, then [{:a {:b 1 :c 2 :id 3}} {:a {:b :c}} {:a {:b :c}}] should return let's say the value of :c, or 2 |
| 14:29 | hiredman | that is a very differnt kettle of fish, you want to search keys and values |
| 14:29 | rrc7cz-hm | hiredman: correct, I think I screwed up my initial question |
| 14:30 | rrc7cz-hm | I'm searching for the first value match of a specific key, then returning a specific sibling's value |
| 14:30 | hiredman | have you looked at clojure.zip yet? |
| 14:31 | rrc7cz-hm | I believe I used it for some xml parsing a while ago, but I'll take another look at it |
| 14:51 | raek | for storing dates (no conversions or anything calculating-ish), is it worth it to use java Dates? |
| 14:51 | raek | ...or should I just use a map? |
| 14:52 | arohner | raek: java Dates are fine |
| 14:52 | arohner | but as soon as you start calculating or converting, use Joda |
| 14:53 | raek | I want to parse "2009-02-13T19:52:12Z" into some internal representation and be able to format it back to the same format |
| 14:53 | raek | java uses year - 1900, right? |
| 14:53 | arohner | java uses unix time |
| 14:56 | raek | ,(str (java.util.Date 2009 02 13)) |
| 14:56 | clojurebot | java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn |
| 14:56 | raek | ,(str (java.util.Date. 2009 02 13)) |
| 14:56 | clojurebot | "Sat Mar 13 00:00:00 PST 3909" |
| 14:56 | raek | hmm, yeah |
| 14:57 | raek | PST? how do I tell it that my datetime is in UTC? |
| 15:02 | arohner | raek: looks like you don't, from the java constructor |
| 15:02 | arohner | incanter has a wrapper lib around joda |
| 15:02 | arohner | it's nice |
| 15:05 | raek | that constructor has been deprecated since JDK 1.1, anyway.. |
| 15:05 | arohner | raek: http://liebke.github.com/incanter/chrono-api.html |
| 15:05 | raek | arohner: ah, thanks! |
| 15:08 | arohner | is there a function that does conj, but if both items are not collections, makes a new collection? |
| 15:10 | raek | arohner: how do you mean? my intuitive interpretation of conj is "to collection X, add element Y" |
| 15:11 | raek | with maps, though, "Y" can be a map too |
| 15:12 | raek | maybe the source code for "->" has some interesting bits |
| 15:12 | raek | as -> turns the arguments into lists if they aren't |
| 15:14 | arohner | right, #(if (seq? %1) (conj %1 %2) (conj [] %1 %2)) works just fine |
| 15:15 | arohner | and I'm surprised I'm the only one with this problem. in clojure, that's usually an indication you're not doing things the right way |
| 15:15 | Chousuke | you might want to use coll? instead of seq? |
| 15:15 | Chousuke | ,(seq? []) |
| 15:15 | clojurebot | false |
| 16:40 | avarus | hi! |
| 16:40 | jimt | good morning! |
| 16:41 | avarus | heh, almost :) |
| 16:42 | avarus | I'm having a problem with data types and jdbc it seems |
| 16:43 | avarus | I play around with contrib.sql and my pgsql server and I struggle with strange error messages about wrong types |
| 16:43 | avarus | first I had the problem with timestamps, now with boolean :) |
| 16:43 | avarus | when I want to update or insert a boolean type contrib.sql spits out an error or does nothing |
| 16:43 | avarus | even doesn't hit the database at all |
| 16:43 | avarus | that's really odd |
| 16:44 | avarus | I tried to do something like (boolean true) e.g. and I got one run where it worked |
| 16:44 | avarus | but the same app, still running doesn't work anymore :P |
| 16:44 | avarus | so after I googled the java guys use something like "java.sql.Types.BOOLEAN" |
| 16:45 | avarus | but how can I do it in clojure? |
| 16:45 | LauJensen | ~clojureql |
| 16:45 | clojurebot | clojureql is http://gitorious.org/clojureql |
| 16:46 | avarus | I check it out, thx |
| 16:49 | avarus | looks interesting :) |
| 16:50 | avarus | I'll try it |
| 16:50 | kevin_lm | Hi! Any enlive users out there know how if it is possible to specify an adjacent selector. i.e. [E + F]? |
| 16:52 | Leafw | I am getting a very weird error: I import one class, but clojure complains about some other class not being found (?) which I never use or import in this code. What sense does that make? |
| 16:52 | Leafw | from the interpreter. |
| 16:53 | Leafw | repl |
| 16:53 | avarus | which is? |
| 16:53 | avarus | the error I mean |
| 16:53 | Leafw | (and, in any case, that other class is in a jar in the classpath anyway) |
| 16:53 | Leafw | java.lang.NoClassDefFoundError: mpicbg/models/CoordinateTransform (FFT_frequency_range_to_stack.clj:56) |
| 16:54 | Leafw | I never import or use that class in my code. |
| 16:54 | avarus | what libs are you using? |
| 16:54 | Leafw | our own lib: imglib.jar |
| 16:54 | Leafw | the class that it "cannot find" is in the mpicbg_.jar, which has classes that also start with "mpicbg.*" |
| 16:55 | Leafw | both jars in classpath. But I cna't see how it should matter |
| 16:55 | Leafw | this error is total astroturf, like C going over an array limit and complaining later about something else |
| 16:55 | avarus | hehe |
| 16:55 | Leafw | not a good thing. |
| 16:57 | Leafw | if anybody has seen import-related errors like this, let me know what can cure clojure of this total mishap |
| 16:57 | avarus | LauJensen: I guess selecting from my own server-stored pgsql functions just works, right? :) |
| 16:58 | avarus | Leafw: are you building the final jar or what? |
| 16:58 | Leafw | avarus: no, just running a script with load-file |
| 16:59 | avarus | and I guess the line number it tells you is utterly useless |
| 16:59 | Leafw | putting the imports under the ns declaration at the top also incurs in the same error |
| 16:59 | Leafw | no, that line number is where the import was. |
| 16:59 | avarus | ook |
| 17:00 | Leafw | the import for that *other* class, which is unrelated except for having the same "mpicbg.*" start of the qualified name |
| 17:00 | LauJensen | avarus: I hope so :) |
| 17:00 | avarus | oh oh :) |
| 17:01 | Leafw | I donn't understand what the import function or macro is doing, but it's doing the wrong thing when there are classes with same start of package name, stored in different jar files. |
| 17:02 | guille_ | hi |
| 17:02 | raek | is there a simple way to filter the keys of a map? |
| 17:02 | Leafw | importing the class that "can't be found" (I never imported nor needed it) directly works. |
| 17:03 | avarus | perhaps you found a bug |
| 17:03 | Leafw | raek: (filter <pred> (keys somemap)) ? |
| 17:03 | raek | i want a function that returns a map, which keys are the union of some "allowed" keys and the actual keys |
| 17:03 | Leafw | more than a bug, this is a calamity. A total show stopper. |
| 17:04 | Leafw | imports are so much unlike the rest of clojure. |
| 17:05 | guille_ | raek: maybe http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/disj ? |
| 17:05 | raek | maybe (into {} (filter #(#{:a :b :c} (key %)) somemap)) |
| 17:06 | raek | I want to remove all bindings in a map, except those whose keys are in a set |
| 17:06 | chouser | ,(select-keys {:a 1, :b 2, :c 3} [:a :b]) |
| 17:06 | clojurebot | {:b 2, :a 1} |
| 17:07 | raek | chouser: perfect! thanks... |
| 17:13 | avarus | LauJensen: so I installed gradle and clojuresque and cloned the clojureql repository, now what? :) the readme.markdown says something aboyt ivy a, not gradle |
| 17:13 | avarus | -a |
| 17:14 | avarus | same as in clojuresque? gradle build? |
| 17:14 | avarus | I'll try |
| 17:14 | avarus | na, that fails, mhh...reading again, I must have missed something |
| 17:15 | LauJensen | avarus: http://www.bestinclass.dk/index.php/2009/12/clojureql-where-are-we-going/ |
| 17:15 | LauJensen | There's a section on building |
| 17:17 | avarus | ya, "Building the thing" |
| 17:19 | avarus | "Gradle will handle that automatically once you build ClojureQL." but then there is already "In closing" :) |
| 17:19 | avarus | or perhaps I misunderstood the part that gradle needs the jar clojuresque jar :) |
| 17:20 | avarus | ya, ok, "gradle build" is all I need regarding tghe mailinglist |
| 17:23 | avarus | but it fails with this: http://pastie.org/823735 |
| 17:24 | avarus | settings.gradle only contains "rootProject.name = clojureql" |
| 17:25 | LauJensen | Did you see both ENV vars correctly ? |
| 17:25 | avarus | http://pastie.org/823736 <-- verbose |
| 17:25 | avarus | yes, I do |
| 17:25 | avarus | bin of gradle is in the path and GRADLE_HOME shows the home dir of gradle |
| 17:26 | LauJensen | If PATH contains the bin, and GRADLE_HOM points to the Gradle root, then enter your newly cloned clojureql root dir and hit 'gradle build', thats it |
| 17:26 | LauJensen | No need to install clojuresque since the build script declares it as a dependency |
| 17:26 | avarus | ya, too late :) I followed your instructions and then read it's not needed :P |
| 17:26 | LauJensen | Sorry - I will practice blogging more |
| 17:27 | avarus | but that's not the problem here, I think |
| 17:30 | avarus | org.gradle.api.GradleScriptException: Settings file '/Users/andreas/clojure/clojureql/settings.gradle' line: 1 |
| 17:30 | avarus | it sounds quite obvious to me but I don't know what's being expected there in line 1 |
| 17:31 | LauJensen | Did you clone the main repo ? |
| 17:32 | avarus | git clone git://gitorious.org/clojureql/clojureql.git <-- is that the main repo? |
| 17:32 | LauJensen | yes |
| 17:32 | LauJensen | http://gitorious.org/clojureql/clojureql/blobs/master/settings.gradle |
| 17:32 | avarus | same content as here :) |
| 17:33 | LauJensen | ok- please delete that file locally, try again |
| 17:34 | avarus | did it! :) |
| 17:35 | r0man | ,(= #"" #"") |
| 17:35 | clojurebot | false |
| 17:35 | r0man | , (= (str #"") (str #"")) |
| 17:35 | clojurebot | true |
| 17:35 | r0man | hello #clojure, i'm wondering about regex equality. why is this? because of java interop? |
| 17:37 | r0man | ,[(= #"" #"") (= (str #"") (str #""))] |
| 17:37 | clojurebot | [false true] |
| 17:37 | LauJensen | I apologize for the trouble |
| 17:38 | avarus | lol! np :). I am the one thanking you if that piece of software is helping me on my way to the millions of dollars I dream of :P |
| 17:39 | LauJensen | I strongly recommend not dreaming about money |
| 17:39 | avarus | ok, I'll earn it :) |
| 17:54 | raek | is there a simple way to do a map (function) like thing, but on the values of a map (data structure) instead of on a seq? |
| 17:55 | raek | if I had made it, I'd call it map-val |
| 17:56 | raek | hmm, clojure.contrib.datalog.util/map-values |
| 17:57 | LauJensen | (map f (vals m)) |
| 18:06 | raek | well, I want the result to be a map too... |
| 18:06 | raek | here's my solution: |
| 18:06 | raek | (defn map-vals [f m] (into (empty m) (for [[k v] m] [k (f v)]))) |
| 18:24 | JonSmith | If i'm using fleetdb, can I just run it in my existing clojure image instead of using the client library? |
| 18:26 | arohner | JonSmith: I don't know, but I'd be surprised if you can't |
| 18:33 | JonSmith | okay |
| 18:33 | JonSmith | well i will try and see |
| 19:55 | jwhitlark | so, 0xFF in the repl gives me 255, but (byte 0xFF) gives me -1. Any suggestions on how to get a byte with all the bits set? |
| 19:55 | gstratton | (and (byte 0xff) |
| 19:56 | raek | jwhitlark: I think you got it |
| 19:56 | _ato | java byets are signed |
| 19:56 | jwhitlark | (and (byte 0xff)) |
| 19:56 | jwhitlark | oops. |
| 19:56 | raek | ,(and (byte 0xff)) |
| 19:56 | clojurebot | -1 |
| 19:56 | raek | (and (byte 0xff) (byte 0xab)) |
| 19:56 | raek | ,(and (byte 0xff) (byte 0xab)) |
| 19:56 | clojurebot | -85 |
| 19:57 | _ato | -1 = 11111111 in two's complement |
| 19:57 | _ato | http://en.wikipedia.org/wiki/Two%27s_complement |
| 19:57 | _ato | ,Byte/MAX_VALUE |
| 19:57 | clojurebot | 127 |
| 19:58 | raek | java doesn't have any unsigned values at all, right? |
| 19:58 | jwhitlark | ok. I'm trying to construct a magic packet for wake on lan, I was using (repeat 6 (byte 0xff)), the (into-array (Byte/TYPE)) xxxx) on the result. |
| 19:59 | raek | ,(format "%x" (byte 0xff)) |
| 19:59 | clojurebot | "ff" |
| 19:59 | _ato | that should work |
| 20:00 | jwhitlark | _ato: the code I have should work? |
| 20:00 | jwhitlark | I must be doing something else wrong. |
| 20:00 | _ato | yes, signed -1 = unsigned 255, so the network card will interpret it has 0xff |
| 20:01 | _ato | I'd use a packet sniffer and compare what your code is sending to some other implementation and see if there's a difference |
| 20:01 | raek | (byte-array 6 (repeat 6 (byte 0xFF))) |
| 20:03 | raek | does the array from into-array get its size from the seq? |
| 20:03 | jwhitlark | I thought so. |
| 20:04 | _ato | ,(count (into-array Integer/TYPE [1, 2, 3])) |
| 20:04 | clojurebot | 3 |
| 20:04 | jwhitlark | I'm passing the length in later, so as long as the data is there, (and I checked with aget), it should work...) |
| 20:04 | avarus | has anyone ever experimented a bit with contrib.sql and pgsql? :( |
| 20:04 | raek | ah, ok. nevermind... :) |
| 20:04 | jwhitlark | I'll try wireshark |
| 20:09 | avarus | I'm having a problem updating simple data by id which is a number |
| 20:09 | avarus | I get an exception because pgsql fired an error due to type mismatch |
| 20:10 | avarus | or I get no exception but nothing has changed |
| 20:10 | avarus | no data being affected |
| 20:10 | avarus | contrib.sql is not hitting the db then |
| 20:13 | tolstoy | There's no official clojure 1.1 jars at clojars for leiningen to grab? |
| 20:16 | _ato | it's here http://build.clojure.org/releases/ |
| 20:16 | _ato | build.clojure.org/snapshots is in lein's default repo list but not releases |
| 20:16 | _ato | guess I should mirror them on clojars too |
| 20:16 | _ato | hmm |
| 20:17 | danlarkin | build.clojure.org is stable |
| 20:17 | tolstoy | lein has a default project file it builds. |
| 20:17 | tolstoy | I've not problem finding clojure and clojure contrib. |
| 20:17 | tolstoy | Was just curious to have lein find them as part of its deps. |
| 20:18 | tolstoy | The default project file has 1.1.0-alpha-SNAPSHOT for clojure, and "1.0-SNAPSHOT" for contrib. |
| 20:20 | tolstoy | That would be cool! ;) |
| 20:21 | tolstoy | I've developed a couple of little projects in clojure but didn't use lein. And now I'm trying it, and feel stymied right at the start! :) |
| 20:24 | _ato | ok done. give [org.clojure/clojure "1.1.0"] a try |
| 20:25 | tolstoy | Ah! Will, do. |
| 20:25 | tolstoy | Is there any more documentation on lein than the github readme? |
| 20:26 | tolstoy | _ato: That works well. Thanks! |
| 20:26 | _ato | not official documentation, there's a couple of random tutorials, just google: leingingen tutorial |
| 20:26 | tolstoy | Okay. Yeah, for instance, how do you make your uberjar know where the main class is? Stuff like that. |
| 20:27 | tolstoy | ah, lein help jar gives me the details. phew! |
| 20:27 | _ato | yep, and the README does mention briefly: :main - specify a namespace to use as main for an executable jar |
| 20:27 | tolstoy | Gotcha. |
| 20:42 | jwhitlark | ah. I got it. I was parsing the mac address wrong. |
| 20:42 | jwhitlark | (map #(byte (Integer/parseInt % 16)) (re-split #"\:" mac)) works properly. |
| 20:42 | jwhitlark | thanks for the help. |
| 20:48 | tolstoy | Hm. I want a "lein swank". ;) And a "lein run". |
| 20:49 | _ato | http://github.com/technomancy/leiningen/tree/master/lein-swank |
| 20:50 | _ato | http://github.com/ericlavigne/leiningen-run |
| 20:51 | tolstoy | Nice! |
| 21:00 | tolstoy | Hm. leiningen run requires all those jars? |
| 21:03 | _ato | odd, looks like it pulls in maven-ant-tasks by mistake |
| 21:04 | tolstoy | That's a mistake? I was just looking at that project.clj |
| 21:04 | _ato | well it doesn't seem to use it |
| 21:05 | tolstoy | Maybe the "exclude" thing will help? |
| 21:06 | tolstoy | Hm. That didn't work. |
| 21:06 | _ato | could do, 'fraid I haven't used excludes or that leiningen run. I either use SLIME or bite the bullet and do the full: java -cp 'src:lib/*:classes' clojure.main -e "(use 'something)(-main)" |
| 21:06 | _ato | guess I should turn that into a shell alias or script to save typing it out all the time |
| 21:07 | tolstoy | Yeah, I'm okay with that sort of thing to. Nice custom "run" and "swank" scripts. |
| 21:07 | seths | lein run is awesome |
| 21:08 | seths | at least it makes me happy :-) |
| 21:08 | tolstoy | seths: Yeah, but it seems to require 23 jars. |
| 21:08 | tolstoy | lein exclusions work only for dependencies, not dev-dependencies, it seems. |
| 21:14 | tolstoy | looks like exclusions don't work at all. maybe the readme is wrong, or that's not in the stable version |
| 21:15 | seths | tolstoy: as long as you lein clean before uberjar, it's not an ongoing annoyance |
| 21:15 | tolstoy | I spose. |
| 21:15 | seths | not ideal mind you |
| 21:15 | seths | I'd love it to be part of lein |
| 21:15 | seths | (just a happy user of both) |
| 21:17 | tolstoy | I don't understand why lein-run requires maven-ant-tasks. |
| 21:19 | tolstoy | For instance, if I delete all those extra dependencies, lein run still works. |
| 21:20 | seths | heh |
| 21:23 | tolstoy | lein-swank includes them too! |
| 21:23 | seths | another plugin I'd like to see in core |
| 21:24 | seths | lein 1.1 should be coming out soon I think. After that might be a good time to fork & issue pull requests on github |
| 21:24 | seths | I'm trying to figure out why putting clojure.jar in -Xbootclasspath:/a causes lein test to get all grumpy |
| 21:24 | tolstoy | Hm. |
| 21:25 | seths | not on Linux, only on Mac so far |
| 21:25 | tolstoy | Each of them (swank and run) seem to require maven because they don't really run in the same context as leiningen. |
| 21:27 | tolstoy | All this would be okay of :exclusions worked. |
| 21:27 | avarus | no! it was a fucking simple typecast! |
| 21:27 | seths | rofl |
| 21:27 | seths | IRC is great at random times |
| 21:28 | avarus | can't believe it was so simple |
| 21:30 | avarus | now, god, please rewind the last 6 hours of my live, please! |
| 21:30 | avarus | life :> |
| 21:30 | avarus | narf |
| 21:39 | JonSmith | ,0xFF |
| 21:39 | clojurebot | 255 |
| 21:41 | tolstoy | Ah hah. Leiningen stable doesn't have the exclusion stuff. |
| 21:50 | avarus | guys...I have to sleep! :P |
| 21:50 | avarus | good night |
| 22:03 | JonSmith | is there a good filesystem ultilities library yet |
| 22:03 | JonSmith | ? |
| 22:03 | JonSmith | like |
| 22:03 | JonSmith | files in a directory, navigate up and down etc. |
| 22:16 | mattrepl | tolstoy: get :exclusions issues worked out? |
| 22:17 | tolstoy | Yep. |
| 22:17 | tolstoy | Turns out the "stable" version didn't have that feature. |
| 22:26 | Drakeson | In the ns macro, how can I :require or :use a namespace that only differs in its last term (after the last .), with the current namespace? (IOW, a namespace relative to the current one) |
| 22:28 | tolstoy | Drakeson: You don't just use the fully qualified name? |
| 22:30 | Drakeson | sometimes it is a bit cumbersome |
| 22:30 | tolstoy | Indeed. |
| 22:30 | Drakeson | especially when you want to move/rename things around |
| 22:31 | tolstoy | I think the names spaces translate to java packages, and they're all relative to the classpath, not the place where the file actually is. |
| 22:31 | tolstoy | Yeah. |
| 22:31 | _ato | yeah there's no relative imports |
| 22:31 | tolstoy | In Java, you don't have to import class that are in the same package, but it's still a problem to move things from package to package. |
| 22:31 | tolstoy | Thus, Eclipse and the like. |
| 22:35 | tolstoy | Can you splice arrays outside of a macro? `@list, or something like that? |
| 22:37 | _ato | ,(let [stuff [1 2 3]] `["hi" ~@stuff "there"]) |
| 22:37 | clojurebot | ["hi" 1 2 3 "there"] |
| 23:01 | JonSmith | hm |
| 23:01 | JonSmith | i bet you could write an uber-ns macro that uses a heriarchy for require and use |
| 23:20 | piccolino | Does proxy invoke the compiler every time it's called? |
| 23:24 | _ato | no, if I remember correctly it generates one class (per parent class + interfaces) at compile time with method stubs that just call a fn pointer, then each time you call proxy it just creates an instance of that class and plugs in your proxy functions. |
| 23:26 | piccolino | OK, cool, thanks _ato. |
| 23:29 | _ato | ,(class (proxy [Thread] [])) |
| 23:29 | clojurebot | java.lang.IllegalStateException: Var null/null is unbound. |
| 23:30 | _ato | ,Thread |
| 23:30 | clojurebot | java.lang.Thread |
| 23:30 | _ato | guess clojurebot disallows it |
| 23:30 | _ato | but it evals to: clojure.proxy.java.lang.Thread |
| 23:30 | _ato | which is that one class that all proxies of Thread will be instances of |
| 23:30 | piccolino | Yeah, I just tried it in the repl. |
| 23:34 | piccolino | And there's no way to give a proxy object a member variable? |
| 23:38 | tolstoy | piccolino: The methods you override are full closures, so you could make use of that, maybe. |
| 23:39 | tolstoy | (let [instance-var (init)] (proxy ....... (some-fun [] (use instance-var) ....)) etc, etc. |
| 23:39 | tolstoy | Poor man's subclass? |
| 23:40 | piccolino | Hm, OK, thanks. |
| 23:41 | tolstoy | piccolino: All I know is that if you proxy a class that calls an abstract method in its constructor, you're screwed. |
| 23:41 | piccolino | Heh, don't need that fortunately. |
| 23:42 | tolstoy | Yeah. I learned that after many hours of dealing with code in which the dev seems to think the constructor was the place for 90% of the business logic. |