#clojure logs

2012-09-30

00:03cjfriszmpan: You could certainly do that
00:03cjfriszmpan: I think capslock-to-esc in vim is a way better idea
00:04UrthwhyteJj is my preference
00:04UrthwhyteRarely typed and on home row
00:04cjfriszHmm
00:04cjfriszI'd have to try that one out
00:04mpanwait, huh?
00:05mpanyou rebound J to ctrl?
00:05mpandoes that not break everything else you want to do?
00:05cjfriszI think he meant for vim
00:05cjfriszWait...
00:05cjfriszNo, still think that might be a good idea
00:06UrthwhyteDepending on what your repeat is set to, jj works
00:06UrthwhyteLet let check the line
00:09Urthwhyteinoremap jj <Esc>
00:16davejacobsi'm having session problems in compojure. i'm using the compojure.handler/site macro to wrap my routes, and my understanding is that that should provide the correct binding for session inside defroutes
00:17davejacobswhy am i getting "Unable to resolve symbol: session" inside defroutes?
00:19davejacobsit seems like the ways in which the session is handled have changed so the docs aren't easy to follow
00:21duck1123Does anyone know how in waltz I can trigger an event, but only if the state machine is in a set of states? (connection opened state)
00:24duck1123I wonder if I should just build up a queue of pending events that'll fire as soon as the connection is back in an idle state
00:27cjfriszI think I might be too proud of the piece of code I just wrote
00:27cjfriszNo, not too proud
00:27cjfriszJust gloating about it too much
00:27cjfriszCuz it's a really awesome piece of code
00:27duck1123link?
00:27clojurebotyour link is dead
00:33cjfriszIt's probably not going to make sense out of context, but here goes: http://pastebin.com/xLdCQgxN
00:33cjfriszIt's really more what it does, which needs a blog post to explain
00:38duck1123that looks like a function you'd be really happy once it works right
00:39duck1123now it's probably time to break it down
01:30mpan&(disj [0 1 2 3] 1 2)
01:30lazybotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.IPersistentSet
01:31mpanwhoops
02:15spoon16best template language to use with noir? does everyone agree re: hiccup?
02:16RaynesWhatever is best for the problem you're solving.
02:16RaynesHiccup, Enlive, Mustache, etc.
02:17RaynesMustache and Enlive are good choices for when you have designers working on your html that don't know Clojure. It's also nice if you like keeping your html and Clojure separate.
02:17RaynesHiccup is the best option for in-code html generation.
02:18RaynesI'm personally a fan of mustache.
02:20spoon16I see
02:20spoon16I'll take a look, that sounds nice… I like using hiccup for generating partials
02:20spoon16but not the templates
02:23spoon16Raynes do you have any examples of actually using mustache on any of your github projects that I could look at/
02:29Raynesspoon16: refheap uses it exclusively for templating.
02:29RaynesNot going to say it is a canonical example though. My templates are due for a bit of a cleanup. ;)
02:30Rayneshttps://github.com/Raynes/refheap
02:30spoon16got it
02:30spoon16thanks
04:44ciccillociao
04:44ciccillo!list
08:48cemerickjonasen: In case you hadn't seen it: http://groups.google.com/group/clojure-dev/browse_thread/thread/a5242f3365149326
08:56jonasencemerick: I did see it. BTW, my post to the clojure-tools ml seems to be stuck in moderation
08:57cemerickjonasen: I green-lighted you right after you sent it. It showed up in my inbox…?
08:58jonasenhmm... I don't see it at https://groups.google.com/forum/#!forum/clojure-tools
08:58cemerickhuh, so it isn't
09:00piranhaeh... so guys can somebody tell me how do you manage data in clojurescript? I mean if you have semi-complex application, which fetches some data from server and then combines with data from user, and needs to show it in various ways. I don't want to put it in DOM, so I could go with some atoms. But having too much atoms is not really nice, is it? If I have like hundred similar objects, should this be one atom? Or maybe single atom for all dat
09:00piranhaa? And then some system to notify those who subscribed about updates?
09:01cemerickjonasen: feel free to resend
09:04jonasencemerick: I wrote it with the google groups web interface so I don't have it anymore.. I'll just rewrite it then.
09:05cemerickjonasen: in that case, it may yet show up; I've seen latencies up to 2 days through the web interface
09:06cemerickjonasen: I can forward your email back to you…
09:07jonasencemerick: Please do, and I'll resend it immediately
09:07cemericksent
09:10jonasenOk, it arrived to google groups.. Thanks cemerick!
09:52raek_jonasen: fyi, I received two mail from you via the clojure-tools list, one yesterday and one today
10:23bonegapiranha: I would go for atoms. The granularity depends on the logical context/performance needs
10:25piranhabonega: sure, I'm just thinking that I have to manage them somehow so I'm seeking if there is any work was done in this direction
10:25piranhaI'm also wondering if having one single big atom will hurt performance too much
10:27bonegaWell, one of the reasons for using multiple atoms are non-stalling writes
10:27bonegain clojurescript I think we still only have one thread
10:28bonegaBut I'm not well versed in clojurescript internals...
10:28bonegaer..
10:28bonegahum
10:29bonegaI see we are not talking about refs
10:44piranhabonega: well, there is one thread, so there can't be any race conditions, hehe
10:45piranhaor whatever :)
11:35devthi'm trying to format a collection as a string (using map and string join) but need to know if i'm on the last item in the collection. is there an idiomatic way to do that?
11:37zamaterian@find lamda
11:37zamaterian@find lambda
12:13SrPxThe lein vimclojure command stopped working... I've installed lein-tarsier and used it once, but now it won't work. http://pastebin.com/iBjveurv any idea?
12:34SrPxnvm got it
12:35benny__SrPx, what is that for a command? my ubuntu packaged lein doesnt have it
12:36SrPxlein vimclojure if I understood runs a vimclojure server (?) or something that magically enables clojure repl and stuff on vim
13:03SrPxAnyone has an idea what this means? java.io.FileNotFoundException: Could not locate clj_webdriver__init.class or clj_webdriver.clj on classpath: at clojure.lang.RT.load (RT.java:432)
13:05SrPxI have added [clj-webdriver "0.5.1"] to my project. restarted "lein vimclojure". it even downloaded clj-webdriver. but calling (require 'clj-webdriver) makes this error show
13:06xeqiSrPx: did you want (require 'clj-webdriver.taxi) ?
13:07SrPxxeqi: actually I have tried (use 'clj-webdriver.taxi), (use 'clj-webdriver), same with require, and other combinations, and it did not work. I tried again just after asking and it miraculously worked.
13:08SrPx(?) but thanks
13:33edengler2Howdy, having some issues using unquote-splicing and map. Basically, trying to figure out why it appears map does a check for an even number of arguments before unquote-splicing is applied, ie, why `[:client {~@[1 2 3 4]}] fails, yet `[:client {~@[1 2 3 4]}] and `[:client {~@[1 2 3 4]}] and `[:client {~@[1 2 3 4]}] all work
13:33edengler2The docs all seem to indicate that unquote-splicing in a map should lead to a (apply hash-map ...) construct.
13:33edengler2Whoops, ,my examples failed to copy, give me a sec
13:34edengler2... why `[:client {~@[1 2] ~@[3 4]}] and `[:client {~@[1] ~@[2 3 4]}] and `[:client {~@[1 2 3 4] ~@[]}] all work
13:37raek,'`[:client {~@[1 2 3 4]}]
13:37clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Map literal must contain an even number of forms>
13:37raek,'`[:client (~@[1 2 3 4])]
13:37clojurebot(clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list :client) (clojure.core/list (clojure.core/seq (clojure.core/concat [1 2 3 4]))))))
13:38raekedengler2: the error comes from the reader.
13:39raekor wait...
13:39raek,'[:client (~@[1 2 3 4])]
13:39clojurebot[:client ((clojure.core/unquote-splicing [1 2 3 4]))]
13:39raek,'[:client {~@[1 2 3 4] :dummy}]
13:39clojurebot[:client {(clojure.core/unquote-splicing [1 2 3 4]) :dummy}]
13:41raekedengler2: I think the reader first reads the syntax quoted expression and then transforms it. But in your case the "inner" expression is not valid
13:41edengler2I guess I am asking the question why the reader is doing a check for even number of arguments before full macro expansion?
13:42ChongLiit's eager?
13:42raekfor ordinary macro expansion that's definitely the case
13:42edengler2It looks if I can fake it out by providing an additional dummy unquote-splicing, but it seems odd
13:42raeka macro is implemented as a function that take and return clojure data
13:43raekreading is just one way to construct that data
13:43raekso a workaround in your case could be `[:client (hash-map ~@[1 2 3 4])]
13:43edengler2For example, I do get a bad mapping if I provide an odd number of elements for the mapping (ie, there is an additional post-check), `[:client {~@[1 2] ~@[3]}]. I would have thought only this check would be done.
13:45edengler2For the workaround, I was thinking of `[:client {~@[1 2] ~@[]}], ie, add an extra expansion for the reader, but adds no new entries to the eventual expansion
13:45raekthe problem is that the macro expander needs valid clojure data structures as its input
13:46raek,[:client {~@[1 2] ~@[]}]
13:46clojurebot#<IllegalStateException java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core/unquote-splicing>
13:46raek,'[:client {~@[1 2] ~@[]}]
13:46clojurebot[:client {(clojure.core/unquote-splicing [1 2]) (clojure.core/unquote-splicing [])}]
13:46edengler2Ok, so I guess adding the extra dummy entry is the way to go
13:47raekI would go with `[:client (hash-map ~@[1 2 3 4])]. In that case the intermediate forms make sense too
13:47raek,'[:client (hash-map ~@[1 2 3 4])]
13:47clojurebot[:client (hash-map (clojure.core/unquote-splicing [1 2 3 4]))]
13:49raekor perhaps you could simply do this: `[:client ~{1 2 3 4}]
13:50edengler2Unfortunately, `[:client (hash-map ~@[1 2 3 4])] doesn't end up at the same spot, my entry of `[:client {~@[1 2 3 4] ~@[]}] ends up with [:client {1 2, 3 4}] rather than [:client (clojure.core/hash-map 1 2 3 4)]
13:50raekwhat do you mean by "end up at the same spot"?
13:51edengler2Ie, equivalent to `[:client {1 2 3 4}]
13:51raek{1 2, 3 4} means the same thing as (clojure.core/hash-map 1 2 3 4) when evaluated
13:52edengler2Will give it a try, but all of this is interacting with other libraries for XML and JSON
13:53raekedengler2: how is the "1 2 3 4" data represented when you receive it in your case?
13:53edengler2Ie, the other libraries are processing the output of the above expansion, and looks like they do not like the clojure.core/hash-map
13:53raekah, you are generating data and not code?
13:53edengler2For example, in one place I am trying to generate attributes that depend if they exist.
13:53hfaafbcode is data!
13:54hfaafb:p
13:54raekedengler2: I think it would be even simpler to just build the map before you splice it in
13:55edengler2raek: Possibly, Any, thanks for the help!
13:55raeklike `[:client ~(...code that builds the map...)], possibly using (into {} (for ...)) or (zipmap ...)
14:00SgeoWould it be a bad idea to use Hiccup for non-HTML?
14:01SgeoI saw somewhere that it has issues generating arbitrary XML?
14:01augustlSgeo: iirc it has special knowledge of some HTML tags, not sure if that's configurable
14:01SgeoSomething about namespaces IIRC
14:01SgeoI should note that I know little about XML
14:03augustlI'd imagine you could support that in hiccup quite easily
14:03augustlsomething like [:nynamespace :tagname {:attrs "here"} "contents here"]
14:08yankovis there a fast way to concat seq's elements into one string? apply str works slow if you got big list
14:13Frozenlockyankov: clojure.string/join perhaps
14:14yankov,(time (clojure.string/join (range 10)))
14:14clojurebot"Elapsed time: 0.171213 msecs"
14:14clojurebot"0123456789"
14:14yankov(time (apply str (range 10)) )
14:14yankovoops
14:14yankov,(time (apply str (range 10)) )
14:14clojurebot"Elapsed time: 0.144494 msecs"
14:14clojurebot"0123456789"
14:15yankovlooks like join is even slower a bit
14:19FrozenlockIndeed. I get in the 0.0X msecs when using it with string directly though. Btw, what kind of performance are you looking for?
14:27xeqi,(time (let [x (StringBuilder.)] (doseq [s (range 10)] (.append x (str s))) (.toString x)))
14:27clojurebot"Elapsed time: 0.301244 msecs"
14:27clojurebot"0123456789"
14:27xeqiheh, not that timing with clojurebot is accurate
14:48Moses_Hi, I'm looking for an open source web app example with a good test suite. I want to learn how to properly write tests for web apps in clojure. Anyone know of any projects that could be used for this?
14:49_ulisesMoses_: what level of testing are you after?
14:50_ulisesMoses_: you may want to look at the tests for clj-webdriver
14:50_ulisesMoses_: if you're using noir, you can look at the util.test namespace as it has many useful functions there for testing
14:50Moses_Wow, okay thank you _ulises
14:50Moses_I'm using Compojure, think that util.test is still releveant?
14:51_ulisesMoses_: in any case, depending on the level of testing you're after, most webdev libraries deal with functions that return a map with the response, so it's a case of checking those maps for what you want
14:51_ulisesMoses_: indeed
14:51weavejesterMoses_: There's ring-mock for creating request maps
14:51xeqiMoses_: I created kerodon for clojars's test suite
14:52SrPxSo, in clojure, can I create a function with 2 separed definitions, in a way that (foo obj_1) and (foo obj_2) will return 2 different values?
14:52Moses_Thank you weavejester and xequi, I'll check those out
14:53_ulisesSrPx: I don't know but I wouldn't think so
14:54xeqiSrPx: maybe multimethods or protocols
14:54SrPxWell I need a 'character' class, and a (image my-char-instance) that will return the character's image. What is the clojure linguistic approach to this?
14:55Moses_I know you can do this (defn ([x] &body) ([x y] &body)) but I don't know if that's what you mean SrPx
14:55SrPxWould the instance of the character be a simple hash with {:type "character"} and image a function inside it like {image my-f} ?
14:55_ulisesSrPx: I was about to suggest multimethods
14:55_ulisesSrPx: if that's the case, you can dispatch on :type
14:55SrPxwhat is :type ?
14:56SrPxCan I dispatch in other things ? Like the value of a key
14:56_ulisesSrPx: yes, that's what I meant by :type
14:56_ulisesSrPx: remember that keywords are functions
15:00SrPxJust compiled the line 4, (derive :square :shape), got an error, http://o7.no/R54Hm0 , any idea ?
15:01SrPxjava.lang.AssertionError: Assert failed: (namespace parent)
15:01SrPxassert failed, namespace parent? hm
15:01gfredericksSrPx: maybe you can only derive namespaced keywords?
15:01gfrederickse.g. (derive ::square ::shape)
15:02SrPx:: ?
15:02_ulisesSrPx: this is what I meant by :type and multimethods https://www.refheap.com/paste/5399
15:02gfredericksSrPx: ##::foo
15:02gfredericksSrPx: ##(identity ::foo)
15:02lazybot⇒ :clojure.core/foo
15:02gfredericksit expands into a namespaced keyword in the current namespace
15:02gfredericksso you could also type out :my.ns/foo if you wanted to
15:03SrPx##(identify ::foo) ?
15:03lazybotjava.lang.RuntimeException: Unable to resolve symbol: identify in this context
15:03SrPx##?
15:04SrPx##::foo
15:04gfredericks## just triggers lazybot
15:04SrPx##(identify ::foo)
15:04lazybotjava.lang.RuntimeException: Unable to resolve symbol: identify in this context
15:04SrPxwhy it does not work with me
15:04xeqi## = inline lazybot eval, & = standalone lazybot eval
15:04gfredericksyou're using identify instead of identity
15:04SrPxohh sorry
15:04gfredericks,::foo
15:04clojurebot:sandbox/foo
15:09SrPx,(isa? java.util.HashMap ::collection)
15:09clojurebotfalse
15:13SrPx_ulises: I dont get it, (defmulti foo :type) ? :type ? Was not it supposed to be a function ?
15:13SrPxOh wait
15:13SrPxkeywords are functions that work on hashes right
15:14_ulisesSrPx: exactly :)
15:14SrPxI get it now! Great!
15:15SrPxActually this is awesome, thanks!
15:15_ulisesSrPx: you can have any function you want instead of :type
15:15_ulisesSrPx: as long as you have matching values instead of :image and :character
15:16_ulisesSrPx: using class as dispatch function will give you the type dispatch you'd expect in Java for instance
15:16SrPx_ulises: so this does not even need derive etc
15:16SrPx_ulises: sorry, using class? What?
15:17_ulises##(class "foo")
15:17lazybot⇒ java.lang.String
15:17_ulisesSrPx: that ^^^^
15:18SrPxso you mean I can .. hmm like, make like, (defmulti inverse class) (defmethod inverse java.lang.String [] ...) to extend java types?
15:19_ulisesSrPx: not extend java types, but dispatch based on them
15:19SrPxhmm but why?
15:19_ulisesSrPx: that's what you wanted to do originally?
15:19_ulisesSrPx: I mean, that was your original question
15:20_ulisesSrPx: on a second read, you weren't asking specifically about java types
15:20_ulisesSrPx: but that's the usual answer "have a Type1 and a Type2 and then overload based on that" etc.
15:20SrPxI see!
15:23SrPxShould I use keywords, symbols or strings to define the type of my object? {:type :character}, {:type "character"}, etc?
15:24gfredericksusing namespaced keywords gives you the derive functionality you were looking for earlier
15:24gfredericksotherwise regular keywords are probably fine
15:25gfredericksif there's any chance this 'type' will be mixing around in other systems then namespacing is safer
15:29SrPxHmm
15:30SrPxOK, thank you very much.
15:30SrPxUnrelated question, is it possible to make a macro such as $test becomes (foo test)? This would be an reader macro, right? I know clojure does not have those, but I have heard it is possible to implement with some hacking
15:30SrPxa reader*
15:32gfredericksSrPx: I'm not sure what the essence of what you're describing is. it's the '$' expanding, so that $bar becomes (foo bar)?
15:33SrPxYes, specifially, I'd want $something to expand to a function that would select a html element with id=#something
15:33gfrederickswell with a few more characters you could do ($ :something), but that just sidesteps the question
15:34SrPxI know, I'm fine with ($ :something). Just wondering if it would be possible
15:34gfredericksI think the only way to get that kind of concision is if you wrapped your whole code in a (regular) macro that did the replacement; e.g. with-dollar-selectors
15:39SrPxHmm I see.
15:40gfredericksthat's the main limitation of macros; you can do damn near anything, but it has to start with a parenthetical s-expression
15:54SrPxWhy it does not provide a reader macro?
15:54SrPxThey are so powerful
15:54gfredericksfear of messy syntax?
15:54SrPxClojure would be perfect with them
15:55SrPxbut you should not deny power to the programmer, it is the fundamental of the lisp spirit
15:55SrPx):
15:56gfrederickswhat about libraries?
15:56SrPxwhat?
15:56clojurebotWhat is meta
15:56gfredericksyou could get two libraries that both define the same reader macro
15:57SrPxLibraries should be discouraged to use them, but you should allow the programmer to define it for personal use if he wants to
15:57SrPxlibraries can define the same macro anyway, right?
15:57gfredericksno they're always defined in namespaces
15:58casionthere is one thing I've learned from using C a lot… if you allow people to do something, even if you strongly advise against it, they will do it
15:58casionand they will do it a lot
15:58casionand they will defend their right to do it
15:58casionand everyone fucking hates it
15:58casionincluding, eventually, the person who did it
15:58gfredericks:)
16:00casionSrPx: http://clojure-log.n01se.net/date/2008-11-06.html
16:01casionstarting at 18:39
16:02gfrederickscasion: (you can link directly to the 18:39)
16:02casiongfredericks: oh…
16:02casioni hate websites that have things like that essentially hidden :|
16:03steven123posted a question on stackoverflow: why do bindings in REPL not work? http://bit.ly/TX6NKJ
16:03casionwhen will people learn that not everyone uses a mouse to browse the web
16:03steven123can anybody help?
16:09SrPxI'm so sad reading that log
16:09SrPx AWizzArd: rhickey: I don't want to convince anyone that reader macros are a good idea in general. But I think that you can't forsee everything, and people might come into situations where 1 or 2 reader macros are really helpful
16:09SrPxTo be honest I would live of reader macros for building my own syntax on top of lisp
16:10SrPxI've chosen clojure over cl for many reasons, but the lack of reader macro thing really hurts me ):
16:11SrPxI don't see why you couldn't implement namespace stuff over reader macros, also
16:11mpanclojure convinced me to try a lisp outside an academic context with its interop
16:13gfredericksSrPx: because once you have to specify the namespace of your reader macro you lose all the concision
16:13SrPxit is awesome but having to write ($ "#myid") instead of $myid all around, for example, is a huge difference to be honest
16:14gfrederickschouser had an interesting idea though
16:14SrPxgfredericks: I dont understand it well, if you can define a macro for ($ something), why cant you define a reader macro for strings starting with $? $something
16:15gfredericksoh hmm...what if you could do (ns foo (:reader-macros [some.lib/$ :as $])), and then it would only apply for your namespace
16:20SrPxsomething like that, I'm not sure, but I'm positive it's possible
16:21SrPxit is the same thing in essence, just that it is a string preceding a symbol, instead of the first string in a s-expression
16:23yankov,(count ( time (map str (range 10000))))
16:23clojurebot"Elapsed time: 0.05503 msecs"
16:23clojurebot10000
16:24spoon16/reload style
16:24yankov,(count ( time (apply str (map str (range 10000)))))
16:24clojurebot"Elapsed time: 33.012849 msecs"
16:24clojurebot38890
16:24yankovseriously.. is there a way to make the second one faster?
16:24gfredericksyankov: the first one doesn't do anything
16:25gfredericksthat's why it's so fast
16:25ivancan you not write some macro that turns every symbol that starts with $ into two forms?
16:25yankovgfredericks: ah..
16:25gfredericksivan: yeah but he'd need a top-level macro call
16:25ivanright
16:25gfredericks,(time (count (map str (range 10000))))
16:25clojurebot"Elapsed time: 23.317793 msecs"
16:25clojurebot10000
16:26gfredericks94% of naive clojure benchmarking just times a noop :)
16:26yankovhm..
16:27yankovanyway, there should be a way to use something instead of apply str. the thing is that server needs to convert seq into a one string before sending it to a client
16:28yankovand that ends up being kinda slow. like 1.5k op/sec for a list of 600 elements
16:28xeqi,(count (time (let [x (StringBuilder.)] (doseq [s (range 10000)] (.append x s)) (.toString x))))
16:28clojurebot"Elapsed time: 17.474309 msecs"
16:28clojurebot38890
16:28gfredericksxeqi: apply str already uses a stringbuilder
16:29gfredericksyankov: at the very least if you apply str you can get rid of the map str
16:29yankovdoes amount of arguments passed to str matter? maybe when I pass 600 args that makes it slow?
16:30gfredericksyankov: I wouldn't think so
16:31yankovhm, then it must be my map. in real code it's more complicated than just str
16:31yankovi just benchmarked it wrong
16:31gfredericksyankov: this is an http server? I wouldn't think you'd have to assemble a string before responding
16:31yankovgfredericks: not http. sort of custom protocol
16:32gfrederickseven so you ought to be able to do streaming
16:33yankovgfredericks: makes sense. i tried to send a separate response for each elements but it was very slow. but again, i could be doing it wrong
16:34yankovwill take a look, thanks
16:46spoon16stencile (https://github.com/davidsantiago/stencil) or clostache (https://github.com/fhd/clostache) for rendering mustache templates?
16:50xeqirefheap uses stencil, so I'd end up choosing it
16:52SrPxHow are :keywords used as functions? I mean how is it possible? I have read something about that but I forgot
16:53spoon16but why did Raynes choose stencil for refheap… I can't really tell the difference between the two except that the author of stencil implies that performance was important during his development and he has done some profiling
16:53spoon16I'm leaning towards stencil as well for that reason
16:53spoon16,(:test {: test "hello world"))
16:53clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Invalid token: :>
16:53jondot`seeing some new projects for android/clojure - anyone really doing this beyond just playing around?
16:54spoon16,(:test {:test "hello world"))
16:54clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>
16:54spoon16I'm terrible at using clojurebot
16:54spoon16,(:test {:test "hello world"})
16:54clojurebot"hello world"
16:56spoon16SrPx: keywords implement IFn with one argument (a map) and an optional second argument (a default value)
16:56spoon16SrPx: For example (:mykey my-hash-map :none) means the same as (get my-hash-map :mykey :none)
16:56spoon16SrPx: docs… http://clojure.org/data_structures#Data%20Structures-Keywords
16:57SrPxwhere is it implemented? hmm
16:57SrPxIFn?
16:58spoon16IFn is the Java interface that identifies functions in clojure
16:58spoon16anything that can be used in the operator position of a sexpression implements IFn
16:58spoon16Keyword is the Java type implemented by all :keyword instances you use in Clojure
16:59spoon16and Keyword implements IFn so it may be used as an operator
16:59spoon16SrPx: see the code https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Keyword.java
17:07nightfly_spoon16: Yay, that explains a very confusing error message I was getting the other day.
17:07jballancanyone know off-hand what repo/branch the Clojure+Lua work was in?
17:08spoon16nightfly_: cool, clojure makes way more sense if you spend the time to reference the github repo and really learn all the different data structures… I am still just beginning that process
17:34nkozaWhat's the simplest way to access a Java class instance protected field?
17:36emezeskenkoza: Maybe 'proxy ?
17:47Raynesspoon16: Performance. Stencil is the fastest spec compliant stencil implementation around.
17:47gf3My brain is failing me, what's the function to execute an arbitrary amount of expressions and only return the last one's value
17:47gf3(something x y z) ; z
17:47Raynesgfredericks: do
17:47RaynesIt isn't a function.
17:47cjfriszgf3: do
17:47gf3Crap
17:47Raynesgf3, not gfredericks
17:48cjfriszI know Raynes already answered...
17:48gf3Wrong channel
17:48gf3SORRY GUYS
17:48gf3(Looking for Racket)
17:48Rayneslol
17:49gf3Just FYI, in Racket it's (begin)
17:50evhangf3: I think it's `begin` in Racket.
17:50gf3AHEM
17:50evhangf3: Ah, there you go.
17:58nkozaemezeske: you cant use "proxy" to access protected fields of the parent class :(
17:58nkozaand I dont want to use AOT/gen-class
18:00Raynesnkoza: https://github.com/arohner/clj-wallhack/blob/master/src/wall/hack.clj#L15
18:01RaynesOh, fields. There is a function for that too below that one.
18:01nkozaRaynes: thanks
18:06spoon16you guys know of any other projects like wallhack but generally make reflection and exploration of objects simpler? I'm just looking at libraries that enrich the repl
18:11kaoDhi
18:34kaoDwhat the hell is going on
18:34ohpauleezkaoD: It's called a netsplit
18:35ohpauleezhttp://en.wikipedia.org/wiki/Netsplit
18:35kaoDhmm nevermind, those where "Excess Flood" messages
18:35kaoD(completely missed it, but it's not a netplit)
18:41alex_baranoskydoes anyone know of a Clojure library for turning time durations into English (like "1 day", "2.34 days", etc)
18:42gfredericks"twoish days"
18:43Raynesalex_baranosky: lazybot has an implementation of that.
18:44Raynesalex_baranosky: https://github.com/flatland/lazybot/blob/develop/src/lazybot/utilities.clj#L7
18:44alex_baranoskyRaynes: thanks
18:46firesofmayHi, can anyone tell me if we can run clojure on raspberry pi? Any idea?
18:46gfredericksman rhickey was all over the IRCs back in the day
18:46mpanfiresofmay: pretty much the normal way
18:46firesofmaympan, have you tried it?
18:47mpanno, but since you can get a regular linux distro on it, the rest of the steps are pretty much the same
18:47firesofmaympan, I see.
18:47spoon16firesofmay: if you are running Debian on the Raspberry Pi you can 'sudo apt-get install openjdk-6-jre'
18:47ivanhttp://raspberrypi.stackexchange.com/questions/91/is-there-a-jdk-with-a-jit-compiler-available
18:47mpanI'm not aware of anything x86 specific along the line
18:47mpanso the same steps should work fine as they do on your regular computer
18:48firesofmayspoon16, mpan ivan I see. Thanks.
18:48firesofmayanyone hacked on raspberry pi here?
19:25cjfriszWoo, finally published a blog post about how CTCO works
19:25cjfriszNow I don't have to feel guilty about never blogging
19:25cjfriszPlus I can write shorter updates about things I figure out how to optimize
19:26dnolencjfrisz: cool!
19:28ohpauleezdefinitely cool
19:43wei_what's the most mature templating and event handling library for clojurescript?
19:57one-luckok what now?
19:58ohpauleezwei_: What specifically are you looking to do?
20:01ohpauleezmost people use some mix of domina, enfocus, singult, crate, and jayq
20:03wei_I'm trying to listen to clicks on elements with a certain class. tried it with domina just now: (dom/listen! (dom/by-class "thumb") "click" thumb-clicked). but it results in Uncaught TypeError: Cannot call method 'call' of undefined
20:31jcromartie,(count (time (apply str (range 1e5))))
20:31clojurebot"Elapsed time: 290.873695 msecs"
20:31clojurebot488890
20:32jcromartiejust butting in, don't mind me
20:33gfredericks,(->> 1e5 range (apply str) time count)
20:33clojurebot"Elapsed time: 221.043181 msecs"
20:33clojurebot488890
20:34muhoojcromartie: you can pm the bot
20:35muhoocjfrisz: link?
20:35cjfriszmuhoo: http://www.chrisfrisz.com/blog/?p=234
20:54wei_solved my issue above. I had to import domina.events in addition to domina
20:54wei_err, require
21:30n00b_I'm currently looking for the source of the function applyTo - it's in clojure.core, but the definition isn't there and core does not import any other namespaces - how is this possible?
21:31n00b_relevent link: http://code.google.com/p/clojure/source/browse/trunk/src/clj/clojure/core.clj
21:38gerthas anyone tried to integrate Chas Emerick's Friend with a clojurescript app?
21:38Raynesn00b_: That's a Java method, not a Clojure function.
21:39RaynesThat is also not the right repository.
21:39Rayneshttps://github.com/clojure/clojure
21:39RaynesThe code.google stuff is so old that it's kinda magical you found it and not the git repo.
21:40brehautgert: cemerick might have ;)
21:42n00b__In the implementation of apply there is a fn applyTo - however when I look for it in core I find nothing, and no imports. How is this possible?/where does this fn come from?
21:42cemerickgert: ClojureScript is just a library in a browser as far as Friend is concerned.
21:43gertI know
21:43gert:)
21:44gertI'm trying to come up with a proper workflow/architecture for a clojurescript app + Chris Granger's Fetch + cemerick's Friend
21:44xeqithat does take some work
21:44xeqifetch + friend
21:45gertI think I'm close to getting something working, but it's a bit messy at the moment. I was just wondering if anyone else has done anything authentication-related in cljs
21:45xeqigert: https://github.com/xeqi/friend-fetch-example has a working example, but I really need to get back and clean it a bit
21:46gertoh!
21:46gertthanks xeqi, I'll check that tout
21:46gert*out
21:46xeqihmm, might make a good blog post too
21:47cemerickxeqi: that's a *really* hard way to do it
21:47gertI'm basically doing an xhr post request to a login url that gets intercepted by Friend. That part, and the authentication, works.
21:47gertI just need to return a result
21:47xeqiah, then fetch doesn't matter much in that case
21:47ohpauleezxeqi: If you're going to use fetch to authenticate, I suggest you replace it with Shoreleave's remotes
21:48cemerickgert: just make a request to a non-fetch URI in order to obtain an authenticated session, and then all of your RPC after that point with the same host will carry those credentials.
21:48ohpauleezto get CSRF protection and proper XSS handling
21:49xeqiohpauleez: heh, I would look at shoreleave and cemerick's ring-remote; not a particular fan of noir/fetch, that was just a one off
21:49gertxeqi: I'm using fetch with Compojure
21:49gertit's trivial to replace the noir defpage with a route that calls call-remote
21:50gertit'd be easy to remove any dependency on noir or compojure from fetch
21:50cemerickgert: doing so would leave you with shoreleave remotes, essentially.
21:50cemerick(AFAICT, I never used fetch myself)
21:51gertcemerick: ohpauleez: I guess it's time for me to have a closer look at Shoreleave. :)
21:51ohpauleezxeqi: Ahh gotcha. I actually have a few key issues with Noir, but I haven't sat down to rework some ideas I have
21:51ohpauleezgert: Enjoy the rabbit hole!
21:52ohpauleezIn all honesty, the code is pretty straight forward - it really is all the grunt work you'd end up doing for a decent CLJS app
21:53gertohpauleez: cheers! it's been a joy so far. I'll see how far I get with Shoreleave. this is the beginning of a fairly complex client side app and it's all very exciting. :)
21:53ohpauleezgert: Awesome to hear it! I've had a blast working on CLJS stuff and a lot of success. I have some pretty interesting metrics to share at the Conj
21:54Raynesohpauleez: What are the key issues?
21:54ohpauleezRaynes: With?
21:54ohpauleezNoir?
21:54clojurebotnoir is great
21:54RaynesYou said you have some key issues with Noir. Just curious what they are.
21:55gertohpauleez: awesome! if I wasn't all the way in New Zealand I'd go to Conj. Or if my startup had the funds to send me. Maybe next year. :)
21:56ohpauleezahh yeah - so i think the pieces you've pulled out into other libs lib-noir and the other one for looking across classpath stuff are awesome. It opens up the door for using metadata on functions rather than stateful atom bashing
21:56ohpauleezreally
21:56ohpauleezI just don't want a macro for my functions, I want real functions. And the style of using an atom gets the job done, but I'm not sure it's totally needed
21:57ohpauleezthat said, I really haven't dug deeper
21:57xeqiohpauleez: did you ever publish the todoMVC example mentioned on http://www.pauldee.org/blog/2012/production-clojurescript/ ?
21:57ohpauleezor tried my hand at it, so please take it with a huge grain of salt
21:57Raynesohpauleez: I agree regarding the statefulness of noir. But once you pull that away, you get compojure. So, I've just been using compojure and lib-noir lately.
21:57ohpauleezxeqi: No, but there is a decent demo linked from Shoreleave's github
21:58ohpauleezRaynes: ahhh cool. That was my thought at well. And I think you could still auto build routes via reflection on metadata, I'm not sure if that's a good idea or not
21:59cjfriszAnybody else amused that the "call for presentations" is still up on the Conj site?
21:59cjfriszAnd also dying for a comprehensive list of who all is speaking and about what?
21:59xeqicjfrisz: not surprised; was told the list of presentations should have been up at the end of last week
22:00ohpauleezcjfrisz: side note - great blog post
22:00SegFaultAXWhat's lib-noir?
22:00Raynesxeqi: I was told that it was put up next week. The Doctor doesn't usually lie about these things.
22:00Raynes$google lib-noir
22:00lazybot[noir-clojure/lib-noir · GitHub] https://github.com/noir-clojure/lib-noir
22:01cjfriszohpauleez: Thanks! I really appreciate feedback.
22:04xeqiRaynes: but rule 1...
22:05duck1123don't wander off
22:05xeqithe other rule number one
22:05duck1123sorry, wrong Doctor
22:06ohpauleezWhat is rule number one? I'm trying to remember
22:06InternetFriendsnow you're going to die
22:06xeqiohpauleez: http://tardis.wikia.com/wiki/The_Doctor%27s_Rules
22:07duck1123Eleven's rule #1 is "the doctor lies"
22:07ohpauleezAhh yes, the doctor lies
22:08ohpauleezthe only one I remember is the last one, "Time is not the boss of you"
22:09duck1123ahh, speaking of... I need to go watch the new one still. night all
22:24jkdufairwould anyone have any idea why a sequence i've obtained via a jdbc query would not cause the body of my map fn to execute but can be materialized via doseq?
22:25ohpauleezmap is lazy, and nothing is forcing its execution
22:25jkdufairah!
22:25ohpauleezwhen you doseq, you realize the entire sequence, making the map (and map fn) happen
22:25jkdufairdidn't know map was lazy
22:25jkdufairthank you!
22:25ohpauleeztotally welcome!
22:27jkdufairheh. read right past "lazy" in (doc map)
22:28cjfriszWell, I'll be
22:28cjfriszI somehow never noticed that, either
22:29jkdufairalso, args are all passed by ref, yes?
22:30ohpauleezjkdufair: reduce is lazy too, as are things like keep, remove, etc
22:31jkdufairsuper. makes total sense. i just hadn't realized my seq yet and couldn't figure out why my damn debug stmts weren't happening
22:31Scriptorohpauleez: how is reduce lazy?
22:31ohpauleezjkdufair: you can always force realization if you need to bring everything into ram
22:32jkdufairno i actually don't
22:32ohpauleezScriptor: I'm almost certain it is, no?
22:32casionI don't think reduce is
22:32Scriptorohpauleez: it can't be, because it doesn't always return a lazy seq
22:32ohpauleezOhh right
22:32ohpauleezduh
22:32Scriptorreductions is lazy, however
22:37jkdufairohpauleez: you broke thru a 2 day logjam i had. whew. i love clojure
22:37mpanyea, I got hit really hard by that recently
22:38casionspeaking of logjams… after all the screwing around with clojure.xml, clojure.zip, clojure.data.zip/xml, clojure.data.xml
22:38mpanbut I figure, it's the sort of wall you run into once, and in the future you remember to consider it
22:38casionthe answer was to just use enlive
22:38casionwhich seems to work correctly and very easly
22:38mpanwhat did you want to do?
22:38casionparse, modify and render xml
22:38mpanI think I'm gonna need to generate xml tomorrow or the day after
22:39jkdufairi'm rather enjoying enlive
22:39casionspent 4 days working on it, searching, searching irc logs and asking questions in here
22:39jkdufairmy app is primarily a web scraper and enlive makes things very straightforward
22:40mpanwait, how does enlive help you with taking in xml?
22:40casionmpan: it has xml-resource
22:40casionwhich uses the sax parser
22:40mpanbut nicer than using sax directly, I hope?
22:40casionsame as clojure.xml iirc
22:40casionyes
22:40mpanawesome thanks
22:40casionthe biggest benefit is that it has xpath-like element referencing
22:41casionwith css syntax
22:41casionAND it renders properly
22:41casionwhich clojure.xml does not do
22:41mpanwait, which part doesn't it?
22:41mpanshould I use that and not clojure.xml, then?
22:42casionclojure.xml does not render properly
22:42mpanrender as in?
22:42casionit has issues with whitespace and character entities
22:42casionrender, print, emit
22:42mpanok
22:42mpanthanks
22:42casionthe process of tree -> xml
22:43casionenlive doesn't support xml namespaces though
22:43casionbut that's not an issue for me
23:07spoon16does hiccup support namespaced attributes on output?