#clojure logs

2011-08-24

00:01jjddbclojure.java.io says: (defn- ^String encoding [opts] (or (:encoding opts) "UTF-8"))
00:01jjddbis such a thing as :encoding "binary" recognized?
00:02jjddba complete list of accepted encodings aren't in the clojure docs
00:02sridafaik, 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:03jjddbah
00:03srid(slurp (-> url (URL.) (.openConnection) (.getInputStream) (GZIPInputStream.))])
00:03sridminus the GZIPInputStream part.
00:03sridno
00:04srid(to-byte-array (-> url (URL.) (.openConnection) (.getInputStream)))
00:04jjddbcan spit write the byte-array?
00:14jjddbugh, I didn't have contrib in my classpath :/
00:25jlimy 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:25jliis that dumb? it's been working for me so far
00:26sridhas anyone integrate lein with http://martiansoftware.com/nailgun/ ? for faster JVM startup
00:26jjddbI think I've heard of it being done
00:27jjddbbut I believe a tool called fark seeks to fill that void
00:27jjddbis clojure.contrib 1.2 compatible with clojure 1.3beta1?
00:28jjddbI'm getting: IllegalStateException Can't dynamically bind non-dynamic var: clojure.contrib.io/*append* clojure.lang.Var.pushThreadBindings (Var.java:339)
00:29jjddbshould I be using the contrib.io version of to-byte-array or the duck-streams version?
00:29jjddbits a shame clojure.java.io doesn't have to-byte-array
00:32scottjsrid: jjddb might have meant jark, which does something like nailgun not sure if it uses nailgun. there's also cake and lein interactive
00:32jjddbscottj: right, my fault. jark uses nailgun
00:33scottjI use jark for my scripts, it supports #!
00:33scottjcake does too I think (with persistent vm also)
00:36dnolencrazy ascii art? https://gist.github.com/1167317 - nope, output from match for a red-black tree balance checker. something to work on ...
00:39jlidnolen: nice. is that a bug? or does it just not do something smart for recursive matches (assuming that's what's going on?)?
00:39jliall the "(cond)"s are interesting
00:40amalloyjli: i like (cond :else (let [] :invalid)), personally
00:42dnolenjli: 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:43dnolensome -> help some.
00:45dnolenjli: the more troubling thing is how long it takes to actually generate the source.
00:45michaelr525hello
00:47dnolenjli: 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:49jjddbamalloy: srid: I remember why I was using http.async.client now... I need something that can handle cookies.
00:49jjddbI've been using the selenium wrapper to automate some downloading processes
00:50jjddbI'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:51jjddbwhen 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:52amalloyjjddb: is there a java binding for libcurl? it's pretty good
00:53jjddbas a matter of fact there is
00:54jjddbat that rate though I could just shell-out to curl or wget
00:55jjddbwas trying to keep it all in one jar
01:00dnolenheh Racket generates about the same amount of code for the red-black tree test
01:00dnolenso all we gotta do is not take so long to generate it.
01:01khaliGdnolen, what's that for?
01:01dnolenkhaliG: ?
01:01khaliGis it for a benchmark?
01:03amaco/
01:03dnolenkhaliG: the benchmark of "I will/won't use this for anything in Clojure" yes :)
01:04khaliGah
01:04amacdnolen: watched your talk on patern matching, very cool
01:05dnolenin fact using Java arrays to representing the red-black trees this could be one of the fastest red-black balance checkers out there.
01:05jjddbhow does one spit a byte-array?
01:05dnolenamac: thx
01:07amalloy&(require 'clojure.java.io)
01:07lazybot⇒ nil
01:07amalloy&(doc clojure.java.io/copy)
01:07lazybot⇒ "([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:07amalloyjjddb: ^
02:38peteriserinsI'm running lein repl in my lein project. How to reload my clojure files without reloading the lein repl?
02:39tomojuse and require take :reload and :reload-all options
02:39tomoje.g. (use 'foo.bar :reload-all)
02:39tomojthe -all version reloads all dependent namespaces too
02:40tomoj(doc require)
02:40clojurebot"([& 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:40tomojhmm
02:40Guest48164need help chaining multiple lazy-seq's into one lazy-seq
02:40tomojchaining?
02:41Guest48164have:
02:41Guest48164(doseq [content (client/string response)] (doseq [line (re-seq #".+\r\n" content)] (let [record (json/read-json line)] (f record)))))))
02:41Guest48164want one lazy-seq back instead of (doseq ... (doseq ... (do something
02:42Guest48164Trying to get content from http stream and pass back a seq that a I can (doseq on
02:43Guest48164Getting 1 lazy-seq from (client/string, then getting another lazy-seq from re-seq
02:44tomojhttps://gist.github.com/d58de88cc6db11bd1122
02:45tomojuntested
02:45tomojbut I think something like one of those should work
02:45tomojeasier to get help if you show a simple extracted example that works by itself
02:45tomoj(also, paste those to gist or pastebin or something, not here)
02:45Guest48164Nice, I'll try it out
02:45Guest48164Yeah, sorry about that
02:45tomojyours was short enough this time
02:46tomojI just tend to warn people because some people have no clue and will paste huge blobs of code :)
02:46tomojmapcat is one way of chaining
02:47tomojit's just like map (you know map?) but concatenates the result seqs into one seq
02:48tomojand do you know ->>? less confusing way of writing records is (map json/read-json (mapcat #(re-seq #".+\r\n" %) (client/string response)))
02:48amalloyGuest48164: fwiw, doseq allows multiple bindings, which it processes in a nested fashion
02:48amalloy(doseq [content (...), line (...content...)] ...)
02:48tomojI wouldn't think that would do what you want
02:49amalloytomoj: it would do the same thing as the nested doseqs
02:49amalloywhether that's what he wants i won't speculate on
02:49tomojoh, right
02:49tomojand you just ignore the bindings
02:49tomojwhich is why they fall out :)
02:49amalloy?
02:50tomojI mean, only line is used inside the body
02:50tomojwhich makes doseq over cross-product seem wrong to me, even though it's actually what nested doseq does...
02:50jlicontent is used to define line, no?
02:50khaliGis there a nicer way to write (.setEnabled foo (not (nil? foop)))
02:51tomojI mean in the body of the unified doseq
02:51Guest48164Here's the paste: http://pastebin.com/QkL0Gysb
02:51tomojkhaliG: if foop is false, you want to enable foo?
02:51tomojotherwise (boolean foop)
02:53khaliGtomoj, ops, right, (boolean foop) is what I'm after
02:53amalloytomoj: i don't understand what you're getting at re: falling out/ignoring. are you worried about holding onto something's head?
02:53tomojI mean, the binding of content is unnecessary
02:54tomojso it 'falls out' when you get rid of the doseqs and use mapcat
02:54amalloyi see
02:54amalloyinteresting way of thinking about it
02:54tomojguess it's still there though
02:54tomojjust became anonymous
02:54amalloyright. it's bound in each invocation of f in (mapcat f ...)
02:55tomojbut if you use it in the body, my code doesn't work
02:55amalloywhich i think is pretty close to what for/doseq translates to, eventually
02:55tomojwell, sure it does, you just have the seq return [content line] pairs, just like doseq..
02:56amalloyGuest48164: 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:57tomojaww
02:57Guest48164amalloy: right
02:57Guest48164amalloy: Can't get my head around it though
02:58tomojdo you find mapcat/partial/->> easier? O_o
02:58Guest48164tried 'for' but things get stuck
02:58tomojjust curious, how do you generate the stream seq?
02:58Guest48164trying the mapcat/partial... was not intuitive to me
02:58amalloyGuest48164: https://gist.github.com/1167449
02:58amalloyoh, but then you run into trouble with with-open closing the stream before you're done
02:59Guest48164http.async.client/stream-seq
02:59tomojbleh
02:59tomojI didn't even notice the with-open
02:59amalloytomoj: yeah
02:59Guest48164ahhhh
02:59amalloyGuest48164: 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:59Guest48164Have to process everything inside the with-open, right?
03:00raek(doall (for ...)) ?
03:00Guest48164No way around it, I guess?
03:00amalloythose seem to be the two options :P
03:00tomojI don't think you want to synchronously process your async stream
03:01Guest48164Would need to have the with-open outside of that subscribe routine
03:01Guest48164Got it
03:01Guest48164Thanks for the help
03:01tomojmaybe you do.. I guess it at least gives you a lazy seq over a streaming response?
03:02robbe-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:02tomojhttps://github.com/ztellman/aleph/wiki/Consuming-and-broadcasting-a-Twitter-stream
03:02tomojGuest48164: ^
03:03Guest48164tomoj: yeah, played around with aleph first
03:03tomojmay 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:04Guest48164aleph seems to have a very different and unique model about stuff, what with the channels and all
03:04tomojyeah, didn't really think about that..
03:04tomojthe receive-all version looks great to me and the pipeline stuff you could do on it too
03:04tomojbut it's ..different
03:04tomojand too much to learn on top of clojure
03:06michaelr525,(map #(%1) ({:a 1}{:b 2}))
03:07clojurebot()
03:07michaelr525what am I doing wrong?
03:07michaelr525I just want to iterate this list of maps and return a new list of maps
03:07Guest48164btw, what's the * in "function*" convention mean?
03:08michaelr525internal to namespace i think
03:08tufflax,({:a 1}{:b 2})
03:08clojurebotnil
03:08amalloy&(:a)
03:08lazybotjava.lang.IllegalArgumentException: Wrong number of args passed to keyword: :a
03:08Guest48164thought that was function-
03:08michaelr525or internal for macro use
03:08amalloyoops. tufflax beat me to it with my dreadful copy/paste skills
03:08Guest48164ahh
03:08michaelr525a macro with the same name
03:08raek,(map #(assoc % :x 3) (list {:a 1}{:b 2}))
03:08clojurebot({:x 3, :a 1} {:x 3, :b 2})
03:09amalloymichaelr525: your #(%1) is also highly suspicious, once you've fixed tufflax's suggestion
03:09michaelr525shit, brb
03:10robbe-Doe we have a nice repl with line-editing capabilities for clojure?
03:10robbe-Do*
03:10amalloy$google rlwrap
03:10lazybot[rlwrap - utopia.ision.nl] http://utopia.knoware.nl/~hlub/rlwrap/
03:10robbe-ty
03:10amalloyreally? 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:12robbe-Okay, I just experimenting a bit now, but I better jot it down for when I revisit closure in a more serious context. :-)
03:15jliamalloy: lein adds line editing?
03:15amalloy*nod* it detects rlwrap, and either uses it or falls back on jline
03:17jlihuh, cool.
03:17thorwili'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:18raekthorwil: check for old files in classes/
03:18raekor perhaps do a lein clean
03:19amalloyraek: or take a flamethrower to them, without first checking to see if there are any :P
03:20MasseRI'm trying to use (:import (java.util Random)) in the ns macro, but I get an error about class java.util not existing
03:20raekAlien II: In space no one can hear you clean
03:21raekMasseR: that looks right. what does your ns form look like? like (ns some-ns (:import (java.util Random))) ?
03:22raek(watch out for quotes)
03:22MasseRhttp://pastebin.com/9SagAatP
03:22MasseRLike that
03:22thorwilraek: 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:23raekMasseR: any reasons you have both duck-streams and java.io? (since the latter replaces the former)
03:24MasseRraek: to-byte-array wasn't in io
03:24raekMasseR: that ns form works for me. are you sure this is not something simple like forgetting to save the file?
03:24thorwilMasseR: there's no need to repeat :require. (i'm suprised that works, even)
03:25MasseRraek: The file is saved, and I just restarted the repl. No go
03:25ibdknoxsweet
03:26raekMasseR: and you are sure the error is caused by these lines?
03:26MasseRraek: -.- I'm an idiot :D
03:26MasseRThanks
03:26ibdknoxI have the base of a d3-like data visualization library for cljs :)
03:26thorwilMasseR: http://pastebin.com/R9SqQcMY
03:26MasseRthorwil: Thanks
03:27thorwilnp
03:31thorwiloh well, the only data i have to visualize right now are nested comments :)
03:37ibdknoxheh
03:37ibdknoxthat's the best kind to visualize ;)
03:37ibdknoxuseless data haha
03:38jliMasseR: ooh, what's a reddit wallpaper?
03:39thorwilshouldn't i be able to call a function from within itself, without using declare?
03:39jlithorwil: recursively? yeah.
03:39amalloythorwil: yes. are you trying to do something like (let [f (fn [] (f ...))])?
03:39jlioh
03:40MasseRjli: A while back I wrote in haskell a script that takes a random wallpaper from r/wallpaper
03:40MasseRI'm trying to port it to clojure as a learning experience
03:41jliMasseR: ah, cool
03:43khaliGhm getting a bit tired of switching to the slime repl to type (-main) after making some changes, is there an easier way?
03:44jliI've never seem /r/wallpaper before - these are pretty good :)
03:44thorwilamalloy, jli: http://paste.pocoo.org/show/463493/
03:45jlikhaliG: a script that runs it your clj automatically when the modtime changes?
03:45khaliGjlf_, was thinking a shortcut, like press F5
03:45khaliGi wouldn't know how to do that though
03:46fhdAny ClojureScript gurus around? I need some help here.
03:46khaliGjli, even, sorry
03:46jlikhaliG: you could record a hacky macro
03:47ibdknoxfhd: dunno if I'm a guru, but I may be able to help
03:47khaliGjli, emacs macro? i'll look into it now
03:47jlisomething like: M-x slime-repl RET (-main) RET C-x b RET
03:47fhdibdknox: I'm using the dom-helpers from the twitterbuzz sample, dom-helpers/build in particular
03:47robbe-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:47jlithat would switch to the repl, enter "(-main)", and switch back (I think)
03:47jlirobbe-: sounds like you need slime
03:48khaliGjli, looks good. how do i tell emacs to run that sequence though?
03:48robbe-jli: Not an emacser ;)
03:48fhdibdknox: 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:48jlikhaliG: do you know how te record macros?
03:49robbe-(although it's on the todo list)
03:49khaliGjli, nope, reading about it now. will i be able to store the macro for reuse?
03:50fhdibdknox: Tried this with the latest clojurescript on two different boxes. The twitterbuzz example works fine
03:50ibdknoxfhd: and you're only executing that code?
03:50jlikhaliG: 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:50amalloythorwil: that looks fine. is line 181 the last line of comments-rendition-recur?
03:50fhdyeah, just a sec
03:50fhdibdknox: I'll put the post in a pastebin
03:50khaliGjli, sounds good. thank you!
03:50jliyup
03:51thorwilamalloy: yes
03:51robbe-http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Enhancing_Clojure_REPL_with_rlwrap ; explains what I was asking
03:51fhdibdknox: http://pastebin.com/QuhGytfv
03:52fhdibdknox: Wait, that was old, here: http://pastebin.com/dvrB3nUR
03:52amalloythen i don't really see any reason it wouldn't work
03:52fhdibdknox: dom-helpers is copied from the twitterbuzz sample, latest revision. I just changed the namespace.
03:52MasseRHmm.. My haskell solution took 82 lines, and clojure 38
03:53ibdknoxfhd: mkay
03:53jlithorwil: can you paste the whole file? or whittle it down to a small complete failcase?
03:53ibdknoxfhd: try without the text
03:54fhdibdknox: Just [:h1] ?
03:54ibdknoxfhd: yep
03:55thorwiljli: sure i could paste more, but the failcase is ... compilation
03:55fhdibdknox: Same
03:56ibdknoxfhd: not that this should really make a difference, but try (dom/append (.body js/document) (dom/build [:h1]))
03:56ibdknoxfhd: I'm not overly familiar with the dom-helpers they wrote, since I wrote a port of hiccup for CLJS
03:56fhdibdknox: Still the same
03:57thorwiljli: the whole set of related fns: http://paste.pocoo.org/show/463499/
03:57fhdibdknox: I must be missing something that twittbuzz does, but I just can't figure out what
03:57ibdknoxfhd: well, I've been reading through the dom-helpers code
03:57ibdknoxfhd: that *should* work
03:58fhdibdknox: Yeah, works fine for twittbuzz, so I don't thing there's a problem with dom-helpers
03:58ibdknoxfhd: try (dom/append (.body js/document) (dom/html "<h1>hey</h1>"))
04:00fhdibdknox: That works.
04:01fhdibdknox: 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:01ibdknoxfhd: hah
04:01ibdknoxfhd: I don't think this is very robust :)
04:02fhdibdknox: And "this" would be?
04:02fhdibdknox: ClojureScript?
04:02ibdknoxfhd: no, dom-helpers
04:02ibdknoxfhd: (dom/append (.body js/document) (dom/build [:h1 [:em "hello"]]))
04:03fhdibdknox: Uncaught TypeError: Object i.'em has no method 'appendChild'
04:04jlithorwil: 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:05jlithorwil: what's defhtml from?
04:05fhdibdknox: Also tried (dom/append (.body js/document) (dom/build [:h1 (dom/html "<em>Hello</em>")]))
04:05thorwiljli: hiccup
04:05fhdibdknox: That gives me "...h1 has no method 'appendChild'" again
04:05ibdknoxfhd: 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:06ibdknoxfhd: but without stepping through it, I couldn't tell you where it's doing that
04:06fhdibdknox: I could create a small GitHub project for this, if you're willing to investigate the issue
04:07ibdknoxsure, though I need to sleep. I'd be happy to check it out tomorrow :)
04:07ibdknoxIn the mean time, you could play around with pinot if you just want to mess around: http://github.com/ibdknox/pinot
04:08fhdibdknox: As an alternative to dom-helpers?
04:08fhdibdknox: Yeah, sounds good.
04:08ibdknoxfhd: yessir, though the goal is more of a fullservice client side library
04:09fhdibdknox: I'll use that then. Although dom manipulation would be cool enough to become its own project :)
04:10ibdknoxI suspect in the long term many pieces of it will spawn off
04:10ibdknoxlike the visualization stuff I was working on tonight :)
04:10michaelr525you
04:10michaelr525yo!
04:15fhdibdknox: I really want to figure this out though, I'll play around some more
04:19michaelr525,{:a 1}
04:19clojurebot{:a 1}
04:20michaelr525(#({:a 1}))
04:20michaelr525,(#({:a 1}))
04:20clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentArrayMap>
04:21michaelr525why in the first case the map evaluates to a map and in the second case it tries to evaluate it as a function
04:21michaelr525?
04:22ordnungswidrig1michaelr525: #() adds parens around its body
04:22ordnungswidrig1,(#(1))
04:22clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
04:23ordnungswidrig1so #(1) is like (fn [] (1))
04:23jlimichaelr525: that was equivalent to ,((fn [] {:a 1}))
04:24jli,((fn [] {:a 1}))
04:24clojurebot{:a 1}
04:24jlier, no, fail.
04:24michaelr525:)
04:24tufflax,(macroexpand '#({1 2}))
04:24clojurebot(fn* [] ({1 2}))
04:24tufflaxjli looks like you are wrong :p
04:24michaelr525macros, they caught us again ;)
04:24ordnungswidrig1michaelr525: you can either to (fn [] {:a 1}) or #(constantly {:a 1})
04:25michaelr525ordnungswidrig1: or identity?
04:25ordnungswidrig1michaelr525: or itendity
04:25michaelr525,#(identity {:a 1})
04:25clojurebot#<sandbox$eval7746$fn__7747 sandbox$eval7746$fn__7747@a0f411>
04:27tufflaxmichaelr525 what are you really trying to do?
04:28michaelr525i would like to take a list of records (maps) and transform to another list of maps with one property's name changed
04:28michaelr525({:a 1}) -> ({:b 1})
04:30ordnungswidrig,(map #(clojure.set/rename-key % {:a :x}) [{:a 1 :b 2 :c 3} {:a 3 :f 4}])
04:30clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set>
04:30ordnungswidrigrename, not rename-key but you get the idea
04:31michaelr525would it be faster than mapping to a new list?
04:31michaelr525ah
04:31ordnungswidrigmichaelr525: it maps to a new list :-)
04:31michaelr525you are mapping to a new list
04:32tufflax,(require 'clojure.set)
04:32clojurebotnil
04:32tufflax,(map #(clojure.set/rename-keys % {:a :x}) [{:a 1 :b 2 :c 3} {:a 3 :f 4}])
04:32clojurebot({:x 1, :c 3, :b 2} {:x 3, :f 4})
04:32michaelr525ok, would it be faster than creating a new map, considering each record has only two properties
04:32michaelr525?
04:32tufflaxit is creating a new map
04:33tufflaxfor each map
04:33michaelr525ok, i think i get it.
04:33ordnungswidrigand a new list of the new maps
04:33tufflaxactually a seq
04:33tufflaxbut, yeah
04:34michaelr525thanks!
04:34tufflaxI don't know what is the fastest way to do it, if it really matters you have to test it :P
05:08gilechamtemplate 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:29MasseRI 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:30MasseRhttp://pastebin.com/sBHF8RvP
05:30MasseRWhat on earth is it doing the rest of the time
05:38MasseRjava -jar redditwallpaper-0.0.1-standalone.jar 2.71s user 0.34s system 4% cpu 1:03.15 total
05:46raekMasseR: btw, there is a copy function in clojure.java.io
05:47MasseRraek: Doesn't handle binary files
05:47MasseRAt least from web
05:47MasseRAt least I wasn't able to make it work
05:48raekI think it should be possible to replace (.write out (duck/to-byte-array in)) with (copy in out)
05:49raekio/copy, that is
05:49MasseRraek: That was my first try, file said 'data' instead of 'jpeg data', and if I understood correctly it copied it as text
05:50MasseR(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:50pyrMasseR: also, for getting a random one, i would (first (shuffle list))
05:50raek(io/copy (io/input-stream uri) (io/output-stream fname)) uses input/ouput-streams, which are binary
05:52MasseRraek: Yep. I did it somehow differently apparently :D. Hmm.. I think it was (io/copy (io/to-byte-array (reader uri)...
05:52raekreader is like input-stream, but for text streams
05:53MasseRMm. I figured it out. Didn't think of using input-stream/output-stream with copy though
05:53raekalso, io/copy won't read the whole file into memory in one piece
05:54MasseRDamn you're helpful
05:55MasseRI really appreciate it
05:55raekMasseR: you might need to call shutdown-agents before your application exits
05:57MasseRraek: It helped
05:57raekbut if that was the problem your app would just freeze and don't shut down
05:57MasseRjava -jar redditwallpaper-0.0.1-standalone.jar 4.08s user 0.30s system 153% cpu 2.862 total
05:58mrBlisshttps://github.com/clojure/clojure/blob/master/changes.txt#L282 should be "InterruptedHandler" instead of Interrupt Handler" (see ToC).
05:58MasseRraek: 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:00tufflaxgilecham apply-template uses prewalk-replace, your example works with postwalk-replace: (postwalk-replace (zipmap '[n] '[(modify n)]) '(+ n 5)) => (+ (modify n) 5)
06:00MasseRraek: And does it close the streams?
06:00raekis the picture cut in half?
06:00MasseRraek: No. Like a couple of rows wen't missing
06:00raekMasseR: copy does not close them, but with-open does
06:01raekso the "bare" copy call without with-open is probably not a good idea...
06:02raekMasseR: I have to go, but good luck!
06:07gilechamtufflax: 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:12tufflaxgilecham replace only replaces things in the list you give it, not recursively in sublists
06:12tufflaxbut postwalk does
06:12tufflax,(require 'walk)
06:12clojurebot#<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate walk__init.class or walk.clj on classpath: >
06:13tufflax,(require 'clojure.walk)
06:13clojurebotnil
06:13tufflax,(walk/postwalk-replace {'[n] '(modify n)} '(+ (+ n 1) 5))
06:13clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: walk, compiling:(NO_SOURCE_PATH:0)>
06:13tufflax,(clojure.walk/postwalk-replace {'[n] '(modify n)} '(+ (+ n 1) 5))
06:13clojurebot(+ (+ n 1) 5)
06:14tufflax,(clojure.walk/postwalk-replace {'n '(modify n)} '(+ (+ n 1) 5))
06:14clojurebot(+ (+ (modify n) 1) 5)
06:14tufflaxthere
06:14tufflax,(replace {'n '(modify n)} '(+ (+ 1 n) 5))
06:14clojurebot(+ (+ 1 n) 5)
06:16tufflaxbut you probably understood without all that... :p
06:17tufflaxbtw i didn't know anything about apply-template, i just read the source :P
06:20gilechamtufflax: Thanks I'll go and play.
06:20tufflaxnp
06:42robbe-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:42tufflaxkhaliG there is no such thing as too much clojure :p
06:43khaliGtufflax, ha :)
06:44opqdonutrobbe-: namespaces
06:44tufflaxrobbe- 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:45robbe-Okay thanks, I'll look up namespaces.
06:51robbe-Hm, defn- but no def- ? :-)
06:52opqdonutyeah, that's weird IMO too
06:52opqdonutbut you can do (def ^{:private true} private-constant ...)
06:52cemerickAll the foo- variants are an anachronism
06:52cemerickJust ^:private in 1.3.0
06:53manutterand it would be pretty trivial to write a def- macro, I should think.
06:53tufflaxrobbe- http://pastebin.com/7XXLfCzw
06:54manutterWell, looks like our 3rd-party corporate email provider is hosed again--today should be interesting *sigh*
06:54robbe-Okay, thanks for the info. Was defining simple functions like (def foo #(+ 1 %))
06:55pyri stopped using :private, it made my testing much harder
06:55pyram i doing things wrong ?
06:56opqdonutpyr: hint: #'
06:56tufflaxpyr you can use this maybe http://pastebin.com/jw5D3Aw0
06:56manutterpyr: I think functional programming does more to protect you from bugs than private vars do.
06:56tufflaxif that's your problem...
06:56manutterfwiw...
06:57opqdonutfor private functions you can do: (let [function-to-test #'name.space/function-to-test] test-it-here)
06:57opqdonutand IMO private functions are good for structuring large programs, they keep interfaces simple
06:57opqdonutand avoid namespace pollution with use
06:58tufflaxmaybe that docstring in my paste is wrong? doesn't seem do be every var
06:59tufflaxpyr oh, you _stopped_ using private
06:59tufflaxi misread
06:59pyryes
07:00manutterHmm, 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:01manuttersorry, I meant if foo.c uses foo.b
07:01manutter(need coffee, just woke up...)
07:01tufflaxor 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:02pyrtufflax: i meant
07:02pyrtufflax: i stopped using private functions because it required kludges (#' trick) in tests
07:03tufflaxok, then use the refer-prvate function!
07:03tufflaxbest of both worlds, or something
07:04pyryes, refer-private is nice, thanks for the tip
07:05ScorchinIf 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:06Scorchinbut I don't want to check it on "x" but a key within x
07:06robbe-how would I include that macro def in every file, load-file or is there something more idiomatic, or better?
07:06tufflaxrobbe- :use within the ns macro
07:07tufflaxScorchin (fn [m] (not= (:key m) something))
07:10tufflaxor (m key) is key is not a keyword
07:10opqdonutor (get m key) to be sure
07:10tufflaxif key
07:11tufflaxopqdonut hm is that better somehow?
07:12opqdonutwell suppose it somehow happend that m isn't a map
07:12opqdonutthat way you catch it earlier
07:12opqdonuterr, isn't a collection, rather
07:13tufflax,(get 1 1)
07:13clojurebotnil
07:13opqdonutoh, what? get doesn't throw an exception any more...
07:13opqdonutI could've sworn
07:13opqdonutI just tested it myself
07:13tufflaxhehe
07:14opqdonutFFS
07:17tufflaxif 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:19opqdonutwell vectors aren't functions etc
07:19tufflax,([1 2 3] 0)
07:19clojurebot1
07:19tufflaxno?
07:19opqdonutwtf
07:20opqdonutmy assumptions are so out of date
07:20tufflaxhehe
07:20opqdonutmaybe I'll just be quiet
07:37raekthe behaviour get has when you pass it something "non-lookup-able" has always puzzled me
07:38ScorchinIs there a simple way to remove a key (or set of keys) from a list of maps?
07:39tufflax(map (partial dissoc key1 key2) list-of-maps)
07:39Scorchinthanks tufflax
07:39tufflaxor no
07:39Scorchinoh?
07:39tufflaxthat does not work
07:40tufflax(map #(dissoc % key1 key2) list-of-maps)
07:40tufflaxthat works better
07:40raekScorchin: 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:40lazybot⇒ ({:a 1} {:b 2})
07:40Scorchinyup, that did it, thanks!
07:41Scorchinraek: why the extra hashes?
07:41tufflaxits for the bot
07:41raekScorchin: that is the syntax to tell lazybot to evaluate something in the middle of an utterance
07:41Scorchin:)
07:42Scorchinthought it was some extra sugar I'd have to learn like the '(stop me from evaluating) ticks thing
07:57manutterCool, you can hide both vars and functions by putting them in a separate ns
07:58manutterPut private stuff in foo.impl, then have foo.public implement the public api and (:use) foo.impl
07:58manutterand then for testing you can use foo.impl too (so no #' trick)
07:59manutterpyr: ^^^
09:59justicefrieswhat's everybody's IDE/editor preference for clojure?
10:01dnolenjusticefries: 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:02justicefriesahh. yeah I use vim with ruby and XCod
10:02justicefriesXcode.
10:02coopernursejusticefries: I enjoy IntelliJ w/La Clojure - community edition is free
10:03justicefrieswas reading about that. works well?
10:03dnolenjusticefries: Vim is popular too.
10:03dnolenjusticefries: vimclojure and slimv
10:05mprenticei'm trying to like eclipse
10:06babilenjusticefries: 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:06coopernursejusticefries: 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:07justicefriesi used hombrew to install clojure and then installed lein
10:08coopernursethat's a good start
10:08coopernursedo you already know emacs?
10:08justicefriesnope.
10:09justicefriesjust vim.
10:09TimMcIs there a paredit for vim?
10:09coopernurseah, you might try vimclojure then (I haven't used it).
10:09coopernursebut if you decide to try intellij, ping me if you have problems
10:10babilenjusticefries: If you know and like vim vimclojure or slimv are good choices (IMHO) -- Install both as slimv comes with a nice paredit implementation.
10:10justicefriessure.
10:10justicefriesah cool. I think janus (github.com/carlhuda/janus) comes with vimclojure at least, but I don't think slimv.
10:10justicefriesi've heard emacs comes with a built in productivity boosts for LISP family languages
10:12babilenI 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:12justicefriesokay.
10:15dnolenjusticefries: 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:15justicefriesyeah. so far Clojure is ruining Ruby for me. :)
10:19babilendnolen: 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:20pyris there a way to define dependencies for lein plugins defined inside a project ?
10:20wastrelvim <3
10:20MasseRbabilen: Haskell support is great
10:20MasseRI'd say way better than clojure
10:20pyrwhen you define lein plugins externally
10:21babilenMasseR: Ah, thanks for mentioning that - seems as if I remembered it wrong. (I use Emacs/viper and vim, but prefer vim where possible)
10:22MasseRbabilen: 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:23babilenMasseR: I must have messed it up then :) -- Do you have your configuration online somewhere?
10:23MasseRbabilen: github MasseR/dotvim
10:24babilenMasseR: thanks, prepare to be cloned and diassembled ;)
10:29pyranswer is yes, by using dev-dependencies
10:30pyr(corollary, don't forget to lein deps which was my mistake)
11:44robbe-Any specific reason why nested #('s are not allowed?
11:45robbe-Or "#()s" as they are written by the compiler. :)
11:47tufflaxrobbe- maybe because the argument names would get used up
11:49thorwil,(macroexpand-1 '#(identity %))
11:49clojurebot(fn* [p1__8138#] (identity p1__8138#))
11:49arohnergah. Why is there no way to concat regexes?
11:50thorwilhmm, not enlightened. but it has to be about the argument names
11:50robbe-tufflax: Fair enough I guess, price payed for the shorthand. (cfr scheme lambda for example)
11:52tufflaxarohner ##((comp re-pattern str) #"," #".")
11:52lazybot⇒ #",."
11:52arohnertufflax: thanks
11:57abedrachouser, I am moving c.c.zip-filter into data.zip
11:58abedrachouser, do you mind if I turn the asserts and comments at the bottom into actual tests?
12:03chouserabedra: that would be awesome, thanks!
12:05abedrachouser, cool, consider it done
12:11arohnerabedra: there's one bug fix that should go in to c.c.zip-filter / data.zip
12:12arohnerabedra: in zip-filter.xml/tag=, the line containing ((zip/node %) :tag) should be flipped to (:tag (zip/node %))
12:12arohnerabedra: that allows data.xml to work with zip-filter
12:44iceyIf anyone is bored, how can I make this code better? https://gist.github.com/1164308
12:45iceyI think I'm going to use dnolen's Enlive tutorial to replace hiccup for this
12:51thorwilicey: 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:52iceythorwil: interesting; do most people use hiccup for smaller projects like this?
12:52thorwilif you do it all yourself, you will just write _more_ with enlive instead of hiccup
12:52thorwilicey: i have no statistics on that ;)
12:52iceythorwil: hah, fair enough
12:53thorwildefn- ?
12:57iceythorwil: i'm not sure where i picked that habit up from; is it not normal to create private functions in projects?
12:59thorwilicey: you probably do right, it's just i never noticed defn- before 0.o
13:33amalloyScorchin: i like (remove (comp #{something} :key) list-of-maps)
13:44r0manhello. does someone know a fn in contrib/contrib that takes 2 seqs that represent
13:44r0manargument lists (that may include destructuring) and returns a somehow
13:44r0man"combined" argument list? something like: (merge-args '(a1 & {:keys [b1 b3]}) '(a2 & {:keys [b2]}))
13:44r0man;=> '(a1 a2 & {:keys [b1 b2 b3]})
13:48amalloyr0man: the connection between those two inputs and the output is quite tenuous. i would be extremely surprised if anyone had written that already
13:50r0mani'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:58amalloythe 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:59amalloyor, better, make the user pass in the new arglist they want
14:37abedraarohner, cool, I'll file that as soon as the library is converted
14:42robbe-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:42robbe-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:43raekall reads from refs inside a transaction will happen as if they all happened at the same point in time
14:43raekthe STM takes care of this
14:44dabdI'd like to parse an html page using clojure.xml/parse. The following code does not work (clojure.xml/parse "http://www.google.com/&quot;) What is the proper way to do it?
14:44arohnerdabd: you need an HTML to XML parser, like tagsoup
14:44dabdThe docs say clojure.xml/parse accepts an uri
14:44ibdknox_dabd: use tag soup ;)
14:45dabdok let me check
14:45dabdthere is a library called enlive does it work for this?
14:46arohnerdabd: https://gist.github.com/1168833
14:46ibdknox_depends on what you're trying to do
14:46ibdknox_arohner, dabd: or better than that: https://github.com/nathell/clj-tagsoup
14:47dabdibdknox I am getting it from clojars thx
14:47dabdclj-tagsoup seems to simplify using tagsoup
14:59abedrachouser, ok data.zip just had a 0.1.0 release
14:59abedrachouser, the comments were all converted to tests
14:59abedrathere were two that were testing things that didn't exist anymore
14:59abedrachouser, and two that are failing
14:59abedraI left those in place with a comment
14:59abedrafeel free to cut them if necessary
15:00mrBliss`abedra: https://github.com/clojure/clojure/blob/master/changes.txt#L282 should be "InterruptedHandler" instead of "Interrupt Handler", like in the ToC
15:01abedramrBliss`, thanks for the heads up
15:03ldhspeaking 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:06thorwilldh: nth-of-type?
15:09thorwilin my now left to rot enlive-using code, i have selectors like this: [[:span (html/nth-of-type 1)]]
15:10ldhthorwil: 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:11ldhi'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:11thorwilldh: i don't recall the why, but i think the [[ ]] is what you should try ;)
15:11ibdknox_I love the idea of enlive, but I feel like the syntax needs to be simpler
15:12ldhthorwil: weirdly, (html/select markup [[:img (html/nth-of-type 1)]]) returns BOTH images
15:12ibdknox_ideally it would just follow the standard selector syntax, and it could parse it into those vectors as an implementation detail
15:12thorwilldh: this is the single place where i used nth-of-type: http://paste.pocoo.org/show/463819/
15:12ldhibdknox_: 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:14thorwilibdknox: well, much of the selectors is just like CSS
15:14thorwilwhere you might see things like: [:ul#stored-items :> :li]
15:15ibdknox_thorwil: yes, but you lose something by not having it in a string
15:15ibdknox_thorwil: and the way you use that selector is a far cry from the simplicity of something like jquery
15:15thorwilldh: 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:15ldhthorwil: your example doesn't seem to work for me. i wonder if there's a bug in 1.0.0
15:16ldhnow i am left to wonder why selectors *aren't* just strings
15:16ibdknox_hehe
15:17ibdknox_exactly
15:17thorwilldh: 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:17thorwilwhat can i say, after all i switched from enlive to hiccup :)
15:18ibdknox_hehe
15:18ldhwith such a simple toy example that does not bode well.
15:19thorwilldh: i'm not sure anymore, but nth-of-type is not global, but looks for siblings, perhaps?
15:19ibdknox_if only I didn't already have such a huge list of things to work on...
15:19ldhi'm actually trying enlive after using hiccup. i like the idea of unobtrusively modifying existing markup, especially when collaborating with others
15:19ldhthorwil: interesting thought, that would possibly explain the behavior i'm seeing
15:20thorwildon't make the mistake of testing right in the browser
15:20ldhhmm, but how to select without matching child elements as well
15:20ldhno, i'm running it at the REPL
15:22thorwilyes, 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:22ibdknoxjust use mustache! :D
15:22ibdknoxhttps://github.com/davidsantiago/stencil
15:29dabdhow 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:35acagleibdknox: 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:35ibdknoxacagle: we're using stencil and handlebars :)
15:36duck1123I 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:36ibdknoxacagle: though handlebars didn't adhere to the mustache spec :(
15:38hiredmanduck1123: one of your other dependencies is pull it in
15:39duck1123that's what I figured, but wouldn't my explicit dependency override it?
15:40ibdknoxduck1123: they're not both there?
15:40duck1123ibdknox: no, just 1.2.0
15:41ibdknoxgist of your project file?
15:41cemerickduck1123: 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:43amalloydabd: c.j.shell just executes a command and passes it args; the | syntax is something bash (and most shells) do for you
15:44dabdamalloy: thx
15:45amalloydabd: you can invoke bash instead, and pass it the args "-c" "echo 56.8 + 77.7 | bc", or something like that
15:56duck1123Ok, It looks like it was happening because I had Midje set as a runtime dependency
15:57duck1123as soon as I moved it to dev-dependencies, it worked
15:59cemerickduck1123: 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:00cemerickThat's a fixed version range, allowing two versions of Clojure, and only those two versions.
16:01duck1123that makes sense. I have a patched version of Midje that works with 1.3 on my home computer. I'll just grab that
16:39hiredmandnolen: https://thestrangeloop.com/sessions/the-mapping-dilemma nice
16:41dnolenhiredman: yeah should be fun!
16:42ubiianybody have an idea how many folks they expect at Clojure/conj this year?
16:42RaynesI'm going. That's all that really matters, isn't it?
16:42Raynes;)
16:44jolyThey're still doing early-bird registration, so there's probably not a good estimate available yet
16:44ubiihow many did they have last year?
16:44ibdknoxthey haven't even announced speakers yet :-p
16:45cemerickubii: ~200
16:45cemerick225 incl. speakers and such
16:46ubiithx
16:46ubiigot tied up with work last year, so I didn't get to go, but am thinking of going this year
16:48ubiialso considering the possibility of taking the associated training class on Nov 7-9th
16:52ubiijust curious, is this basically the same class offered through The Pragmatic Studio or is the Clojure/core folks doing this on their own?
17:04SomelauwI 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:05hiredmanSomelauw: if filter took multiple seqs (filter = [1 2 3] [4 2 4]) would return (2)
17:05lobotomy_##(map = [1 2 3] [4 2 4])
17:05lazybot⇒ (false true false)
17:06nkozawhen 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:08lobotomy_##(map #(when (apply = %&) (first %&)) [1 2 3] [4 2 4])
17:08lazybot⇒ (nil 2 nil)
17:08lobotomy_hmm
17:09hiredmannkoza: equality is very complex, but yes, in the case of comparing two maps you walk the maps
17:09hiredmanwell, two clojure maps
17:09Somelauwhiredman: You are right.
17:10cemerickn is likely to be smaller than you think, due to hashCode caching
17:10SomelauwOh, I think I understand why now.
17:11nkozahiredman: why is complex?
17:15hiredmannkoza: 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:15nkozahiredman: thanks
18:06agzhey what kind of database library would you suggest for personal use in unix enviroment?
18:08dnolenagz: sqlite?
18:09agzdnolen: 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:09agzso I though ask the wise gremium here :)
18:09tufflaxspit and slurp with pr and read-string?
18:10agztufflax: haha :D -> although maybe you are wright, I will have data of 200Mb max
18:11agzin sqlite format it was 100Mb .. but it's outdated now so I can't use that
18:11agzhow much will it be in plain text?
18:11tufflaxdunno
18:20amalloy0 bytes if you use an optimal serialization format
18:20amalloy(defn unserialize (constantly {:x 1, :y 2, ...}))
18:21amalloys/defn/def
18:21lazybot<amalloy> (def unserialize (constantly {:x 1, :y 2, ...}))
18:36leedaIs this the right way to base64 encode a string?
18:36leeda,(str (.encode (new Base64) (to-byte-array "abc")))
18:36clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: Base64, compiling:(NO_SOURCE_PATH:0)>
18:37leedaok, have to import org.apache.commons.codec.binary.Base64 and clojure.contrib.io first...
18:42leedaor maybe: (str (.encode (new Base64) (.getBytes "abc"))) ?
18:46leedahm, i guess (str x) != (new String x)
19:02ibdknoxleeda: unrelated, but it's more idiomatic to use the . notation for instantiation: (Base64.) or (String. x)
19:37iceyibdknox: 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:37iceyibdknox: here's all the code (it's not much - https://github.com/pmn/cljstrial )
19:37ibdknoxicey: yeah, use cljs-watch instead
19:38iceyibdknox: ah, will do, thanks :)
19:38ibdknoxicey: 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:38iceyibdknox: it's something you've seen before?
19:38ibdknoxicey: yeah
19:38ibdknoxicey: apparently the cljs compiler doesn't like being in a jar
19:38iceyibdknox: that makes me feel a little bit better, lol
19:39iceyit was pretty nice to get everything packaged up straight out of clojars
19:39ibdknoxI know. I tried :(
19:39scottjibdknox: are you aware cljs-watch creates a dir bootstrap.js if run before there are .cljs files ?
19:39ibdknoxI fixed that I think
19:39scottjnot pushed
19:40iceyibdknox: btw, i implemented your suggestions from that page i posted in here the other day; it ended up looking much cleaner afterwards, thanks :)
19:40ibdknoxscottj: you are correct. One second :)
19:40ibdknoxicey: I'm glad :)
19:41scottjibdknox: no hurry I don't need it just fyi
19:42ibdknoxit was my own fault expecting the Java api to be smart enough not to create a directory out of a file name
19:42ibdknox*sigh*
19:43ibdknoxscottj: pushed anyways :)
19:44ibdknoxI also made the watcher more resilient to parsing exceptions, so it doesn't quit when you save intermediate states of your file
19:45scottjnice, it's annoying how the repl bails on those errors
19:45ibdknoxbrepl fixes that too
19:46ibdknoxof course then you're in the browser, so may not be what you really want, but just heads up
19:48scottjbrepl should print a file:// url to the index.htlm so you can just click on it
19:49ibdknoxyour terminal hyperlinks links?
19:49ibdknoxhah
19:49ibdknoxcool
19:49ibdknoxscottj: I'll do that
19:50scottjalso I don't like that you changed the clojure repl prompt format :)
19:50ibdknoxI did it on purpose, since it's not the clojure repl and it behaves differently than the clojurescript repl likely ever will
19:51amalloyibdknox: your terminal doesn't? what OS?
19:52ibdknoxamalloy: 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:53amalloyheh, i hear you. if i could figure out how to cut/paste from the terminal emacs-style without the mouse...
19:53ibdknoxyeah that has always bothered me
19:53tomojibdknox: nice!
19:53tomojI hadn't seen cljs-watch
19:54ibdknoxtomoj: as far as I can tell it works for everyone, so I'm happy about that lol
19:54scottjwith urxvt you can folow the hyperlinks with keystrokes conkeror hinting style
19:54tomojwha?
19:54tomojI've been using urxvt and never knew
19:55ibdknoxI really wish I could get noir-cljs to work consistently
19:55tomojeverything should work like conkeror
19:55ibdknoxwhen I stop being lazy, I'll submit a patch to get cljs-watch into clojurescript itself
19:58scottjyou can also copy with keys using screen
19:58iceyibdknox: switching from noir-cljs to cljs-watch did the trick. everything's rock & roll now. thanks
19:58ibdknoxicey: good deal, let me know if you run into any issues
19:59amalloyscottj: i confess i'm barely competent with screen. opening multiple terminal emulators is just easier
19:59iceyibdknox: 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:59scottjamalloy: it's not emacs style though, it's vi
19:59ibdknoxicey: haha good luck ;)
19:59ibdknoxicey: nah, pinot should make it relatively painless. Though if you have errors, it can be very difficult to track them down
19:59amalloyscottj: the default C-a screen prefix makes me want to rip someone's throat out
20:00scottjibdknox: what's the plan for returning the result in brepl not the browser?
20:00scottjcljs browser branch style
20:01scottjamalloy: 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:01amalloyof course. but it prevents me from using the dang shell prompt, because i navigate around that with C-a as well
20:01scottjoh yeah I've gotten pretty used to C-a a
20:02ibdknoxscottj: I expect brepl to eventually no longer be necessary
20:02amalloyheh
20:02amalloyon the rare occasions i remember to use screen, i just use C-z
20:02ibdknoxscottj: I also think it's more valuable to have the result in the browser, since I can then inspect objects and such
20:02scottjamalloy: actually do C-a a a pretty often since I run screen's inside of screens
20:03amalloyi'm pretty sure that makes you a lunatic
20:04ibdknoxhaha
20:04scottjibdknox: see if you used emacs you'd change your mind on both the prompt and return values I think
20:04amalloynot sure if that means: "It's a thing that lunatics do", or "If you do it, you become a lunatic"
20:04ibdknoxscottj: I can't inspect a dom object in emacs
20:05scottjsince it would allow you to use inferior-lisp and C-x C-e expressions from your code
20:05scottjibdknox: you return it in both places :)
20:05scottjkeep current return but also send it back to brepl
20:05ibdknoxyep yep
20:05ibdknoxI did that originally
20:05ibdknoxit didn't do well with it
20:05ibdknoxsince the result is often a long javascript function
20:06ibdknoxthat needed to be broken up over multiple websocket frames
20:06ibdknoxyou have to keep in mind brepl was done in a night + a couple hours the next day :)
20:06ibdknoxI had originally expected to help with the official clojurescript bcrepl
20:09scottjrequire and fault tolerance are the things I really like over bcrepl
20:11ibdknoxto be honest, I find it easier to not use the repl in this case
20:11ibdknoxit's easier to just let the watcher recompile the thing and refresh
20:41agzhey guys, my agents are lost:
20:41agz(def a (agent []))
20:41agz(send a conj 1)
20:41agz(await a) <-- and no return
20:42amalloymaybe someone called shutdown-agents?
20:42agzlein swank clojure 1.2.1 contrib 1.2 fetcher 0.5-SNAP clj-time 0.4-SNAP
20:42agzuhm googling shutdown-agents
20:43agzwhat I observed, that with a fresh restart of the server it still doesn't work - maybe fetcher did shutdown?
20:43amalloyfetcher?
20:43agzhttps://github.com/getwoven/fetcher/blob/master/project.clj
20:43agzhttp grabber
20:44amalloyholy...i just saw the (ns) statement in fetcher.core
20:45ibdknoxwow
20:45agzshutdown agent is not called - if I write the above in the fresh interpreter the
20:46agzthe idleing occur.. :(
20:47agzis there an easy way to print the threadpool or sg?
20:51agzdohh .. 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:55agzreboots
21:00agzhey I've lost my agents, a bit desperate here ,D
21:00agz(def a (agent [])) (send a conj 1 2 3) (await a) <--- hangs
21:04cemerickthat ns form is out of control. Something went pear-shaped there.
21:07agzif I lein-swank a totally different project with no dependencies other than clojure I still got this misfunction
21:08agzI 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:09ibdknoxagz: did you install it as a plugin?
21:11agzibdknox: no.. I lein install -
21:11ibdknoxagz: it shouldn't pick it up then
21:11ibdknoxbut the simplest way to prove that
21:11ibdknoxis to remove ~/.m2/repository
21:12ibdknoxagz: then check to see what's in ~/.lein
21:16agzibdknox: I cleaned .m2/repository
21:16agzwith lein deps it downloaded a new clojure
21:16agzbut still not working .. is it possible that it's problem with the jvm?
21:17ibdknoxno idea
21:17agzibdknox: anyway thx
21:17ibdknoxmost likely has to be given that you just removed everything specific to clojure right there, assuming you've only used lein
21:18agzbtw I have lein-1.4.2 and lein-1.6.1 in ~/.lein
21:18agzdont is it have any effect
22:41technomancyagz: you need swank 1.3.2 which plays well with lein's workaround for Clojure's lack of control over thread pools
22:45technomancyoh, he's gone
22:47quotemstrIs the Java 7 dynamic language stuff good for Clojure?
22:53technomancyquotemstr: sorta. afaict it can make calls that would otherwise be reflective significantly faster, but not as fast as if they were hinted
22:54quotemstrAh, cool.
22:54quotemstrI'll have to read up on the details sometime.
22:55technomancyquotemstr: so there's reluctance to drop compatibility with java 6 or add two modes to the compiler since it's not pure awesome
22:56quotemstrtechnomancy: 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:57technomancywell, 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:57sridcan I define multiple entry points instead of the singular `lein run`?
22:57sridit seems that project.clj can only contain one :main entry
22:58sridi want to define one entry for running the web app, and another for running the command line interface.
22:59technomancysrid: lein run -m my.name.space # ought to do it
23:00amalloythanks, 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:26iceyibdknox: 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:45technomancybizarre: 3x as many python refugees in haskell vs former rubyists, while they are neck and neck with clojure
23:47iceytechnomancy: because of significant whitespace, maybe?
23:47technomancyicey: 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:48iceytechnomancy: also very possible
23:48iceytechnomancy: are there many perl people getting into haskell?
23:49technomancyicey: only 6% vs 10% ruby and 28% python
23:50iceyother 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:51technomancythe type system, I guess?
23:51technomancyit's a lot stricter than ocaml/scala about purity