2012-08-05
| 00:00 | m0smith | oh I have another question about futures: Does using futures keep the program from terminiating, even if they are all completed? |
| 00:02 | m0smith | that is, are they deamon threads? |
| 00:02 | m0smith | (##source future) |
| 00:02 | m0smith | ##(source future) |
| 00:02 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: source in this context |
| 00:08 | m0smith | I found it: http://dev.clojure.org/jira/browse/CLJ-124 |
| 00:09 | m0smith | ok thanks all. night |
| 00:11 | mdeboard | adios |
| 00:16 | mdeboard | Are there ever actually any locals in the clojure stacktrace? |
| 00:23 | xeqi | mdeboard: http://dev.clojure.org/jira/browse/CLJ-860 looks like a way was added to keep them |
| 00:24 | mdeboard | oic |
| 00:26 | mdeboard | wonder if that's slated for 1.5 or what |
| 00:27 | xeqi | says resolved in 1.4 |
| 00:27 | xeqi | though I've never tried it |
| 00:28 | muhoo | slingshot can show locals in stacktrace, IIRC |
| 00:30 | mdeboard | xeqi: Not clear here on how I would even try it. |
| 00:47 | amalloy | you 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:06 | polypus | ~ping |
| 02:06 | clojurebot | PONG! |
| 02:06 | polypus | carmine Q here: http://gist.github.com/3262135 |
| 03:07 | mdeboard | Why is this macro giving me a stack overflow error? https://gist.github.com/d85b7f024a431cbbdfdf |
| 03:08 | mdeboard | These two macroexpand exprs yield practically the same code https://gist.github.com/5263a49008da659e89ec |
| 03:12 | amalloy | mdeboard: proxy-foo unconditionally contains itself in its expansion |
| 03:12 | amalloy | so that nested macro needs to be expanded, ad infinitum |
| 03:12 | mdeboard | amalloy: I've been reading through your blog post on this exact topic btw (macros in macros) |
| 03:12 | amalloy | hah |
| 03:13 | amalloy | but you're not doing any nested macros |
| 03:13 | mdeboard | well, I guess I mean that like proxy-foo contains proxy, which is a macro itself |
| 03:13 | amalloy | yeah, but pretty much every macro contains another in that way, because let is a macro too |
| 03:13 | mdeboard | oh, right. defn, etc. |
| 03:14 | mdeboard | So, in this case with proxy-foo invoking itself, how do I go about expressing this? |
| 03:14 | amalloy | you probably need your macro to generate a function, and have withMeta call that function |
| 03:14 | mdeboard | I see |
| 03:15 | amalloy | btw, no need for this klass tomfoolery. clojure doesn't have java keywords |
| 03:15 | mdeboard | alternatively, is there a way to define a variable like `(def r PdfReader)' then `(proxy [r clojure.lang.IObj] ...)' |
| 03:15 | amalloy | no |
| 03:15 | mdeboard | ok |
| 03:17 | amalloy | anyway, 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:18 | mdeboard | multiple eval of moremeta? Where? |
| 03:19 | amalloy | then it's more like (defmacro proxy-foo [class] `(fn make# [infile# & [moremeta#]] (proxy [~class IObj] [infile#] (withMeta [newmeta#] (make# infile# newmeta#))))) |
| 03:20 | mdeboard | the 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:20 | mdeboard | I see |
| 03:20 | amalloy | mdeboard: 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:24 | polypus | anybody 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:25 | mdeboard | amalloy: Waddya know, that works. |
| 03:25 | mdeboard | amalloy: You're ok |
| 03:26 | mdeboard | this is like 3 levels of abstraction higher than I'm prepared to go at 3am |
| 03:27 | mdeboard | amalloy: So basically in this gist, the macro below is generating the (proxy-meta) function above right? |
| 03:27 | amalloy | errr, what gist, what's above/below? |
| 03:28 | mdeboard | https://gist.github.com/4010a4cc804b8e83bb56 |
| 03:29 | amalloy | yes |
| 03:29 | amalloy | so the latter macro lets you write the former function with (def proxy-meta (proxy-foo PdfReader)) |
| 03:30 | amalloy | (though seriously, when it's no longer 3am, work on those names) |
| 03:30 | mdeboard | lol, you got it |
| 03:54 | muhoo | heh, a promise is an empty future. |
| 03:57 | foodoo | muhoo: sounds poetic, but sad |
| 03:57 | michaelr` | good morning |
| 03:59 | mdeboard | god I hate itext so much |
| 04:00 | mdeboard | Impossible to extend it via proxy |
| 04:00 | mdeboard | er, it being a particular class in the lib |
| 05:16 | alexyakushev | Is it possible to attach pre- and postconditions to a lambda? |
| 05:57 | TEttinger2 | (https://github.com/technomancy/leiningen/blob/master/bin/lein.bat) |
| 05:57 | TEttinger2 | ,(https://github.com/technomancy/leiningen/blob/master/bin/lein.bat) |
| 05:57 | clojurebot | #<CompilerException java.lang.RuntimeException: No such namespace: https://github.com/technomancy/leiningen/blob/master/bin, compiling:(NO_SOURCE_PATH:0)> |
| 05:57 | TEttinger2 | anyone know how to get lazybot to announce the titles of linked webpages? |
| 05:58 | TEttinger2 | &(https://github.com/technomancy/leiningen/blob/master/bin/lein.bat) |
| 05:58 | lazybot | java.lang.RuntimeException: No such namespace: https://github.com/technomancy/leiningen/blob/master/bin |
| 05:58 | TEttinger2 | &https://github.com/technomancy/leiningen/blob/master/bin/lein.bat |
| 05:58 | lazybot | java.lang.RuntimeException: No such namespace: https://github.com/technomancy/leiningen/blob/master/bin |
| 05:58 | TEttinger2 | hey edlothiol |
| 05:58 | TEttinger2 | just so you know, I am debugging my own lazybot over in #rgrd |
| 05:59 | TEttinger2 | https://github.com/technomancy/leiningen/blob/master/bin/lein.bat |
| 06:00 | TEttinger2 | and I imagine that a bot meant to do this passively wouldn't respond to a PM with a link |
| 06:02 | TEttinger2 | -> https://github.com/technomancy/leiningen/blob/master/bin/lein.bat |
| 06:19 | raek | TEttinger2: note that bots can usually only print titles for HTML documents |
| 06:20 | TEttinger2 | raek, that is a github webpage right? |
| 06:20 | raek | oh, I see. the link _is_ to an html file... |
| 06:28 | Raynes | TEttinger2: Did you get it working? |
| 06:28 | Raynes | $title https://github.com |
| 06:28 | lazybot | "GitHub · Social Coding" |
| 06:28 | Raynes | To make it do it automatically, you have to add some configuration. |
| 06:28 | Raynes | Let me look it up. |
| 06:28 | TEttinger2 | Raynes, I did not. however, I know about the config |
| 06:29 | TEttinger2 | I am trying to get the thing to actually run a selenium test |
| 06:29 | Raynes | I don't follow. |
| 06:29 | TEttinger2 | yes |
| 06:29 | TEttinger2 | so if you paste in www.github.com |
| 06:30 | TEttinger2 | then 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:30 | TEttinger2 | what it is supposed to do is check for trackers on linked sites |
| 06:31 | TEttinger2 | google analytics, advertising networks, the whole deal |
| 06:39 | TEttinger2 | Raynes, 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:39 | TEttinger2 | https://github.com/semperos/clj-webdriver |
| 06:40 | TEttinger2 | I keep getting an unable to resolve symbol error on what should be a valid symbol |
| 06:42 | TEttinger2 | I am trying to edit the title plugin, if that matters |
| 07:28 | TEttinger2 | guh |
| 07:29 | TEttinger2 | java.lang.IllegalArgumentException: No value supplied for key: true |
| 07:29 | TEttinger2 | anyone know what that could be? |
| 07:30 | TEttinger2 | is that like a mismatched hash literal? |
| 08:12 | DaoWen | I've been looking through the docs, and I'm confused by these three macros: binding, with-bindings, with-redefs |
| 08:12 | DaoWen | when would I want to use one as opposed to the others? |
| 08:15 | clj_newb | Hi all, how do I merge sets? |
| 08:16 | DaoWen | clj_newb: (into set-a set-b) |
| 08:16 | clj_newb | thanks! |
| 08:17 | DaoWen | clj_newb: you can also use the functions in clojure.set: http://clojuredocs.org/clojure_core/clojure.set |
| 08:18 | DaoWen | clojure.set/union and clojure.set/intersection specifically, depending on what you mean by "merge" |
| 08:45 | clj_newb | Thanks very much DaoWen |
| 08:46 | DaoWen | you're welcome! |
| 08:50 | gfredericks | DaoWen: with-redefs is just for testing |
| 08:50 | gfredericks | and/or development |
| 08:50 | gfredericks | binding is standard and used whenever you want to give a var a thread-local value |
| 08:51 | gfredericks | with-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:52 | gfredericks | which is probably rare |
| 08:52 | DaoWen | ok |
| 08:52 | DaoWen | so it sounds like with-redefs would never come up in production code |
| 08:52 | gfredericks | if it does you're abusing it |
| 08:53 | gfredericks | it changes globals across all threads |
| 08:53 | gfredericks | so it's not really safe |
| 08:54 | DaoWen | that makes sense |
| 08:56 | DaoWen | I'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:56 | DaoWen | thanks |
| 09:30 | benedikt | Using 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:48 | benedikt | somewhat 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:50 | michaelr` | benedikt: both |
| 09:50 | michaelr` | you can do (use 'clojure.string) |
| 09:51 | michaelr` | or in (ns (:use [clojure.string)) |
| 09:51 | benedikt | what is the syntax like if i embed it in the ns namespace? |
| 09:51 | benedikt | ah |
| 09:51 | benedikt | thanks |
| 09:51 | michaelr` | 'welcome |
| 10:13 | gfredericks | ,(rationalize (rand)) |
| 10:13 | clojurebot | 6761690242602623/10000000000000000 |
| 10:13 | gfredericks | :) |
| 10:15 | michaelr` | ,(rationalize (rand)) |
| 10:15 | clojurebot | 4030645784873027/125000000000000000 |
| 10:16 | TEttinger2 | Raynes, do you remember what customizations lazybot requires to have auto-announce of the titles of links? |
| 10:17 | TEttinger2 | I have :title {:automatic? true} in my config.clj |
| 10:27 | TEttinger2 | ,(apply str (shuffle ["▼" "◀" "▶" "◢" "◣" "◥" "◤" "△" "▽" "◿" "◺" "◹" "◸" "▴" "▾" "◂" "▸" "▵" "▿" "◃" "▹" "◁" "▷" "◅" "▻" "◬" "⟁" "⧋" "⧊" "⊿" "∆" "∇" "◭" "◮" "⧩" "⧨" "⌔" "⟐" "◇" "◆" "◈" "⬖" "⬗" "⬘" "⬙" "⬠" "⬡" "⎔" "⋄" "◊" "⧫" "⬢" "⬣" "▰" "▪" "◼" "▮" "◾" "▗" "▖" "■" "∎" "▃" "▄" "▅" "▆" "▇" |
| 10:27 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 10:28 | TEttinger2 | ,(apply str (shuffle ["▼" "◀" "▶" "◢" "◣" "◥" "◤" "△" "▽" "◿" "◺" "◹" "◸" "▴" "▾" "◂" "▸" "▵" "▿" "◃" "▹" "◁" "▷" "◅" "▻" "◬" "⟁" "⧋" "⧊" "⊿" "∆" "∇" "◭" "◮" "⧩" "⧨" "⌔" "⟐" "◇" "◆" "◈" "⬖" "⬗" "⬘" "⬙" "⬠" "⬡" "⎔" "⋄" "◊" "⧫" "⬢" "⬣" "▰" "▪" "◼" "▮" "◾" "▗" "▖" "■" "∎" "▃" "▄" "▅" "▆" "▇" |
| 10:28 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 10:29 | TEttinger2 | ,(apply str (shuffle ["▼" "◀" "▶" "◢" "◣" "◥" "◤" "△" "▽" "◿" "▂" "▁" "▬" "▔" "▫" "▯" "▭" "▱" "◽" "□" "◻" "▢" ])) |
| 10:29 | clojurebot | "??????????????????????????????????????????????????????????????????" |
| 10:30 | TEttinger2 | (take 10 (cycle (range 0 3))) |
| 10:31 | clojure-newcomer | hi 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:31 | TEttinger2 | ,(apply str (shuffle (take 100 (cycle (range 0 10))))) |
| 10:31 | clojurebot | "2305923435368826349813166532448267361445182423703409270509171857772184654509951599678082198760701906" |
| 10:49 | raek | clojure-newcomer: are the keys integers? |
| 10:50 | clojure-newcomer | raek: I'm trying the following : (contains? st2 {:db/id 17592186045427}) |
| 10:50 | clojure-newcomer | raek: where st2 is : #{{:db/id 17592186045427}} |
| 10:50 | clojure-newcomer | this one works |
| 10:51 | clojure-newcomer | but not st which to all intents and purposes is the same |
| 10:51 | clojure-newcomer | one is a result from diatomic, the other is an explicit set definition |
| 10:52 | raek | what does (class? ...) return for the number values? |
| 10:53 | clojure-newcomer | raek: java.lang.Long |
| 10:54 | raek | for both ones? |
| 10:55 | clojure-newcomer | raek: it seems to |
| 10:55 | clojure-newcomer | raek: (= st st2) yields false |
| 10:55 | raek | does these two maps yield true when passed to =? |
| 10:56 | raek | what is st? |
| 10:56 | clojure-newcomer | both are the sets I mentioned earlier |
| 10:56 | antares_ | clojure-newcomer: can you post a REPL session example? |
| 10:56 | raek | clojure-newcomer: I only see st2 |
| 10:56 | clojure-newcomer | raek: st is the set returned from querying a diatomic result |
| 10:57 | clojure-newcomer | raek: sorry, I was not clear on that |
| 10:57 | raek | what does it look like if you print it? |
| 10:57 | antares_ | 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:57 | clojure-newcomer | raek: st and sty look identical when println'd |
| 10:57 | clojure-newcomer | raek: *st2 |
| 10:58 | raek | antares_: what? I think they use the same model of equality. |
| 11:00 | raek | clojure-newcomer: so if you run (do (prn st) (prn st2) (prn (= st st2))) you get two identical lines, followed by false? |
| 11:01 | clojure-newcomer | here is a REPL session demonstrating my fail: http://pastebin.com/MKWeZ0p4 |
| 11:02 | clojure-newcomer | raek: yes I do |
| 11:04 | raek | clojure-newcomer: the first line has a different number that the rest |
| 11:05 | raek | 17592186045425 instead of 17592186045427 |
| 11:05 | raek | (last digit) |
| 11:05 | antares_ | it is hard to tell what's inside entity but those timestamp-looking ids are not the same |
| 11:06 | antares_ | ,(= "17592186045425" "17592186045427") |
| 11:06 | clojurebot | false |
| 11:06 | clojure-newcomer | raek: yeah, thats ok thats the paren entity, I am pulling a property off that |
| 11:06 | raek | that string comparison might yield true in PHP though... :-) |
| 11:07 | raek | hrm. strange. |
| 11:09 | clojure-newcomer | if its any help, clojure: 1.4.0, datomic: 0.8.3343 |
| 11:09 | raek | clojure-newcomer: what does (for [x [st st2]] [(class x) (class (first x)) (class (first (keys (first x)))) (class (first (vals (first x))))]) return? |
| 11:09 | clojure-newcomer | raek: 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:10 | michaelr` | antares_: Isn't (String. payload) in msg-handler in subscribe supposed to convert the byte array to string? |
| 11:11 | clojure-newcomer | raek: so the first has EntityMap, the second has PersistentHashSet |
| 11:11 | raek | to me it looks like equality is broken for the datomic.query.EntityMap type |
| 11:11 | raek | or maybe this is by design and you should do things differently |
| 11:11 | raek | I recommend asking the datomic folks about this |
| 11:12 | michaelr` | antares_: nm, it does :) |
| 11:12 | clojure-newcomer | raek: thanks for the help, I'll go try to get help |
| 11:12 | clojure-newcomer | from the diatomic guys |
| 11:13 | clojure-newcomer | *datomic… stupid auto correct |
| 11:14 | raek | I would advice against using the (String. byte-array) constructor |
| 11:14 | raek | use (String. byte-array encoding) instead |
| 11:14 | michaelr` | oh |
| 11:15 | michaelr` | raek: otherwise it tries to guess the encoding? |
| 11:15 | raek | michaelr`: no, otherwise it will use the "default one" |
| 11:16 | raek | which is not a very good idea |
| 11:16 | michaelr` | oh |
| 11:16 | raek | this encoding depends on the locale of the user |
| 11:16 | raek | and is wrong on OS X computers |
| 11:16 | raek | (java is told it is Mac Roman, but OS X uses UTF-8) |
| 11:17 | raek | use "UTF-8" unless you have a good reason |
| 11:17 | michaelr` | ok |
| 11:17 | michaelr` | thanks |
| 11:17 | antares_ | leiningen 2 will make JVM use UTF-8 starting with preview5 or so |
| 11:18 | antares_ | via a -Dproperty |
| 11:18 | raek | that's good to hear |
| 11:43 | michaelr` | why pprint doesn't show anything when run inside a `lein run`? |
| 11:44 | michaelr` | i know it' |
| 11:44 | michaelr` | s |
| 11:44 | michaelr` | something with the stdout redirection |
| 11:44 | michaelr` | better question is how do i fix it? :) |
| 11:47 | michaelr` | ,(doc pprint) |
| 11:47 | clojurebot | I don't understand. |
| 12:23 | duck1123 | michaelr`: are you able to see normal println messages |
| 12:59 | davidd___ | I wrote a function that looks really ugly. can someone tell me how I can refactor it: https://www.refheap.com/paste/4055 |
| 13:06 | tmciver | davidd___: 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:08 | gfredericks | davidd___: s/save-user/save-user?/ |
| 13:21 | davidd___ | tmciver, gfredericks: thanks! |
| 13:49 | muhoo | hmm, 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:52 | muhoo | so there are two compilers going in parallel on what may be the same code? |
| 14:01 | muhoo | also, 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:02 | muhoo | i.e. this is not the expected behavior: https://www.refheap.com/paste/4057 |
| 14:03 | muhoo | oh, duh, it's javascript, i can use js interop. nm. |
| 14:11 | pandeiro | muhoo: what would you like to do? |
| 14:13 | pandeiro | are you trying to get (.-innerHTML el) or (.-innerText el) by chance? |
| 14:13 | pandeiro | or are you wanting to do the reverse of what crate does? ie HTMLDivElement -> [:div "something"] ? |
| 14:13 | muhoo | pandeiro: that's the one :-) |
| 14:14 | pandeiro | the reverse? |
| 14:14 | muhoo | well, the crate docs say this: https://github.com/ibdknox/crate |
| 14:14 | pandeiro | man that i have no idea but when you figure it out, please pass me that code :) |
| 14:14 | muhoo | but what i was getting in the repl was this: https://www.refheap.com/paste/4057 |
| 14:14 | pandeiro | but is it necessarily coming from the HTML object? |
| 14:14 | muhoo | so, nrepl was, for me, returning the object, but in the docs, it looks like it was returning .-innerHTML on it |
| 14:15 | pandeiro | DOM object i mean? |
| 14:15 | muhoo | i'm not sure. this is cljs :-) |
| 14:16 | meenal | Hi, is there a StringBuffer like datastructure in clojure? |
| 14:16 | pandeiro | I don't think you can go from a DOM Object (ie <[object HTMLParagraphElement]>) to a crate/hiccup vector very easily |
| 14:16 | pandeiro | i think you'd need to serialize it to HTML string (.-innerHTML) and then parse |
| 14:16 | pandeiro | basically a new lib for that |
| 14:16 | muhoo | pandeiro: no i'm just looking at having readable in the repl |
| 14:17 | muhoo | #<[object HTMLParagraphElement]> is not very informative |
| 14:17 | muhoo | but, 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:17 | pandeiro | maybe somehow crate could save a string representation of the vector data structure when it makes the DOMElement |
| 14:18 | pandeiro | no it never printed out the entire html string, not that i remember |
| 14:18 | pandeiro | hiccup would do that |
| 14:18 | muhoo | but, that's what i'm seeing in that Readme.md |
| 14:18 | pandeiro | not crate, which creates DOMObjects |
| 14:18 | pandeiro | ah, different fn? |
| 14:18 | muhoo | https://github.com/ibdknox/crate/blob/master/README.md |
| 14:19 | muhoo | not 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:20 | muhoo | this istuff is very cool though. |
| 14:20 | muhoo | heh, not istuff, i don't like iStuff |
| 14:21 | pandeiro | nah if you look at crate.core, html is creating actual DOM objects |
| 14:21 | pandeiro | i think the README is wrong |
| 14:21 | pandeiro | maybe ibdknox will chime in |
| 14:21 | muhoo | right, as i'd expect. ok maybe that's it then. |
| 14:22 | pandeiro | wonder 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:22 | muhoo | metadata? |
| 14:22 | clojurebot | ? "Returns the metadata of obj, returns nil if there is no metadata." |
| 14:22 | pandeiro | right, in HTML? |
| 14:22 | muhoo | if it's an object, hmm.. how does cljs store metadata, i wonder |
| 14:22 | pandeiro | like, attached the DOM object? don't think it's possible? |
| 14:23 | pandeiro | i think that's all in clojure's data structure code, not applicable to a HTMLParagraphElement etc |
| 14:23 | pandeiro | jQuery can attach data to DOM nodes |
| 14:24 | pandeiro | i've never looked at how that's implemented though |
| 14:24 | pandeiro | i guess there's no reason it couldn't just be added to the DOM object itself |
| 14:25 | muhoo | No protocol method IWithMeta.-with-meta defined for type object: [object HTMLParagraphElement]> |
| 14:25 | pandeiro | maybe you could extend it |
| 14:26 | muhoo | looks that way |
| 14:26 | pandeiro | or just use JS interop a la (set! (.-crate el) crate-string) |
| 14:27 | pandeiro | but 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:27 | muhoo | i'd rather it be clojureish, like with-meta. i'll put that on the loist of things to play with. |
| 14:28 | pandeiro | yeah should be possible to extend those DOM objects to IWithMeta right? |
| 14:28 | muhoo | just add the protocol i think. |
| 14:28 | muhoo | i saw a talk by lynagh or chouser or someone on how to extend js with protocols |
| 14:28 | pandeiro | muhoo: jayq.core has a good examples, he made the jQuery object seqable |
| 14:29 | muhoo | cool, thanks! |
| 14:29 | antares_ | Spyglass 1.0 is out: http://clojurememcached.info |
| 14:29 | muhoo | i 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:31 | meenal | fbuffe |
| 14:31 | piranha_ | 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:33 | antares_ | piranha_: start with showing your code |
| 14:33 | piranha_ | antares_: https://github.com/piranha/cj-locations/blob/master/src/google.cljs#L9 |
| 14:33 | piranha_ | here are they in different modules, protocol is obviously in map.cljs |
| 14:35 | muhoo | piranha: google maps wrapper in cljs? very cool! |
| 14:35 | antares_ | 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:36 | piranha | muhoo: well, this is only for a limited thing, I'm just starting with clojure/cljs |
| 14:36 | antares_ | however, I typically use defprotocol + extend-protocol, not the extended defrecord form |
| 14:36 | piranha | well, I tried to go this way |
| 14:36 | muhoo | piranha: maybe it's the order in which they are included? |
| 14:36 | piranha | it generates code in same way... |
| 14:36 | piranha | muhoo: hmhm, well, the thing is that it looks like there is some support code which wasn't generated or something like that |
| 14:36 | muhoo | might want to look at the generated js and see the order of the require() calls |
| 14:37 | antares_ | piranha: have you tried separating defrecord and protocol extension code (with extend-protocol, for example)? |
| 14:37 | piranha | well, satisfies? checks that Map knows about this Google it seems |
| 14:37 | piranha | antares_: yes, I did - result was the same |
| 14:38 | piranha | well, not exactly, since I couldn't use just names of properties (gmap/coder/info), but in other way same effect |
| 14:39 | piranha | eh... probably it would be better to write to a clojure mailing list, since not everybody is online on irc all the time :) |
| 14:39 | antares_ | you :use [locations.map :only [Map init locate set-city]]. That's a little strange. |
| 14:39 | antares_ | :only should be listing functions, not protocol names |
| 14:39 | antares_ | although it should not matter, the point is to get the namespace loaded & compiled |
| 14:39 | antares_ | and :use accomplishes that |
| 14:40 | piranha | hmmm |
| 14:40 | piranha | well, I wanted to import Map to check with satisfies? |
| 14:40 | piranha | I could check it with require as well, give me a second |
| 14:48 | piranha | antares_: it's the same... |
| 14:49 | antares_ | ok, probably CLJS protocols have something to them that I do not know |
| 14:49 | piranha | seems like a bug to me |
| 14:49 | piranha | I'll write to mailing list then |
| 14:54 | clj_newb | Hi, in this persistent array map {false [1 2], true [4]} how do I get the keys? |
| 14:54 | gfredericks | ,(keys {false [1 2], true [4]} |
| 14:54 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 14:54 | gfredericks | ,(keys {false [1 2], true [4]}) |
| 14:54 | clojurebot | (true false) |
| 14:54 | antares_ | ,(keys {:a 1 :b 2}) |
| 14:54 | clojurebot | (:a :b) |
| 14:55 | antares_ | ,(values {:a 1 :b 2}) |
| 14:55 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: values in this context, compiling:(NO_SOURCE_PATH:0)> |
| 14:55 | clj_newb | (keys {false [1 2], true [4]}) yields (false true), but (:false {false [1 2], true [4]}) yields nil |
| 14:55 | antares_ | ,(vals {:a 1 :b 2}) |
| 14:55 | clojurebot | (1 2) |
| 14:55 | gfredericks | clj_newb: false and :false are different |
| 14:55 | gfredericks | ,(get {false [1 2], true [4]} false) |
| 14:55 | clojurebot | [1 2] |
| 14:56 | gfredericks | ,(map type [false :false]) |
| 14:56 | clojurebot | (java.lang.Boolean clojure.lang.Keyword) |
| 14:56 | clj_newb | aah, I got confuse when (false {false [1 2], true [4]}) failed |
| 14:56 | clj_newb | thanks both |
| 14:57 | gfredericks | clj_newb: keywords (like :false) are special in that you can use them as functions for accessing maps |
| 14:57 | gfredericks | for any other type of key you can use get or you can use the map itself as a function |
| 14:57 | antares_ | they are not "special", they just can be used as functions on maps |
| 14:57 | antares_ | to look themselves up in the argument |
| 14:57 | gfredericks | antares_: what's not special about that? |
| 14:57 | antares_ | (map :age [{:name "Joe" :age 30} {:name "Marie" :age 29}]) |
| 14:57 | antares_ | ,(map :age [{:name "Joe" :age 30} {:name "Marie" :age 29}]) |
| 14:57 | clojurebot | (30 29) |
| 14:58 | antares_ | gfredericks: several other things in Clojure can be used as functions, e.g. sets |
| 14:59 | gfredericks | antares_: 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:10 | muhoo | piranha__: i don't fully trust the compiler yet, so i'd recommend checking the generated .js and make sure it has your changes |
| 15:11 | piranha__ | muhoo: yes, it does |
| 15:11 | jrheard | hi 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:12 | jrheard | the compiler doesn't like it when i have a bare Exception. sitting around though |
| 15:12 | piranha | muhoo: 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:12 | jrheard | e.g. this fails: |
| 15:12 | jrheard | (ensure-in x resource-types 'ClassCastException.) |
| 15:12 | jrheard | with and without the quote |
| 15:12 | jrheard | am i doing something really stupid :/ |
| 15:14 | jrheard | are java constructors not first-class functions or is my mental map of the situation messed up? |
| 15:17 | antares_ | jrheard: they are not functions |
| 15:17 | jrheard | huh! |
| 15:17 | antares_ | they are invoked via special forms |
| 15:17 | jrheard | aha |
| 15:17 | jrheard | i'm working through "clojure programming" but haven't gotten to the interop chapter yet :/ |
| 15:17 | jrheard | do i have any options here? i kind of like this idea, it seems nice |
| 15:18 | antares_ | jrheard: it's not hard: (ClassName. arg1 arg2 arg3) |
| 15:18 | jrheard | so i should pass along an instance instead of just what i was hoping was a reference to a function? |
| 15:18 | jrheard | e.g. (ensure-in x resource-types (ClassCastException.)) |
| 15:19 | antares_ | jrheard: you want to instantiate an object from a class you get in a local? |
| 15:19 | jrheard | yes indeed |
| 15:19 | jrheard | specifically that |
| 15:20 | muhoo | jrheard: the interop chapter in clojure programming is very good. once you get there, it will all make sense :-) |
| 15:21 | jrheard | good to hear :) this book has been really fantastic so far |
| 15:21 | muhoo | i'd recommend skipping ahead and skimming if this is in your critical path now. |
| 15:21 | jrheard | i'll do that, it is |
| 15:21 | muhoo | it's a great book for skipping around if you need to |
| 15:23 | antares_ | jrheard: that's possible but a bit tricky. I will try to put together a reasonable example (out of curiosity) |
| 15:23 | antares_ | jrheard: basically, Java classes have the newInstance method you can use but there are nuances |
| 15:24 | antares_ | you can also do things like ,(Class/forName "java.lang.Long") |
| 15:24 | jrheard | whooa |
| 15:24 | antares_ | this is how all those ORMs and stuff dynamically load DB drivers, for example |
| 15:24 | antares_ | w/o depending on them all at once |
| 15:25 | jrheard | i would love to see that example whenever you get around to it :) i'm @jrheard in case i'm not online |
| 15:25 | jrheard | thanks for the guidance antares_ muhoo! |
| 15:29 | gfredericks | jrheard: also you could instead of passing in classes pass in functions that will return an exception |
| 15:29 | gfredericks | so #(ClassCastException.) |
| 15:29 | jrheard | yeah, that makes sense |
| 15:29 | jrheard | i'll just do that! |
| 15:29 | jrheard | thanks :) |
| 15:47 | babysnakes | hi, 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:47 | muhoo | that's kinda funny. ($ :a) returns an object, but there are no links. and (count ($ :a)) is 0 |
| 15:48 | muhoo | leaky abstraction, perhance |
| 15:50 | muhoo | babysnakes: one of the guys here (borkdude)? wrote a hebrew tutorial app in clojure |
| 15:51 | muhoo | babysnakes: http://borkent-app2.appspot.com, i think |
| 15:52 | babysnakes | muhoo: 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:10 | TimMc | Presumably babysnakes wants to extract it because it screws up a normal text editor. |
| 16:23 | otfrom | evening all |
| 16:38 | weavejester | otfrom: Evenin' |
| 17:01 | Frozenlock | It's possible to sort in congomongo using :sort, but how does one can change the sort order? |
| 17:02 | cshell | does mongo have a sort construct? |
| 17:02 | Frozenlock | yes http://www.mongodb.org/display/DOCS/Sorting+and+Natural+Order |
| 17:04 | cshell | looks like you can |
| 17:05 | cshell | :sort {:key 1} |
| 17:05 | cshell | or -1 |
| 17:05 | Frozenlock | Yeah, I've tried that :P |
| 17:07 | Frozenlock | I'm unable to change the sort order... I've tried :sort {:key -1}, [:key -1], [[:key -1]]... |
| 17:09 | cshell | you're not using fetch-one are you |
| 17:09 | cshell | ? |
| 17:10 | Frozenlock | I am, why? |
| 17:11 | cshell | www.litbuildingdb.com/search |
| 17:11 | cshell | oops |
| 17:11 | cshell | not that |
| 17:11 | cshell | http://bit.ly/PxGe60 |
| 17:11 | cshell | that |
| 17:13 | cshell | looks like you have to use fetch to do it |
| 17:13 | Frozenlock | eh what... If I understand correctly, if I want to sort, I will get all the results? |
| 17:13 | cshell | no, you'll get a cursor |
| 17:14 | Frozenlock | So if I do (first (fetch...)) I will NOT download the entire collection? |
| 17:15 | cshell | not sure, you'll have to experiment, but there's also :limit |
| 17:15 | Frozenlock | Oh right! |
| 17:15 | Frozenlock | Forgot about this one. |
| 17:16 | Frozenlock | Thanks for the answer btw, I would never have guessed that fetch-one was different from fetch! |
| 17:16 | cshell | haha either would I |
| 18:12 | akhudek | working with google's closure is often very frustrating. :-( |
| 18:26 | pandeiro | akhudek: tell me about it |
| 18:27 | pandeiro | and the partially unfinished abstractions in clojure.browser.* don't make it much easier |
| 18:28 | pandeiro | i 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:29 | pandeiro | all the protocols in clojure.browser.net are just an additional layer of indirection that makes it harder to understand what's happening |
| 18:51 | akhudek | pandeiro: I briefly looked at the clojure.browser.net namespace and ended up using jayq to do RPC instead |
| 18:51 | akhudek | my latest frustrations have been with the closure editor |
| 18:52 | akhudek | some of the editor plugins just don't do what they advertise and there is no information or complaints on their discussion group |
| 18:52 | akhudek | It's quite confusing. I can only imagine that not many people use it outside of google. |
| 18:57 | pandeiro | akhudek: yes and i get the impression even much of google has moved on? |
| 18:57 | pandeiro | definitely google docs isn't using it |
| 18:57 | pandeiro | then there's angular js or whatever it is |
| 18:57 | pandeiro | i was also disappointed with the editor for lack of documentation |
| 18:58 | pandeiro | not lack of docs per se, but the lack of an open source ecosystem, blog posts, irc, that sort of thing |
| 19:16 | cshell | has anyone had any problems with ring's sessions not being shared across heroku dynos? |
| 19:16 | weavejester | cshell: What session store are you using? |
| 19:17 | weavejester | cshell: If it's the in-memory store, well, it's an in-memory store. |
| 19:17 | cshell | I'm using noir |
| 19:17 | cshell | that makes sense |
| 19:17 | cshell | is there an easy way to switch it? |
| 19:17 | weavejester | cshell: 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:18 | weavejester | cshell: I don't know how you'd change it in Noir. I assume there is a way. |
| 19:18 | cshell | what's the limit? |
| 19:19 | weavejester | cshell: 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:20 | cshell | so 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:21 | akhudek | cshell: 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:22 | cshell | okay, cool, thanks guys |
| 19:29 | cshell | ah, it looks like the cookie store can be encrypted |
| 19:29 | cshell | nice thinking Ring authors :) |
| 19:36 | weavejester | cshell: 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:37 | cshell | Yeah, I noticed that it's there automatically - pretty nice! |
| 19:40 | cshell | hmm, 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:46 | akhudek | cshell: try deleting your browsers existing cookie |
| 19:47 | cshell | I did, it's still intermittent :( |
| 19:47 | cshell | on a single deployment it doesn't have the problem |
| 19:51 | cshell | hmm, i wonder if enlive is caching it on one and not the other |
| 19:51 | cshell | or in different states |
| 19:51 | akhudek | enlive shouldn't be caching anything other than templates |
| 19:53 | cshell | and even then it doesn't cache all templates, right? |
| 19:56 | akhudek | I think it caches anything defined with deftemplate or defsnippet |
| 19:56 | akhudek | For dynamic parsing you should be using html-resource with emit*. |
| 19:57 | cshell | yeah, it looks like the 'at' form is assigning cacheable |
| 20:32 | cshell | omg |
| 20:32 | cshell | i bet it's because teh key i'm sending in is different on each server |
| 20:33 | cshell | since i'm not passing it, it's generating separate ones |
| 20:50 | lambda-stu | i'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:51 | cshell | yes |
| 20:52 | cshell | lein 2 doesn't use the lib directory anymore |
| 20:52 | cshell | it uses your local maven repository |
| 20:52 | cshell | you might be able to enable some sort of local directory |
| 20:53 | xeqi | lambda-stu: lein2 uses deps straight from ~/.m2. You can use lein-localrepo to put it there |
| 20:53 | xeqi | though you break repeatability |
| 20:53 | xeqi | ~repeatability |
| 20:53 | clojurebot | repeatability is crucial for builds, see https://github.com/technomancy/leiningen/wiki/Repeatability |
| 20:55 | lambda-stu | thanks! i'll take a look |
| 22:30 | sridatta | hey is anyone here familiar with the "dieter" middleware for ring? |
| 22:32 | weavejester | dieter's a little odd... |
| 22:32 | sridatta | what makes you say that? |
| 22:34 | weavejester | Well, Dieter is middleware that implements a Ruby-inspired middleware system on top of itself. |
| 22:36 | weavejester | There doesn't appear to be any advantage to this extra layer. |
| 22:37 | sridatta | ah 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:40 | weavejester | sridatta: 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:41 | weavejester | sridatta: 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:41 | sridatta | hehe yeah I recall coming across your clj-less repo while searching, actually. was wondering why your handle seemed familiar... |
| 22:42 | sridatta | Dieter seems to be broken for me though. it throws parse errors on Less files that the lessc compiler successfully compile :( |
| 22:42 | Peregrine | A fairly large number of the more prolific clojure library creators hang out here. |
| 22:43 | Peregrine | So a lot of names will appear familiar |
| 22:43 | rbxbx | Hey all, I was just following along with https://github.com/swannodette/logic-tutorial and got to this example: |
| 22:43 | weavejester | sridatta: See if clj-less does any better. Unfortunately I haven't written up the README, but I believe the library is on Clojars. |
| 22:43 | rbxbx | (run* [q] |
| 22:43 | rbxbx | (conde |
| 22:43 | rbxbx | ((fun q)) |
| 22:43 | rbxbx | ((likes q 'Mary)))) |
| 22:44 | rbxbx | why the double parens around the forms inside of conde? |
| 22:44 | rbxbx | Does (fun q) return a function which we're then calling? |
| 22:44 | rbxbx | (same with likes) |
| 22:44 | Peregrine | I'd open up a repl and experiment with removing those parens |
| 22:45 | Peregrine | and see what you get. |
| 22:45 | rbxbx | ArityException Wrong number of args (1) passed to likes |
| 22:46 | rbxbx | it does look like likes and fun return functions though... so yes. Repl'ing up good. |
| 22:46 | rbxbx | I would think you'd want to pass the functions unevaluated to conde though, hm. |
| 22:46 | weavejester | rbxbx: That example is a little confusing. It would be better if it used a vector, rather than a list. |
| 22:47 | weavejester | rbxbx: So (conde [(fun q)] [(likes q 'Mary)]) |
| 22:48 | weavejester | It's basically a logical OR |
| 22:48 | rbxbx | weavejester gotcha. That works as well. Still not sure I grok it fully though. |
| 22:48 | rbxbx | as in, I understand what it's doing, but I don't quite get the invocation |
| 22:48 | weavejester | So: (conde [goal1 goal2] [goal3 goal4]) is (goal1 AND goal2) OR (goal3 AND goal4) |
| 22:49 | rbxbx | ah |
| 22:49 | rbxbx | That clarifies. Thanks weavejester :) |
| 22:49 | weavejester | In the same way that (run* q goal1 goal2 goal3) is goal1 AND goal2 AND goal3 |
| 22:49 | rbxbx | *nod* |
| 22:50 | joshua__ | $findfn [1 2 3] [2 3] [1] |
| 22:50 | lazybot | [] |
| 22:50 | joshua__ | $findfn [2 3] [1 2 3] [1] |
| 22:50 | lazybot | [] |
| 23:05 | tos9 | a/5 |
| 23:16 | rbarraud | Who's watching the NASA MSL Curiosity probe coverage? |
| 23:16 | jhulten | rbarraud: you have a good link? |
| 23:17 | rbarraud | HD Internet, yep, seems good.... Dunno whether it's Akamaized here in NZ or not |
| 23:18 | rbarraud | Jhulten where u? |
| 23:56 | Roxxi | Can anyone tell me where standard out goes when using Slime/swank with emacs? |