2012-03-31
| 00:00 | ibdknox | it's neat and a wonderful source of documentation :) |
| 00:01 | autodidakto | ibdknox: documentation? |
| 00:01 | ibdknox | it has an epic wiki |
| 00:01 | ibdknox | brenton did great work on that |
| 00:01 | autodidakto | ah |
| 00:04 | johnkpaul-afk | oakwise: great, thank you! |
| 00:04 | johnkpaul-afk | very happy to not only know that it wasn't just me going crazy, but also that someone could fix it so soon |
| 00:06 | autodidakto | ibdknox: reading the google group thread on the pinot separation. I agree with the need of an awesome united wiki/documentation for Noir/Pinot :) |
| 00:06 | ibdknox | none of the new libs have had an official release yet :) |
| 00:08 | autodidakto | ibdknox: you're overworked, delegate |
| 00:09 | ibdknox | that's likely what will need to happen at some point soon |
| 00:09 | ibdknox | I seem to only be getting busier |
| 00:46 | gtrak`` | is there a complement to group-by that inverts the relationship, vals are what's returned from the function? |
| 00:46 | qbg | inverts how? |
| 00:47 | gtrak`` | with group-by, original seq is the vals, i want the original seq to be the keys |
| 00:47 | qbg | Returns a map of val -> group? |
| 00:49 | gtrak`` | I suppose I could just reduce assoc, but that's lame |
| 00:49 | qbg | So you want a result like {:a [:a], :b [:b :b :b]} for example? |
| 00:49 | ibdknox | gtrak``: I don't understand what you're asking for |
| 00:50 | gtrak`` | just... inputs [:a :b :c :d], result is {:a (f :a) :b (f :b) ...} |
| 00:50 | qbg | Check out zipmap |
| 00:51 | qbg | &(let [x [1 2 3 4]] (zipmap x (map inc x))) |
| 00:51 | lazybot | ⇒ {4 5, 3 4, 2 3, 1 2} |
| 00:51 | gtrak`` | ah, perfect |
| 00:51 | gtrak`` | i remember people hating on zipmap, just found this to look at though: http://stackoverflow.com/questions/6135764/when-to-use-zipmap-and-when-map-vector |
| 02:06 | muhoo | so if i were to try to use a persistent store for sessions in noir, it looks like session.clj just stores sessions in a map in an atom |
| 02:06 | muhoo | so, what kind of database would i use that has functions like assoc, get, swap!, and reset! |
| 02:07 | muhoo | or rather, that'd work with those core clojure functions. |
| 02:12 | muhoo | hmm, there's this i see now: https://gist.github.com/1565647 |
| 02:17 | ibdknox | muhoo: just use a different session store |
| 02:17 | ibdknox | like the mongo one: https://github.com/amalloy/mongo-session/blob/develop/src/mongo_session/core.clj |
| 02:18 | muhoo | ok, thanks |
| 02:28 | muhoo | hee hee hee. try this if you dare: https://refheap.com/paste/1603 |
| 02:28 | muhoo | warning: don't try it on a repl that has history or data you care about |
| 02:30 | muhoo | &(use '[ring.middleware.session.store :only [SessionStore]]) |
| 02:30 | lazybot | java.io.FileNotFoundException: Could not locate ring/middleware/session/store__init.class or ring/middleware/session/store.clj on classpath: |
| 02:30 | muhoo | good |
| 02:32 | muhoo | print_r() in php has it, ffs, so i'm sure it can be done in clojure too |
| 02:42 | muhoo | aha! (set! *print-level* 15) |
| 02:48 | emezeske | If anyone ran into issues with lein-cljsbuild 0.1.4 with hooks enabled: I just released 0.1.5, which should fix that. |
| 05:11 | adriann | halo |
| 07:33 | tomoj | js2-mode highlights lines with a warning "Code has no side effects" :) |
| 08:35 | frankvilhelmsen | /who *sam* |
| 08:36 | AimHere | /whois frankvilhelmsen |
| 08:38 | solussd_ | I was thinking, it would be nice to have pre/post condition support in protocol declarations. Right now the best I can do is describe in the docstrings for the protocol functions what the implementor is suppose to do, but the protocol cannot enforce any details of the interface- notably its input and output. :/ |
| 08:47 | gfredericks | solussd_: I can imagine a macro that does that |
| 08:48 | gfredericks | no I can't |
| 08:48 | solussd_ | gfredericks: I can't think of a way to do it using a macro around defprotocol |
| 08:48 | solussd_ | b/c I want to be able to (defrecord …. Protocol .. implementations) |
| 08:48 | gfredericks | yeah that's why I retracted |
| 08:49 | solussd_ | ;) |
| 08:49 | gfredericks | so if we redef one of the protocol functions after defining the protocol, does that either crash or somehow screw things up? |
| 08:53 | solussd_ | hmm |
| 08:54 | gfredericks | also I think fogus's relevant library does stuff with adding constraints afterwards |
| 08:54 | gfredericks | though that's not any more obviously bound to succeed |
| 10:21 | gortsleigh | In Korma, is it possible to specify entity relationship for something like table 'song' with column 'artistid' that joins to table 'artist' on (song.artistid = artist.id) ?? |
| 10:21 | lazybot | gortsleigh: Uh, no. Why would you even ask? |
| 10:43 | bork | given a list of maps, how can I find the map with the maximum :x value? |
| 10:44 | gfredericks | hm |
| 10:45 | gfredericks | &(first (sort-by (comp - :x) [{:x 12} {:x 18} {:x -8}])) |
| 10:45 | lazybot | ⇒ {:x 18} |
| 10:46 | AimHere | Something like &(reduce #(if (> (%1 :x) (%2 :x)) %1 %2) {:x 1} {:x 14} {:x 17}) |
| 10:46 | gfredericks | that's not the most efficient way, but the linear-time solution might require some custom loop code or something |
| 10:46 | gfredericks | or reduce :) |
| 10:47 | gfredericks | I knew there'd be something |
| 10:47 | AimHere | &(reduce #(if (> (%1 :x) (%2 :x)) %1 %2) [{:x 1} {:x 414} {:x 17}]) |
| 10:47 | lazybot | ⇒ {:x 414} |
| 10:47 | AimHere | The more I play with clojure, the more I like reduce |
| 10:47 | bork | thanks! |
| 10:47 | bork | right after i asked the question, i remembered about reduce |
| 10:47 | bork | yay reduce! |
| 10:48 | bork | ... for some reason it didn't occur to me to think about the 2-parameter case first |
| 10:48 | bork | is there an easy to find the first local maximum in a list? |
| 10:49 | gfredericks | reduce! or loop if you want to short circuit |
| 10:49 | gfredericks | no wait there's a lazy way too i think |
| 10:50 | bork | maybe i could do something like |
| 10:50 | gfredericks | "local maximum" just means element greater than both neighbors right? |
| 10:50 | gfredericks | &(partition 3 1 (range 5)) |
| 10:50 | bork | yeah |
| 10:50 | lazybot | ⇒ ((0 1 2) (1 2 3) (2 3 4)) |
| 10:50 | gfredericks | so doing that ^ would be a good pr-step |
| 10:50 | gfredericks | pre-step |
| 10:50 | bork | oh, and then i could use 'some' |
| 10:50 | gfredericks | yeah something like that |
| 10:51 | gfredericks | (def first-local-max (comp (partial some #(...)) (partial partition 3 1))) :D |
| 10:52 | gfredericks | bork: you don't need it here I was just indulging in some point-free play |
| 10:52 | gfredericks | but it's good to know about |
| 10:57 | the-kenny | Hey, I just wrote a small elisp function to run lein-cljsbuild in a dedicated Emacs buffer. As a bonus you get "Build {succeeded,failed}" messages in the minibuffer: https://gist.github.com/2265584 |
| 10:57 | the-kenny | Might be useful for some people |
| 11:06 | bork | gfredericks: also came up with (defn localmax [x & xs] (if (and xs (< x (first xs))) (apply localmax xs) x) |
| 11:26 | gfredericks | bork: I think that particular impl would eat a lot of stack |
| 11:26 | Phallah- | &(let [some-datum (list (symbol "I worship His Shadow"))] (= some-datum (read-str (print-string some-datum)))) |
| 11:26 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: read-str in this context |
| 11:26 | Phallah- | &(let [some-datum (list (symbol "I worship His Shadow"))] (= some-datum (read-string (print-str some-datum)))) |
| 11:26 | lazybot | ⇒ false |
| 11:26 | Phallah- | Burp |
| 11:26 | Phallah- | So ehhh |
| 11:27 | Phallah- | does Clojure have support for multiple value return? |
| 11:31 | progo | using the usual datastructures is idiomatic |
| 11:34 | Zoka | Phallah-: yes, just return them in a vector |
| 11:35 | Bronsa | Phallah-: spaces in symbol are not supported |
| 11:35 | Phallah- | Okay, I take that as a no then. |
| 11:35 | Phallah- | But thanks for assuming I'm stupid. |
| 11:35 | Phallah- | Bronsa, I know |
| 11:35 | bork | gfredericks: oh, okay! i don't have a good understanding of how the builtin functions work |
| 11:35 | Phallah- | that is what makes it burpidurp |
| 11:35 | Bronsa | oh. |
| 11:35 | Phallah- | Because (symbol "Some spaces and tralalala" |
| 11:35 | bork | (yet) |
| 11:36 | Phallah- | Doesn't signal an error |
| 11:36 | Phallah- | &(symbol? (symbol "Burp herp derp")) |
| 11:36 | lazybot | ⇒ true |
| 11:36 | Phallah- | I beg to differ! |
| 11:36 | Bronsa | oh, that bugs me too |
| 11:36 | Phallah- | Quite |
| 11:36 | Phallah- | I love a man who gets bugged by this kind of stuff |
| 11:37 | Phallah- | &(print (list (symbol "This doesn't quite do what one expects")) |
| 11:37 | lazybot | java.lang.RuntimeException: EOF while reading, starting at line 1 |
| 11:37 | Phallah- | &(print (list (symbol "This doesn't quite do what one expects"))) |
| 11:37 | lazybot | ⇒ (This doesn't quite do what one expects)nil |
| 12:20 | muhoo | fliebel__: i haven't written stuff to use it, but i use ols, which seems a lot more reliable since they switched from rxtx to purejavacomm, fwiw |
| 12:21 | fliebel__ | muhoo: https://github.com/nyholku/purejavacomm/pull/5 :/ |
| 12:21 | fliebel__ | (= fliebel pepijndevos) |
| 12:22 | muhoo | nice |
| 12:23 | fliebel__ | Anyway, after writing half of clojure.core in Python, writing my DPScope interface was fairly easy. |
| 12:25 | muhoo | ! |
| 12:25 | muhoo | what, greenspun's law? |
| 12:25 | fliebel__ | $google greenspun's law |
| 12:25 | lazybot | [Greenspun's tenth rule - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Greenspun's_tenth_rule |
| 12:26 | muhoo | also, i looked at that patch, didn't see any change to that case statement excelt indentation, afaict |
| 12:27 | fliebel__ | muhoo: The change is that I don't use the case statement, on Mac, we twiddle some ioctl parameters instead. |
| 12:48 | muhoo | huh. maybe a bsd termios vs linux termios difference. |
| 12:49 | muhoo | still, imagine trying to fix that in rxtx? |
| 12:51 | muhoo | fliebel__: did you build your own dpscope or buy one? |
| 13:26 | fliebel__ | muhoo: buy one |
| 13:31 | Phallah- | &(apply vector [[1 2 3] [4 5 6] [7 8 9]]) |
| 13:31 | lazybot | ⇒ [[1 2 3] [4 5 6] [7 8 9]] |
| 13:32 | Phallah- | &(map vector [[1 2 3] [4 5 6] [7 8 9]]) |
| 13:32 | lazybot | ⇒ ([[1 2 3]] [[4 5 6]] [[7 8 9]]) |
| 13:32 | Phallah- | &(apply map vector [[1 2 3] [4 5 6] [7 8 9]]) |
| 13:32 | lazybot | ⇒ ([1 4 7] [2 5 8] [3 6 9]) |
| 13:34 | Iceland_jack | Check out http://en.wikipedia.org/wiki/Convolution_%28computer_science%29#In_programming_languages |
| 13:39 | mbriggs | hey guys, using noir (wrapper on top of compojure), do you know if there is any way to set both the response status code and the content type? |
| 13:39 | mbriggs | the noir.response ns seems to just do one thing for each method |
| 13:41 | mbriggs | nvm, was reading response.clj, and set-headers is low level enough to do multiple things |
| 13:45 | xeqi | mbriggs: I think you can use ->> to thread them |
| 13:47 | RickInGA | I am working through ch 2 in the reasoned schemer, and I wasn't sure why this code gave me an error: https://refheap.com/paste/1614 |
| 13:50 | oakwise | dnolen: how are you testing the browser repl against cljs HEAD? It seems broken in either `cljsbuild repl-listen` or started manually in 1006 and 1010, but works in 993 for me. |
| 13:52 | cjfrisz | RickInGA: what error are you getting? |
| 13:53 | RickInGA | It says it can't create ISeq from a logic var |
| 13:54 | RickInGA | if I write it as (cons x (cons y ()) I get (grape (a)) because y resolves to the list '(a) |
| 13:54 | cjfrisz | Right |
| 13:55 | RickInGA | &(cons 'a '(b)) |
| 13:55 | lazybot | ⇒ (a b) |
| 13:55 | cjfrisz | I've used a fair amount of miniKanren in Scheme but never core.logic and this sounds like a Clojure-specific problem |
| 13:55 | cjfrisz | So it might be a question specifically for dnolen unless I'm overlooking something |
| 13:55 | xeqi | RickInGA: have they introduced conso in chp 2? |
| 13:56 | RickInGA | xeqi yes |
| 13:56 | cjfrisz | He should be able to use cons there |
| 13:56 | cjfrisz | And "Reasoned" uses cons there specifically |
| 13:56 | xeqi | ah |
| 13:57 | cjfrisz | The point is supposed to be that a grounded logic variable is just a normal value. |
| 13:59 | RickInGA | xeqi: does work there. |
| 13:59 | RickInGA | er, conso does work there |
| 14:00 | cjfrisz | You shouldn't have to use conso |
| 14:01 | jonasen | RickInGA: in clojure, cons takes a seq as its second argument. In scheme both the car and the cdr can be any object |
| 14:01 | cjfrisz | Yes...but why wouldn't y be a sequence in this case? |
| 14:01 | RickInGA | jonasen: so it is not recognizing the lvar as a seq, even though it has been set to (a) |
| 14:02 | jonasen | RickInGA: yes (i think so) |
| 14:02 | jonasen | You could simply do (== [x y] r) |
| 14:03 | RickInGA | ah, I needed lcons |
| 14:05 | cjfrisz | I see |
| 14:05 | RickInGA | I don't understand why y wasn't a sequence, but like jonasen said, it didn't have to be a sequence in scheme… lcons allows you to cons even if the second item isn't a seq |
| 14:05 | RickInGA | https://github.com/clojure/core.logic/wiki/Differences-from-The-Reasoned-Schemer |
| 14:05 | mk | ,(doc lcons) |
| 14:05 | clojurebot | No entiendo |
| 14:06 | RickInGA | thanks all for the help! |
| 14:06 | mk | ,(cons 1 [2 3]) |
| 14:06 | clojurebot | (1 2 3) |
| 14:07 | mk | [2 3] isn't a seq either, but perhaps I've missed something important mentioned above |
| 14:07 | RickInGA | mk: I may have used 'seq' improperly… vectors do implement ISeq, which is the relevant fact |
| 14:08 | xeqi | &(seq? [2 3]) |
| 14:08 | lazybot | ⇒ false |
| 14:08 | RickInGA | &(sequable? [2 3]) |
| 14:08 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: sequable? in this context |
| 14:08 | RickInGA | &(sequential? [2 3]) |
| 14:08 | lazybot | ⇒ true |
| 14:29 | weavejester | Gah, someone "lein push"ed my project before I did :( |
| 14:37 | simard | hello, I have a clojure sandbox in which I have a few functions defined. The init is done from the main thread and I then start a swank server wrapped in a future. I gain access to the sandbox through emacs and issue some commands: https://gist.github.com/2267395 |
| 14:37 | simard | I can see the function jump is defined in the sandbox, but whenever I define a new function (asdf), jump disapears |
| 14:38 | simard | there's probably something basic I don't understand about threads here, can anyone help ? |
| 14:46 | dnolen | oakwise: yes, I think brenton's last commit may have messed things up. |
| 14:46 | dnolen | oakwise: I emailed him, hopefully we can get that sorted out with a new release. |
| 14:47 | oakwise | dnolen: great |
| 15:14 | TimMc | weavejester: Ouch. rotary? |
| 15:14 | weavejester | TimMc: Yeah, hopefully it'll be sorted out soon |
| 15:15 | weavejester | TimMc: Until then I'll just push to org.clojars.weavejester/rotary |
| 15:26 | gtrak`` | what's the best guide for a step debugger? I have some hairy code that's hard to test |
| 15:32 | aperiodic | gtrak``: i usually just use debug-repl https://github.com/GeorgeJahad/debug-repl |
| 15:32 | gtrak`` | ah, neato |
| 15:33 | gtrak`` | but it doesn't step |
| 15:45 | aperiodic | yeah, i usually just stick it where i'd stick breakpoints in a stepping debugger |
| 15:46 | hugod | gtrak``: ritz does stepping, though I think cdt does too |
| 15:46 | aperiodic | you can terminate it by evaluating the empty list, and then control passes back to your code |
| 15:47 | gtrak`` | i think i figured it out, i'm doing stuff that cares about identity, so things that shouldn't be equal are evaluating equal.. :/ hammock time |
| 15:51 | gtrak`` | basically, trying to do some simple rigid body collisions and failing :-), I tried to build maps of game objects to corresponding rigid-bodies, but it got complicated, I might just add a key to the game object for the rigid body instead |
| 15:58 | TimMc | My kingdom for a step debugger that lets me inspect return values. |
| 16:02 | jayunit100 | user=> (derive ::rect ::shape) |
| 16:02 | jayunit100 | nil |
| 16:02 | jayunit100 | user=> (derive :rect :shape) |
| 16:02 | jayunit100 | java.lang.AssertionError: Assert failed: (namespace parent) (NO_SOURCE_FILE:0) |
| 16:02 | jayunit100 | Curious -> what is the "double colon" doing ? |
| 16:03 | Bronsa | ,::a |
| 16:03 | clojurebot | :sandbox/a |
| 16:03 | RickInGA | jayunit100: I believe :: resolves to a namespace |
| 16:03 | RickInGA | s/resolves/qualifies/ |
| 16:03 | Bronsa | it qualifies the keyword to the current namespace |
| 16:04 | Bronsa | ,(= ::a (keyword (str *ns*) "a")) |
| 16:04 | clojurebot | true |
| 16:05 | jayunit100 | ,(= ::a (keyword (str *ns*) "a")) |
| 16:05 | clojurebot | true |
| 16:05 | jayunit100 | ,(= :a (keyword (str *ns*) "a")) |
| 16:05 | clojurebot | false |
| 16:05 | fliebel__ | $mail samaaron Am I correct that your RxTx does not include parallel natives? :( had to figure that out on a 800MHz Windows machine. |
| 16:05 | lazybot | Message saved. |
| 16:05 | Bronsa | :a is not namespace qualified |
| 16:05 | Bronsa | (= :a :sandbox/a) |
| 16:05 | Bronsa | ,(= :a :sandbox/a) |
| 16:05 | clojurebot | false |
| 16:05 | Bronsa | ,(= ::a :sandbox/a) |
| 16:05 | clojurebot | true |
| 16:06 | gfredericks | ,(= :a (keyword "a")) |
| 16:06 | clojurebot | true |
| 16:06 | jayunit100 | why do i need to qualify a namespace for a multimethod |
| 16:06 | jayunit100 | shouldnt the qualification be local to the dispatcher ? |
| 16:08 | jayunit100 | hmmm maybe im not thinking about this the right way :0 |
| 16:09 | jayunit100 | ,(::a) |
| 16:09 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args passed to keyword: :sandbox/a> |
| 16:09 | jayunit100 | ,::a |
| 16:10 | clojurebot | :sandbox/a |
| 16:10 | gfredericks | $doc derive |
| 16:10 | jayunit100 | okay --- so why does a have to be namespaced for a multimethod ? |
| 16:10 | gfredericks | ,(doc derive) |
| 16:10 | clojurebot | "([tag parent] [h tag parent]); Establishes a parent/child relationship between parent and tag. Parent must be a namespace-qualified symbol or keyword and child can be either a namespace-qualified symbol or keyword or a class. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to, and modifies, the global hierarchy." |
| 16:10 | jayunit100 | aha |
| 16:10 | jayunit100 | so derive doesnt work if the parent is NOT namespace-qualified. |
| 16:11 | gfredericks | sounds like both have to be qualified |
| 16:11 | jayunit100 | so ... what is the namespace qualification buying us ? |
| 16:11 | gfredericks | well at least for the global hierarchy |
| 16:11 | gfredericks | it is ensuring you don't affect other stuff going on elsewhere in the program |
| 16:11 | gfredericks | that's my guess |
| 16:12 | gfredericks | why it matters with an explicit hierarchy...dunno |
| 16:12 | gfredericks | maybe just for consistency? :/ |
| 16:16 | yoklov | jayunit100, i think its just normal collision detection stuff. if you derive something in a hierarchy and then someone does that later, they could accidentally override one of your bindings (derivations?) |
| 16:17 | yoklov | if its namespace qualified that won't happen |
| 16:17 | jayunit100 | yeah ok that makes sense |
| 16:17 | jayunit100 | it, unfortunately, complicates my ability to adopt the theory behind multimethods though. accidental complexity rears its ugly head. |
| 16:18 | yoklov | what's happening? |
| 16:18 | jayunit100 | trying to figure out why multimethods are more effective then run-of-the-mill polymorphism (i.e. c++ java style) |
| 16:19 | yoklov | it gives you more flexible dispatch |
| 16:19 | yoklov | e.g. multiple dispatch |
| 16:19 | yoklov | (or more). in c++/java you'd use the visitor pattern for this, which is far more complex |
| 16:20 | gfredericks | not to mention dispatching on arbitrary functions is more general than always and only dispatching on type |
| 16:20 | yoklov | ^ |
| 16:21 | yoklov | multimethods are one of my favorite features of clojure, but i rarely use them in a way similar to OO |
| 16:21 | jayunit100 | in java, you can delegate using class annotations combined with reflection . right ? |
| 16:21 | yoklov | err, what? |
| 16:22 | jayunit100 | Well.. i guess even then you still have to "check" each classes annotation values, which would amount to the visitor pattern. |
| 16:22 | yoklov | sounds ugly. |
| 16:22 | yoklov | multimethods are much cleaner. |
| 16:23 | yoklov | (and if you don't need a hierarchy you don't need namespace qualify your keywords) |
| 16:23 | jayunit100 | can you elaborate on the last statement ? |
| 16:23 | yoklov | oh |
| 16:23 | jayunit100 | "(and if you don't need a hierarchy you don't need namespace qualify your keywords)" |
| 16:23 | yoklov | if you never use derive |
| 16:23 | yoklov | theres no problem. |
| 16:24 | yoklov | (defmulti foo some-function-which-returns-a-non-namespace-qualified-keyword) (defmethod :bar …) etc. |
| 16:25 | jayunit100 | ... i guess im still wondering --> how can you compare java object's polymorphism with that of a clojure function's ploymorphism. |
| 16:25 | yoklov | i mean the hierarchies are certainly powerful, but you don't need them in every case |
| 16:25 | yoklov | oh |
| 16:25 | jayunit100 | java functions are polymorphic w/ their primitives. |
| 16:25 | jayunit100 | s/primitives/arguments |
| 16:26 | yoklov | that's the same as a multimethod whose dispatch function is class |
| 16:26 | jayunit100 | the dispatching is done for you by method name and args alone, and confirmed at compile time . |
| 16:26 | yoklov | well, i don't really think that when it occurs effects the semantics a lot |
| 16:27 | yoklov | and clojure functions can already dispatch on number of args, if you want type of args or type confirmation… clojure's a dynamic language |
| 16:29 | yoklov | if you want something like that protocols are what you should look into anyway. |
| 16:30 | jayunit100 | ah i see . the magic is in the dispatching function. |
| 16:31 | jayunit100 | thats what i was missing |
| 16:31 | yoklov | the magic is that you can provide an arbitrary one |
| 16:31 | jayunit100 | yeah. |
| 16:31 | yoklov | not just "on type" |
| 16:31 | jayunit100 | so, if we only dispatch on the # of args and their types its equivalent to java. |
| 16:31 | yoklov | right. |
| 16:31 | yoklov | even then |
| 16:31 | jayunit100 | thanks mister yoklov :) |
| 16:31 | yoklov | np |
| 16:35 | jayunit100 | yeah , these multimethods are nice - we define a function in the dispatcher, and then |
| 16:35 | jayunit100 | we simply match the output of the function to predicates in each "case" |
| 16:36 | jayunit100 | can the "cases" be predicates themselves ? |
| 16:36 | clojurebot | Cool story bro. |
| 16:36 | gfredericks | I think they're just values |
| 16:36 | gfredericks | else things that are values and functions would be ambiguous |
| 16:36 | jayunit100 | how did clojurebot know that i was rambling ? :) |
| 16:36 | gfredericks | clojurebot is very attentive |
| 16:36 | jayunit100 | ha. so ... what about wildcards. |
| 16:37 | gfredericks | I think you can give a default implementation |
| 16:37 | yoklov | :default |
| 16:38 | yoklov | you can also do something like [::foo ::bar ::baz], and it will dispatch against each in turn (e.g. if those all derived from ::frob, it would match [::frob ::frob ::frob] also) |
| 16:39 | jayunit100 | so, a dispatcher will run multiple methods at one time? its not just a greedy first match -> run . |
| 16:39 | yoklov | no |
| 16:40 | yoklov | you'd need a |
| 16:40 | yoklov | (defmulti [::frob ::frob ::frob] …) for that |
| 16:40 | yoklov | *for my example |
| 16:40 | yoklov | and if there are 2 matches you need to do prefer-method |
| 16:40 | jayunit100 | (doc defmulti) |
| 16:40 | clojurebot | "([name docstring? attr-map? dispatch-fn & ...]); Creates a new multimethod with the associated dispatch function. The docstring and attribute-map are optional. Options are key-value pairs and may be one of: :default the default dispatch value, defaults to :default :hierarchy the isa? hierarchy to use for dispatching defaults to the global hierarchy" |
| 16:40 | yoklov | whoops |
| 16:40 | yoklov | (defmethod [::frob ::frob ::frob]) |
| 16:41 | yoklov | is what i meant. |
| 16:41 | yoklov | and then a function name too. |
| 16:41 | jayunit100 | ah ok |
| 16:41 | yoklov | (defmethod some-method [::frob ::frob ::frob]) there. |
| 16:42 | jayunit100 | I think that method would only run if the result of the function was [::frob :: frob ::frob] |
| 16:43 | yoklov | or a 3-element vector of things which decend from ::frob |
| 16:43 | gfredericks | I don't think I've ever heard of someone making extensive use of the hierarchy feature |
| 16:43 | yoklov | no, me neither |
| 16:44 | gfredericks | let's rip that out into a library and add a function that tests if an item is in a collection |
| 16:45 | yoklov | hm? |
| 16:46 | gfredericks | bad joke |
| 16:48 | yoklov | lol, it's okay |
| 16:48 | ferd | I need to do String interpolation and found strint: https://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/strint.clj |
| 16:48 | ferd | is it available anywhere as a maven artifact? |
| 16:49 | gfredericks | ferd: I think there are some unofficial snapshots on clojars |
| 16:49 | gfredericks | no guarantee they've got that exact code |
| 16:49 | ferd | gfredericks: thanks... will check |
| 16:50 | gfredericks | ferd: I assume you already know about clojure.core/format? |
| 16:52 | ferd | gfredericks: yes, thanks. I like strint better though |
| 16:53 | gfredericks | it does look interesting |
| 16:55 | ferd | I need to do templates, and they'd look cleaner with string interpolation |
| 16:56 | ferd | (format ) has its uses though... mmm... if you need to actually "format" each value (alignment, numer decimals, etc) |
| 16:56 | gfredericks | huh |
| 16:57 | gfredericks | I guess if you want to emit a "~(" you can do "~(str \"~(\")" |
| 16:59 | ferd | :-\ should have a way to escape, like \~ |
| 17:00 | gfredericks | just read through the code, don't think so |
| 17:00 | gfredericks | I like ~~ as an escape better though |
| 17:02 | ferd | gfredericks: agreed... Clojure uses \ for escaping within strings right? so... it would require two backslashes to work |
| 17:02 | gfredericks | exactly |
| 17:02 | gfredericks | and ~~ covers pretty much all cases and is unambiguous I think |
| 17:03 | gfredericks | like %% in format strings |
| 17:04 | jayunit100 | im trying to run the string partition function from the repl... but its breaking because the repl is tring to run the numerical partition function. |
| 17:04 | jayunit100 | I assume clojure.contrib.string.partition wont work -- to obvious. :) |
| 17:05 | RickInGA | jayunit100 you can require the string ns and give it an alias |
| 17:06 | jayunit100 | alias? |
| 17:06 | gfredericks | (:require [clojure.contrib.string.partition :as spart]) |
| 17:06 | jayunit100 | can i just reference it explicitly ? |
| 17:06 | jayunit100 | rather than aliasing, id like to reference the function inline . |
| 17:07 | gfredericks | then at least require the ns regularly |
| 17:07 | jayunit100 | (clojure.contrib.string.partition "a" "AabC") |
| 17:07 | jayunit100 | so ... there is no way to reference the partition function explicitly ? |
| 17:08 | yoklov | clojure.contrib.string/partition ? |
| 17:08 | jayunit100 | oh ooop |
| 17:08 | jayunit100 | than |
| 17:08 | jayunit100 | x |
| 17:18 | weavejester | If you have a function like… (fn [x & {:as opts}] …) |
| 17:19 | weavejester | Then apply doesn't work. Is there anything like apply that can be used instead? |
| 17:19 | weavejester | Or is it recommended not to have keyword arguments? |
| 17:19 | amalloy | weavejester: "apply doesn't work"? |
| 17:20 | amalloy | &(apply (fn [x & {:as opts}] (:x opts)) 1 '(:x 3)) |
| 17:20 | lazybot | ⇒ 3 |
| 17:20 | weavejester | amalloy: Because (apply foo {:a 1, :b 2}) expands to (foo [:a 1] [:b 2]) |
| 17:20 | amalloy | personally, i recommend using kwargs only at the outer shell of your api, and just pass around maps once you get any deeper |
| 17:21 | weavejester | Yeah, but I have a create-table and an update-table |
| 17:21 | weavejester | And I want to have a "ensure-table" that either creates or updates |
| 17:21 | weavejester | So all three are exposed to the user |
| 17:22 | weavejester | I wonder if I should just use maps instead of kwargs |
| 17:22 | amalloy | (defn update-table* [x opts] ...) (defn update-table [x & {:as opts}] (update-table x opts)), if you're married to this API |
| 17:22 | amalloy | (except you should probably fix the obvious error in that) |
| 17:23 | weavejester | Hm… I'm not married to the API. I could have (create-table cred "foo" {:hash-key "id", :range-key "date"}) instead of (create-table cred "foo" :hash-key "id" :range-key "date") |
| 17:24 | weavejester | Or even: (create-table cred {:name "foo" :hash-key "id" :range-key "date"}) |
| 17:25 | amalloy | that also makes it easier for the user to store/load their options from some config file |
| 17:26 | amalloy | which is the kind of thing it sounds like your users will want to do |
| 17:27 | TimMc | ~mapply |
| 17:27 | clojurebot | mapply is (defn mapply [f & args] (apply f (apply concat (butlast args) (last args)))) |
| 17:28 | TimMc | weavejester: ^ *shrug* |
| 17:29 | weavejester | &(doc mapply) |
| 17:29 | lazybot | java.lang.RuntimeException: Unable to resolve var: mapply in this context |
| 17:29 | weavejester | I might just have everything use maps. Easier :) |
| 17:30 | amalloy | TimMc: your mapply factoid seems to be difficult for people to recognize |
| 17:30 | amalloy | clojurebot: forget mapply |is| (defn mapply [f & args] (apply f (apply concat (butlast args) (last args)))) |
| 17:30 | amalloy | clojurebot: mapply |is| (defn mapply [f & args] (apply f (apply concat (butlast args) (last args)))) |
| 17:30 | clojurebot | I forgot that mapply is (defn mapply [f & args] (apply f (apply concat (butlast args) (last args)))) |
| 17:30 | clojurebot | You don't have to tell me twice. |
| 17:30 | amalloy | oops |
| 17:32 | amalloy | ~mapply |
| 17:32 | clojurebot | You could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args)))) |
| 17:32 | TimMc | hrm |
| 17:32 | TimMc | Might be better, yeah. |
| 17:46 | jhickner | In my clojurescript code I keep wanting to use defrecord and extend it to Object so I can create "classes" with "instance methods". Is that bad practice? stuff like this: https://gist.github.com/2268831 |
| 17:49 | arohner | jhickner: yes. Rather than thinking in instance methods, think of protocols as "properties this thing has" |
| 17:50 | arohner | so yes, sockets are a weird beast, but rather than putting (close) on websocket, consider a protocol Closable |
| 17:50 | arohner | that's if you're going to reuse these protocols at all |
| 17:50 | arohner | if not, just write fns that take sockets as arguments |
| 18:03 | amalloy | arohner: you're going to have to catch him during one of the brief periods between his logging-in and getting disconnected |
| 18:05 | jhickner | sorry, not sure why that's happening |
| 18:23 | devn | hm, im having issues with org-babel |
| 18:23 | devn | i can't seem it to give me a result of evaluation that *isn't* a table |
| 18:24 | devn | when i evaluate my begin_src block containing (+ 1 1) it prints the results as: | | 2 | |
| 18:25 | gtrak`` | you guys wanna see a shitty physics simulation written in clojure with quil for drawing? https://github.com/gtrak/quilltest just lein run it |
| 18:27 | gtrak`` | wasd adds acceleration to the balls, q stops the game-loop, escape will kill the process |
| 18:29 | gtrak`` | i'm still not sure why they only actually collide half the time :-) |
| 18:38 | lynaghk` | Does anyone know of decent clojure libs for interacting with webpages for scraping? Something like Mechanize from the perl/ruby worlds? |
| 18:39 | devn | anyone have any ideas? This is driving me a little crazy. |
| 18:39 | devn | lynaghk`: You can try enlive if you like, but to answer you question succinctly, no -- I do not believe something like that exists right now in Clojure |
| 18:40 | lynaghk` | devn: yeah, I was looking at enlive for tag matching, but I need to actually submit forms and such. I'm compiling PhantomJS right now, so I was just doing some idle daydreaming while waiting = ) |
| 18:44 | y3di | what clojure podcasts besides mostlylazy exist? |
| 18:44 | RickInGA | think relevance |
| 18:44 | RickInGA | http://thinkrelevance.com/blog/tags/podcast |
| 18:46 | devn | lynaghk`: oh...well, i mean, there's clj-webdriver |
| 18:46 | devn | which is really nice, but maybe not what you need |
| 18:46 | devn | it's not headless |
| 18:47 | lynaghk` | devn: yeah, I need something headless. |
| 18:48 | lynaghk` | I am just googling around about using mechanize through jruby |
| 18:48 | lynaghk` | Any way to get jruby gems handled transparently using Lein? |
| 18:54 | gtrak`` | this quil example I just made is also an example of an asynchronous update/draw loop, they run on separate threads |
| 18:54 | Araq | how does clojure deal with ambiguous multimethods? runtime exception? |
| 18:54 | gtrak`` | the atom makes it super trivial |
| 18:59 | hugod | b |
| 19:13 | emezeske | dnolen: Is there an upstream case for the clojurescript repl issues? |
| 19:14 | dnolen | emezeske: I already emailed brenton - he's going to fix tonight, and they'll cut a release on Monday. |
| 19:14 | emezeske | dnolen: As usual, you da man! |
| 19:15 | devn | Araq: prefer-method |
| 19:34 | arohner | lynaghk`: webdriver can use htmlunit, which is headless, but isn't a full-featured browser |
| 19:34 | arohner | lynaghk`: similar to links |
| 19:35 | arohner | lynaghk`: also, https://github.com/detro/ghostdriver |
| 19:37 | arohner | another option is 'normal' webdriver + Xvfb |
| 19:37 | devn | doh, and here i was writing a simple wrapper around htmlunit for the last hour or two |
| 19:38 | devn | i think im gonna just keep working on it |
| 19:39 | arohner | the new clj-webdriver alphas with taxi are really nice |
| 19:39 | gfredericks | devn: something on github? |
| 19:39 | devn | gfredericks: not yet, ive been toying around with protocols, multimethods, and now im back to just simple fn wrappers |
| 19:39 | gfredericks | devn: threading-friendly fns? :) |
| 19:40 | devn | :) |
| 19:41 | gfredericks | (-> (start-browser "foo.com") (submit-form "#form" {...}) (should-see "made new foo")) |
| 19:41 | iwo | hey, does anyone know why when i run a clojure repl with jline, the prompt 'user=>' seems to confuse jline? |
| 19:42 | gfredericks | iwo: I think maybe we hate jline |
| 19:42 | gfredericks | but I could be wrong |
| 19:42 | devn | gfredericks: well, now that you mention it, i wasn't thread friendly for a bit because i had a (with-client) macro |
| 19:42 | gfredericks | devn: I don't know why I get fixated on that way of doing it |
| 19:42 | gfredericks | I wrote a library around that once |
| 19:42 | devn | it can be nice gfredericks but idk |
| 19:42 | devn | sometimes it can get too clever |
| 19:42 | iwo | when i use up-arrow to recall the previous command, the text displayed is not insync with reality |
| 19:43 | gfredericks | devn: it doesn't seem like a bad situation for a global |
| 19:43 | iwo | so when i move into the text with a cursor, i'm editing characters that are not the same as displayed |
| 19:43 | gfredericks | iwo: is installing rlwrap an option? |
| 19:43 | iwo | they're shifted because jline appears to not understand that there is a prompt 'user=>' |
| 19:44 | devn | gfredericks: i started with (def *client* (new WebClient)) |
| 19:44 | iwo | gfredericks: i expect so, i'm just following a tutorial to set up a clojure dev environment and it recommends jline (i see it recommended quite a lot) |
| 19:44 | iwo | ctrl-R history would be very nice |
| 19:45 | gfredericks | iwo: do you see it recommended in writing less than 2 years old? |
| 19:45 | devn | i was thinking that way you could (with-client (make-client :other options :go here) (visit "http://www.google.com")) |
| 19:45 | gfredericks | (two years in real life is equivalent to fifteen clojure years) |
| 19:45 | devn | too much rumination |
| 19:46 | iwo | gfredericks: i think so: http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html |
| 19:47 | gfredericks | iwo: if using (and learning if necessary) emacs is a valid option, that is where the most happiness lies |
| 19:47 | gfredericks | I've never seen jline work not terribly |
| 19:47 | gtrak`` | not the riddell.us tutorial, use the swank-clojure docs and leiningen |
| 19:47 | lazybot | The riddell.us tutorials are much more highly-ranked on Google than they deserve to be. They're old and way too complicated. If you're trying to install Clojure...don't! Instead, install Leiningen (https://github.com/technomancy/leiningen/tree/stable) and let it manage Clojure for you.leiningen |
| 19:52 | iwo | thanks for the pointers |
| 20:04 | TimMc | technomancy: This is how work gets done at Heroku, right? https://bitbucket.org/spooning/ |
| 20:04 | offby1 | taught my wife to program that way. |
| 20:05 | gtrak`` | haha |
| 20:05 | gtrak`` | brilliant |
| 20:05 | offby1 | guy I knew in college tried to teach some neighborhood kids that way ... he'll be eligible for parole in 2025 |
| 20:06 | simard | amalloy: I have a clojure sandbox in which I have a few functions defined. The init is done from the main thread and I then start a swank server wrapped in a future. I gain access to the sandbox through emacs and issue some commands. If I now (defn) some function from swank, the otherwise already defined functions disapear. See: https://gist.github.com/2267395 |
| 20:06 | TimMc | Heroku seems like just the sort of crunchy granola place where these advanced team methodologies could work. |
| 20:06 | simard | amalloy: does that ring a bell ? could multithreading be somehow responsible for that ? |
| 20:07 | offby1 | mmm ... granola |
| 20:07 | mega` | hahaha |
| 20:07 | TimMc | (Hmm, "crunchy granola" isn't actually what I meant, but it's close enough in semantic space for my purposes.) |
| 20:07 | mega` | lovws ir :S |
| 20:07 | mega` | :D* |
| 20:09 | amalloy | i doubt if swank is relevant. threading might be, i dunno; the ablity to def in a sandbox is a feature only Raynes has really worked on. but i do know there's a queue of def'd things, and as you def new ones the older ones disappear |
| 20:10 | amalloy | (which, btw Raynes, i still think is pointless) |
| 20:11 | simard | a queue where def'd things disappear ? |
| 20:11 | simard | that sounds odd. |
| 20:11 | Frozenlo` | How does one force the evaluation of `map'? It returns a lazy sequence and I need it evaluated on the spot. |
| 20:13 | gfredericks | TimMc: perhaps you meant "soggy granola"? |
| 20:14 | gfredericks | Frozenlock: doall does that; I personally prefer doseq if you're using an anonymous function with your (doall (map ...)) |
| 20:16 | simard | amalloy: max-defs 5 |
| 20:16 | simard | no wonder ! |
| 20:16 | simard | thank you |
| 20:16 | simard | yeah, I think it's pointless too, and, frustrating :D |
| 20:17 | Frozenlock | gfredericks: In this case I need to obtain the results. If I remember correctly doseq only returns nil. I'll try doall immediately! |
| 20:17 | gfredericks | Frozenlock: ah ha yes; |
| 20:18 | Frozenlock | gfredericks: Works as promised, thanks! :) |
| 20:23 | gfredericks | doall rarely makes a liar out of me |
| 20:32 | Frozenlock | Aw cmon! When I type the result (bound to 'tt') in the REPL, everything is fine, but when I do (spit "test.txt" tt), I get clojure.lang.LazySeq@91de0c38 in the file :( |
| 20:37 | TimMc | simard: Double/POSITIVE_INFINITY, perhaps :-) |
| 20:44 | Frozenlock | I think I found a solution.. `into' seems to evaluate everything. |
| 20:44 | devn | gfredericks: https://gist.github.com/bdc2f0729ea6d478ec08 |
| 20:44 | devn | gfredericks: that's all ive really finished tbqh |
| 20:46 | TimMc | Frozenlock: doall really should work there |
| 20:47 | devn | gfredericks: (map attrs (take 3 (xpath (visit (make-client) "http://www.google.com") "//a"))) |
| 20:47 | devn | => ({:href "http://www.google.com/webhp?hl=en&tab=ww", :id "gb_1", :class "gbzt gbz0l gbp1", :onclick "gbar.logger.il(1,{t:1});"} {:href "http://www.google.com/imghp?hl=en&tab=wi", :id "gb_2", :class "gbzt", :onclick "gbar.qs(this);gbar.logger.il(1,{t:2});"} {:href "http://video.google.com/?hl=en&tab=wv", :id "gb_12", :class "gbzt", :onclick "gbar.qs(this);gbar.logger.il(1,{t:12});"}) |
| 20:50 | gfredericks | Frozenlock: when you're converting a data structure to a string pr-str might be helpful |
| 20:51 | TimMc | oh, that's the problem, yes |
| 20:51 | mega` | , [(str (range 0 5)) (pr-str (range 0 5))] |
| 20:52 | clojurebot | ["clojure.lang.LazySeq@1b554e1" "(0 1 2 3 4)"] |
| 20:52 | gfredericks | ,(str (doall (range 5))) |
| 20:52 | clojurebot | "clojure.lang.LazySeq@1b554e1" |
| 20:52 | mega` | &(doc pr-str) |
| 20:52 | lazybot | ⇒ "([& xs]); pr to a string, returning it" |
| 20:52 | Frozenlock | Interesting... |
| 20:52 | gfredericks | &(doc pr) |
| 20:52 | lazybot | ⇒ "([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print in a way that objects can be read by the reader" |
| 20:53 | Frozenlock | Should I use this instead of `into'? |
| 20:53 | gfredericks | Frozenlock: yeah |
| 20:53 | mega` | unless you want a vector? |
| 20:53 | Frozenlock | Yes. |
| 20:53 | gfredericks | (vec) is shorter than (into []) |
| 20:53 | gfredericks | tell all your friends |
| 20:53 | mega` | but less cool |
| 20:53 | Frozenlock | I was doing (vector my-stuff) |
| 20:54 | gfredericks | mega`: you see that's where you're wrong |
| 20:54 | Frozenlock | Before using (into []) |
| 20:54 | gfredericks | this is making less and less sense the more things you say |
| 20:54 | Frozenlock | Unsurprisingly :p |
| 20:55 | Frozenlock | (into [] |
| 20:55 | Frozenlock | (map (fn [rd oids] |
| 20:55 | Frozenlock | (hash-map .... |
| 20:55 | mega` | anny one seen more programming related aprill fools stuff? |
| 20:56 | gfredericks | is the spooning video old hat by now? |
| 20:56 | gfredericks | I only just saw it |
| 20:56 | mega` | no me to |
| 20:56 | mega` | loved it tho :D |
| 20:58 | gfredericks | pull request will never mean the same thing again |
| 20:59 | gfredericks | devn: that expression looked great for threading! |
| 20:59 | gfredericks | (-> (make-client) (visit "google.com") (xpath "//a") (->> (take 3) (map attrs))) |
| 20:59 | atarax | so maybe this is a stupid question that will get me banned, but how do I learn clojure |
| 21:00 | gfredericks | ~guards |
| 21:00 | clojurebot | SEIZE HIM! |
| 21:00 | mega` | BAAAAAN |
| 21:00 | gfredericks | atarax: you've failed the have-to-already-know-clojure test for this room |
| 21:00 | mega` | theres books ofc |
| 21:01 | atarax | gfredericks: ok, I think I answered my own question - I should just sit here quietly and watch |
| 21:01 | mega` | and i saw the begining of a video series not to long ago |
| 21:01 | gfredericks | atarax: 4clojure.com maybe |
| 21:01 | Frozenlock | Yes 4 clojure is great. |
| 21:02 | gfredericks | lazybot: does Frozenlock know clojure?? |
| 21:02 | lazybot | gfredericks: Definitely not. |
| 21:02 | Frozenlock | :p |
| 21:02 | atarax | are your bots here in clojure? :) |
| 21:02 | Frozenlock | Well no, which is why I use 4clojure |
| 21:02 | gfredericks | &(println "yes") |
| 21:02 | lazybot | ⇒ yes nil |
| 21:03 | gfredericks | &(println "yes nil") |
| 21:03 | lazybot | ⇒ yes nil nil |
| 21:03 | atarax | hehe, nice |
| 21:03 | gfredericks | &(println "this sentence ends with") |
| 21:03 | lazybot | ⇒ this sentence ends with nil |
| 21:04 | offby1 | This sentence no verb. |
| 21:05 | mega` | http://tryclj.com/ |
| 21:05 | devn | gfredericks: yeah, i guess it's okay, but there's so much to do to make it usable as a general library |
| 21:06 | gf3 | ibdknox: is Noir supposed to be a wine thing? |
| 21:06 | offby1 | Pinot, I don't think so |
| 21:06 | gfredericks | $google greengrocer github |
| 21:06 | lazybot | [whymirror.github.com] http://whymirror.github.com/ |
| 21:06 | devn | gfredericks: maybe (defn with-client [c f & args] (apply #(f c %) args)) |
| 21:06 | gfredericks | devn: ^ that's my original shot at something like this |
| 21:07 | devn | (defn visit [^WebClient c, ^String url] (. c getPage url)) |
| 21:07 | gfredericks | doesn't use any underlying engine though |
| 21:07 | atarax | &(hello me) |
| 21:07 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: hello in this context |
| 21:07 | gfredericks | wait what |
| 21:07 | devn | &(hello "me") |
| 21:07 | gfredericks | did lazybot return there |
| 21:07 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: hello in this context |
| 21:07 | gfredericks | devn: I meant https://github.com/fredericksgary/greengrocer |
| 21:07 | devn | &'(hello me) |
| 21:07 | lazybot | ⇒ (hello me) |
| 21:08 | atarax | &(defn hello [who] (str "Hello," who "!")) |
| 21:08 | lazybot | java.lang.SecurityException: You tripped the alarm! def is bad! |
| 21:08 | gf3 | haaaaaaaaa haaaaaaaaaaaa, offby1 |
| 21:08 | devn | gfredericks: cool |
| 21:08 | offby1 | \o/ |
| 21:08 | devn | gfredericks: i think im taking a bit of a different approach -- i really just want epic screen scraping with ease |
| 21:08 | atarax | uh, ok |
| 21:08 | devn | predicates, inspectors, etc. |
| 21:09 | gfredericks | devn: okay; maybe you and I aren't the same person after all |
| 21:09 | devn | lol |
| 21:09 | devn | i can assure you we are not! (i think) |
| 21:09 | atarax | &((defn hello [who] (str "Hello, " who "!"))) |
| 21:09 | lazybot | java.lang.SecurityException: You tripped the alarm! def is bad! |
| 21:10 | atarax | &(+ 1 2) |
| 21:10 | lazybot | ⇒ 3 |
| 21:10 | gfredericks | atarax: lazybot also supports private messages :) |
| 21:10 | atarax | thanks :) |
| 21:10 | devn | gfredericks: do you know if Htmlunit supports CSS? |
| 21:10 | devn | selectors |
| 21:11 | gfredericks | devn: man I didn't even know about Htmlunit until like last week |
| 21:11 | devn | nor i until today |
| 21:11 | mega` | , ((fn [who] (str "Hello, " who "!")) "mega") |
| 21:11 | gfredericks | I think it runs a JS engine though... |
| 21:11 | clojurebot | "Hello, mega!" |
| 21:11 | devn | i was using cyberneko |
| 21:11 | devn | and i found it to be an epic PITA |
| 21:11 | gfredericks | People for the Ithical Treatment of Animals |
| 21:11 | devn | then again, maybe it's not so bad |
| 21:12 | devn | im basically at the same point i was with cyberneko in htmlunit |
| 21:12 | devn | htmlunit actually uses cyberneko under the covers |
| 21:12 | devn | for tag balancing and what-not |
| 21:14 | gfredericks | dangit I don't know how to google for fogus's try-cljs app |
| 21:15 | mega` | do you mean the one whit the weird name? |
| 21:15 | mega` | himera |
| 21:16 | gfredericks | yep found it |
| 21:16 | mega` | think its a russian cat or something |
| 21:20 | atarax | thanks for that 4clojure.com site, I'll ask what's next if I finish that |
| 21:20 | mega` | atarax: back in 5 then? |
| 21:21 | atarax | mega`: i'm an idiot though, maybe not |
| 21:21 | Licenser | hmm is there something like dissoc for seqs so I can say (dissoc '(1 2 3) 1) -> '(1 3) |
| 21:22 | TimMc | Licenser: You want to remove things as specific indices? |
| 21:22 | gfredericks | nope |
| 21:22 | gfredericks | finger trees if you really need to do that efficiently |
| 21:22 | mega` | Licenser: theres take and skip |
| 21:22 | Licenser | TimMc yap |
| 21:23 | Licenser | mega` that is a good idea |
| 21:24 | yoklov | i should really just stop trying to use sets in cljs. |
| 21:24 | yoklov | they are sloooooow :/ |
| 21:24 | Licenser | I'll go with mega`s suggestion :) |
| 21:28 | mega` | yoklov: linear lookup?? |
| 21:28 | lazybot | mega`: Definitely not. |
| 21:28 | mega` | ok :P |
| 21:28 | yoklov | mega: i think it needs to copy the entire set when you make a change |
| 21:34 | gfredericks | yoklov: no way |
| 21:35 | gfredericks | &(let [s (set (range 1000000))] (time ((disj s 8) 7))) |
| 21:35 | lazybot | ⇒ "Elapsed time: 0.496074 msecs" 7 |
| 21:35 | yoklov | gfredericks: clojurescript |
| 21:35 | gfredericks | oh |
| 21:35 | gfredericks | well yes of course |
| 21:35 | yoklov | yup :( |
| 21:35 | gfredericks | oh I see you said "in cljs" |
| 21:35 | gfredericks | I repent in dust and ashes |
| 21:36 | yoklov | no problem :p |
| 21:37 | TimMc | Anyone here have experience dumping moderately large numbers of records (~50000) into SQLite without it taking forever? |
| 21:38 | TimMc | I'm wondering how to even tell whether SQLite or clojure.java.jdbc is the bottleneck. |
| 21:38 | lynaghk` | TimMc, yeah |
| 21:38 | lynaghk` | are you doing it in a transaction? That will make it hella faster |
| 21:39 | TimMc | lynaghk`: Here's the code as it is: https://github.com/timmc/kpawebgen/blob/master/clj/src/kpawebgen/spit.clj#L59 |
| 21:40 | TimMc | (The chunking into 10k blocks is for debugging.) |
| 21:40 | TimMc | I think that when I tried to wrap it in a transaction, it complained about already having one open. |
| 21:42 | lynaghk` | TimMc: what's goin on with the outer doseq? |
| 21:43 | TimMc | Iterating over a list of tables. |
| 21:43 | TimMc | Well, a map. |
| 21:43 | lynaghk` | that's just named db? Okay. |
| 21:44 | TimMc | Yes, for various reasons I'm sucking the data out of a different DB and doing everything in-memory. |
| 21:44 | dnolen | yoklov: yeah somebody needs to take on PersistentHashMap now that we have PersistentVector ... |
| 21:45 | mega` | dnolen: is PresistentVector written in cljs?? or in js |
| 21:45 | dnolen | mega`: cljs |
| 21:45 | lynaghk` | TimMc: I'm not sure where the outer transaction is coming from, sorry. I would try macroexpanding and seeing what's what. All I know is that for lots of inserts like this, if you wrap the entire thing in one DB transaction it will go much much faster. |
| 21:50 | yoklov | dnolen: yup. heh, i'd be down to try if nobody else gets to it by the summer |
| 21:50 | TimMc | I think insert-records is doing it. Well, time to dig into the source, I guess... |
| 21:51 | TimMc | lynaghk`: Curiously, this operation is quite fast if I use a :memory: SQLite db. |
| 21:51 | arohner | do I need to do anything special to make a defrecord implement clojure.lang.IFn? |
| 21:51 | lynaghk` | TimMc: everything is faster in memory = ) |
| 21:52 | arohner | I'm (trying) to implement clojure.lang.IFn [this], and getting "Foo cannot be cast to clojure.lang.IFn |
| 21:52 | gfredericks | arohner: and you're calling it with no args? |
| 21:52 | TimMc | lynaghk`: Maybe there's a way to build an in-memory DB and slap it down onto disk... |
| 21:52 | arohner | gfredericks: yes. I've only implemented (invoke [this}). Is that enough? |
| 21:53 | gfredericks | arohner: it just worked for me |
| 21:53 | lynaghk` | TimMc: I think the reason transactions help is that sqlite won't try to update indexes until the transaction is completed. That probably doesn't make much of a difference in memory, but really kills on disk. |
| 21:53 | gfredericks | arohner: I did (defrecord Foo [] clojure.lang.IFn (invoke [this] :nularity-foo)) |
| 21:54 | arohner | gfredericks: thanks. going to try restarting the JVM. I had previously defined the class, so maybe that's a problem |
| 21:54 | gfredericks | bet so |
| 21:59 | oakwise | wow, source maps look amazing |
| 21:59 | oakwise | that could be a huge boon to cljs if we beat coffeescript to the punch |
| 22:00 | yoklov | coffeescript doesn't seem to care that much about them. it's output is much more readable than compiled cljs |
| 22:01 | gfredericks | I've spent lots of time debugging coffeescript and it wasn't really an issue |
| 22:01 | yoklov | nope |
| 22:01 | oakwise | yeah I've had no problem debugging coffeescript with chrome tools but it's a huge scare factor for people |
| 22:01 | yoklov | clojurescript is more of a pain though. |
| 22:02 | oakwise | at least from the not-yet-using-cs-or-cljs-devs I've talked to |
| 22:02 | yoklov | yeah, thats definitely true |
| 22:11 | TimMc | lynaghk`: Oh silly me, I should have seen the sql/transaction command. I was trying to do BEGIN TRANSACTION >_< |
| 22:12 | lynaghk` | TimMc ahhhh. Well, at least it wasn't a missing colon or period or something = ) |
| 22:12 | TimMc | Now it is fast! |
| 22:13 | lynaghk` | node.js fast? |
| 22:13 | TimMc | haha |
| 22:13 | TimMc | I wouldn't know. |
| 22:15 | lynaghk` | I haven't tried Datomic yet, but thus far SQLite is my favorite datastore ever. |
| 22:25 | TimMc | It's pretty freaking convenient. |
| 22:26 | TimMc | I wish MySQL, PostGres, etc. had a file-based mode like SQLite. Testing would be so much easier... |
| 22:27 | jordandanford | I'm somewhat new to Clojure, and I'm trying to make a Processing sketch using Quil – following the examples, here's how it's structured: https://gist.github.com/f223314b747981afc1fa |
| 22:27 | gfredericks | TimMc: file-based -> serverless? |
| 22:27 | TimMc | yep |
| 22:28 | TimMc | that's the word |
| 22:28 | gfredericks | yeah I guess they're equivalent more or less |
| 22:28 | gfredericks | sorta |
| 22:28 | jordandanford | What's the easiest way to run this? |
| 22:29 | TimMc | gfredericks: I guess it would be kinda hellish on the devs to try to make e.g. MySQL run in both serverless and server modes... |
| 22:30 | atarax | I just started learning clojure and I can't do anything |
| 22:30 | TimMc | jordandanford: lein run, but that will look for a -main fn. |
| 22:30 | TimMc | jordandanford: You can also run it from the repl. |
| 22:31 | jordandanford | Is that my only option? |
| 22:32 | TimMc | Well, for distribution you can build an uberjar, and run that with java -jar |
| 22:32 | mutinyonthebay | Just getting into Clojure w/ JOC; how can I declare a dependency to a contrib module in a lein project.clj? |
| 22:32 | jordandanford | TimMc: Okay, thanks |
| 22:33 | TimMc | mutinyonthebay: Well, monolithic contrib is deprecated. Which part are you trying to use? |
| 22:34 | mutinyonthebay | TimMc: algo.monads |
| 22:35 | mutinyonthebay | TimMc: currently 0.1.3-SNAPSHOT, to my knowledge |
| 22:35 | TimMc | ~contrib |
| 22:35 | clojurebot | Monolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go |
| 22:36 | TimMc | I see, that is new contrib. |
| 22:36 | TimMc | [org.clojure/algo.monads "0.1.3-SNAPSHOT"] should do it |
| 22:36 | mutinyonthebay | TimMc: Thanks! |
| 22:37 | TimMc | ~builds |
| 22:37 | clojurebot | I don't understand. |
| 22:37 | TimMc | hmm |
| 22:37 | TimMc | clojurebot: clojure build status? |
| 22:37 | clojurebot | Pardon? |
| 22:38 | TimMc | clojurebot: build status is http://build.clojure.org/ |
| 22:38 | clojurebot | Ack. Ack. |
| 22:39 | TimMc | I'm actually not sure what the best way is right now to find the most recent release of new-contrib artifacts. |
| 22:42 | mutinyonthebay | TimMc: Yeah, I'm having a bit of a problem with it |
| 22:44 | TimMc | mutinyonthebay: The community generally releases to clojars. I suspect Clojure.org releases to Maven central, come to think of it. |
| 22:44 | amalloy | certainly it does |
| 22:45 | ns_pablo | anybody who's familiar with Compojure and Noir, how can I mix both and do something like this: (defroutes main-routes (context "/blog" [] blog-routes) other-routes)) |
| 22:45 | TimMc | Those are the only two default release sites that Lein checks, right? |
| 22:45 | ns_pablo | and then (defroutes blog-routes (defpage "/something" [] ...) |
| 22:46 | ns_pablo | I've looked everywhere, including Noir source, but there doesn't seem to be any support for nested routes |
| 22:49 | ns_pablo | I've asked this a few times in #Noir but there doesn't seem to be any active user over there |
| 22:50 | mutinyonthebay | TimMc: I was getting an Artifact Missing error on lein deps until I added :repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"} |
| 22:51 | TimMc | Might be one of your other deps. |
| 22:51 | mutinyonthebay | I just had clojure and monads |
| 22:51 | mutinyonthebay | It was strange, but everything seems to fix itself with that repo |
| 22:52 | TimMc | Maven Central has v0.1.0 |
| 22:53 | xeqi | clojure/core pushes snapshots to sonatype |
| 22:53 | TimMc | aha |
| 22:53 | xeqi | or clojure/dev really |
| 22:53 | xeqi | releases go to maven central |
| 22:53 | TimMc | That's curious. |
| 22:54 | mutinyonthebay | Ah, I see |
| 22:54 | xeqi | lein searches maven central and clojars by default |
| 22:56 | Frozenlock | ns_pablo: I was checking for the same problem. I "fixed" it by simply putting the entire path: (defpage "/blog/something" [] ... |
| 23:00 | ns_pablo | Frozenlock: so you're repeating "/blog" for every route? |
| 23:02 | ns_pablo | Frozenlock that's what I usually find when looking at Noir source, but that's not gonna work with my app because I need to separate routes from views |
| 23:02 | Frozenlock | As it is yes. PLEASE let me know if you stumble over a more elegant the solution "{ |
| 23:02 | gfredericks | }" |
| 23:02 | Frozenlock | .. |
| 23:03 | gfredericks | Frozenlock: you started it |
| 23:03 | Frozenlock | --> :P |
| 23:03 | Frozenlock | I know. My fault. |
| 23:03 | ns_pablo | It's weird because since Noir build on top of Compojure, I would expect it to extend it, not limit features that are already available |
| 23:03 | ns_pablo | *builds |
| 23:04 | ns_pablo | I'd go with Moustache, but then I'd lose all the goodies from Noir... |
| 23:20 | Frozenlock | ns_pablo: It is still possible to do powerful stuff with the url matching: |
| 23:20 | Frozenlock | (defpage "/user/:id" {:keys [id]} |
| 23:20 | Frozenlock | (str "You are user number " id)) |
| 23:21 | Frozenlock | You can even have another page "/user/:id/anotherPage" which is completely different. |
| 23:23 | ns_pablo | Frozenlock: yeah, it's fine for small apps, I guess. In my case I'm porting legacy code and I need a way to separate the code into indepentent "modules" |
| 23:31 | arohner | if I have a templated java interface Foo<X>, and a method void bar(X arg), what does the reify call need to look like? |
| 23:33 | TimMc | arohner: You can skip the generics under most circumstances. |
| 23:34 | arohner | TimMc: that's what I thought, but I'm getting "Can't define method not in interfaces" |
| 23:34 | Lajla | &(symbol ":()3732(3235) 3832 3dhdha %%%%% ashjad") |
| 23:34 | lazybot | ⇒ :()3732(3235) 3832 3dhdha %%%%% ashjad |
| 23:34 | arohner | lazybot: that's interesting |
| 23:36 | amalloy | (reify Foo (bar [this x])) |
| 23:37 | Lajla | arohner, I do believe ti is a bug. |
| 23:37 | Lajla | And I shall not rest until it is avenged and vanquished |
| 23:37 | arohner | amalloy: that's what I tried. Do I have to do anything different because bar returns nil? |
| 23:38 | amalloy | Lajla: just read one of the many mailing-list threads or stack-overflow questions about it |
| 23:40 | amalloy | arohner: no. whatever problem you're having is down to some specifics you glossed over with your foo/bar example |
| 23:41 | arohner | amalloy: ha. yeah, like misspelling the method name. I totally didn't just do that. |
| 23:43 | y3di | keywords are functions so you can use them to look up values in maps. Can you not use normal primitives the same way? i.e. ("key" {"key" "value"}) |
| 23:43 | amalloy | no, because they're not functions |
| 23:44 | Raynes | You can't use toilet paper to open doors either. |
| 23:44 | arohner | y3di: keywords can implement clojure.lang.IFn, which takes a map as an argument. java strings are final, so that behavior can't be added to strings (or other primitives) |
| 23:45 | flazz | is there a way to run lein tasks from within emacs? |
| 23:45 | Raynes | M-! |
| 23:46 | flazz | Raynes: thanks! duh on my part |
| 23:47 | Raynes | flazz: You can also use eshell if you're running a lot of commands and want to keep the output handy on a buffer. |
| 23:47 | Raynes | M-x eshell |
| 23:50 | flazz | is there an emacs project mode people prefer for clojure projects? |
| 23:50 | Frozenlock | /troll-mode I like clojure-mode |
| 23:51 | Raynes | I've never used any sort of project mode. |
| 23:52 | flazz | i think i need learn-emacs-better-mode |
| 23:53 | y3di | yea pretty dumb q on my part... just wanted to belong ='[ |
| 23:53 | y3di | real question: is the ' in '(1 2 3) and the . in (Date.) macros? |
| 23:55 | TimMc | Reader "macro"s. |
| 23:56 | Raynes | &(doc .) |
| 23:56 | lazybot | ⇒ "Special: .; The instance member form works for both fields and methods.\n They all expand into calls to the dot operator at macroexpansion time." |
| 23:56 | Raynes | TimMc: . is a special form. |
| 23:57 | TimMc | Ah, so it is. |
| 23:57 | Raynes | ' is a reader macro. |
| 23:58 | Raynes | &(doc quote) |
| 23:58 | lazybot | ⇒ "Special: quote; Yields the unevaluated form." |
| 23:58 | Raynes | But it expands to a special form. |
| 23:58 | Raynes | So they're really both special forms. |
| 23:58 | y3di | whats a special form? i don't think ive heard that term |
| 23:59 | arohner | y3di: http://clojure.org/special_forms |
| 23:59 | arohner | y3di: the built in forms that aren't fns or macros |