2011-08-24
| 00:01 | jjddb | clojure.java.io says: (defn- ^String encoding [opts] (or (:encoding opts) "UTF-8")) |
| 00:01 | jjddb | is such a thing as :encoding "binary" recognized? |
| 00:02 | jjddb | a complete list of accepted encodings aren't in the clojure docs |
| 00:02 | srid | afaik, slurp always return string (never byte-array). and the 'encoding' parameter controls how to convert the incoming bytes to the to-be-returned String |
| 00:03 | jjddb | ah |
| 00:03 | srid | (slurp (-> url (URL.) (.openConnection) (.getInputStream) (GZIPInputStream.))]) |
| 00:03 | srid | minus the GZIPInputStream part. |
| 00:03 | srid | no |
| 00:04 | srid | (to-byte-array (-> url (URL.) (.openConnection) (.getInputStream))) |
| 00:04 | jjddb | can spit write the byte-array? |
| 00:14 | jjddb | ugh, I didn't have contrib in my classpath :/ |
| 00:25 | jli | my classpath solution is just to include ~/.clojure/* in CLASSPATH in my bash config, and then symlink everything I could ever want in that directory |
| 00:25 | jli | is that dumb? it's been working for me so far |
| 00:26 | srid | has anyone integrate lein with http://martiansoftware.com/nailgun/ ? for faster JVM startup |
| 00:26 | jjddb | I think I've heard of it being done |
| 00:27 | jjddb | but I believe a tool called fark seeks to fill that void |
| 00:27 | jjddb | is clojure.contrib 1.2 compatible with clojure 1.3beta1? |
| 00:28 | jjddb | I'm getting: IllegalStateException Can't dynamically bind non-dynamic var: clojure.contrib.io/*append* clojure.lang.Var.pushThreadBindings (Var.java:339) |
| 00:29 | jjddb | should I be using the contrib.io version of to-byte-array or the duck-streams version? |
| 00:29 | jjddb | its a shame clojure.java.io doesn't have to-byte-array |
| 00:32 | scottj | srid: jjddb might have meant jark, which does something like nailgun not sure if it uses nailgun. there's also cake and lein interactive |
| 00:32 | jjddb | scottj: right, my fault. jark uses nailgun |
| 00:33 | scottj | I use jark for my scripts, it supports #! |
| 00:33 | scottj | cake does too I think (with persistent vm also) |
| 00:36 | dnolen | crazy ascii art? https://gist.github.com/1167317 - nope, output from match for a red-black tree balance checker. something to work on ... |
| 00:39 | jli | dnolen: nice. is that a bug? or does it just not do something smart for recursive matches (assuming that's what's going on?)? |
| 00:39 | jli | all the "(cond)"s are interesting |
| 00:40 | amalloy | jli: i like (cond :else (let [] :invalid)), personally |
| 00:42 | dnolen | jli: we haven't applied any of the suggested heuristic which should some with code size. even so, this code once generated compiles instantaneously. And it verifies balanced trees very, very quickly. |
| 00:43 | dnolen | some -> help some. |
| 00:45 | dnolen | jli: the more troubling thing is how long it takes to actually generate the source. |
| 00:45 | michaelr525 | hello |
| 00:47 | dnolen | jli: just means there's more work to do. however if we can get the code size down some and really shrink compile times this will be a powerful match library indeed. still the fact that it works at all having only worked on this lib in a highly focused manner for about a month … I'm optimistic. |
| 00:49 | jjddb | amalloy: srid: I remember why I was using http.async.client now... I need something that can handle cookies. |
| 00:49 | jjddb | I've been using the selenium wrapper to automate some downloading processes |
| 00:50 | jjddb | I've been fairly successful crawling to the necessary pages and elements, now I just need to download the files and the wrapper doesn't have great "wget" functionality |
| 00:51 | jjddb | when it "clicks" on the link, a 'save as' dialog box pops up -- which I don't want, obviously.. I'm trying to automate the whole thing. |
| 00:52 | amalloy | jjddb: is there a java binding for libcurl? it's pretty good |
| 00:53 | jjddb | as a matter of fact there is |
| 00:54 | jjddb | at that rate though I could just shell-out to curl or wget |
| 00:55 | jjddb | was trying to keep it all in one jar |
| 01:00 | dnolen | heh Racket generates about the same amount of code for the red-black tree test |
| 01:00 | dnolen | so all we gotta do is not take so long to generate it. |
| 01:01 | khaliG | dnolen, what's that for? |
| 01:01 | dnolen | khaliG: ? |
| 01:01 | khaliG | is it for a benchmark? |
| 01:03 | amac | o/ |
| 01:03 | dnolen | khaliG: the benchmark of "I will/won't use this for anything in Clojure" yes :) |
| 01:04 | khaliG | ah |
| 01:04 | amac | dnolen: watched your talk on patern matching, very cool |
| 01:05 | dnolen | in fact using Java arrays to representing the red-black trees this could be one of the fastest red-black balance checkers out there. |
| 01:05 | jjddb | how does one spit a byte-array? |
| 01:05 | dnolen | amac: thx |
| 01:07 | amalloy | &(require 'clojure.java.io) |
| 01:07 | lazybot | ⇒ nil |
| 01:07 | amalloy | &(doc clojure.java.io/copy) |
| 01:07 | lazybot | ⇒ "([input output & opts]); Copies input to output. Returns nil or throws IOException. Input may be an InputStream, Reader, File, byte[], or String. Output may be an OutputStream, Writer, or File. Options are key/value pairs and may be one of :buffer-size buffer size ... http://gist.github.com/1167347 |
| 01:07 | amalloy | jjddb: ^ |
| 02:38 | peteriserins | I'm running lein repl in my lein project. How to reload my clojure files without reloading the lein repl? |
| 02:39 | tomoj | use and require take :reload and :reload-all options |
| 02:39 | tomoj | e.g. (use 'foo.bar :reload-all) |
| 02:39 | tomoj | the -all version reloads all dependent namespaces too |
| 02:40 | tomoj | (doc require) |
| 02:40 | clojurebot | "([& args]); Loads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a prefix list that identifies multiple libs whose names share a common prefix, or a flag that modifies how all the identified libs are loaded. Use :require in the ns macro in preference to calling this directly. Libs A 'lib' is a named set of resources in classpath whose contents define a library of Cloju |
| 02:40 | tomoj | hmm |
| 02:40 | Guest48164 | need help chaining multiple lazy-seq's into one lazy-seq |
| 02:40 | tomoj | chaining? |
| 02:41 | Guest48164 | have: |
| 02:41 | Guest48164 | (doseq [content (client/string response)] (doseq [line (re-seq #".+\r\n" content)] (let [record (json/read-json line)] (f record))))))) |
| 02:41 | Guest48164 | want one lazy-seq back instead of (doseq ... (doseq ... (do something |
| 02:42 | Guest48164 | Trying to get content from http stream and pass back a seq that a I can (doseq on |
| 02:43 | Guest48164 | Getting 1 lazy-seq from (client/string, then getting another lazy-seq from re-seq |
| 02:44 | tomoj | https://gist.github.com/d58de88cc6db11bd1122 |
| 02:45 | tomoj | untested |
| 02:45 | tomoj | but I think something like one of those should work |
| 02:45 | tomoj | easier to get help if you show a simple extracted example that works by itself |
| 02:45 | tomoj | (also, paste those to gist or pastebin or something, not here) |
| 02:45 | Guest48164 | Nice, I'll try it out |
| 02:45 | Guest48164 | Yeah, sorry about that |
| 02:45 | tomoj | yours was short enough this time |
| 02:46 | tomoj | I just tend to warn people because some people have no clue and will paste huge blobs of code :) |
| 02:46 | tomoj | mapcat is one way of chaining |
| 02:47 | tomoj | it's just like map (you know map?) but concatenates the result seqs into one seq |
| 02:48 | tomoj | and do you know ->>? less confusing way of writing records is (map json/read-json (mapcat #(re-seq #".+\r\n" %) (client/string response))) |
| 02:48 | amalloy | Guest48164: fwiw, doseq allows multiple bindings, which it processes in a nested fashion |
| 02:48 | amalloy | (doseq [content (...), line (...content...)] ...) |
| 02:48 | tomoj | I wouldn't think that would do what you want |
| 02:49 | amalloy | tomoj: it would do the same thing as the nested doseqs |
| 02:49 | amalloy | whether that's what he wants i won't speculate on |
| 02:49 | tomoj | oh, right |
| 02:49 | tomoj | and you just ignore the bindings |
| 02:49 | tomoj | which is why they fall out :) |
| 02:49 | amalloy | ? |
| 02:50 | tomoj | I mean, only line is used inside the body |
| 02:50 | tomoj | which makes doseq over cross-product seem wrong to me, even though it's actually what nested doseq does... |
| 02:50 | jli | content is used to define line, no? |
| 02:50 | khaliG | is there a nicer way to write (.setEnabled foo (not (nil? foop))) |
| 02:51 | tomoj | I mean in the body of the unified doseq |
| 02:51 | Guest48164 | Here's the paste: http://pastebin.com/QkL0Gysb |
| 02:51 | tomoj | khaliG: if foop is false, you want to enable foo? |
| 02:51 | tomoj | otherwise (boolean foop) |
| 02:53 | khaliG | tomoj, ops, right, (boolean foop) is what I'm after |
| 02:53 | amalloy | tomoj: i don't understand what you're getting at re: falling out/ignoring. are you worried about holding onto something's head? |
| 02:53 | tomoj | I mean, the binding of content is unnecessary |
| 02:54 | tomoj | so it 'falls out' when you get rid of the doseqs and use mapcat |
| 02:54 | amalloy | i see |
| 02:54 | amalloy | interesting way of thinking about it |
| 02:54 | tomoj | guess it's still there though |
| 02:54 | tomoj | just became anonymous |
| 02:54 | amalloy | right. it's bound in each invocation of f in (mapcat f ...) |
| 02:55 | tomoj | but if you use it in the body, my code doesn't work |
| 02:55 | amalloy | which i think is pretty close to what for/doseq translates to, eventually |
| 02:55 | tomoj | well, sure it does, you just have the seq return [content line] pairs, just like doseq.. |
| 02:56 | amalloy | Guest48164: your goal is to return a seq instead of using a doseq inside subscribe? i approve of that goal, and it's a pretty easy change |
| 02:57 | tomoj | aww |
| 02:57 | Guest48164 | amalloy: right |
| 02:57 | Guest48164 | amalloy: Can't get my head around it though |
| 02:58 | tomoj | do you find mapcat/partial/->> easier? O_o |
| 02:58 | Guest48164 | tried 'for' but things get stuck |
| 02:58 | tomoj | just curious, how do you generate the stream seq? |
| 02:58 | Guest48164 | trying the mapcat/partial... was not intuitive to me |
| 02:58 | amalloy | Guest48164: https://gist.github.com/1167449 |
| 02:58 | amalloy | oh, but then you run into trouble with with-open closing the stream before you're done |
| 02:59 | Guest48164 | http.async.client/stream-seq |
| 02:59 | tomoj | bleh |
| 02:59 | tomoj | I didn't even notice the with-open |
| 02:59 | amalloy | tomoj: yeah |
| 02:59 | Guest48164 | ahhhh |
| 02:59 | amalloy | Guest48164: so the problem with my gist is that the stream gets closed as soon as aubscribe returns, but the data inside it is read lazily |
| 02:59 | Guest48164 | Have to process everything inside the with-open, right? |
| 03:00 | raek | (doall (for ...)) ? |
| 03:00 | Guest48164 | No way around it, I guess? |
| 03:00 | amalloy | those seem to be the two options :P |
| 03:00 | tomoj | I don't think you want to synchronously process your async stream |
| 03:01 | Guest48164 | Would need to have the with-open outside of that subscribe routine |
| 03:01 | Guest48164 | Got it |
| 03:01 | Guest48164 | Thanks for the help |
| 03:01 | tomoj | maybe you do.. I guess it at least gives you a lazy seq over a streaming response? |
| 03:02 | robbe- | Hmm, agents with data structures including refs kind of mis the point of using agents in the first place - except they are asynchronous - or am I still missing something? |
| 03:02 | tomoj | https://github.com/ztellman/aleph/wiki/Consuming-and-broadcasting-a-Twitter-stream |
| 03:02 | tomoj | Guest48164: ^ |
| 03:03 | Guest48164 | tomoj: yeah, played around with aleph first |
| 03:03 | tomoj | may be relevant to your interests, didn't play with http.async.client for more than a day so I don't know how it compares |
| 03:04 | Guest48164 | aleph seems to have a very different and unique model about stuff, what with the channels and all |
| 03:04 | tomoj | yeah, didn't really think about that.. |
| 03:04 | tomoj | the receive-all version looks great to me and the pipeline stuff you could do on it too |
| 03:04 | tomoj | but it's ..different |
| 03:04 | tomoj | and too much to learn on top of clojure |
| 03:06 | michaelr525 | ,(map #(%1) ({:a 1}{:b 2})) |
| 03:07 | clojurebot | () |
| 03:07 | michaelr525 | what am I doing wrong? |
| 03:07 | michaelr525 | I just want to iterate this list of maps and return a new list of maps |
| 03:07 | Guest48164 | btw, what's the * in "function*" convention mean? |
| 03:08 | michaelr525 | internal to namespace i think |
| 03:08 | tufflax | ,({:a 1}{:b 2}) |
| 03:08 | clojurebot | nil |
| 03:08 | amalloy | &(:a) |
| 03:08 | lazybot | java.lang.IllegalArgumentException: Wrong number of args passed to keyword: :a |
| 03:08 | Guest48164 | thought that was function- |
| 03:08 | michaelr525 | or internal for macro use |
| 03:08 | amalloy | oops. tufflax beat me to it with my dreadful copy/paste skills |
| 03:08 | Guest48164 | ahh |
| 03:08 | michaelr525 | a macro with the same name |
| 03:08 | raek | ,(map #(assoc % :x 3) (list {:a 1}{:b 2})) |
| 03:08 | clojurebot | ({:x 3, :a 1} {:x 3, :b 2}) |
| 03:09 | amalloy | michaelr525: your #(%1) is also highly suspicious, once you've fixed tufflax's suggestion |
| 03:09 | michaelr525 | shit, brb |
| 03:10 | robbe- | Doe we have a nice repl with line-editing capabilities for clojure? |
| 03:10 | robbe- | Do* |
| 03:10 | amalloy | $google rlwrap |
| 03:10 | lazybot | [rlwrap - utopia.ision.nl] http://utopia.knoware.nl/~hlub/rlwrap/ |
| 03:10 | robbe- | ty |
| 03:10 | amalloy | really? what a bizarre google result. anyway, installing rlwrap requires the least effort, but in the long run you want to use lein or cake |
| 03:12 | robbe- | Okay, I just experimenting a bit now, but I better jot it down for when I revisit closure in a more serious context. :-) |
| 03:15 | jli | amalloy: lein adds line editing? |
| 03:15 | amalloy | *nod* it detects rlwrap, and either uses it or falls back on jline |
| 03:17 | jli | huh, cool. |
| 03:17 | thorwil | i'm not aware of any relevant changes, but suddenly i get: "java.lang.NoClassDefFoundError: Could not initialize class tlog.core__init (NO_SOURCE_FILE:0)" when trying to bring up my project |
| 03:18 | raek | thorwil: check for old files in classes/ |
| 03:18 | raek | or perhaps do a lein clean |
| 03:19 | amalloy | raek: or take a flamethrower to them, without first checking to see if there are any :P |
| 03:20 | MasseR | I'm trying to use (:import (java.util Random)) in the ns macro, but I get an error about class java.util not existing |
| 03:20 | raek | Alien II: In space no one can hear you clean |
| 03:21 | raek | MasseR: that looks right. what does your ns form look like? like (ns some-ns (:import (java.util Random))) ? |
| 03:22 | raek | (watch out for quotes) |
| 03:22 | MasseR | http://pastebin.com/9SagAatP |
| 03:22 | MasseR | Like that |
| 03:22 | thorwil | raek: just clearing it did the trick, thanks. so far i thought this problem would only come up on changing version numbers of deps in the project file. not the case, here |
| 03:23 | raek | MasseR: any reasons you have both duck-streams and java.io? (since the latter replaces the former) |
| 03:24 | MasseR | raek: to-byte-array wasn't in io |
| 03:24 | raek | MasseR: that ns form works for me. are you sure this is not something simple like forgetting to save the file? |
| 03:24 | thorwil | MasseR: there's no need to repeat :require. (i'm suprised that works, even) |
| 03:25 | MasseR | raek: The file is saved, and I just restarted the repl. No go |
| 03:25 | ibdknox | sweet |
| 03:26 | raek | MasseR: and you are sure the error is caused by these lines? |
| 03:26 | MasseR | raek: -.- I'm an idiot :D |
| 03:26 | MasseR | Thanks |
| 03:26 | ibdknox | I have the base of a d3-like data visualization library for cljs :) |
| 03:26 | thorwil | MasseR: http://pastebin.com/R9SqQcMY |
| 03:26 | MasseR | thorwil: Thanks |
| 03:27 | thorwil | np |
| 03:31 | thorwil | oh well, the only data i have to visualize right now are nested comments :) |
| 03:37 | ibdknox | heh |
| 03:37 | ibdknox | that's the best kind to visualize ;) |
| 03:37 | ibdknox | useless data haha |
| 03:38 | jli | MasseR: ooh, what's a reddit wallpaper? |
| 03:39 | thorwil | shouldn't i be able to call a function from within itself, without using declare? |
| 03:39 | jli | thorwil: recursively? yeah. |
| 03:39 | amalloy | thorwil: yes. are you trying to do something like (let [f (fn [] (f ...))])? |
| 03:39 | jli | oh |
| 03:40 | MasseR | jli: A while back I wrote in haskell a script that takes a random wallpaper from r/wallpaper |
| 03:40 | MasseR | I'm trying to port it to clojure as a learning experience |
| 03:41 | jli | MasseR: ah, cool |
| 03:43 | khaliG | hm getting a bit tired of switching to the slime repl to type (-main) after making some changes, is there an easier way? |
| 03:44 | jli | I've never seem /r/wallpaper before - these are pretty good :) |
| 03:44 | thorwil | amalloy, jli: http://paste.pocoo.org/show/463493/ |
| 03:45 | jli | khaliG: a script that runs it your clj automatically when the modtime changes? |
| 03:45 | khaliG | jlf_, was thinking a shortcut, like press F5 |
| 03:45 | khaliG | i wouldn't know how to do that though |
| 03:46 | fhd | Any ClojureScript gurus around? I need some help here. |
| 03:46 | khaliG | jli, even, sorry |
| 03:46 | jli | khaliG: you could record a hacky macro |
| 03:47 | ibdknox | fhd: dunno if I'm a guru, but I may be able to help |
| 03:47 | khaliG | jli, emacs macro? i'll look into it now |
| 03:47 | jli | something like: M-x slime-repl RET (-main) RET C-x b RET |
| 03:47 | fhd | ibdknox: I'm using the dom-helpers from the twitterbuzz sample, dom-helpers/build in particular |
| 03:47 | robbe- | Hmm, any good rlwrap completion files? Maybe some tool that parses clojure source files for function definitions and add them too the completion list? :D |
| 03:47 | jli | that would switch to the repl, enter "(-main)", and switch back (I think) |
| 03:47 | jli | robbe-: sounds like you need slime |
| 03:48 | khaliG | jli, looks good. how do i tell emacs to run that sequence though? |
| 03:48 | robbe- | jli: Not an emacser ;) |
| 03:48 | fhd | ibdknox: However, when I write code like this: (dom/build [:h1 "Hello, World!"]), all I get from Chrome is: "Uncaught TypeError: Object i.'h1 has no method 'appendChild'" |
| 03:48 | jli | khaliG: do you know how te record macros? |
| 03:49 | robbe- | (although it's on the todo list) |
| 03:49 | khaliG | jli, nope, reading about it now. will i be able to store the macro for reuse? |
| 03:50 | fhd | ibdknox: Tried this with the latest clojurescript on two different boxes. The twitterbuzz example works fine |
| 03:50 | ibdknox | fhd: and you're only executing that code? |
| 03:50 | jli | khaliG: after you record it, you can do name-last-kbd-macro to give it a name, and then insert-kbd-macro <name-you-gave-it>, which will dump the elisp for the macro |
| 03:50 | amalloy | thorwil: that looks fine. is line 181 the last line of comments-rendition-recur? |
| 03:50 | fhd | yeah, just a sec |
| 03:50 | fhd | ibdknox: I'll put the post in a pastebin |
| 03:50 | khaliG | jli, sounds good. thank you! |
| 03:50 | jli | yup |
| 03:51 | thorwil | amalloy: yes |
| 03:51 | robbe- | http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Enhancing_Clojure_REPL_with_rlwrap ; explains what I was asking |
| 03:51 | fhd | ibdknox: http://pastebin.com/QuhGytfv |
| 03:52 | fhd | ibdknox: Wait, that was old, here: http://pastebin.com/dvrB3nUR |
| 03:52 | amalloy | then i don't really see any reason it wouldn't work |
| 03:52 | fhd | ibdknox: dom-helpers is copied from the twitterbuzz sample, latest revision. I just changed the namespace. |
| 03:52 | MasseR | Hmm.. My haskell solution took 82 lines, and clojure 38 |
| 03:53 | ibdknox | fhd: mkay |
| 03:53 | jli | thorwil: can you paste the whole file? or whittle it down to a small complete failcase? |
| 03:53 | ibdknox | fhd: try without the text |
| 03:54 | fhd | ibdknox: Just [:h1] ? |
| 03:54 | ibdknox | fhd: yep |
| 03:55 | thorwil | jli: sure i could paste more, but the failcase is ... compilation |
| 03:55 | fhd | ibdknox: Same |
| 03:56 | ibdknox | fhd: not that this should really make a difference, but try (dom/append (.body js/document) (dom/build [:h1])) |
| 03:56 | ibdknox | fhd: I'm not overly familiar with the dom-helpers they wrote, since I wrote a port of hiccup for CLJS |
| 03:56 | fhd | ibdknox: Still the same |
| 03:57 | thorwil | jli: the whole set of related fns: http://paste.pocoo.org/show/463499/ |
| 03:57 | fhd | ibdknox: I must be missing something that twittbuzz does, but I just can't figure out what |
| 03:57 | ibdknox | fhd: well, I've been reading through the dom-helpers code |
| 03:57 | ibdknox | fhd: that *should* work |
| 03:58 | fhd | ibdknox: Yeah, works fine for twittbuzz, so I don't thing there's a problem with dom-helpers |
| 03:58 | ibdknox | fhd: try (dom/append (.body js/document) (dom/html "<h1>hey</h1>")) |
| 04:00 | fhd | ibdknox: That works. |
| 04:01 | fhd | ibdknox: BTW, I refreshed the wrong page earlier. When we removed the text from h1, the error message changed: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8 |
| 04:01 | ibdknox | fhd: hah |
| 04:01 | ibdknox | fhd: I don't think this is very robust :) |
| 04:02 | fhd | ibdknox: And "this" would be? |
| 04:02 | fhd | ibdknox: ClojureScript? |
| 04:02 | ibdknox | fhd: no, dom-helpers |
| 04:02 | ibdknox | fhd: (dom/append (.body js/document) (dom/build [:h1 [:em "hello"]])) |
| 04:03 | fhd | ibdknox: Uncaught TypeError: Object i.'em has no method 'appendChild' |
| 04:04 | jli | thorwil: weird, I don't know. declare should only be necessary for forward declarations, when you want to call a function that's defined below. |
| 04:05 | jli | thorwil: what's defhtml from? |
| 04:05 | fhd | ibdknox: Also tried (dom/append (.body js/document) (dom/build [:h1 (dom/html "<em>Hello</em>")])) |
| 04:05 | thorwil | jli: hiccup |
| 04:05 | fhd | ibdknox: That gives me "...h1 has no method 'appendChild'" again |
| 04:05 | ibdknox | fhd: I'm not sure, there's no obvious reason why it would fail. I'm fairly certain it's not correctly creating and holding onto the dom object |
| 04:06 | ibdknox | fhd: but without stepping through it, I couldn't tell you where it's doing that |
| 04:06 | fhd | ibdknox: I could create a small GitHub project for this, if you're willing to investigate the issue |
| 04:07 | ibdknox | sure, though I need to sleep. I'd be happy to check it out tomorrow :) |
| 04:07 | ibdknox | In the mean time, you could play around with pinot if you just want to mess around: http://github.com/ibdknox/pinot |
| 04:08 | fhd | ibdknox: As an alternative to dom-helpers? |
| 04:08 | fhd | ibdknox: Yeah, sounds good. |
| 04:08 | ibdknox | fhd: yessir, though the goal is more of a fullservice client side library |
| 04:09 | fhd | ibdknox: I'll use that then. Although dom manipulation would be cool enough to become its own project :) |
| 04:10 | ibdknox | I suspect in the long term many pieces of it will spawn off |
| 04:10 | ibdknox | like the visualization stuff I was working on tonight :) |
| 04:10 | michaelr525 | you |
| 04:10 | michaelr525 | yo! |
| 04:15 | fhd | ibdknox: I really want to figure this out though, I'll play around some more |
| 04:19 | michaelr525 | ,{:a 1} |
| 04:19 | clojurebot | {:a 1} |
| 04:20 | michaelr525 | (#({:a 1})) |
| 04:20 | michaelr525 | ,(#({:a 1})) |
| 04:20 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentArrayMap> |
| 04:21 | michaelr525 | why in the first case the map evaluates to a map and in the second case it tries to evaluate it as a function |
| 04:21 | michaelr525 | ? |
| 04:22 | ordnungswidrig1 | michaelr525: #() adds parens around its body |
| 04:22 | ordnungswidrig1 | ,(#(1)) |
| 04:22 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 04:23 | ordnungswidrig1 | so #(1) is like (fn [] (1)) |
| 04:23 | jli | michaelr525: that was equivalent to ,((fn [] {:a 1})) |
| 04:24 | jli | ,((fn [] {:a 1})) |
| 04:24 | clojurebot | {:a 1} |
| 04:24 | jli | er, no, fail. |
| 04:24 | michaelr525 | :) |
| 04:24 | tufflax | ,(macroexpand '#({1 2})) |
| 04:24 | clojurebot | (fn* [] ({1 2})) |
| 04:24 | tufflax | jli looks like you are wrong :p |
| 04:24 | michaelr525 | macros, they caught us again ;) |
| 04:24 | ordnungswidrig1 | michaelr525: you can either to (fn [] {:a 1}) or #(constantly {:a 1}) |
| 04:25 | michaelr525 | ordnungswidrig1: or identity? |
| 04:25 | ordnungswidrig1 | michaelr525: or itendity |
| 04:25 | michaelr525 | ,#(identity {:a 1}) |
| 04:25 | clojurebot | #<sandbox$eval7746$fn__7747 sandbox$eval7746$fn__7747@a0f411> |
| 04:27 | tufflax | michaelr525 what are you really trying to do? |
| 04:28 | michaelr525 | i would like to take a list of records (maps) and transform to another list of maps with one property's name changed |
| 04:28 | michaelr525 | ({:a 1}) -> ({:b 1}) |
| 04:30 | ordnungswidrig | ,(map #(clojure.set/rename-key % {:a :x}) [{:a 1 :b 2 :c 3} {:a 3 :f 4}]) |
| 04:30 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set> |
| 04:30 | ordnungswidrig | rename, not rename-key but you get the idea |
| 04:31 | michaelr525 | would it be faster than mapping to a new list? |
| 04:31 | michaelr525 | ah |
| 04:31 | ordnungswidrig | michaelr525: it maps to a new list :-) |
| 04:31 | michaelr525 | you are mapping to a new list |
| 04:32 | tufflax | ,(require 'clojure.set) |
| 04:32 | clojurebot | nil |
| 04:32 | tufflax | ,(map #(clojure.set/rename-keys % {:a :x}) [{:a 1 :b 2 :c 3} {:a 3 :f 4}]) |
| 04:32 | clojurebot | ({:x 1, :c 3, :b 2} {:x 3, :f 4}) |
| 04:32 | michaelr525 | ok, would it be faster than creating a new map, considering each record has only two properties |
| 04:32 | michaelr525 | ? |
| 04:32 | tufflax | it is creating a new map |
| 04:33 | tufflax | for each map |
| 04:33 | michaelr525 | ok, i think i get it. |
| 04:33 | ordnungswidrig | and a new list of the new maps |
| 04:33 | tufflax | actually a seq |
| 04:33 | tufflax | but, yeah |
| 04:34 | michaelr525 | thanks! |
| 04:34 | tufflax | I don't know what is the fastest way to do it, if it really matters you have to test it :P |
| 05:08 | gilecham | template newbie getting tied in knots: How would I do a non-recursive `apply-template' so as to replace all occurrences of n with (modify n) in (apply-template '[n] '(+ n 5) '[ (modify n) ]) |
| 05:29 | MasseR | I created an uberjar, and I am able to run it fine. However the jvm is still running for many more seconds after the last line of code is executed |
| 05:30 | MasseR | http://pastebin.com/sBHF8RvP |
| 05:30 | MasseR | What on earth is it doing the rest of the time |
| 05:38 | MasseR | java -jar redditwallpaper-0.0.1-standalone.jar 2.71s user 0.34s system 4% cpu 1:03.15 total |
| 05:46 | raek | MasseR: btw, there is a copy function in clojure.java.io |
| 05:47 | MasseR | raek: Doesn't handle binary files |
| 05:47 | MasseR | At least from web |
| 05:47 | MasseR | At least I wasn't able to make it work |
| 05:48 | raek | I think it should be possible to replace (.write out (duck/to-byte-array in)) with (copy in out) |
| 05:49 | raek | io/copy, that is |
| 05:49 | MasseR | raek: That was my first try, file said 'data' instead of 'jpeg data', and if I understood correctly it copied it as text |
| 05:50 | MasseR | (But I'll try again. It's not the first time I think I've tried something, but it was with a slight variation) |
| 05:50 | pyr | MasseR: also, for getting a random one, i would (first (shuffle list)) |
| 05:50 | raek | (io/copy (io/input-stream uri) (io/output-stream fname)) uses input/ouput-streams, which are binary |
| 05:52 | MasseR | raek: Yep. I did it somehow differently apparently :D. Hmm.. I think it was (io/copy (io/to-byte-array (reader uri)... |
| 05:52 | raek | reader is like input-stream, but for text streams |
| 05:53 | MasseR | Mm. I figured it out. Didn't think of using input-stream/output-stream with copy though |
| 05:53 | raek | also, io/copy won't read the whole file into memory in one piece |
| 05:54 | MasseR | Damn you're helpful |
| 05:55 | MasseR | I really appreciate it |
| 05:55 | raek | MasseR: you might need to call shutdown-agents before your application exits |
| 05:57 | MasseR | raek: It helped |
| 05:57 | raek | but if that was the problem your app would just freeze and don't shut down |
| 05:57 | MasseR | java -jar redditwallpaper-0.0.1-standalone.jar 4.08s user 0.30s system 153% cpu 2.862 total |
| 05:58 | mrBliss | https://github.com/clojure/clojure/blob/master/changes.txt#L282 should be "InterruptedHandler" instead of Interrupt Handler" (see ToC). |
| 05:58 | MasseR | raek: Another problem. Seems like it can't download the entire picture before setting it up. I get a bit of grey area in the pictrues |
| 06:00 | tufflax | gilecham apply-template uses prewalk-replace, your example works with postwalk-replace: (postwalk-replace (zipmap '[n] '[(modify n)]) '(+ n 5)) => (+ (modify n) 5) |
| 06:00 | MasseR | raek: And does it close the streams? |
| 06:00 | raek | is the picture cut in half? |
| 06:00 | MasseR | raek: No. Like a couple of rows wen't missing |
| 06:00 | raek | MasseR: copy does not close them, but with-open does |
| 06:01 | raek | so the "bare" copy call without with-open is probably not a good idea... |
| 06:02 | raek | MasseR: I have to go, but good luck! |
| 06:07 | gilecham | tufflax: thanks for that. I appear to be getting a similar result using core/replace. Is the only difference the greater range of data structures supported by walk? |
| 06:12 | tufflax | gilecham replace only replaces things in the list you give it, not recursively in sublists |
| 06:12 | tufflax | but postwalk does |
| 06:12 | tufflax | ,(require 'walk) |
| 06:12 | clojurebot | #<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate walk__init.class or walk.clj on classpath: > |
| 06:13 | tufflax | ,(require 'clojure.walk) |
| 06:13 | clojurebot | nil |
| 06:13 | tufflax | ,(walk/postwalk-replace {'[n] '(modify n)} '(+ (+ n 1) 5)) |
| 06:13 | clojurebot | #<CompilerException java.lang.RuntimeException: No such namespace: walk, compiling:(NO_SOURCE_PATH:0)> |
| 06:13 | tufflax | ,(clojure.walk/postwalk-replace {'[n] '(modify n)} '(+ (+ n 1) 5)) |
| 06:13 | clojurebot | (+ (+ n 1) 5) |
| 06:14 | tufflax | ,(clojure.walk/postwalk-replace {'n '(modify n)} '(+ (+ n 1) 5)) |
| 06:14 | clojurebot | (+ (+ (modify n) 1) 5) |
| 06:14 | tufflax | there |
| 06:14 | tufflax | ,(replace {'n '(modify n)} '(+ (+ 1 n) 5)) |
| 06:14 | clojurebot | (+ (+ 1 n) 5) |
| 06:16 | tufflax | but you probably understood without all that... :p |
| 06:17 | tufflax | btw i didn't know anything about apply-template, i just read the source :P |
| 06:20 | gilecham | tufflax: Thanks I'll go and play. |
| 06:20 | tufflax | np |
| 06:42 | robbe- | Does clojure have some kind of module system? I'm thinking about erlang and swi prolog modules; What I want to do is export some functions, and keep some helper functions private. |
| 06:42 | tufflax | khaliG there is no such thing as too much clojure :p |
| 06:43 | khaliG | tufflax, ha :) |
| 06:44 | opqdonut | robbe-: namespaces |
| 06:44 | tufflax | robbe- i don't know much about erlang or prolog, but yes: there are namespaces that you typically put in a file per namespace, and then there is defn- to define private functions |
| 06:45 | robbe- | Okay thanks, I'll look up namespaces. |
| 06:51 | robbe- | Hm, defn- but no def- ? :-) |
| 06:52 | opqdonut | yeah, that's weird IMO too |
| 06:52 | opqdonut | but you can do (def ^{:private true} private-constant ...) |
| 06:52 | cemerick | All the foo- variants are an anachronism |
| 06:52 | cemerick | Just ^:private in 1.3.0 |
| 06:53 | manutter | and it would be pretty trivial to write a def- macro, I should think. |
| 06:53 | tufflax | robbe- http://pastebin.com/7XXLfCzw |
| 06:54 | manutter | Well, looks like our 3rd-party corporate email provider is hosed again--today should be interesting *sigh* |
| 06:54 | robbe- | Okay, thanks for the info. Was defining simple functions like (def foo #(+ 1 %)) |
| 06:55 | pyr | i stopped using :private, it made my testing much harder |
| 06:55 | pyr | am i doing things wrong ? |
| 06:56 | opqdonut | pyr: hint: #' |
| 06:56 | tufflax | pyr you can use this maybe http://pastebin.com/jw5D3Aw0 |
| 06:56 | manutter | pyr: I think functional programming does more to protect you from bugs than private vars do. |
| 06:56 | tufflax | if that's your problem... |
| 06:56 | manutter | fwiw... |
| 06:57 | opqdonut | for private functions you can do: (let [function-to-test #'name.space/function-to-test] test-it-here) |
| 06:57 | opqdonut | and IMO private functions are good for structuring large programs, they keep interfaces simple |
| 06:57 | opqdonut | and avoid namespace pollution with use |
| 06:58 | tufflax | maybe that docstring in my paste is wrong? doesn't seem do be every var |
| 06:59 | tufflax | pyr oh, you _stopped_ using private |
| 06:59 | tufflax | i misread |
| 06:59 | pyr | yes |
| 07:00 | manutter | Hmm, if namespace foo.b uses foo.a, and then some other program uses foo.c, will the vars from foo.a be imported into foo.c? |
| 07:01 | manutter | sorry, I meant if foo.c uses foo.b |
| 07:01 | manutter | (need coffee, just woke up...) |
| 07:01 | tufflax | or maybe not: it's not clear what you mean. Was it private that made testing harder or that you stopped using it that made testing harder |
| 07:02 | pyr | tufflax: i meant |
| 07:02 | pyr | tufflax: i stopped using private functions because it required kludges (#' trick) in tests |
| 07:03 | tufflax | ok, then use the refer-prvate function! |
| 07:03 | tufflax | best of both worlds, or something |
| 07:04 | pyr | yes, refer-private is nice, thanks for the tip |
| 07:05 | Scorchin | If I have a list of maps, how can I remove maps from the list if one of the keys doesn't match what I want it to? Is it something like (remove (fn [x] (not= "expected" x) my-list-of-maps) ? I can't quite figure it out |
| 07:06 | Scorchin | but I don't want to check it on "x" but a key within x |
| 07:06 | robbe- | how would I include that macro def in every file, load-file or is there something more idiomatic, or better? |
| 07:06 | tufflax | robbe- :use within the ns macro |
| 07:07 | tufflax | Scorchin (fn [m] (not= (:key m) something)) |
| 07:10 | tufflax | or (m key) is key is not a keyword |
| 07:10 | opqdonut | or (get m key) to be sure |
| 07:10 | tufflax | if key |
| 07:11 | tufflax | opqdonut hm is that better somehow? |
| 07:12 | opqdonut | well suppose it somehow happend that m isn't a map |
| 07:12 | opqdonut | that way you catch it earlier |
| 07:12 | opqdonut | err, isn't a collection, rather |
| 07:13 | tufflax | ,(get 1 1) |
| 07:13 | clojurebot | nil |
| 07:13 | opqdonut | oh, what? get doesn't throw an exception any more... |
| 07:13 | opqdonut | I could've sworn |
| 07:13 | opqdonut | I just tested it myself |
| 07:13 | tufflax | hehe |
| 07:14 | opqdonut | FFS |
| 07:17 | tufflax | if get would have resulted in an error unless used on something associative, it seems to me that it would have been just like using the map or whatever as a function. now at least get has slightly different behaviour :p |
| 07:19 | opqdonut | well vectors aren't functions etc |
| 07:19 | tufflax | ,([1 2 3] 0) |
| 07:19 | clojurebot | 1 |
| 07:19 | tufflax | no? |
| 07:19 | opqdonut | wtf |
| 07:20 | opqdonut | my assumptions are so out of date |
| 07:20 | tufflax | hehe |
| 07:20 | opqdonut | maybe I'll just be quiet |
| 07:37 | raek | the behaviour get has when you pass it something "non-lookup-able" has always puzzled me |
| 07:38 | Scorchin | Is there a simple way to remove a key (or set of keys) from a list of maps? |
| 07:39 | tufflax | (map (partial dissoc key1 key2) list-of-maps) |
| 07:39 | Scorchin | thanks tufflax |
| 07:39 | tufflax | or no |
| 07:39 | Scorchin | oh? |
| 07:39 | tufflax | that does not work |
| 07:40 | tufflax | (map #(dissoc % key1 key2) list-of-maps) |
| 07:40 | tufflax | that works better |
| 07:40 | raek | Scorchin: to remove a key, use 'dissoc'. for each thing in a sequence, use 'map'. and voilà: ##(map #(dissoc % :x) [{:a 1, :x 0}, {:b 2, :x 3}]) |
| 07:40 | lazybot | ⇒ ({:a 1} {:b 2}) |
| 07:40 | Scorchin | yup, that did it, thanks! |
| 07:41 | Scorchin | raek: why the extra hashes? |
| 07:41 | tufflax | its for the bot |
| 07:41 | raek | Scorchin: that is the syntax to tell lazybot to evaluate something in the middle of an utterance |
| 07:41 | Scorchin | :) |
| 07:42 | Scorchin | thought it was some extra sugar I'd have to learn like the '(stop me from evaluating) ticks thing |
| 07:57 | manutter | Cool, you can hide both vars and functions by putting them in a separate ns |
| 07:58 | manutter | Put private stuff in foo.impl, then have foo.public implement the public api and (:use) foo.impl |
| 07:58 | manutter | and then for testing you can use foo.impl too (so no #' trick) |
| 07:59 | manutter | pyr: ^^^ |
| 09:59 | justicefries | what's everybody's IDE/editor preference for clojure? |
| 10:01 | dnolen | justicefries: there's a lot. Emacs dominates. I recommend clooj if you just want to see what Clojure is about w/o any hassle. It's like Python's IDLE but for Clojure. |
| 10:02 | justicefries | ahh. yeah I use vim with ruby and XCod |
| 10:02 | justicefries | Xcode. |
| 10:02 | coopernurse | justicefries: I enjoy IntelliJ w/La Clojure - community edition is free |
| 10:03 | justicefries | was reading about that. works well? |
| 10:03 | dnolen | justicefries: Vim is popular too. |
| 10:03 | dnolen | justicefries: vimclojure and slimv |
| 10:05 | mprentice | i'm trying to like eclipse |
| 10:06 | babilen | justicefries: I would also recommend to use leiningen (https://github.com/technomancy/leiningen) to install clojure. If you use vimclojure I also found it nice to have the lein-vimclojure plugin installed (lein plugin install org.clojars.oskarkv/lein-vimclojure "1.0.0-SNAPSHOT") which enables you to start the nailgun server with "lein vimclojure &" |
| 10:06 | coopernurse | justicefries: IntelliJ? Yes, I like it. It also works well with lein. But I already used IntelliJ for Java, so it was a natural choice for me |
| 10:07 | justicefries | i used hombrew to install clojure and then installed lein |
| 10:08 | coopernurse | that's a good start |
| 10:08 | coopernurse | do you already know emacs? |
| 10:08 | justicefries | nope. |
| 10:09 | justicefries | just vim. |
| 10:09 | TimMc | Is there a paredit for vim? |
| 10:09 | coopernurse | ah, you might try vimclojure then (I haven't used it). |
| 10:09 | coopernurse | but if you decide to try intellij, ping me if you have problems |
| 10:10 | babilen | justicefries: If you know and like vim vimclojure or slimv are good choices (IMHO) -- Install both as slimv comes with a nice paredit implementation. |
| 10:10 | justicefries | sure. |
| 10:10 | justicefries | ah cool. I think janus (github.com/carlhuda/janus) comes with vimclojure at least, but I don't think slimv. |
| 10:10 | justicefries | i've heard emacs comes with a built in productivity boosts for LISP family languages |
| 10:12 | babilen | I have no idea what learning EMACS and using it would do to your productivity, but I am pretty happy with vimclojure and my vim setup. Not sure if anybody actually knows both worlds well enough to be able to comment on the merits/problems of both. |
| 10:12 | justicefries | okay. |
| 10:15 | dnolen | justicefries: I mostly use Emacs because the quality of modes for various languages that influenced Clojure is so high. Amazing modes for Standard ML, Prolog, Haskell, Scheme. But such polyglot-ism might not be your cup of tea. |
| 10:15 | justicefries | yeah. so far Clojure is ruining Ruby for me. :) |
| 10:19 | babilen | dnolen: Indeed -- Even though the support for Clojure is very good in vim, the quality of the Scala, Haskell and Erlang ones seems to be ages behind Emacs. (or were when I last had a look) |
| 10:20 | pyr | is there a way to define dependencies for lein plugins defined inside a project ? |
| 10:20 | wastrel | vim <3 |
| 10:20 | MasseR | babilen: Haskell support is great |
| 10:20 | MasseR | I'd say way better than clojure |
| 10:20 | pyr | when you define lein plugins externally |
| 10:21 | babilen | MasseR: Ah, thanks for mentioning that - seems as if I remembered it wrong. (I use Emacs/viper and vim, but prefer vim where possible) |
| 10:22 | MasseR | babilen: The haskell-mode plugin is quite sensitive, and small changes to your configurations can hurt a lot, but by being careful, it's great. :) |
| 10:23 | babilen | MasseR: I must have messed it up then :) -- Do you have your configuration online somewhere? |
| 10:23 | MasseR | babilen: github MasseR/dotvim |
| 10:24 | babilen | MasseR: thanks, prepare to be cloned and diassembled ;) |
| 10:29 | pyr | answer is yes, by using dev-dependencies |
| 10:30 | pyr | (corollary, don't forget to lein deps which was my mistake) |
| 11:44 | robbe- | Any specific reason why nested #('s are not allowed? |
| 11:45 | robbe- | Or "#()s" as they are written by the compiler. :) |
| 11:47 | tufflax | robbe- maybe because the argument names would get used up |
| 11:49 | thorwil | ,(macroexpand-1 '#(identity %)) |
| 11:49 | clojurebot | (fn* [p1__8138#] (identity p1__8138#)) |
| 11:49 | arohner | gah. Why is there no way to concat regexes? |
| 11:50 | thorwil | hmm, not enlightened. but it has to be about the argument names |
| 11:50 | robbe- | tufflax: Fair enough I guess, price payed for the shorthand. (cfr scheme lambda for example) |
| 11:52 | tufflax | arohner ##((comp re-pattern str) #"," #".") |
| 11:52 | lazybot | ⇒ #",." |
| 11:52 | arohner | tufflax: thanks |
| 11:57 | abedra | chouser, I am moving c.c.zip-filter into data.zip |
| 11:58 | abedra | chouser, do you mind if I turn the asserts and comments at the bottom into actual tests? |
| 12:03 | chouser | abedra: that would be awesome, thanks! |
| 12:05 | abedra | chouser, cool, consider it done |
| 12:11 | arohner | abedra: there's one bug fix that should go in to c.c.zip-filter / data.zip |
| 12:12 | arohner | abedra: in zip-filter.xml/tag=, the line containing ((zip/node %) :tag) should be flipped to (:tag (zip/node %)) |
| 12:12 | arohner | abedra: that allows data.xml to work with zip-filter |
| 12:44 | icey | If anyone is bored, how can I make this code better? https://gist.github.com/1164308 |
| 12:45 | icey | I think I'm going to use dnolen's Enlive tutorial to replace hiccup for this |
| 12:51 | thorwil | icey: i think enlive is only worth the effort if you work in a setting where someone who does not touch the code works on the html templates |
| 12:52 | icey | thorwil: interesting; do most people use hiccup for smaller projects like this? |
| 12:52 | thorwil | if you do it all yourself, you will just write _more_ with enlive instead of hiccup |
| 12:52 | thorwil | icey: i have no statistics on that ;) |
| 12:52 | icey | thorwil: hah, fair enough |
| 12:53 | thorwil | defn- ? |
| 12:57 | icey | thorwil: i'm not sure where i picked that habit up from; is it not normal to create private functions in projects? |
| 12:59 | thorwil | icey: you probably do right, it's just i never noticed defn- before 0.o |
| 13:33 | amalloy | Scorchin: i like (remove (comp #{something} :key) list-of-maps) |
| 13:44 | r0man | hello. does someone know a fn in contrib/contrib that takes 2 seqs that represent |
| 13:44 | r0man | argument lists (that may include destructuring) and returns a somehow |
| 13:44 | r0man | "combined" argument list? something like: (merge-args '(a1 & {:keys [b1 b3]}) '(a2 & {:keys [b2]})) |
| 13:44 | r0man | ;=> '(a1 a2 & {:keys [b1 b2 b3]}) |
| 13:48 | amalloy | r0man: the connection between those two inputs and the output is quite tenuous. i would be extremely surprised if anyone had written that already |
| 13:50 | r0man | i'm doing some macro stuff where i need to combine two argument lists and thought this is maybe a common pattern when defining new fns via a macro ... |
| 13:58 | amalloy | the number of reasonable ways to combine them is just too large, and it's not clear how you would use the combined argument list effectively anyway; i don't think you can expect any macro to be smart enough to do the combination for you in a general way, so write your own for the specific case you want |
| 13:59 | amalloy | or, better, make the user pass in the new arglist they want |
| 14:37 | abedra | arohner, cool, I'll file that as soon as the library is converted |
| 14:42 | robbe- | Hmm, I'm confused about refs and dosync. I understand that if a 'state change' actually involves changing multiple refs, you do that in a dosync block to avoid exposing intermediate state. But what about for example summing all elements of a list implementation with refs. Will reading all values in one dosync block make it sum exactly one version of the list? |
| 14:42 | robbe- | I'm confused because the tail of the list may change wile summing and then you're summing some version of the head and a newer version of the tail, of you wold deref outside of the dosync block. |
| 14:43 | raek | all reads from refs inside a transaction will happen as if they all happened at the same point in time |
| 14:43 | raek | the STM takes care of this |
| 14:44 | dabd | I'd like to parse an html page using clojure.xml/parse. The following code does not work (clojure.xml/parse "http://www.google.com/") What is the proper way to do it? |
| 14:44 | arohner | dabd: you need an HTML to XML parser, like tagsoup |
| 14:44 | dabd | The docs say clojure.xml/parse accepts an uri |
| 14:44 | ibdknox_ | dabd: use tag soup ;) |
| 14:45 | dabd | ok let me check |
| 14:45 | dabd | there is a library called enlive does it work for this? |
| 14:46 | arohner | dabd: https://gist.github.com/1168833 |
| 14:46 | ibdknox_ | depends on what you're trying to do |
| 14:46 | ibdknox_ | arohner, dabd: or better than that: https://github.com/nathell/clj-tagsoup |
| 14:47 | dabd | ibdknox I am getting it from clojars thx |
| 14:47 | dabd | clj-tagsoup seems to simplify using tagsoup |
| 14:59 | abedra | chouser, ok data.zip just had a 0.1.0 release |
| 14:59 | abedra | chouser, the comments were all converted to tests |
| 14:59 | abedra | there were two that were testing things that didn't exist anymore |
| 14:59 | abedra | chouser, and two that are failing |
| 14:59 | abedra | I left those in place with a comment |
| 14:59 | abedra | feel free to cut them if necessary |
| 15:00 | mrBliss` | abedra: https://github.com/clojure/clojure/blob/master/changes.txt#L282 should be "InterruptedHandler" instead of "Interrupt Handler", like in the ToC |
| 15:01 | abedra | mrBliss`, thanks for the heads up |
| 15:03 | ldh | speaking of enlive, given input like the markup here https://gist.github.com/1168880, how can i select only the first img tag? (html/select markup [:img html/first-of-type]) does not work |
| 15:06 | thorwil | ldh: nth-of-type? |
| 15:09 | thorwil | in my now left to rot enlive-using code, i have selectors like this: [[:span (html/nth-of-type 1)]] |
| 15:10 | ldh | thorwil: no luck with (html/select markup [:img (html/nth-of-type 1)]), which is what first-of-type is an alias for. can you explain the double [[ ]]? |
| 15:11 | ldh | i'm not sure when or if to use those, nor can I seem to discover any explanation of how the "selector-step" component of the selector works |
| 15:11 | thorwil | ldh: i don't recall the why, but i think the [[ ]] is what you should try ;) |
| 15:11 | ibdknox_ | I love the idea of enlive, but I feel like the syntax needs to be simpler |
| 15:12 | ldh | thorwil: weirdly, (html/select markup [[:img (html/nth-of-type 1)]]) returns BOTH images |
| 15:12 | ibdknox_ | ideally it would just follow the standard selector syntax, and it could parse it into those vectors as an implementation detail |
| 15:12 | thorwil | ldh: this is the single place where i used nth-of-type: http://paste.pocoo.org/show/463819/ |
| 15:12 | ldh | ibdknox_: agreed. maybe it's just that i haven't wrapped my head around the details, but there seems to be a layer of foggy magic which prevents me from fully grokking it |
| 15:14 | thorwil | ibdknox: well, much of the selectors is just like CSS |
| 15:14 | thorwil | where you might see things like: [:ul#stored-items :> :li] |
| 15:15 | ibdknox_ | thorwil: yes, but you lose something by not having it in a string |
| 15:15 | ibdknox_ | thorwil: and the way you use that selector is a far cry from the simplicity of something like jquery |
| 15:15 | thorwil | ldh: it helped me to look at enlive code and especially to look at how enlive represents the html. that also opens the possibility for some inbretween manipulation |
| 15:15 | ldh | thorwil: your example doesn't seem to work for me. i wonder if there's a bug in 1.0.0 |
| 15:16 | ldh | now i am left to wonder why selectors *aren't* just strings |
| 15:16 | ibdknox_ | hehe |
| 15:17 | ibdknox_ | exactly |
| 15:17 | thorwil | ldh: maybe your html structure is not what you think it is, or more likely, enlive has a differnt idea of what you are asking for |
| 15:17 | thorwil | what can i say, after all i switched from enlive to hiccup :) |
| 15:18 | ibdknox_ | hehe |
| 15:18 | ldh | with such a simple toy example that does not bode well. |
| 15:19 | thorwil | ldh: i'm not sure anymore, but nth-of-type is not global, but looks for siblings, perhaps? |
| 15:19 | ibdknox_ | if only I didn't already have such a huge list of things to work on... |
| 15:19 | ldh | i'm actually trying enlive after using hiccup. i like the idea of unobtrusively modifying existing markup, especially when collaborating with others |
| 15:19 | ldh | thorwil: interesting thought, that would possibly explain the behavior i'm seeing |
| 15:20 | thorwil | don't make the mistake of testing right in the browser |
| 15:20 | ldh | hmm, but how to select without matching child elements as well |
| 15:20 | ldh | no, i'm running it at the REPL |
| 15:22 | thorwil | yes, if someone else is responsible for the templates, enlive might be worth it. even then, you would likely end up with selection code that is tightly coupled to the templates ... |
| 15:22 | ibdknox | just use mustache! :D |
| 15:22 | ibdknox | https://github.com/davidsantiago/stencil |
| 15:29 | dabd | how do I exec a command such as 'echo 56.8 + 77.7 | bc' with clojure.java.shell? I tried (sh "echo" "56.8 + 77.7" "|" "bc") but it doesn't work |
| 15:35 | acagle | ibdknox: I was wondering how long it would be before mustache got migrated to Clojure. The Sproutcore folks are doing some nice things integrating Handlebars (a mustache variant) into their framework. |
| 15:35 | ibdknox | acagle: we're using stencil and handlebars :) |
| 15:36 | duck1123 | I seem to be having an issue with lein. I specify 1.3.0-beta1 in my project.clj, but it still insists on pulling in 1.2. Has anyone else seen this issue? |
| 15:36 | ibdknox | acagle: though handlebars didn't adhere to the mustache spec :( |
| 15:38 | hiredman | duck1123: one of your other dependencies is pull it in |
| 15:39 | duck1123 | that's what I figured, but wouldn't my explicit dependency override it? |
| 15:40 | ibdknox | duck1123: they're not both there? |
| 15:40 | duck1123 | ibdknox: no, just 1.2.0 |
| 15:41 | ibdknox | gist of your project file? |
| 15:41 | cemerick | duck1123: version numbers are actually just "preferences". If you want to override, you'll have to use a version range like "[1.3.0-beta1,)". |
| 15:43 | amalloy | dabd: c.j.shell just executes a command and passes it args; the | syntax is something bash (and most shells) do for you |
| 15:44 | dabd | amalloy: thx |
| 15:45 | amalloy | dabd: you can invoke bash instead, and pass it the args "-c" "echo 56.8 + 77.7 | bc", or something like that |
| 15:56 | duck1123 | Ok, It looks like it was happening because I had Midje set as a runtime dependency |
| 15:57 | duck1123 | as soon as I moved it to dev-dependencies, it worked |
| 15:59 | cemerick | duck1123: That's because midje is configured to not work with Clojure 1.3.0 at all; notice the version number in its project.clj: https://github.com/marick/Midje/blob/master/project.clj |
| 16:00 | cemerick | That's a fixed version range, allowing two versions of Clojure, and only those two versions. |
| 16:01 | duck1123 | that makes sense. I have a patched version of Midje that works with 1.3 on my home computer. I'll just grab that |
| 16:39 | hiredman | dnolen: https://thestrangeloop.com/sessions/the-mapping-dilemma nice |
| 16:41 | dnolen | hiredman: yeah should be fun! |
| 16:42 | ubii | anybody have an idea how many folks they expect at Clojure/conj this year? |
| 16:42 | Raynes | I'm going. That's all that really matters, isn't it? |
| 16:42 | Raynes | ;) |
| 16:44 | joly | They're still doing early-bird registration, so there's probably not a good estimate available yet |
| 16:44 | ubii | how many did they have last year? |
| 16:44 | ibdknox | they haven't even announced speakers yet :-p |
| 16:45 | cemerick | ubii: ~200 |
| 16:45 | cemerick | 225 incl. speakers and such |
| 16:46 | ubii | thx |
| 16:46 | ubii | got tied up with work last year, so I didn't get to go, but am thinking of going this year |
| 16:48 | ubii | also considering the possibility of taking the associated training class on Nov 7-9th |
| 16:52 | ubii | just curious, is this basically the same class offered through The Pragmatic Studio or is the Clojure/core folks doing this on their own? |
| 17:04 | Somelauw | I am not sure, but since map takes multiple arguments, wouldn't it make sense to make filter accept multiple arguments as well like filter(= [1 2 3] [4 2 4]) ;=> [false true false]? |
| 17:05 | hiredman | Somelauw: if filter took multiple seqs (filter = [1 2 3] [4 2 4]) would return (2) |
| 17:05 | lobotomy_ | ##(map = [1 2 3] [4 2 4]) |
| 17:05 | lazybot | ⇒ (false true false) |
| 17:06 | nkoza | when you do (= a-map another-map) you are traversing all the elements to find if the maps are equal? I mean, is = O(n) ? |
| 17:08 | lobotomy_ | ##(map #(when (apply = %&) (first %&)) [1 2 3] [4 2 4]) |
| 17:08 | lazybot | ⇒ (nil 2 nil) |
| 17:08 | lobotomy_ | hmm |
| 17:09 | hiredman | nkoza: equality is very complex, but yes, in the case of comparing two maps you walk the maps |
| 17:09 | hiredman | well, two clojure maps |
| 17:09 | Somelauw | hiredman: You are right. |
| 17:10 | cemerick | n is likely to be smaller than you think, due to hashCode caching |
| 17:10 | Somelauw | Oh, I think I understand why now. |
| 17:11 | nkoza | hiredman: why is complex? |
| 17:15 | hiredman | nkoza: http://en.wikipedia.org/wiki/Relational_operator#Equality http://www.nhplace.com/kent/PS/EQUAL.html http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.9999 |
| 17:15 | nkoza | hiredman: thanks |
| 18:06 | agz | hey what kind of database library would you suggest for personal use in unix enviroment? |
| 18:08 | dnolen | agz: sqlite? |
| 18:09 | agz | dnolen: yep, but I heard about mongodb so I thought asking about it.. I just want to pick one which has the easiest/no-complication in clojure |
| 18:09 | agz | so I though ask the wise gremium here :) |
| 18:09 | tufflax | spit and slurp with pr and read-string? |
| 18:10 | agz | tufflax: haha :D -> although maybe you are wright, I will have data of 200Mb max |
| 18:11 | agz | in sqlite format it was 100Mb .. but it's outdated now so I can't use that |
| 18:11 | agz | how much will it be in plain text? |
| 18:11 | tufflax | dunno |
| 18:20 | amalloy | 0 bytes if you use an optimal serialization format |
| 18:20 | amalloy | (defn unserialize (constantly {:x 1, :y 2, ...})) |
| 18:21 | amalloy | s/defn/def |
| 18:21 | lazybot | <amalloy> (def unserialize (constantly {:x 1, :y 2, ...})) |
| 18:36 | leeda | Is this the right way to base64 encode a string? |
| 18:36 | leeda | ,(str (.encode (new Base64) (to-byte-array "abc"))) |
| 18:36 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: Base64, compiling:(NO_SOURCE_PATH:0)> |
| 18:37 | leeda | ok, have to import org.apache.commons.codec.binary.Base64 and clojure.contrib.io first... |
| 18:42 | leeda | or maybe: (str (.encode (new Base64) (.getBytes "abc"))) ? |
| 18:46 | leeda | hm, i guess (str x) != (new String x) |
| 19:02 | ibdknox | leeda: unrelated, but it's more idiomatic to use the . notation for instantiation: (Base64.) or (String. x) |
| 19:37 | icey | ibdknox: I'm checking out Pinot; starting by following the instructions here: https://github.com/ibdknox/noir-cljs ... I'm getting this crazy-ass chain of errors (https://gist.github.com/1169588), and I'm sure I'm doing something obviously wrong... is there something people tend to screw up when setting this up? |
| 19:37 | icey | ibdknox: here's all the code (it's not much - https://github.com/pmn/cljstrial ) |
| 19:37 | ibdknox | icey: yeah, use cljs-watch instead |
| 19:38 | icey | ibdknox: ah, will do, thanks :) |
| 19:38 | ibdknox | icey: I've done everything in my power to try and make that work, I even started ripping out pieces of the compiler to isolate what it is |
| 19:38 | icey | ibdknox: it's something you've seen before? |
| 19:38 | ibdknox | icey: yeah |
| 19:38 | ibdknox | icey: apparently the cljs compiler doesn't like being in a jar |
| 19:38 | icey | ibdknox: that makes me feel a little bit better, lol |
| 19:39 | icey | it was pretty nice to get everything packaged up straight out of clojars |
| 19:39 | ibdknox | I know. I tried :( |
| 19:39 | scottj | ibdknox: are you aware cljs-watch creates a dir bootstrap.js if run before there are .cljs files ? |
| 19:39 | ibdknox | I fixed that I think |
| 19:39 | scottj | not pushed |
| 19:40 | icey | ibdknox: btw, i implemented your suggestions from that page i posted in here the other day; it ended up looking much cleaner afterwards, thanks :) |
| 19:40 | ibdknox | scottj: you are correct. One second :) |
| 19:40 | ibdknox | icey: I'm glad :) |
| 19:41 | scottj | ibdknox: no hurry I don't need it just fyi |
| 19:42 | ibdknox | it was my own fault expecting the Java api to be smart enough not to create a directory out of a file name |
| 19:42 | ibdknox | *sigh* |
| 19:43 | ibdknox | scottj: pushed anyways :) |
| 19:44 | ibdknox | I also made the watcher more resilient to parsing exceptions, so it doesn't quit when you save intermediate states of your file |
| 19:45 | scottj | nice, it's annoying how the repl bails on those errors |
| 19:45 | ibdknox | brepl fixes that too |
| 19:46 | ibdknox | of course then you're in the browser, so may not be what you really want, but just heads up |
| 19:48 | scottj | brepl should print a file:// url to the index.htlm so you can just click on it |
| 19:49 | ibdknox | your terminal hyperlinks links? |
| 19:49 | ibdknox | hah |
| 19:49 | ibdknox | cool |
| 19:49 | ibdknox | scottj: I'll do that |
| 19:50 | scottj | also I don't like that you changed the clojure repl prompt format :) |
| 19:50 | ibdknox | I did it on purpose, since it's not the clojure repl and it behaves differently than the clojurescript repl likely ever will |
| 19:51 | amalloy | ibdknox: your terminal doesn't? what OS? |
| 19:52 | ibdknox | amalloy: I just tried it on linux and it did, I'm usually on OSX and it may very well do that... I just never use the mouse such that I would see it haha |
| 19:53 | amalloy | heh, i hear you. if i could figure out how to cut/paste from the terminal emacs-style without the mouse... |
| 19:53 | ibdknox | yeah that has always bothered me |
| 19:53 | tomoj | ibdknox: nice! |
| 19:53 | tomoj | I hadn't seen cljs-watch |
| 19:54 | ibdknox | tomoj: as far as I can tell it works for everyone, so I'm happy about that lol |
| 19:54 | scottj | with urxvt you can folow the hyperlinks with keystrokes conkeror hinting style |
| 19:54 | tomoj | wha? |
| 19:54 | tomoj | I've been using urxvt and never knew |
| 19:55 | ibdknox | I really wish I could get noir-cljs to work consistently |
| 19:55 | tomoj | everything should work like conkeror |
| 19:55 | ibdknox | when I stop being lazy, I'll submit a patch to get cljs-watch into clojurescript itself |
| 19:58 | scottj | you can also copy with keys using screen |
| 19:58 | icey | ibdknox: switching from noir-cljs to cljs-watch did the trick. everything's rock & roll now. thanks |
| 19:58 | ibdknox | icey: good deal, let me know if you run into any issues |
| 19:59 | amalloy | scottj: i confess i'm barely competent with screen. opening multiple terminal emulators is just easier |
| 19:59 | icey | ibdknox: this is the first i've spent any time with clojurescript, so it may be a day or two before i know enough to have real questions :) |
| 19:59 | scottj | amalloy: it's not emacs style though, it's vi |
| 19:59 | ibdknox | icey: haha good luck ;) |
| 19:59 | ibdknox | icey: nah, pinot should make it relatively painless. Though if you have errors, it can be very difficult to track them down |
| 19:59 | amalloy | scottj: the default C-a screen prefix makes me want to rip someone's throat out |
| 20:00 | scottj | ibdknox: what's the plan for returning the result in brepl not the browser? |
| 20:00 | scottj | cljs browser branch style |
| 20:01 | scottj | amalloy: it sure prevents me from using emacs in screen, but other than emacs it's better imo than the stumpwm C-t default. of course both can be changed |
| 20:01 | amalloy | of course. but it prevents me from using the dang shell prompt, because i navigate around that with C-a as well |
| 20:01 | scottj | oh yeah I've gotten pretty used to C-a a |
| 20:02 | ibdknox | scottj: I expect brepl to eventually no longer be necessary |
| 20:02 | amalloy | heh |
| 20:02 | amalloy | on the rare occasions i remember to use screen, i just use C-z |
| 20:02 | ibdknox | scottj: I also think it's more valuable to have the result in the browser, since I can then inspect objects and such |
| 20:02 | scottj | amalloy: actually do C-a a a pretty often since I run screen's inside of screens |
| 20:03 | amalloy | i'm pretty sure that makes you a lunatic |
| 20:04 | ibdknox | haha |
| 20:04 | scottj | ibdknox: see if you used emacs you'd change your mind on both the prompt and return values I think |
| 20:04 | amalloy | not sure if that means: "It's a thing that lunatics do", or "If you do it, you become a lunatic" |
| 20:04 | ibdknox | scottj: I can't inspect a dom object in emacs |
| 20:05 | scottj | since it would allow you to use inferior-lisp and C-x C-e expressions from your code |
| 20:05 | scottj | ibdknox: you return it in both places :) |
| 20:05 | scottj | keep current return but also send it back to brepl |
| 20:05 | ibdknox | yep yep |
| 20:05 | ibdknox | I did that originally |
| 20:05 | ibdknox | it didn't do well with it |
| 20:05 | ibdknox | since the result is often a long javascript function |
| 20:06 | ibdknox | that needed to be broken up over multiple websocket frames |
| 20:06 | ibdknox | you have to keep in mind brepl was done in a night + a couple hours the next day :) |
| 20:06 | ibdknox | I had originally expected to help with the official clojurescript bcrepl |
| 20:09 | scottj | require and fault tolerance are the things I really like over bcrepl |
| 20:11 | ibdknox | to be honest, I find it easier to not use the repl in this case |
| 20:11 | ibdknox | it's easier to just let the watcher recompile the thing and refresh |
| 20:41 | agz | hey guys, my agents are lost: |
| 20:41 | agz | (def a (agent [])) |
| 20:41 | agz | (send a conj 1) |
| 20:41 | agz | (await a) <-- and no return |
| 20:42 | amalloy | maybe someone called shutdown-agents? |
| 20:42 | agz | lein swank clojure 1.2.1 contrib 1.2 fetcher 0.5-SNAP clj-time 0.4-SNAP |
| 20:42 | agz | uhm googling shutdown-agents |
| 20:43 | agz | what I observed, that with a fresh restart of the server it still doesn't work - maybe fetcher did shutdown? |
| 20:43 | amalloy | fetcher? |
| 20:43 | agz | https://github.com/getwoven/fetcher/blob/master/project.clj |
| 20:43 | agz | http grabber |
| 20:44 | amalloy | holy...i just saw the (ns) statement in fetcher.core |
| 20:45 | ibdknox | wow |
| 20:45 | agz | shutdown agent is not called - if I write the above in the fresh interpreter the |
| 20:46 | agz | the idleing occur.. :( |
| 20:47 | agz | is there an easy way to print the threadpool or sg? |
| 20:51 | agz | dohh .. something is really wrong here, if I start a total fresh interpreter with only clojure1.2.2 and contrib1.2.0 swank1.2.1 still not working :O |
| 20:55 | agz | reboots |
| 21:00 | agz | hey I've lost my agents, a bit desperate here ,D |
| 21:00 | agz | (def a (agent [])) (send a conj 1 2 3) (await a) <--- hangs |
| 21:04 | cemerick | that ns form is out of control. Something went pear-shaped there. |
| 21:07 | agz | if I lein-swank a totally different project with no dependencies other than clojure I still got this misfunction |
| 21:08 | agz | I don't know lein - so is it possible installing fetcher made something wrong, which affects interpreter even if I don't include fetcher??? - It would be somehow beyond my comprehense |
| 21:09 | ibdknox | agz: did you install it as a plugin? |
| 21:11 | agz | ibdknox: no.. I lein install - |
| 21:11 | ibdknox | agz: it shouldn't pick it up then |
| 21:11 | ibdknox | but the simplest way to prove that |
| 21:11 | ibdknox | is to remove ~/.m2/repository |
| 21:12 | ibdknox | agz: then check to see what's in ~/.lein |
| 21:16 | agz | ibdknox: I cleaned .m2/repository |
| 21:16 | agz | with lein deps it downloaded a new clojure |
| 21:16 | agz | but still not working .. is it possible that it's problem with the jvm? |
| 21:17 | ibdknox | no idea |
| 21:17 | agz | ibdknox: anyway thx |
| 21:17 | ibdknox | most likely has to be given that you just removed everything specific to clojure right there, assuming you've only used lein |
| 21:18 | agz | btw I have lein-1.4.2 and lein-1.6.1 in ~/.lein |
| 21:18 | agz | dont is it have any effect |
| 22:41 | technomancy | agz: you need swank 1.3.2 which plays well with lein's workaround for Clojure's lack of control over thread pools |
| 22:45 | technomancy | oh, he's gone |
| 22:47 | quotemstr | Is the Java 7 dynamic language stuff good for Clojure? |
| 22:53 | technomancy | quotemstr: sorta. afaict it can make calls that would otherwise be reflective significantly faster, but not as fast as if they were hinted |
| 22:54 | quotemstr | Ah, cool. |
| 22:54 | quotemstr | I'll have to read up on the details sometime. |
| 22:55 | technomancy | quotemstr: so there's reluctance to drop compatibility with java 6 or add two modes to the compiler since it's not pure awesome |
| 22:56 | quotemstr | technomancy: As long as it's source-compatible, I don't see a problem. It's no different from gcc optionally compiling binaries that won't work on older CPUs, yes? |
| 22:57 | technomancy | well, if someone were so inclined to add it to the compiler, it's not out of the question that it'd be accepted. I just don't think there's anyone currently working on it or planning to. |
| 22:57 | srid | can I define multiple entry points instead of the singular `lein run`? |
| 22:57 | srid | it seems that project.clj can only contain one :main entry |
| 22:58 | srid | i want to define one entry for running the web app, and another for running the command line interface. |
| 22:59 | technomancy | srid: lein run -m my.name.space # ought to do it |
| 23:00 | amalloy | thanks, clojure, for immutability-by-default, and atoms/stm for the rest. means i don't have to be too ashamed i never really grasped the difference between barriers and guards, or whatever locking constructs |
| 23:26 | icey | ibdknox: cljs-watch is working great, but you may want to add the note from the mailing list regarding copying the goog.jar to the readme on github |
| 23:45 | technomancy | bizarre: 3x as many python refugees in haskell vs former rubyists, while they are neck and neck with clojure |
| 23:47 | icey | technomancy: because of significant whitespace, maybe? |
| 23:47 | technomancy | icey: it could also be that there are just a lot more pythonistas than rubyists and clojure is the odd one for having an even number |
| 23:48 | icey | technomancy: also very possible |
| 23:48 | icey | technomancy: are there many perl people getting into haskell? |
| 23:49 | technomancy | icey: only 6% vs 10% ruby and 28% python |
| 23:50 | icey | other than the reputation for being ultra-functional and "mind-bendingly hard" to pick up, what is the major marketing point for haskell? is it just the ultra-functional part? |
| 23:51 | technomancy | the type system, I guess? |
| 23:51 | technomancy | it's a lot stricter than ocaml/scala about purity |