#clojure logs

2012-08-05

00:00m0smithoh I have another question about futures: Does using futures keep the program from terminiating, even if they are all completed?
00:02m0smiththat is, are they deamon threads?
00:02m0smith(##source future)
00:02m0smith##(source future)
00:02lazybotjava.lang.RuntimeException: Unable to resolve symbol: source in this context
00:08m0smithI found it: http://dev.clojure.org/jira/browse/CLJ-124
00:09m0smithok thanks all. night
00:11mdeboardadios
00:16mdeboardAre there ever actually any locals in the clojure stacktrace?
00:23xeqimdeboard: http://dev.clojure.org/jira/browse/CLJ-860 looks like a way was added to keep them
00:24mdeboardoic
00:26mdeboardwonder if that's slated for 1.5 or what
00:27xeqisays resolved in 1.4
00:27xeqithough I've never tried it
00:28muhooslingshot can show locals in stacktrace, IIRC
00:30mdeboardxeqi: Not clear here on how I would even try it.
00:47amalloyyou can't put locals into a stacktrace. disabling locals clearing just gets the compiler to stop nulling out values you're done with so that a debugger, or slingshot, can collect that information for you and put it somewhere useful
02:06polypus~ping
02:06clojurebotPONG!
02:06polypuscarmine Q here: http://gist.github.com/3262135
03:07mdeboardWhy is this macro giving me a stack overflow error? https://gist.github.com/d85b7f024a431cbbdfdf
03:08mdeboardThese two macroexpand exprs yield practically the same code https://gist.github.com/5263a49008da659e89ec
03:12amalloymdeboard: proxy-foo unconditionally contains itself in its expansion
03:12amalloyso that nested macro needs to be expanded, ad infinitum
03:12mdeboardamalloy: I've been reading through your blog post on this exact topic btw (macros in macros)
03:12amalloyhah
03:13amalloybut you're not doing any nested macros
03:13mdeboardwell, I guess I mean that like proxy-foo contains proxy, which is a macro itself
03:13amalloyyeah, but pretty much every macro contains another in that way, because let is a macro too
03:13mdeboardoh, right. defn, etc.
03:14mdeboardSo, in this case with proxy-foo invoking itself, how do I go about expressing this?
03:14amalloyyou probably need your macro to generate a function, and have withMeta call that function
03:14mdeboardI see
03:15amalloybtw, no need for this klass tomfoolery. clojure doesn't have java keywords
03:15mdeboardalternatively, is there a way to define a variable like `(def r PdfReader)' then `(proxy [r clojure.lang.IObj] ...)'
03:15amalloyno
03:15mdeboardok
03:17amalloyanyway, there are some other problems in your macro (what leaps out at me is multiple-evaluation of moremeta, and evaluating moremeta and infile at macro-expansion time), which will all be pretty much fixed if you just have your macro emit a function, rather than trying to expand into a call to proxy
03:18mdeboardmultiple eval of moremeta? Where?
03:19amalloythen it's more like (defmacro proxy-foo [class] `(fn make# [infile# & [moremeta#]] (proxy [~class IObj] [infile#] (withMeta [newmeta#] (make# infile# newmeta#)))))
03:20mdeboardthe fundamental thing I'm trying to do here is not have a function to proxy every class I need so I can use the iobj interface, and that requires at least being able to use one function to proxy any class
03:20mdeboardI see
03:20amalloymdeboard: you let metadata be (merge blah meta), but you do that at compile-time. then every time someone calls (meta the-proxy), you expand metadata. so if moremeta is {:x (println "1")}, that println happens every time someone calls meta
03:24polypusanybody here used carmine (redis) atomically helper? wondering if i'm doing it right or if i've found a bug? http://gist.github.com/3262135
03:25mdeboardamalloy: Waddya know, that works.
03:25mdeboardamalloy: You're ok
03:26mdeboardthis is like 3 levels of abstraction higher than I'm prepared to go at 3am
03:27mdeboardamalloy: So basically in this gist, the macro below is generating the (proxy-meta) function above right?
03:27amalloyerrr, what gist, what's above/below?
03:28mdeboardhttps://gist.github.com/4010a4cc804b8e83bb56
03:29amalloyyes
03:29amalloyso the latter macro lets you write the former function with (def proxy-meta (proxy-foo PdfReader))
03:30amalloy(though seriously, when it's no longer 3am, work on those names)
03:30mdeboardlol, you got it
03:54muhooheh, a promise is an empty future.
03:57foodoomuhoo: sounds poetic, but sad
03:57michaelr`good morning
03:59mdeboardgod I hate itext so much
04:00mdeboardImpossible to extend it via proxy
04:00mdeboarder, it being a particular class in the lib
05:16alexyakushevIs it possible to attach pre- and postconditions to a lambda?
05:57TEttinger2(https://github.com/technomancy/leiningen/blob/master/bin/lein.bat)
05:57TEttinger2,(https://github.com/technomancy/leiningen/blob/master/bin/lein.bat)
05:57clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: https://github.com/technomancy/leiningen/blob/master/bin, compiling:(NO_SOURCE_PATH:0)>
05:57TEttinger2anyone know how to get lazybot to announce the titles of linked webpages?
05:58TEttinger2&(https://github.com/technomancy/leiningen/blob/master/bin/lein.bat)
05:58lazybotjava.lang.RuntimeException: No such namespace: https://github.com/technomancy/leiningen/blob/master/bin
05:58TEttinger2&https://github.com/technomancy/leiningen/blob/master/bin/lein.bat
05:58lazybotjava.lang.RuntimeException: No such namespace: https://github.com/technomancy/leiningen/blob/master/bin
05:58TEttinger2hey edlothiol
05:58TEttinger2just so you know, I am debugging my own lazybot over in #rgrd
05:59TEttinger2https://github.com/technomancy/leiningen/blob/master/bin/lein.bat
06:00TEttinger2and I imagine that a bot meant to do this passively wouldn't respond to a PM with a link
06:02TEttinger2-> https://github.com/technomancy/leiningen/blob/master/bin/lein.bat
06:19raekTEttinger2: note that bots can usually only print titles for HTML documents
06:20TEttinger2raek, that is a github webpage right?
06:20raekoh, I see. the link _is_ to an html file...
06:28RaynesTEttinger2: Did you get it working?
06:28Raynes$title https://github.com
06:28lazybot"GitHub · Social Coding"
06:28RaynesTo make it do it automatically, you have to add some configuration.
06:28RaynesLet me look it up.
06:28TEttinger2Raynes, I did not. however, I know about the config
06:29TEttinger2I am trying to get the thing to actually run a selenium test
06:29RaynesI don't follow.
06:29TEttinger2yes
06:29TEttinger2so if you paste in www.github.com
06:30TEttinger2then my version of lazybot is supposed to load the page in firefox (complete security hole, I may get around to stopping that up), check a specific plugin's added span area, and report it back
06:30TEttinger2what it is supposed to do is check for trackers on linked sites
06:31TEttinger2google analytics, advertising networks, the whole deal
06:39TEttinger2Raynes, as far as I can tell, there isn't an error with LazyBot. I just don't know how to work semperos's lib
06:39TEttinger2https://github.com/semperos/clj-webdriver
06:40TEttinger2I keep getting an unable to resolve symbol error on what should be a valid symbol
06:42TEttinger2I am trying to edit the title plugin, if that matters
07:28TEttinger2guh
07:29TEttinger2java.lang.IllegalArgumentException: No value supplied for key: true
07:29TEttinger2anyone know what that could be?
07:30TEttinger2is that like a mismatched hash literal?
08:12DaoWenI've been looking through the docs, and I'm confused by these three macros: binding, with-bindings, with-redefs
08:12DaoWenwhen would I want to use one as opposed to the others?
08:15clj_newbHi all, how do I merge sets?
08:16DaoWenclj_newb: (into set-a set-b)
08:16clj_newbthanks!
08:17DaoWenclj_newb: you can also use the functions in clojure.set: http://clojuredocs.org/clojure_core/clojure.set
08:18DaoWenclojure.set/union and clojure.set/intersection specifically, depending on what you mean by "merge"
08:45clj_newbThanks very much DaoWen
08:46DaoWenyou're welcome!
08:50gfredericksDaoWen: with-redefs is just for testing
08:50gfredericksand/or development
08:50gfredericksbinding is standard and used whenever you want to give a var a thread-local value
08:51gfrederickswith-bindings I wasn't even aware of, but it looks like it's useful for when you have runtime references to var objects rather than the normal compile-time case
08:52gfrederickswhich is probably rare
08:52DaoWenok
08:52DaoWenso it sounds like with-redefs would never come up in production code
08:52gfredericksif it does you're abusing it
08:53gfredericksit changes globals across all threads
08:53gfredericksso it's not really safe
08:54DaoWenthat makes sense
08:56DaoWenI'm still confused about with-bindings, but since you didn't even know it existed it sounds like it would only come up in really weird situations since it works with runtime references to vars
08:56DaoWenthanks
09:30benediktUsing emacs and lein, if I create a new project with lein, open it with emacs and start "clojure-jack-in" and try to evalute something with C-M-x, i get the error "No buffer named *nrepl-connection*". Google is of no help.
09:48benediktsomewhat confused with including libraries with use. Is the convention to use (user 'library) or somehow use it in the ns macro (if so, what's the syntax?)
09:50michaelr`benedikt: both
09:50michaelr`you can do (use 'clojure.string)
09:51michaelr`or in (ns (:use [clojure.string))
09:51benediktwhat is the syntax like if i embed it in the ns namespace?
09:51benediktah
09:51benediktthanks
09:51michaelr`'welcome
10:13gfredericks,(rationalize (rand))
10:13clojurebot6761690242602623/10000000000000000
10:13gfredericks:)
10:15michaelr`,(rationalize (rand))
10:15clojurebot4030645784873027/125000000000000000
10:16TEttinger2Raynes, do you remember what customizations lazybot requires to have auto-announce of the titles of links?
10:17TEttinger2I have :title {:automatic? true} in my config.clj
10:27TEttinger2,(apply str (shuffle ["▼" "◀" "▶" "◢" "◣" "◥" "◤" "△" "▽" "◿" "◺" "◹" "◸" "▴" "▾" "◂" "▸" "▵" "▿" "◃" "▹" "◁" "▷" "◅" "▻" "◬" "⟁" "⧋" "⧊" "⊿" "∆" "∇" "◭" "◮" "⧩" "⧨" "⌔" "⟐" "◇" "◆" "◈" "⬖" "⬗" "⬘" "⬙" "⬠" "⬡" "⎔" "⋄" "◊" "⧫" "⬢" "⬣" "▰" "▪" "◼" "▮" "◾" "▗" "▖" "■" "∎" "▃" "▄" "▅" "▆" "▇"
10:27clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
10:28TEttinger2,(apply str (shuffle ["▼" "◀" "▶" "◢" "◣" "◥" "◤" "△" "▽" "◿" "◺" "◹" "◸" "▴" "▾" "◂" "▸" "▵" "▿" "◃" "▹" "◁" "▷" "◅" "▻" "◬" "⟁" "⧋" "⧊" "⊿" "∆" "∇" "◭" "◮" "⧩" "⧨" "⌔" "⟐" "◇" "◆" "◈" "⬖" "⬗" "⬘" "⬙" "⬠" "⬡" "⎔" "⋄" "◊" "⧫" "⬢" "⬣" "▰" "▪" "◼" "▮" "◾" "▗" "▖" "■" "∎" "▃" "▄" "▅" "▆" "▇"
10:28clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
10:29TEttinger2,(apply str (shuffle ["▼" "◀" "▶" "◢" "◣" "◥" "◤" "△" "▽" "◿" "▂" "▁" "▬" "▔" "▫" "▯" "▭" "▱" "◽" "□" "◻" "▢" ]))
10:29clojurebot"??????????????????????????????????????????????????????????????????"
10:30TEttinger2(take 10 (cycle (range 0 3)))
10:31clojure-newcomerhi guys, I've got two sets, which appear to be equal, I'm getting a different value for a contains? on them both… which got ya is catching me out ?
10:31TEttinger2,(apply str (shuffle (take 100 (cycle (range 0 10)))))
10:31clojurebot"2305923435368826349813166532448267361445182423703409270509171857772184654509951599678082198760701906"
10:49raekclojure-newcomer: are the keys integers?
10:50clojure-newcomerraek: I'm trying the following : (contains? st2 {:db/id 17592186045427})
10:50clojure-newcomerraek: where st2 is : #{{:db/id 17592186045427}}
10:50clojure-newcomerthis one works
10:51clojure-newcomerbut not st which to all intents and purposes is the same
10:51clojure-newcomerone is a result from diatomic, the other is an explicit set definition
10:52raekwhat does (class? ...) return for the number values?
10:53clojure-newcomerraek: java.lang.Long
10:54raekfor both ones?
10:55clojure-newcomerraek: it seems to
10:55clojure-newcomerraek: (= st st2) yields false
10:55raekdoes these two maps yield true when passed to =?
10:56raekwhat is st?
10:56clojure-newcomerboth are the sets I mentioned earlier
10:56antares_clojure-newcomer: can you post a REPL session example?
10:56raekclojure-newcomer: I only see st2
10:56clojure-newcomerraek: st is the set returned from querying a diatomic result
10:57clojure-newcomerraek: sorry, I was not clear on that
10:57raekwhat does it look like if you print it?
10:57antares_it is generally a good idea to use clojure.set functions instead of contains? because you won't have to worry about ref equality vs value equality
10:57clojure-newcomerraek: st and sty look identical when println'd
10:57clojure-newcomerraek: *st2
10:58raekantares_: what? I think they use the same model of equality.
11:00raekclojure-newcomer: so if you run (do (prn st) (prn st2) (prn (= st st2))) you get two identical lines, followed by false?
11:01clojure-newcomerhere is a REPL session demonstrating my fail: http://pastebin.com/MKWeZ0p4
11:02clojure-newcomerraek: yes I do
11:04raekclojure-newcomer: the first line has a different number that the rest
11:05raek17592186045425 instead of 17592186045427
11:05raek(last digit)
11:05antares_it is hard to tell what's inside entity but those timestamp-looking ids are not the same
11:06antares_,(= "17592186045425" "17592186045427")
11:06clojurebotfalse
11:06clojure-newcomerraek: yeah, thats ok thats the paren entity, I am pulling a property off that
11:06raekthat string comparison might yield true in PHP though... :-)
11:07raekhrm. strange.
11:09clojure-newcomerif its any help, clojure: 1.4.0, datomic: 0.8.3343
11:09raekclojure-newcomer: what does (for [x [st st2]] [(class x) (class (first x)) (class (first (keys (first x)))) (class (first (vals (first x))))]) return?
11:09clojure-newcomerraek: it returns : ([clojure.lang.PersistentHashSet datomic.query.EntityMap clojure.lang.Keyword java.lang.Long] [clojure.lang.PersistentHashSet clojure.lang.PersistentHashMap clojure.lang.Keyword java.lang.Long])
11:10michaelr`antares_: Isn't (String. payload) in msg-handler in subscribe supposed to convert the byte array to string?
11:11clojure-newcomerraek: so the first has EntityMap, the second has PersistentHashSet
11:11raekto me it looks like equality is broken for the datomic.query.EntityMap type
11:11raekor maybe this is by design and you should do things differently
11:11raekI recommend asking the datomic folks about this
11:12michaelr`antares_: nm, it does :)
11:12clojure-newcomerraek: thanks for the help, I'll go try to get help
11:12clojure-newcomerfrom the diatomic guys
11:13clojure-newcomer*datomic… stupid auto correct
11:14raekI would advice against using the (String. byte-array) constructor
11:14raekuse (String. byte-array encoding) instead
11:14michaelr`oh
11:15michaelr`raek: otherwise it tries to guess the encoding?
11:15raekmichaelr`: no, otherwise it will use the "default one"
11:16raekwhich is not a very good idea
11:16michaelr`oh
11:16raekthis encoding depends on the locale of the user
11:16raekand is wrong on OS X computers
11:16raek(java is told it is Mac Roman, but OS X uses UTF-8)
11:17raekuse "UTF-8" unless you have a good reason
11:17michaelr`ok
11:17michaelr`thanks
11:17antares_leiningen 2 will make JVM use UTF-8 starting with preview5 or so
11:18antares_via a -Dproperty
11:18raekthat's good to hear
11:43michaelr`why pprint doesn't show anything when run inside a `lein run`?
11:44michaelr`i know it'
11:44michaelr`s
11:44michaelr`something with the stdout redirection
11:44michaelr`better question is how do i fix it? :)
11:47michaelr`,(doc pprint)
11:47clojurebotI don't understand.
12:23duck1123michaelr`: are you able to see normal println messages
12:59davidd___I wrote a function that looks really ugly. can someone tell me how I can refactor it: https://www.refheap.com/paste/4055
13:06tmciverdavidd___: It looks good but I think that you can replace the the if-let and ifs with when-let and when since they will return nil if their test expressions are falsey. That way you don't have to return false explicitly.
13:08gfredericksdavidd___: s/save-user/save-user?/
13:21davidd___tmciver, gfredericks: thanks!
13:49muhoohmm, cljsbuild seems to compile everything into .lein-cljsbuild-compiler-0, but then if you run the cljs repl, it re-compiles everything all over again, and puts it in .lein-cljsbuild-repl .
13:52muhooso there are two compilers going in parallel on what may be the same code?
14:01muhooalso, one more cljs question since nobody's listening: how do i force cljs repl to give me a cljs-usable object, or a string, from stuff like "[object HTMLParagraphElement]"
14:02muhooi.e. this is not the expected behavior: https://www.refheap.com/paste/4057
14:03muhoooh, duh, it's javascript, i can use js interop. nm.
14:11pandeiromuhoo: what would you like to do?
14:13pandeiroare you trying to get (.-innerHTML el) or (.-innerText el) by chance?
14:13pandeiroor are you wanting to do the reverse of what crate does? ie HTMLDivElement -> [:div "something"] ?
14:13muhoopandeiro: that's the one :-)
14:14pandeirothe reverse?
14:14muhoowell, the crate docs say this: https://github.com/ibdknox/crate
14:14pandeiroman that i have no idea but when you figure it out, please pass me that code :)
14:14muhoobut what i was getting in the repl was this: https://www.refheap.com/paste/4057
14:14pandeirobut is it necessarily coming from the HTML object?
14:14muhooso, nrepl was, for me, returning the object, but in the docs, it looks like it was returning .-innerHTML on it
14:15pandeiroDOM object i mean?
14:15muhooi'm not sure. this is cljs :-)
14:16meenalHi, is there a StringBuffer like datastructure in clojure?
14:16pandeiroI don't think you can go from a DOM Object (ie <[object HTMLParagraphElement]>) to a crate/hiccup vector very easily
14:16pandeiroi think you'd need to serialize it to HTML string (.-innerHTML) and then parse
14:16pandeirobasically a new lib for that
14:16muhoopandeiro: no i'm just looking at having readable in the repl
14:17muhoo#<[object HTMLParagraphElement]> is not very informative
14:17muhoobut, i guess the repl used to print out the HTML of the dom element. but now it doesn't, or maybe i'm doing something wrong
14:17pandeiromaybe somehow crate could save a string representation of the vector data structure when it makes the DOMElement
14:18pandeirono it never printed out the entire html string, not that i remember
14:18pandeirohiccup would do that
14:18muhoobut, that's what i'm seeing in that Readme.md
14:18pandeironot crate, which creates DOMObjects
14:18pandeiroah, different fn?
14:18muhoohttps://github.com/ibdknox/crate/blob/master/README.md
14:19muhoonot sure. again, i'm just feeling my way around, and when i see output that doesn't match the readme, i wonder what i might be doing wrong
14:20muhoothis istuff is very cool though.
14:20muhooheh, not istuff, i don't like iStuff
14:21pandeironah if you look at crate.core, html is creating actual DOM objects
14:21pandeiroi think the README is wrong
14:21pandeiromaybe ibdknox will chime in
14:21muhooright, as i'd expect. ok maybe that's it then.
14:22pandeirowonder if you could somehow save the (pr-str) representation of the element before creating it, and keep that around (where? dunno) for inspection purposes
14:22muhoometadata?
14:22clojurebot? "Returns the metadata of obj, returns nil if there is no metadata."
14:22pandeiroright, in HTML?
14:22muhooif it's an object, hmm.. how does cljs store metadata, i wonder
14:22pandeirolike, attached the DOM object? don't think it's possible?
14:23pandeiroi think that's all in clojure's data structure code, not applicable to a HTMLParagraphElement etc
14:23pandeirojQuery can attach data to DOM nodes
14:24pandeiroi've never looked at how that's implemented though
14:24pandeiroi guess there's no reason it couldn't just be added to the DOM object itself
14:25muhooNo protocol method IWithMeta.-with-meta defined for type object: [object HTMLParagraphElement]>
14:25pandeiromaybe you could extend it
14:26muhoolooks that way
14:26pandeiroor just use JS interop a la (set! (.-crate el) crate-string)
14:27pandeirobut yeah i don't think that's a robust solution.. you'd need to change the toString() method for the REPL to output that crate key's values
14:27muhooi'd rather it be clojureish, like with-meta. i'll put that on the loist of things to play with.
14:28pandeiroyeah should be possible to extend those DOM objects to IWithMeta right?
14:28muhoojust add the protocol i think.
14:28muhooi saw a talk by lynagh or chouser or someone on how to extend js with protocols
14:28pandeiromuhoo: jayq.core has a good examples, he made the jQuery object seqable
14:29muhoocool, thanks!
14:29antares_Spyglass 1.0 is out: http://clojurememcached.info
14:29muhooi came into cljs wanting to do productive stuff, but i got seduced by the dark side and now i just want to play around with how it works
14:31meenalfbuffe
14:31piranha_ehm... I'm trying to get defprotocol/defrecord working on ClojureScript and failing at this point. If I define them in different modules, cjsc generates different method names and `satisfies?` says `false`. If I define them (both protocol and record) in a single module, I can use protocol methods on record, because names are the same, but then `satisfies?` is still saying false. Any comments?
14:33antares_piranha_: start with showing your code
14:33piranha_antares_: https://github.com/piranha/cj-locations/blob/master/src/google.cljs#L9
14:33piranha_here are they in different modules, protocol is obviously in map.cljs
14:35muhoopiranha: google maps wrapper in cljs? very cool!
14:35antares_I am not familiar with CLJS, in JVM Clojure protocols definitely can be defined in a different namespace from the type you extend them to
14:36piranhamuhoo: well, this is only for a limited thing, I'm just starting with clojure/cljs
14:36antares_however, I typically use defprotocol + extend-protocol, not the extended defrecord form
14:36piranhawell, I tried to go this way
14:36muhoopiranha: maybe it's the order in which they are included?
14:36piranhait generates code in same way...
14:36piranhamuhoo: hmhm, well, the thing is that it looks like there is some support code which wasn't generated or something like that
14:36muhoomight want to look at the generated js and see the order of the require() calls
14:37antares_piranha: have you tried separating defrecord and protocol extension code (with extend-protocol, for example)?
14:37piranhawell, satisfies? checks that Map knows about this Google it seems
14:37piranhaantares_: yes, I did - result was the same
14:38piranhawell, not exactly, since I couldn't use just names of properties (gmap/coder/info), but in other way same effect
14:39piranhaeh... probably it would be better to write to a clojure mailing list, since not everybody is online on irc all the time :)
14:39antares_you :use [locations.map :only [Map init locate set-city]]. That's a little strange.
14:39antares_:only should be listing functions, not protocol names
14:39antares_although it should not matter, the point is to get the namespace loaded & compiled
14:39antares_and :use accomplishes that
14:40piranhahmmm
14:40piranhawell, I wanted to import Map to check with satisfies?
14:40piranhaI could check it with require as well, give me a second
14:48piranhaantares_: it's the same...
14:49antares_ok, probably CLJS protocols have something to them that I do not know
14:49piranhaseems like a bug to me
14:49piranhaI'll write to mailing list then
14:54clj_newbHi, in this persistent array map {false [1 2], true [4]} how do I get the keys?
14:54gfredericks,(keys {false [1 2], true [4]}
14:54clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
14:54gfredericks,(keys {false [1 2], true [4]})
14:54clojurebot(true false)
14:54antares_,(keys {:a 1 :b 2})
14:54clojurebot(:a :b)
14:55antares_,(values {:a 1 :b 2})
14:55clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: values in this context, compiling:(NO_SOURCE_PATH:0)>
14:55clj_newb(keys {false [1 2], true [4]}) yields (false true), but (:false {false [1 2], true [4]}) yields nil
14:55antares_,(vals {:a 1 :b 2})
14:55clojurebot(1 2)
14:55gfredericksclj_newb: false and :false are different
14:55gfredericks,(get {false [1 2], true [4]} false)
14:55clojurebot[1 2]
14:56gfredericks,(map type [false :false])
14:56clojurebot(java.lang.Boolean clojure.lang.Keyword)
14:56clj_newbaah, I got confuse when (false {false [1 2], true [4]}) failed
14:56clj_newbthanks both
14:57gfredericksclj_newb: keywords (like :false) are special in that you can use them as functions for accessing maps
14:57gfredericksfor any other type of key you can use get or you can use the map itself as a function
14:57antares_they are not "special", they just can be used as functions on maps
14:57antares_to look themselves up in the argument
14:57gfredericksantares_: what's not special about that?
14:57antares_(map :age [{:name "Joe" :age 30} {:name "Marie" :age 29}])
14:57antares_,(map :age [{:name "Joe" :age 30} {:name "Marie" :age 29}])
14:57clojurebot(30 29)
14:58antares_gfredericks: several other things in Clojure can be used as functions, e.g. sets
14:59gfredericksantares_: I don't mean they're special because they're functions, I mean (like I said) that they're special because they're functions for accessing themselves in maps
15:10muhoopiranha__: i don't fully trust the compiler yet, so i'd recommend checking the generated .js and make sure it has your changes
15:11piranha__muhoo: yes, it does
15:11jrheardhi folks - i'm having a little trouble figuring something out: i have a simple validation function and want to let you pass in a particular kind of exception to throw if validation fails
15:12jrheardthe compiler doesn't like it when i have a bare Exception. sitting around though
15:12piranhamuhoo: it's just they don't make much sense to me... i.e. satisifies? checks for something what is never done (Google record assigned as a property to Map protocol, for example)
15:12jrhearde.g. this fails:
15:12jrheard(ensure-in x resource-types 'ClassCastException.)
15:12jrheardwith and without the quote
15:12jrheardam i doing something really stupid :/
15:14jrheardare java constructors not first-class functions or is my mental map of the situation messed up?
15:17antares_jrheard: they are not functions
15:17jrheardhuh!
15:17antares_they are invoked via special forms
15:17jrheardaha
15:17jrheardi'm working through "clojure programming" but haven't gotten to the interop chapter yet :/
15:17jrhearddo i have any options here? i kind of like this idea, it seems nice
15:18antares_jrheard: it's not hard: (ClassName. arg1 arg2 arg3)
15:18jrheardso i should pass along an instance instead of just what i was hoping was a reference to a function?
15:18jrhearde.g. (ensure-in x resource-types (ClassCastException.))
15:19antares_jrheard: you want to instantiate an object from a class you get in a local?
15:19jrheardyes indeed
15:19jrheardspecifically that
15:20muhoojrheard: the interop chapter in clojure programming is very good. once you get there, it will all make sense :-)
15:21jrheardgood to hear :) this book has been really fantastic so far
15:21muhooi'd recommend skipping ahead and skimming if this is in your critical path now.
15:21jrheardi'll do that, it is
15:21muhooit's a great book for skipping around if you need to
15:23antares_jrheard: that's possible but a bit tricky. I will try to put together a reasonable example (out of curiosity)
15:23antares_jrheard: basically, Java classes have the newInstance method you can use but there are nuances
15:24antares_you can also do things like ,(Class/forName "java.lang.Long")
15:24jrheardwhooa
15:24antares_this is how all those ORMs and stuff dynamically load DB drivers, for example
15:24antares_w/o depending on them all at once
15:25jrheardi would love to see that example whenever you get around to it :) i'm @jrheard in case i'm not online
15:25jrheardthanks for the guidance antares_ muhoo!
15:29gfredericksjrheard: also you could instead of passing in classes pass in functions that will return an exception
15:29gfredericksso #(ClassCastException.)
15:29jrheardyeah, that makes sense
15:29jrheardi'll just do that!
15:29jrheardthanks :)
15:47babysnakeshi, I'm new here :) I want to create a website in hebrew (RTL) and I thought of ways to extract all the strings into other files. In my very limited java knowledge I know there is a good support for i18n, but I don't really need to support multi language. I just remember that they have nice resource handling. Is there a better way to do it (something like rails yaml files)?
15:47muhoothat's kinda funny. ($ :a) returns an object, but there are no links. and (count ($ :a)) is 0
15:48muhooleaky abstraction, perhance
15:50muhoobabysnakes: one of the guys here (borkdude)? wrote a hebrew tutorial app in clojure
15:51muhoobabysnakes: http://borkent-app2.appspot.com, i think
15:52babysnakesmuhoo: thx, what I'm looking for have nothing to do directly with hebrew :) I just want to extract the RTL text from the regular clojure files and I was wondering what's a good way to do it.
16:10TimMcPresumably babysnakes wants to extract it because it screws up a normal text editor.
16:23otfromevening all
16:38weavejesterotfrom: Evenin'
17:01FrozenlockIt's possible to sort in congomongo using :sort, but how does one can change the sort order?
17:02cshelldoes mongo have a sort construct?
17:02Frozenlockyes http://www.mongodb.org/display/DOCS/Sorting+and+Natural+Order
17:04cshelllooks like you can
17:05cshell:sort {:key 1}
17:05cshellor -1
17:05FrozenlockYeah, I've tried that :P
17:07FrozenlockI'm unable to change the sort order... I've tried :sort {:key -1}, [:key -1], [[:key -1]]...
17:09cshellyou're not using fetch-one are you
17:09cshell?
17:10FrozenlockI am, why?
17:11cshellwww.litbuildingdb.com/search
17:11cshelloops
17:11cshellnot that
17:11cshellhttp://bit.ly/PxGe60
17:11cshellthat
17:13cshelllooks like you have to use fetch to do it
17:13Frozenlockeh what... If I understand correctly, if I want to sort, I will get all the results?
17:13cshellno, you'll get a cursor
17:14FrozenlockSo if I do (first (fetch...)) I will NOT download the entire collection?
17:15cshellnot sure, you'll have to experiment, but there's also :limit
17:15FrozenlockOh right!
17:15FrozenlockForgot about this one.
17:16FrozenlockThanks for the answer btw, I would never have guessed that fetch-one was different from fetch!
17:16cshellhaha either would I
18:12akhudekworking with google's closure is often very frustrating. :-(
18:26pandeiroakhudek: tell me about it
18:27pandeiroand the partially unfinished abstractions in clojure.browser.* don't make it much easier
18:28pandeiroi am trying to make the browser repl work from a content script in a chrome extension and debugging goog.net.xpc.CrossPageChannel etc, no fun
18:29pandeiroall the protocols in clojure.browser.net are just an additional layer of indirection that makes it harder to understand what's happening
18:51akhudekpandeiro: I briefly looked at the clojure.browser.net namespace and ended up using jayq to do RPC instead
18:51akhudekmy latest frustrations have been with the closure editor
18:52akhudeksome of the editor plugins just don't do what they advertise and there is no information or complaints on their discussion group
18:52akhudekIt's quite confusing. I can only imagine that not many people use it outside of google.
18:57pandeiroakhudek: yes and i get the impression even much of google has moved on?
18:57pandeirodefinitely google docs isn't using it
18:57pandeirothen there's angular js or whatever it is
18:57pandeiroi was also disappointed with the editor for lack of documentation
18:58pandeironot lack of docs per se, but the lack of an open source ecosystem, blog posts, irc, that sort of thing
19:16cshellhas anyone had any problems with ring's sessions not being shared across heroku dynos?
19:16weavejestercshell: What session store are you using?
19:17weavejestercshell: If it's the in-memory store, well, it's an in-memory store.
19:17cshellI'm using noir
19:17cshellthat makes sense
19:17cshellis there an easy way to switch it?
19:17weavejestercshell: The in-memory store is the default. You'll probably want to change it. The cookie store is the easiest option, but you're limited on space.
19:18weavejestercshell: I don't know how you'd change it in Noir. I assume there is a way.
19:18cshellwhat's the limit?
19:19weavejestercshell: I believe IE has a 4k limit on the size of cookies, which limits how much data you can store using the cookie session store.
19:20cshellso if you put it all in the cookie, you'd be vulnerable to replay/man in the middle attacks if they were able to obtain the cookie?
19:21akhudekcshell: I don't think you can't rely on the cookie information being secure. There are also various database backed session store libraries though.
19:22cshellokay, cool, thanks guys
19:29cshellah, it looks like the cookie store can be encrypted
19:29cshellnice thinking Ring authors :)
19:36weavejestercshell: The cookie store is encrypted and signed with a HMAC. It's not really an option, as you wouldn't want to store any session data in plaintext.
19:37cshellYeah, I noticed that it's there automatically - pretty nice!
19:40cshellhmm, still doesn't seem to be working when deployed to heroku on multi dynos - it seems to get the session on the server side only some of the time
19:46akhudekcshell: try deleting your browsers existing cookie
19:47cshellI did, it's still intermittent :(
19:47cshellon a single deployment it doesn't have the problem
19:51cshellhmm, i wonder if enlive is caching it on one and not the other
19:51cshellor in different states
19:51akhudekenlive shouldn't be caching anything other than templates
19:53cshelland even then it doesn't cache all templates, right?
19:56akhudekI think it caches anything defined with deftemplate or defsnippet
19:56akhudekFor dynamic parsing you should be using html-resource with emit*.
19:57cshellyeah, it looks like the 'at' form is assigning cacheable
20:32cshellomg
20:32cshelli bet it's because teh key i'm sending in is different on each server
20:33cshellsince i'm not passing it, it's generating separate ones
20:50lambda-stui'm trying to use a jar I've copied into my lib folder with lein 2.0.0-preview7, but it's not showing up with lein classpath. any ideas?
20:51cshellyes
20:52cshelllein 2 doesn't use the lib directory anymore
20:52cshellit uses your local maven repository
20:52cshellyou might be able to enable some sort of local directory
20:53xeqilambda-stu: lein2 uses deps straight from ~/.m2. You can use lein-localrepo to put it there
20:53xeqithough you break repeatability
20:53xeqi~repeatability
20:53clojurebotrepeatability is crucial for builds, see https://github.com/technomancy/leiningen/wiki/Repeatability
20:55lambda-stuthanks! i'll take a look
22:30sridattahey is anyone here familiar with the "dieter" middleware for ring?
22:32weavejesterdieter's a little odd...
22:32sridattawhat makes you say that?
22:34weavejesterWell, Dieter is middleware that implements a Ruby-inspired middleware system on top of itself.
22:36weavejesterThere doesn't appear to be any advantage to this extra layer.
22:37sridattaah I see. I was mainly trying to use it to compile LESS stylesheets on the fly in my web app. do you know any better way of doing something like this?
22:40weavejestersridatta: Well, Dieter is more complete than any other interpretation I know of. I wrote a library, clj-less, that would just compile a LESS file from a source, and I was planning on writing Ring middleware for LESS compilation and for general caching.
22:41weavejestersridatta: But I've yet to get round to do that. Dieter has a lot of useful code, it's just wrapped up in a really odd structure :/
22:41sridattahehe yeah I recall coming across your clj-less repo while searching, actually. was wondering why your handle seemed familiar...
22:42sridattaDieter seems to be broken for me though. it throws parse errors on Less files that the lessc compiler successfully compile :(
22:42PeregrineA fairly large number of the more prolific clojure library creators hang out here.
22:43PeregrineSo a lot of names will appear familiar
22:43rbxbxHey all, I was just following along with https://github.com/swannodette/logic-tutorial and got to this example:
22:43weavejestersridatta: See if clj-less does any better. Unfortunately I haven't written up the README, but I believe the library is on Clojars.
22:43rbxbx(run* [q]
22:43rbxbx (conde
22:43rbxbx ((fun q))
22:43rbxbx ((likes q 'Mary))))
22:44rbxbxwhy the double parens around the forms inside of conde?
22:44rbxbxDoes (fun q) return a function which we're then calling?
22:44rbxbx(same with likes)
22:44PeregrineI'd open up a repl and experiment with removing those parens
22:45Peregrineand see what you get.
22:45rbxbxArityException Wrong number of args (1) passed to likes
22:46rbxbxit does look like likes and fun return functions though... so yes. Repl'ing up good.
22:46rbxbxI would think you'd want to pass the functions unevaluated to conde though, hm.
22:46weavejesterrbxbx: That example is a little confusing. It would be better if it used a vector, rather than a list.
22:47weavejesterrbxbx: So (conde [(fun q)] [(likes q 'Mary)])
22:48weavejesterIt's basically a logical OR
22:48rbxbxweavejester gotcha. That works as well. Still not sure I grok it fully though.
22:48rbxbxas in, I understand what it's doing, but I don't quite get the invocation
22:48weavejesterSo: (conde [goal1 goal2] [goal3 goal4]) is (goal1 AND goal2) OR (goal3 AND goal4)
22:49rbxbxah
22:49rbxbxThat clarifies. Thanks weavejester :)
22:49weavejesterIn the same way that (run* q goal1 goal2 goal3) is goal1 AND goal2 AND goal3
22:49rbxbx*nod*
22:50joshua__$findfn [1 2 3] [2 3] [1]
22:50lazybot[]
22:50joshua__$findfn [2 3] [1 2 3] [1]
22:50lazybot[]
23:05tos9a/5
23:16rbarraudWho's watching the NASA MSL Curiosity probe coverage?
23:16jhultenrbarraud: you have a good link?
23:17rbarraudHD Internet, yep, seems good.... Dunno whether it's Akamaized here in NZ or not
23:18rbarraudJhulten where u?
23:56RoxxiCan anyone tell me where standard out goes when using Slime/swank with emacs?