2011-09-19
| 00:11 | archaiic | hi, anyone experienced with google app engine here? |
| 00:16 | brehaut | ~anyone |
| 00:16 | clojurebot | Please do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help. |
| 00:18 | archaiic | using appengine magic, I send an XHR request that works in interactive and development modes but fails in production, any advice? i think it might be due to gae whitelist |
| 00:21 | amalloy | ae-magic does some weird stuff to detect whether you're in production or not, is what i heard last time someone had an issue like this |
| 00:22 | amalloy | ~search for ide sniffing |
| 00:22 | clojurebot | <#clojure:shtutgart> zvrba: well, maybe it's because clojure seems the most popular and practical lisp right now, but if you just want to learn new concepts etc, Racket will be just fine (simple, no java, batteries including ide) |
| 00:22 | clojurebot | <#clojure:konr> what text editor/IDE do you use? |
| 00:22 | clojurebot | <#clojure:raek> ae/start is conditionally compiled and is only there if ae-m thinks you are using an IDE |
| 00:22 | clojurebot | <#clojure:raek> maybe this is the "IDE sniffing" appengine-magic does |
| 00:24 | tomoj | whoa |
| 00:24 | tomoj | brilliant |
| 00:25 | archaiic | emacs |
| 00:33 | michaelr525 | good morning |
| 00:39 | archaiic | Update: I can get XHR request to work in production without using a json response - using json still throws a 500, possibly clj-json.core uses classes not on GAE whitelist? |
| 00:42 | brehaut | clj-json uses the jackson library doesnt it? |
| 00:44 | archaiic | yes |
| 00:44 | archaiic | it imports java.io StringReader and BufferedReader both are fine |
| 01:18 | archaiic | ahhh that was the worst thing I had to debug in a real long time for anyone interested clj-json 0.4.3 doesn't seem to run on GAE, use clojure-json instead |
| 01:23 | michaelr525 | why use GAE anyway? |
| 01:23 | archaiic | slightly tied into datastore right now |
| 01:24 | archaiic | and some other of their services |
| 02:12 | cemerick | It's all dnolen's fault. Scotch and such. |
| 02:13 | michaelr525 | functional scotch? |
| 02:14 | cemerick | hrm, presumably |
| 02:15 | cemerick | maybe scotch provokes imperative thinking |
| 02:15 | michaelr525 | hhhh |
| 02:15 | cemerick | That's all speculative. |
| 02:16 | cemerick | It might have been the five margaritias too. |
| 02:16 | cemerick | The data is inconclusive. |
| 02:17 | michaelr525 | dnolen quit first ;) |
| 02:17 | cemerick | Hrm, I wonder what hypothesis that supports. |
| 02:25 | michaelr525 | cemerick: The hypothesis of getting up to work in the morning.. |
| 03:31 | Nanakhiel | Chousuke, Juumalan kyrpä, eestilaiset on tulevat! miehitä tykit! |
| 03:43 | michaelr525 | Nanakhiel: Potato chips? What do you mean? |
| 03:47 | opqdonut | that was some very disconcerting stuff in finnish |
| 03:50 | Nanakhiel | opqdonut, what does disconcerting mean? |
| 03:50 | opqdonut | disturbing |
| 03:51 | Nanakhiel | Really? |
| 03:51 | Nanakhiel | Why so? |
| 03:51 | opqdonut | well you don't usually encounter people saying "the penis of god" followed by blabbering in #haskell |
| 03:52 | opqdonut | sory, #clojure |
| 03:52 | opqdonut | got my contexts mixed up again :) |
| 03:53 | Chousuke | This guy likes to say random offensive things in Finnish to me for some reason. |
| 03:53 | Nanakhiel | Your standards of offensive are peculiar |
| 03:53 | Nanakhiel | I would losely translate as 'omg, the estonians are coming, man the cannons!' |
| 03:54 | Chousuke | very loosely. |
| 03:54 | Nanakhiel | Of course. |
| 03:54 | Nanakhiel | Literal translation always fails one. |
| 03:54 | opqdonut | oh, Chousuke is finnish. I had no idea |
| 03:54 | raek | "Nanakhiel"... another one of you nicks? |
| 03:55 | Nanakhiel | raek, one of the many names I had throughout the milennia. |
| 03:57 | michaelr525 | what did I miss? ;) |
| 04:18 | sthuebner | how do I parse a large xml file (larger than memory) lazily? |
| 04:19 | sthuebner | I'm using clojure.contrib.lazy-xml together with clojure.contrib.zip/xml-zip, but it blows up heap memory |
| 04:20 | amalloy | i would be pretty surprised if you could zip lazily |
| 04:20 | amalloy | since the zip api has ways to go up and down in the tree, you can't throw away elements you're "done" with |
| 04:21 | sthuebner | zip-filter/children reads as it would return a lazy sequence of children. |
| 04:21 | amalloy | so? |
| 04:21 | sthuebner | you're saying that it nevertheless has to parse the whole file? |
| 04:21 | amalloy | no, it has to hang onto the whole file in case you decide to go back up towards the root |
| 04:22 | sthuebner | OK, I see. so zippers are the wrong path to go then |
| 04:22 | amalloy | yes |
| 04:22 | sthuebner | what other option do I have? |
| 04:24 | amalloy | dunno. it is xml's nature that it's pretty hierarchical |
| 04:25 | amalloy | https://github.com/clojure/data.xml/blob/master/modules/xml/src/main/clojure/clojure/data/xml.clj has some code that looks like it's supposed to parse things lazily, but (a) doesn't have any released versions yet, and (b) i'm not really convinced it would work |
| 04:26 | amalloy | $google xml sax |
| 04:26 | lazybot | [SAX] http://www.saxproject.org/ |
| 04:26 | sthuebner | OK, I'll take a look on that |
| 04:26 | amalloy | of course that's very stateful and low-level/unpleasant |
| 04:27 | amalloy | but i'm not sure you have have both the convenience of hierarchical-looking structures *and* lazy parsing |
| 04:28 | sthuebner | I don't really need the whole structure, but just a sequence of children of the root element. each of these is of reasonable size |
| 04:29 | amalloy | then just lazy-xml/parse-seq looks like it should be sufficient |
| 04:40 | khaliG | when using clojure-jack-in - is there a way to restart everything? i've added a new jar to lib and want it to pick it up |
| 04:41 | khaliG | or if there is some other way to do it short of restarting emacs i'd like to know |
| 04:44 | amalloy | i think you just kill the *swank* buffer |
| 04:45 | khaliG | amalloy, wicked, that'll do |
| 04:59 | michaelr525 | sthuebner: maybe lazy-xml already does it. but I remember that i looked into this stuff when I had a similar problem: https://github.com/marktriggs/xml-picker-seq |
| 05:05 | sthuebner | michaelr525: thanks, I've just discovered xml-picker-seq myself. I'll check it out |
| 07:47 | dzderic | here's a question: What's the best way to do distributed web scraping in clojure? |
| 07:47 | dzderic | I'll be scraping sites where some workers will download lists of URLs for other workers to grab, parse and insert into a db |
| 07:48 | dzderic | I was thinking of using redis as a queue, although I don't know if it's reliable enough |
| 07:49 | dzderic | or should I really be using hadoop for something like this? |
| 07:51 | michaelr525 | dzderic: i'm currently looking into kestrel as a reliable queue for other purpose, but maybe it would be good for yours as well.. |
| 07:54 | dzderic | the main concern I have with reliability is that I want this to run on EC2 and have the IPs of the workers change every couple of hours |
| 07:54 | dzderic | and I'm not really sure on how I would go about implementing this |
| 07:58 | chrido | why not use the amazon queue? |
| 07:59 | dzderic | would it be fast enough? |
| 08:01 | chrido | for me it's enough (~10-150 msg/sec), don't know your requirements |
| 08:02 | dzderic | that should be fast enough |
| 08:02 | dzderic | i'll check it out |
| 08:07 | michaelr525 | dzderic: or your own queue such as kestrel, saving to amazon EBS (persistent storage). I think it will cost you less than amazon queue |
| 08:07 | michaelr525 | dzderic: please let me know what you find out :) |
| 08:08 | dzderic | michaelr525: I just realised I will be well above the free tier :S |
| 08:08 | dzderic | michaelr525: I'll check out kestrel |
| 08:17 | dzderic | kestrel looks very simple |
| 08:18 | dzderic | the only problem with it is that it has no equivalent of redis' "BRPOPLPUSH", which retrieves an element from a list and pushes it onto another one (eg. "currently processing"), which helps to make sure every link gets processed |
| 08:21 | thorwil | is there a nicer way for something like : (map #(vector %1 %2) [:a :b :c] (range)) ? |
| 08:22 | michaelr525 | dzderic: well, from what I read I understood that you can pop an element from the queue and process it and when you are finished with it you signal the queue and only then it is removed from the queue.. |
| 08:23 | michaelr525 | it's called reliable reads I think |
| 08:23 | dzderic | michaelr525: i saw the peek command |
| 08:23 | dzderic | michaelr525: which could help[ |
| 08:27 | bhenry | ,(map vec (zipmap [:a :b :c] (range))) |
| 08:27 | clojurebot | ([:c 2] [:b 1] [:a 0]) |
| 08:27 | bhenry | thorwil: ^^ ? |
| 08:28 | bhenry | yours might be faster though. less work i think. |
| 08:30 | thorwil | it's interesting and a good reminder of zipmap (which belongs to the collections of things i tend to forget), thanks :) |
| 08:31 | dzderic | bhenry: note that your implementation returns a reversed vector |
| 08:31 | dzderic | s/vector/list |
| 08:31 | lazybot | <dzderic> bhenry: note that your implementation returns a reversed list |
| 08:32 | bhenry | dzderic: i noticed that. sometimes that doesn't matter. |
| 08:32 | dzderic | fair |
| 08:33 | bhenry | i should have told thorwil to note that in case it matters for him |
| 08:33 | thorwil | do i see this correctly, that additional bindings in a for are executed in a nested fashion? |
| 08:34 | raek | ,(map-indexed vector [:a :b :c]) |
| 08:34 | clojurebot | ([0 :a] [1 :b] [2 :c]) |
| 08:35 | bhenry | raek: nice. |
| 08:35 | thorwil | indeed |
| 08:54 | fhd | Is there something like a (def-) to define private variables, like (defn-) for private functions? |
| 08:55 | manutter | fhd: that's a frequently-asked question, and the answer I usually hear is "No, but it's easy to make one if you really need it" |
| 08:56 | manutter | private vars make it harder to write tests though |
| 08:56 | fhd | manutter: I see. Was wondering because googling around didn't give me much. |
| 08:56 | manutter | an alternative is to make a namespace foo and a namespace foo.impl, have foo require foo.impl, then put "private" vars in foo.impl |
| 08:56 | fhd | manutter: Yeah, I haven't needed this in 12 months of working with Clojure, but right now I do. I need a simple in-memory storage for test purposes. |
| 08:57 | manutter | foo.impl is "private" since nobody else calls it, but still public enough that your tests can require it |
| 08:57 | fhd | manutter: That's how they do it in C++ :) |
| 08:57 | manutter | yeah, the "impl" rang a bell when I first saw it |
| 08:58 | fhd | manutter: I like that solution, guess I'll use it for all of the storage related functions |
| 09:00 | Kototama | hello, in compojure i'm having my POST parameters indexed on a string when using swank but on keywords when building a WAR. Why is it so?? |
| 09:00 | lazybot | Kototama: What are you, crazy? Of course not! |
| 09:01 | manutter | botsmack |
| 09:03 | manutter | Kototama: classpath issues? |
| 09:03 | manutter | I'm taking wild guesses, that sounds like a very weird problem to me |
| 09:07 | Kototama | these are the parameters within an wrap-multipart-params |
| 09:09 | manutter | The only thing I can think of is there's an older version of wrap-multipart-params in the classpath that the WAR/servlet-container sees, which is different from the version in the classpath that slime/jetty sees |
| 09:09 | manutter | but like I said, wild guess |
| 09:11 | Kototama | i'm using jetty7, could this be related? |
| 09:15 | manutter | I couldn't say |
| 09:17 | xian | Hi. I have a leiningen project where Java and Clojure code are mixed. Compiling the Java code requires some jar-file to be in the classpath. However, leiningen seems to have its own classpath and typing "lein javac" leads to many compiler errors (because the required jar file is not in leiningen's CP). Is there any way to modify leiningen's CP? |
| 09:18 | manutter | yes, there is, but you're going to ask me "what is it" and I don't remember :( |
| 09:19 | manutter | I think there's a tag in the leiningen examples project.clj file, on the leiningen site |
| 09:22 | raek | xian: the simplest way is to find the artifact id for your jar and add it as a dependency in your project.clj (if the jar is available in a maven repo somewhere) |
| 09:23 | raek | xian: if you search for the jar at http://www.jarvana.com/, is it there? |
| 09:24 | raek | (this is the most common reason to want to include an external jar that I hear of) |
| 09:24 | manutter | oh, yeah, that'll work! :) I'm pretty sure there's a project.clj key for it too, though. Maybe :library-path ? |
| 09:28 | raek | xian: in case the jar is not available as a maven artifact, it should be possible to add it to the lein classpath somehow, yes. (I don' recall exactly how to do it now, but I know where I can look) |
| 09:30 | joegallo | mvn install the thing, and then, hey presto, it is available. the output from the maven error messages tell you how to do it. |
| 09:32 | manutter | Yeah, I just put it in as a dependency in project.clj, and then the error message from 'lein deps' gives pretty precise instructions on how to install it |
| 09:33 | manutter | I did javamail that way, come to think of it. |
| 09:33 | manutter | (before I knew how to search for the right maven repo ;) |
| 09:34 | xian | raek: I just copied the jar in the libs directory and it worked. |
| 09:34 | xian | raek: I will look into your suggestions later today, thanks so far. |
| 09:34 | manutter | eh, but keep a spare copy around, lein has a tendency to wipe out the libs dir and rebuild it from scratch |
| 09:37 | raek | xian: beware that leiningen will remove that jar when you do a lein deps. (there is an option for that) |
| 09:37 | joegallo | xian: that is a solution, but it's not a good one for anything besides an immediate fix, because of what manutter said. the lib dir is not for you to add and remove things from, you should treat is a magic black box under the management of leiningen. |
| 09:38 | manutter | raek: you added info that I forgot, though, so it's all good |
| 09:41 | chrido | a question: which application server would you use on windows server? |
| 09:42 | chrido | it's a small web application with a db behind |
| 09:44 | manutter | chrido: you mean like tomcat vs jetty? I'm not clear on "application server on a windows server" |
| 09:45 | chrido | yes, tomcat, jboss and so on |
| 09:46 | chrido | geronimo |
| 09:46 | chrido | or glassfish? |
| 09:49 | manutter | eh, I don't really know enough to have an informed opinion, I should just keep my mouth shut. |
| 09:50 | manutter | I do like heroku for clojure tho ;) |
| 09:51 | chrido | something like that would be great, but running on a windows box. |
| 09:53 | manutter | well, the point of heroku is letting someone else maintain the box. If you've got your own server I would think tomcat or jetty would suffice, unless you need the extra services that come with jboss/glassfish |
| 09:53 | manutter | don't really know much about geronimo |
| 09:56 | zippy314 | Can anybody tell me the correct way to serialize a clojurescript hashmap to a Json string? My current attempt, an example of which is: (goog.json.serialize (.strobj {:cmd "authenticate" :params {:user "eric"}})) , produces a very weird json string: {"\ufdd0'cmd":"authenticate","\ufdd0'params":{"meta":null,"keys":["\ufdd0'user"],"strobj":{"\ufdd0'user":"eric"}}} Notice the \ufddo' before all key values, as well as the "m |
| 10:00 | chrido | manutter: just found out there exists a windows service wrapper for jetty, so there could be a possibility that our admin can deal with the deployment. there could also be an possiblity to get the integrated windows authentication running with waffle => so i will go with jetty |
| 10:01 | zippy314 | never mind, found a nice answer here: http://mmcgrana.github.com/2011/09/clojurescript-nodejs.html |
| 10:27 | choffstein | Morning all! Quick question -- is there an easy way to pull the doc-string from any function? |
| 10:27 | choffstein | I thought (:doc (meta function)) would work -- but :doc doesn't seem to pull up the doc-string |
| 10:27 | choffstein | ideally, I'd like to get it back in string format -- not print it |
| 10:27 | raek | choffstein: the docstring metadata is actually not stored on the function object, but on the var |
| 10:28 | choffstein | raek: ah, well, that explains it :) Is it stored in the namespace? |
| 10:28 | raek | ,(-> #'conj meta :doc) |
| 10:28 | clojurebot | "conj[oin]. Returns a new collection with the xs\n 'added'. (conj nil item) returns (item). The 'addition' may\n happen at different 'places' depending on the concrete type." |
| 10:28 | choffstein | Thhhatttt is probably what is going wrong then. |
| 10:28 | raek | well, the var can be accessed from the namespace, from var-quote or from 'resolve' |
| 10:30 | raek | there might not by any simple way to go from conj (the function) to #'conj (the var) |
| 10:30 | choffstein | Awesome. Thanks :) |
| 10:30 | raek | but from 'conj (the symbol, e.g. using a macro) to #'conj is possible with resolve |
| 10:35 | choffstein | Appreciate the help, raek. Think I got it working |
| 10:36 | raek | np :) |
| 10:55 | kzar | I'm changing the library I require in one of my files, I would like to use the same alias as before but now I get an error. Without kiling restarting the Java process is there a way to clear the alias so I can re-use it? |
| 11:06 | nerooth | Is there any difference in syntax between a lazy seq and a list in clojure? They booth look like (a b c) as far as I can tell |
| 11:08 | ambrosebs | nerooth, they both print identically at the REPL |
| 11:08 | manutter | nerooth: yes, there's a difference, but it's mostly invisible unless you get into the grit |
| 11:09 | manutter | (range) is a lazy seq of all numbers greater than zero |
| 11:09 | manutter | there is no equivalent list that will fit inside your RAM |
| 11:14 | nerooth | I see, thanks. I was sure I had a list at my hands but it turned out to be a lazy seq. |
| 11:16 | manutter | a common gotcha is that a lazy seq is essentially a generator that churns out list items incrementally, but the REPL gets the seq items eagerly, making a lazy seq look like a list |
| 11:16 | nerooth | Ah I see |
| 11:16 | manutter | but in your actual code (not at the REPL), it goes back to behaving like a lazy seq, especially if you pass it to (apply str i-thought-this-was-a-list!) |
| 11:17 | khaliG | nerooth, why cant it be both? |
| 11:17 | nerooth | both? |
| 11:17 | manutter | (where i-thought-this-was-a-list! is the lazy seq, of course) |
| 11:17 | khaliG | (class '(10 20 30)) == (class (seq '(10 20 30))) == clojure.lang.PersistentList |
| 11:18 | manutter | right, but seq is not necessarily lazy seq |
| 11:19 | manutter | ,(class (map identity [1 2 3])) |
| 11:19 | clojurebot | clojure.lang.LazySeq |
| 11:19 | nerooth | nify bot |
| 11:19 | nerooth | nifty* |
| 11:37 | gfredericks | $findfn {:a 2 :b 2 :c 3} {3 [:c] 2 [:a :b]} |
| 11:37 | lazybot | [] |
| 11:39 | aaelony | a curious question: There is map and pmap. Is there a reason why there is no pfilter for filter in parallel ? |
| 11:40 | gfredericks | aaelony: not sure, but it should be easy to implement |
| 11:40 | raek | kzar: try (ns-unalias 'your-ns 'the-alias) |
| 11:41 | raek | remove-ns can be handy too |
| 11:41 | aaelony | gfredericks: perhaps that's the reason then... |
| 11:41 | gfredericks | (->> coll (pmap #(list (p %) %)) (filter first) (map second)) |
| 11:42 | aaelony | gfredericks: wow, that's cool |
| 11:42 | gfredericks | aaelony: haven't tried it, that was just off the top of my head :) |
| 11:42 | aaelony | :) |
| 11:44 | aaelony | gfredericks: interesting the that 2nd map is not a pmap. |
| 11:44 | gfredericks | aaelony: I assumed that p is the computationally intensive part, so the last two operations wouldn't be helped by parallelism |
| 11:44 | gfredericks | first and second are pretty efficient operations :) |
| 11:45 | aaelony | right. |
| 11:45 | gfredericks | I'm not an expert on parallel algorithms, so I don't know if that's valid reasoning |
| 11:46 | aaelony | Thanks for your example. I'm thinking it over. :) |
| 11:46 | gfredericks | aaelony: no problem |
| 11:47 | aaelony | :) |
| 11:47 | khaliG | manutter, yep good point :) |
| 11:48 | aaelony | wow. Hope nathan will make slides available on storm soon :) |
| 11:50 | gfredericks | manutter: I'll just transcribe all the talks here on IRC so it'll be just like you're there |
| 11:50 | TimMc | yay |
| 11:50 | manutter | :D |
| 11:50 | TimMc | Do the voices, do the voices! |
| 11:50 | gfredericks | "So finally we add the last bolt in the topology, which gives us all the word counts..." |
| 11:51 | TimMc | Can you relay our questions back? :-P |
| 11:51 | gfredericks | of course |
| 11:51 | manutter | what if somebody @ strangeloop reads your transcription during a presentation, and begins relaying it to the audience? |
| 11:51 | gfredericks | then I can use copy and paste |
| 11:51 | TimMc | That would be silly, who would do that? :-) |
| 11:52 | manutter | or am I taking the name too literally? |
| 11:52 | gfredericks | so I hope that hapens |
| 11:52 | manutter | :D |
| 11:52 | manutter | strangeloop -> feedbackloop |
| 11:53 | TimMc | gfredericks: That takes all the fun out of it. You should introduce typos. |
| 11:53 | gfredericks | if the person shouting out my transcription doesn't make errors I can still copy/paste |
| 11:54 | gfredericks | I guess the clojure folks at SL probably aren't on IRC |
| 11:54 | gfredericks | khaliG: it'll be open source in a few minutes |
| 11:54 | gfredericks | actually right this minute I think |
| 11:54 | manutter | that would be a pretty interesting twitter app, actually. Have retweets create random mutations in the text, see how the message evolves over time/propagation |
| 11:54 | tomoj | :D |
| 11:54 | khaliG | gfredericks, oh? |
| 11:54 | gfredericks | he promised to open-source it right in the middle of the talk |
| 11:55 | gfredericks | and someone just interrupted to remind him |
| 11:55 | manutter | TimMc: ^_above_^ |
| 11:55 | gfredericks | should be at github.com/nathanmarz |
| 11:55 | manutter | storm is what they're using on the twitter backend isn't it? |
| 11:55 | gfredericks | 4 projects |
| 11:55 | gfredericks | storm-deploy |
| 11:55 | gfredericks | manutter: yeah |
| 11:55 | gfredericks | storm-starter |
| 11:56 | gfredericks | storm-kestrel |
| 11:56 | gfredericks | (all repos being made public now) |
| 11:56 | gfredericks | and storm |
| 11:56 | tomoj | hurrah |
| 11:57 | gfredericks | TimMc: ha! |
| 11:58 | gfredericks | looks like it's all in java? somebody quick write a clojure lib for it |
| 11:59 | gfredericks | clorm? |
| 11:59 | mrBliss | apparently storm still depends on clojure 1.2.0 instead of 1.2.1 |
| 11:59 | TimMc | jtorm |
| 11:59 | gfredericks | maybe storcl and pronounced "storkle" |
| 11:59 | gfredericks | oh is storm itself in clojure? |
| 11:59 | gfredericks | all his demos and sample code is in java |
| 12:00 | TimMc | gfredericks: https://github.com/nathanmarz/storm/graphs/languages |
| 12:00 | TimMc | 20% Clojure |
| 12:00 | hugod | storm-deploy uses pallet :) |
| 12:00 | TimMc | And 64% Java, so about even. |
| 12:01 | gfredericks | TimMc: wifi here not good enough to load that page apparently |
| 12:01 | gfredericks | even though I can stay ssh'd into my server w/ irc |
| 12:11 | edw | Can someone tell me why I get an assertion exception in this case: (binding [*assert* false] ((fn [x] {:pre [(>= x 0)]} x) -1)) |
| 12:13 | TimMc | edw: Here's a lead: http://stackoverflow.com/questions/4874517/how-to-make-clojure-respect-assert-variable |
| 12:14 | edw | TimMc: Thanks! |
| 12:14 | TimMc | You apparently need to set! it. |
| 12:15 | edw | TimMc: That's what I expected, that *assert*'s value was significant and read- and compile-time, not execution time. |
| 12:15 | TimMc | I think it was something to do with fn's expansion. |
| 12:15 | TimMc | *has |
| 12:16 | TimMc | Well, maybe not. (After some experimentation.) |
| 12:16 | devn | Aw, I'm not the first to mention Storm |
| 12:17 | devn | gfredericks: I think you just need to disconnect and reconnect. A lot of people were going to watch/fork/clone when nathan released that. |
| 12:19 | TimMc | devn: I think gfredericks is disconnected already. |
| 12:26 | pauldoo | Is there an easy way to intern arbitary objects (a la String.intern())? I'd imagine some macro along the lines of memoize could create an interner.. |
| 12:31 | srid | what is the best way to run command in clojure asynchronously? i.e., i don't want to block when reading lines from the process's stdout. (background -- the command I intend to run is "tail -f ..." via ssh) |
| 12:32 | srid | specifically, i have a list of hosts on which I want to run "ssh $host tail -f /var/log/app" and get the log lines as a seq. |
| 12:33 | srid | the commands should run in background, and i should be able to read the output (lines from tail) asynchronously |
| 12:33 | srid | i'm not a java programmer, so this stumps me. |
| 12:38 | scottj | srid: maybe (pmap #(sh "ssh" % .. ) hosts) |
| 12:40 | srid | doesn't `sh` block until the process is ended? (remember, `tail -f` never ends) |
| 12:51 | eliOcs | hihi!! |
| 12:55 | eliOcs | is there anyone alive in this idle world? |
| 12:55 | eliOcs | :) |
| 12:55 | Fossi | nope |
| 12:55 | eliOcs | crap |
| 12:55 | eliOcs | willing to talk? |
| 12:55 | Fossi | at least i do feel more like a zombie |
| 12:55 | eliOcs | me too working long hours with java legacy code makes me feel that way |
| 12:56 | eliOcs | trying to clean up my mind on my free mind with a little bit of clojure |
| 12:56 | Fossi | i wish this was already "legacy" ;) |
| 12:56 | eliOcs | haha |
| 12:56 | eliOcs | do you own a mac? |
| 12:56 | Fossi | nope |
| 12:56 | eliOcs | ok |
| 12:57 | eliOcs | I'm trying to setup emacs for clojure on my mac but I keep getting to outdated tutorials |
| 12:57 | eliOcs | which don't work :( |
| 12:57 | eliOcs | I've always been a vim guy and getting to setup clojure for emacs is killing me |
| 12:57 | eliOcs | ˆˆ |
| 12:58 | eliOcs | fossi which ide do you use for clojure? |
| 12:59 | zerokarmaleft | eliOcs: the first method described at https://github.com/technomancy/swank-clojure works well |
| 12:59 | zerokarmaleft | it's much simpler with clojure-jack-in |
| 13:00 | eliOcs | okay I'm going to try it right now |
| 13:01 | nickmbailey | fwiw, i've found vimclojure works fine for me. not ready to try the jump to emacs :) |
| 13:04 | eliOcs | I guess if a try to learn clojure I'll go all the way and try to learn emacs |
| 13:05 | zackham | eliOcs: i was a (am still a...) heavy vim user and just made the switch. basic keybindings don't take long to learn. pain lasted for 2 days at most |
| 13:06 | Fossi | emacs is simply tooooo nice for lisps |
| 13:06 | Fossi | esp with paredit |
| 13:06 | Fossi | takes a month to get up to full speed though |
| 13:07 | zackham | i jumped in for org-mode and coincidentally got interested in clojure at the same time, convenient i guess |
| 13:08 | zackham | now im using erc and notmuch and half the time open vim in a term buffer =( |
| 13:08 | zackham | sucks you in |
| 13:08 | TimMc | Having a physical (dead tree!) cheatsheet *really* helps. Write it as you go. |
| 13:09 | zackham | yea the png cheatsheet for paredit is really good |
| 13:10 | khaliG | zackham, linky? |
| 13:11 | zackham | http://www.emacswiki.org/emacs/PareditCheatsheet |
| 13:11 | zackham | never did find a pdf of it, just printed the png *shrug* |
| 13:17 | Bronsa | https://github.com/nathanmarz/storm |
| 13:17 | eliOcs | thanks for the cheatsheet guys |
| 13:20 | zackham | eliOcs: no problem, here's a decent one for emacs in general: http://www.cs.colorado.edu/~main/cs1300/lab/refcard-emacs.pdf - prepare to be pretty disappointed at how small the "motion" section is =) |
| 13:20 | srid | how do I find if the first of a lazy-seq is realized or not? |
| 13:20 | srid | (specifically a line-seq) |
| 13:21 | eliOcs | zackham: omg all this material makes me feel like a real noob ˆˆ |
| 13:27 | gfredericks | srid: why do you need to know? |
| 13:28 | amalloy | (inc gfredericks) |
| 13:28 | lazybot | ⟹ 1 |
| 13:29 | srid | gfredericks: the line-seq was run a 'tail -f' command. i do this for more than one 'tail -f' commands. since looping over a single line-seq could block (because a 'tail -f' command had othing to pring due to unmodified logfile), i want to first check if there is any data before doing the same to other line-seq's |
| 13:29 | srid | put simply, i want to 'tail -f' more than one log file in clojure without blocking. (then send them to redis) |
| 13:29 | srid | (and these logs live on remote machines; so I wrap the command with ssh) |
| 13:30 | srid | apparently clojure 1.3 introduced a `realized?` function to do just that. but this is not possible in 1.2? |
| 13:31 | srid | but realized? probably doesn't help here. a line-seq must be realized anyway, and that could either block or not |
| 13:33 | amalloy | instead of looping over the files and checking to see if data is available, why not give each of them a thread/future that reads them as fast as possible, doing whatever you want when data comes in |
| 13:34 | amalloy | eg, having an agent somewhere that re-syncs all those futures into one cohesive seq of lines |
| 13:35 | srid | hmm, then i'd have to read upon on concurrency features such as agent. |
| 13:35 | srid | i'm looking to do a quick prototype by today and worry about doing it properly later. |
| 13:36 | manutter | srid: agent is pretty easy, just look it up on clojuredocs and that should be enough for a quick workable proto |
| 13:38 | manutter | actually, look agents in the clojuredocs quick reference section, send and send-off are probably really all you need. |
| 13:38 | manutter | (well, one of them anyway) |
| 13:41 | nkoza | An example for JOC: (let [r (range 1 1e9)] [(last r) (first r)]) blows the heap, but let [r (range 1 1e9)] [(first r) (last r)]) not. I think in the second case r is being unbound before calling last as a compiler optimization. My question is, how is this optimization called? "automatic unbounding" or something like that? |
| 13:41 | khaliG | that cheatsheet is excellent, i wish i'd tried paredit earlier |
| 13:42 | srid | manutter: `send` on an agent is an async operation? |
| 13:42 | manutter | srid: I think you want send-off for the non-blocking functionality |
| 13:42 | srid | that's neat |
| 13:42 | manutter | I just reviewed the docs on clojuredocs myself and I'm not sure there isn't a typo there in the docs for send |
| 13:43 | srid | i suppose the thread is automatically killed upon function exit (in send) |
| 13:43 | manutter | They'll time out, or you can call shutdown-agents explicitly if you know you just want to bail. |
| 13:44 | srid | i don't understand how send invokes `f`. in (send agent inc) it passes the agent' curent value to inc. but in (send agent slurp "file.txt"), it doesn't |
| 13:45 | manutter | right, the arg to f is the current state of the agent, if you want different args use (fn [_] (slurp "file.txt")) |
| 13:45 | srid | i was looking at the send-off example that caused the above confusion |
| 13:46 | manutter | (fn [_]) means (function that takes one argument and ignores it completely :) |
| 13:46 | srid | so that example is wrong? |
| 13:46 | srid | http://clojuredocs.org/clojure_core/clojure.core/send-off |
| 13:46 | manutter | Hmm, I think it is, haven't tried it. |
| 13:46 | amalloy | &(doc slurp) |
| 13:46 | lazybot | ⇒ "([f & opts]); Reads the file named by f using the encoding enc into a string and returns it." |
| 13:47 | amalloy | ugh. what are the damn opts please |
| 13:47 | manutter | you know what, though, I might be wrong |
| 13:47 | amalloy | manutter: it looks wrong to me, but might by coincidence work |
| 13:48 | amalloy | no |
| 13:48 | manutter | er, send-off I mean |
| 13:48 | amalloy | no |
| 13:48 | amalloy | only functions are germane to the current discussion |
| 13:49 | manutter | yeah, no, just checked the source: send-off is a function, and the example at clojuredocs is correct |
| 13:49 | amalloy | manutter: what makes you say it's correct? |
| 13:50 | manutter | amalloy: The & opts refers to optional additional arguments to be passed to f as arguments #2 & following |
| 13:51 | amalloy | uh... |
| 13:51 | amalloy | (let [a (agent nil)] (send a slurp "http://google.com") (await a)) ;; fails |
| 13:52 | clojurebot | ,(let [testar (fn [x y] (if (= (reduce + (filter odd? (range 0 x))) y) (str y " is an")) )] (testar 10 25)) |
| 13:52 | bhenry | manutter: he was doc-ing slurp not send-off |
| 13:52 | manutter | oh wait, you were looking at the opts for slurp not for send-off |
| 13:52 | manutter | lol, yeah, ok sry |
| 13:52 | manutter | trying to multi-task here |
| 13:52 | manutter | github is timing out on me, quit trying to fork storm you guys |
| 13:53 | amalloy | (let [a (agent "UTF-8")] (send a slurp "http://google.com") (await a)) ;; might work, the first time, maybe, by coincidence |
| 13:55 | amalloy | srid: weren't you asking like...last wednesday whether you had to learn concurrency primitives in order to do concurrency stuff? and i think people said yes. it seems they've been proven right in that you're stuck here with no idea how to advance your program, but you're still saying you want to do it without learning how to use agentss |
| 13:56 | TimMc | nkoza: I don't know if r is being unbound -- what version of Clojure are you using? |
| 13:57 | manutter | I'm stuck, the definition of send-off is (.dispatch a (binding [*agent* a] (binding-conveyor-fn f)) args true) |
| 13:57 | srid | wanting to do it by today. i may use agents if that doesn't take too much of today's time to learn. |
| 13:57 | manutter | and I don't really know what .dispatch is doing |
| 13:57 | amalloy | nkoza: "locals clearing" |
| 13:57 | nkoza | TimMc: 1.2 |
| 13:57 | manutter | srid: I'd play around with it, send-off is what you need, and if the example at clojuredocs doesn't work for you, try the version I suggested. |
| 13:58 | TimMc | OK. I waited for both to finish, and neither did. |
| 13:58 | nkoza | amalloy: thanks |
| 13:58 | nkoza | TimMc: check the memory comsumption of both |
| 13:58 | TimMc | You mean before I kill them? |
| 13:59 | amalloy | anyway, short answer is that the slurp example is just wrong. it does send the agent's current value to slurp |
| 13:59 | nkoza | khaliG: where is the paredit cheatsheet? |
| 13:59 | nkoza | TimMc: yep |
| 13:59 | khaliG | nkoza, http://www.emacswiki.org/emacs/PareditCheatsheet |
| 13:59 | manutter | nkoza: http://www.emacswiki.org/emacs/PareditCheatsheet |
| 14:00 | manutter | lol, I was racing you khaliG, but you beat me |
| 14:00 | khaliG | haha :) |
| 14:00 | nkoza | thanks guys |
| 14:00 | srid | interesting. peek cannot be used on a seq? |
| 14:01 | TimMc | ,(peek (seq '(2 3 4))) |
| 14:01 | amalloy | $google paredit cheat sheet |
| 14:01 | clojurebot | 2 |
| 14:01 | lazybot | [EmacsWiki: Paredit Cheatsheet] http://www.emacswiki.org/emacs/PareditCheatsheet |
| 14:01 | amalloy | would have been the fastest way, just fyi |
| 14:01 | amalloy | TimMc: that's cheating |
| 14:01 | amalloy | &(peek (seq [2 3 4])) |
| 14:01 | lazybot | java.lang.ClassCastException: clojure.lang.PersistentVector$ChunkedSeq cannot be cast to clojure.lang.IPersistentStack |
| 14:01 | TimMc | hee hee |
| 14:02 | srid | peek on a lazy-zeq, I mean. |
| 14:03 | srid | anyway, it doesn't matter. `(send t (fn [[_ s]] [(first s) (rest s)]))` works to pull elements from a line-seq without blocking. i just do (first @t) to get the recent line. |
| 14:05 | TimMc | nkoza: first/last plateaus at 960 MiB, last/first at 330 MiB. Neither halts within a minute, and both reach that steady memory level. |
| 14:06 | TimMc | I suppose the latter is churning through quite a bit of garbage, but I don't see why the former continues to run at all. |
| 14:06 | TimMc | Maybe it is waiting for swap space. |
| 14:06 | srid | cd - |
| 14:21 | chouser | General-purpose 4clojure solution: #(reify Object (equals [_ _] (= %&))) |
| 14:22 | amalloy | ~guards |
| 14:22 | clojurebot | SEIZE HIM! |
| 14:23 | srid | can agents be a collection of other agents? |
| 14:24 | amalloy | chouser: i'm sure we have a few problems that aren't of the form (= (__ ...) ...) |
| 14:24 | chouser | amalloy: indeed you do |
| 14:24 | amalloy | but that's a clever cheat |
| 14:24 | chouser | this is what comes of golfing |
| 14:26 | amalloy | the server counters by disallowing code submissions when username=chouser |
| 14:27 | srid | btw, send itself returns immediately. so why does send-off exist? |
| 14:27 | chouser | amalloy: heh |
| 14:31 | technomancy | srid: different thread pool |
| 14:32 | chouser | amalloy: actually, that fails for many many of the problems. Any that have a collection on the right-hand side of = |
| 14:33 | chouser | for those you need: #(reify clojure.lang.IPersistentCollection (equiv [_ _] (= %&))) |
| 14:34 | amalloy | chouser: i like the use of (= %&) to imply you're doing actual equality tests |
| 14:34 | chouser | heh |
| 14:34 | srid | (send agt afunc) is followed by a loop that prints @agt. the print stops right when afunc returns. what could have happened? |
| 14:35 | TimMc | chouser: I see, it has to use %& to accept any number of arguments. |
| 14:36 | amalloy | right. he could optimize by using % for single-argument functions |
| 14:39 | joly | evil... :P |
| 14:40 | chouser | careful with that always-true object. My REPL thinks it's equal to the EOF sentinel and quits. |
| 14:40 | chouser | not always true, I guess. "equal to everything" |
| 14:41 | TimMc | chouser: Ah, I was wondering what was going on. |
| 14:41 | TimMc | Nasty. |
| 14:43 | amalloy | chouser: that's fantastic |
| 14:43 | TimMc | It doesn't kill the REPL, it just hangs it. |
| 14:43 | chouser | huh, mine shuts down very cleanly. |
| 14:44 | chouser | aw, http://4clojure.com/problem/114 does the equality in the wrong order. |
| 14:45 | TimMc | A.k.a. the chouser-proof order. |
| 14:45 | chouser | :-P |
| 14:48 | srid | invoking https://gist.github.com/1227251 blocks right after printing "Returning new agent value:" ... and I have no idea why! |
| 14:49 | srid | even when run in the context of no agents, i.e, direct invoke |
| 14:49 | srid | 'curr' is a map of hostname to line-seq |
| 14:50 | chouser | srid: it bloack? it doesn't return nxt? |
| 14:51 | chouser | s/bloack/blocks/ |
| 14:51 | lazybot | <chouser> srid: it blocks? it doesn't return nxt? |
| 14:51 | srid | yes, when I do (update-running-deas) in repl it just hangs right after that println statement |
| 14:51 | srid | i had to kill swank and restart it |
| 14:51 | Nocab | wow |
| 14:51 | Nocab | HN is so full of android-hate today, I might as well do some clojure :P |
| 14:52 | srid | chouser: ah, I see why. the values of the map are lazy-seq .. so the repl is trying to print them. but these lazy-seq's point 'tail -f' processes, so repl hangs. |
| 14:52 | srid | I guess. |
| 14:53 | srid | but not sure why this happens in (send aAgent update-running-deas) too |
| 14:53 | srid | is `send` realizing the lazy-seqs (in map values)? |
| 14:55 | srid | my guess was right. (keys (update-running-deas)) runs finitely in repl |
| 15:07 | arohner | has clojure.contrib.def made it into 1.3 contrib anywhere? |
| 15:08 | Bronsa | arohner: part of it should be into core.incubator |
| 15:08 | arohner | Bronsa: thanks |
| 15:32 | nerooth | I have user={:type "tester", :name "hej", :_id "57c6d53e-daca-46b6-92ab-63c3b37de22e"} but (get user :type) returns nil. What am I doing wrong? |
| 15:34 | arohner | nerooth: user is a vector |
| 15:34 | arohner | get looks up things in maps by their keys, but in vectors looks them up by index |
| 15:34 | arohner | so you could do (def user {:type "tester" … }) |
| 15:34 | arohner | and that would work, or with your current version, (get user 0) |
| 15:35 | arohner | nerooth: I'm sorry, I misread that |
| 15:35 | nerooth | Hm, but aren't k:v related? |
| 15:36 | zerokarmaleft | looks like a map to me, and it should return "tester" |
| 15:36 | arohner | nerooth: I misread the { as [ |
| 15:36 | opqdonut | ,(let [user {:type "tester", :name "hej", :_id "57c6d53e-daca-46b6-92ab-63c3b37de22e"}] (get user :type)) |
| 15:36 | clojurebot | "tester" |
| 15:36 | amalloy | nerooth: given that your user object is what you say it is, then your get statement will work. so, one of the two is not quite pasted accurately |
| 15:36 | opqdonut | you are mistaken |
| 15:36 | opqdonut | user is not a map like that :) |
| 15:38 | xian | raek: I'm back. The jar is not available on Jarvana :( I'm still not quite sure how to modify the CP for a leiningen project. Btw, the required jar is the tools.jar from the J2SE distribution. |
| 15:38 | nerooth | http://pastie.org/2559373 |
| 15:39 | nerooth | That's copy paste from code and my lein run window |
| 15:40 | xian | raek: I found this (http://binarysolo.posterous.com/using-roberthooke-to-alter-the-classpath-of-a) to modify leiningen's CP but accepting another dependency just for that seems a bit ugly. |
| 15:41 | nerooth | Am I blind or does opqdonut and my paste look the same? |
| 15:41 | ordnungswidrig | hi all, is there a guide for working with leiningen and multiple source directories? I typically have a main project and some libs which I work on at the same the. |
| 15:42 | opqdonut | nerooth: what's (.getClass user)? |
| 15:42 | opqdonut | it might be something weird |
| 15:42 | amalloy | nerooth: drop the println |
| 15:42 | amalloy | &(println {:x "test"}) |
| 15:42 | lazybot | ⇒ {:x test} nil |
| 15:43 | amalloy | &(println {:x "\"test\""}) |
| 15:43 | lazybot | ⇒ {:x "test"} nil |
| 15:43 | opqdonut | right |
| 15:43 | amalloy | println makes it so easy to lose type information |
| 15:43 | opqdonut | prn is better |
| 15:43 | amalloy | &(println {":x" "test"}) |
| 15:43 | lazybot | ⇒ {:x test} nil |
| 15:44 | amalloy | &(println {:x 'test}) |
| 15:44 | lazybot | ⇒ {:x test} nil |
| 15:44 | opqdonut | indeed |
| 15:44 | opqdonut | I'm thinking user might be a string |
| 15:44 | opqdonut | since you get those quotes |
| 15:44 | opqdonut | but _always_ use prn when debug-printing things :) |
| 15:45 | amalloy | opqdonut: worse, user is a string *with quotes in it* |
| 15:45 | nerooth | It is indeed a string |
| 15:46 | nerooth | what's the difference between prn and println information-wise? |
| 15:48 | amalloy | prn is designed to print data in such a way that, if you run the reader over the result of prn, you get back the same data |
| 15:48 | amalloy | println is designed to look reasonably nice when a human reads it |
| 15:48 | TimMc | prn is just pr + newline, yeah? |
| 15:49 | amalloy | yes |
| 15:49 | lazybot | ⇒ "([]); Writes a newline to the output stream that is the current value of *out*" |
| 15:49 | TimMc | weird |
| 15:50 | TimMc | Ok, so: ##(pr-str ['hello "hello" :hello]) |
| 15:50 | lazybot | ⇒ "[hello \"hello\" :hello]" |
| 15:50 | TimMc | &(read-string (pr-str ['hello "hello" :hello])) |
| 15:50 | lazybot | ⇒ [hello "hello" :hello] |
| 15:54 | nerooth | Thanks for the help :) |
| 15:57 | TimMc | nerooth: Tip on read-string -- check out the *read-eval* var |
| 15:58 | TimMc | Bind it to false if you are reading user-supplied forms. |
| 16:00 | srid | apparently setting an agent to a lazy-seq realizes it (thus hangs) :-( |
| 16:00 | srid | no. |
| 16:01 | amalloy | agents have no magic properties. they are just adjustable pointers to objects |
| 16:01 | arohner | technomancy: why does lein HEAD depend on contrib, when lein contains no contrib code? |
| 16:02 | arohner | I can't start 1.3 projects w/ swank because of it |
| 16:06 | nerooth | I will TimMic, thanks |
| 16:06 | nerooth | TimMc* |
| 16:06 | arohner | is anyone else in AOT hell because of clojure 1.3 + contrib 1.2? |
| 16:07 | srid | (send realize-lazy-seq lazyseq) returns immediatley; how do I know when/if it has realized or not? it could use counters, but that is ugly. |
| 16:09 | arohner | srid: you could use a promise |
| 16:09 | arohner | ,(doc promise) |
| 16:09 | clojurebot | "([]); Alpha - subject to change. Returns a promise object that can be read with deref/@, and set, once only, with deliver. Calls to deref/@ prior to delivery will block, unless the variant of deref with timeout is used. All subsequent derefs will return the same delivered value without blocking. See also - realized?." |
| 16:09 | arohner | &(doc promise) |
| 16:09 | lazybot | ⇒ "([]); Alpha - subject to change. Returns a promise object that can be read with deref/@, and set, once only, with deliver. Calls to deref/@ prior to delivery will block. All subsequent derefs will return the same delivered value without blocking." |
| 16:09 | arohner | sorry, lag |
| 16:10 | amalloy | i run my code by both bots anyway, just to be sure |
| 16:10 | srid | i don't know. value can be set only once? i intend to (first a-lazy-seq) multiple times and set the result on the agent. |
| 16:10 | arohner | amalloy: ha. I wasn |
| 16:11 | arohner | I wasn't sure whether the bot was working |
| 16:11 | srid | i suppose i should just use threads. |
| 16:11 | arohner | amalloy: from my perspective, I saw nothing for 5+ seconds, so I tried the other bot |
| 16:12 | srid | or I can call (send) recursively from f. |
| 16:13 | amalloy | arohner: i know, you explained it. but i can't be expected to miss an opportunity |
| 16:23 | TimMc | chouser: I suppose the REPL wouldn't barf on that equals-everything object if it reversed its own argument order. |
| 16:26 | srid | nice, just using agents I can accumulate logs from multiple source into a single clojure list. |
| 16:26 | srid | no threads needed, yet. |
| 16:29 | TimMc | I'm too lazy to implement .equals properly. I'll just use this: (equals [me them] (if (nil? them) false (.equals them me))) |
| 16:30 | TimMc | See, it even works within-type: ##(let [lazy-eq (reify Object (equals [me them] (if (nil? them) false (.equals them me))))] (= lazy-eq lazy-eq)) |
| 16:30 | lazybot | ⇒ true |
| 16:31 | amalloy | *blink* that seems like it shouldn't work. what's the trick? |
| 16:31 | amalloy | oh, = probably does a pointer-comparison before delegating to .equals? |
| 16:32 | TimMc | Seems so. |
| 16:33 | srid | ,(doc seque) |
| 16:33 | clojurebot | "([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer." |
| 16:33 | srid | this is probably what I needed before |
| 16:33 | srid | or not - "reading from a seque can block"? |
| 16:34 | TimMc | srid: As opposed to returning nil? |
| 16:34 | srid | yea |
| 16:34 | srid | i am currently using agents to process the lazy-seq |
| 16:35 | srid | i involved some substantial code though. |
| 16:41 | Nocab | cant recall who asked me |
| 16:42 | Nocab | but Ive been using clojure with eclipse for a while |
| 16:42 | Nocab | and now Im trying it out in emacs with swank/slime instead |
| 16:42 | Nocab | (and lein) |
| 16:42 | Nocab | so far the only thing I can say eclipse does better is the integration with the repl |
| 16:42 | Nocab | I cant for the life of me figure out how to send my code from the file to the repl... |
| 16:43 | Nocab | am I supposed to copy it manually? |
| 16:45 | TimMc | There's some command to send the current expression, and another for the whole buffer. (I think.) |
| 16:45 | Nocab | yeah that was sorta what I figured, just cant find it :P |
| 16:45 | brehaut | C-x C-e ? |
| 16:45 | Nocab | let me try |
| 16:45 | brehaut | Nocab: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs |
| 16:46 | raek | Nocab: C-c C-k |
| 16:46 | amalloy | (inc raek) |
| 16:46 | lazybot | ⟹ 10 |
| 16:47 | amalloy | C-x C-e and/or C-M-x to evaluate the current form (where they differ is their definition of "current form") |
| 16:47 | amalloy | and C-c C-k to eval the whole file |
| 16:48 | srid | is it possible to atomically pop a agent queue? my code is likely not atomic - https://gist.github.com/1227572 |
| 16:50 | amalloy | no. if you want to do something synchronous, don't use agents |
| 16:52 | raek | srid: you cannot do multiple reads from an agent atomically. |
| 16:52 | Nocab | amalloy: Im trying to use C-x C-e to evaluate the current form. and I do get a tiny line at the bottom with the result |
| 16:53 | amalloy | mission accomplished, that's what you're supposed to get |
| 16:53 | Nocab | amalloy: ie, (+ 1 2) yields a one-line "3" at the bottom. |
| 16:53 | Nocab | but it doesnt intergrate with the bigger slime console/panel |
| 16:53 | raek | srid: you could perhaps send it a "pop request" with a 'promise' and deref that promise |
| 16:53 | Nocab | like load my code in there, my functions, so I can fool around with them in the interactive console |
| 16:53 | Nocab | I could do that in eclipse |
| 16:53 | amalloy | Nocab: C-c C-k |
| 16:54 | amalloy | and if the code you had <C-x C-e>'d had been a defn, it would indeed have been available at the repl after that |
| 16:54 | raek | Nocab: yeah, you don't see the result in the repl |
| 16:54 | raek | Nocab: but you can do this: http://bc.tech.coop/blog/070424.html |
| 16:54 | Nocab | amalloy: aaah. my bad |
| 16:54 | Nocab | it did work, but the code and the REPL was operating in different namespaces |
| 16:54 | raek | ah |
| 16:55 | Nocab | I had to prefix my function namespaces and then it worked |
| 16:55 | Nocab | silly emacs |
| 16:55 | raek | C-c M-p |
| 16:55 | Nocab | eclipse didnt cause that to happen ;) |
| 16:55 | srid | raek: i'll try that in a moment. |
| 16:55 | raek | to change namespace of the repl |
| 16:55 | raek | srid: but maybe you should reconsider the concurrency primitive (atom/ref/agent) you are using |
| 16:55 | amalloy | eclipse probably just guessed what namespace to put you in at startup; if you'd started editing a different namespace i suspect you would have had similar problems |
| 16:55 | hugod | C-c C-c to compile the current top level form |
| 16:56 | raek | if you need to synchronize the state of the agent with your own thread, then agents are not ideal |
| 16:56 | zerokarmaleft | Nocab: just change slime's active namespace with in-ns |
| 16:56 | raek | since they are meant to be asynchronous |
| 16:57 | zerokarmaleft | oh, there's a keybinding for that, derp |
| 16:57 | amalloy | Nocab: since it was probably unclear; raek's C-c M-p was aimed at you |
| 16:57 | raek | C-c M-p <ret> in the source file buffer has the same effect as in-ns |
| 16:57 | zerokarmaleft | nice, storing that away |
| 16:57 | raek | Nocab: ^ |
| 16:57 | raek | ^^ |
| 17:04 | Nocab | cool thanks |
| 17:04 | Nocab | (view (function-plot pdf-normal -3 3)) ;woo |
| 17:06 | Nocab | man this channel is like #linux back in the 90s |
| 17:06 | Nocab | useful |
| 17:06 | Nocab | and alive too ;) |
| 17:41 | srid | raek: hmm, not sure how I can bake (promise) in https://gist.github.com/1227572 .. where exactly would you call deliver? |
| 17:42 | srid | calling deliver from send's function still doesn't guarantee atomicity |
| 17:42 | srid | ctx - the agent primitive was suggested to me as a quick hack before going on learning the clojure concurrency primitives |
| 17:58 | Cozey | Hi. I'm using swank.cdt - i can break on a function, but can i insert a "debug repl" call compatible with swank.cdt somewhere in the code? |
| 18:03 | srid | raek: I fixed the pop issue by using *ref* to store the last popped item, and sleep till it no longer refers to (peek). but it terribly slowed down the log processing. i.e., (pop-log) is now taking much time to run (presumably spending time on Thread/sleep) https://gist.github.com/1227750 |
| 18:08 | Netpilgrim | What would be the #(…) equivalent of (map (fn [x] [0 x]) [1 2 3])? With both #([0 %]) and #('[0 %]) the vector is called as a function. |
| 18:08 | amalloy | (juxt (constantly 0) identity) ;; lol? |
| 18:09 | amalloy | #(vector 0 %) |
| 18:09 | brehaut | Netpilgrim: ##(read-string "#([0 %])") |
| 18:09 | lazybot | ⇒ (fn* [p1__8482#] ([0 p1__8482#])) |
| 18:10 | Netpilgrim | amalloy: vector works. I'm mostly curious why the quoting doesn't have any effect. |
| 18:11 | amalloy | Netpilgrim: brehaut's answer to that is pretty definitive |
| 18:11 | amalloy | &'#([0 %]) ;; a shorter way to write it |
| 18:11 | lazybot | ⇒ (fn* [p1__8483#] ([0 p1__8483#])) |
| 18:11 | Netpilgrim | amalloy: Neither of you quoted the vector. |
| 18:12 | amalloy | but ##'#('[0 %]) won't work any better |
| 18:12 | lazybot | ⇒ (fn* [p1__8491#] ((quote [0 p1__8491#]))) |
| 18:12 | amalloy | (all those hashes and quotes look funny) |
| 18:13 | amalloy | the point is that in a #(foo) form, foo is *always* called as a function, because it is *always* wrapped with parens |
| 18:13 | amalloy | you can quote it; fine. then the quoted vector is called as a function |
| 18:13 | Netpilgrim | amalloy: But in the latter case it's the quote that's called as a function, isn't it? |
| 18:14 | Netpilgrim | amalloy: Hm, okay more parens than I thought. :) |
| 18:14 | brehaut | pedantry: i dont think quote is a function |
| 18:16 | Netpilgrim | Well, I'll just remember that #(…) can only call a function while (fn …) can return a value. |
| 18:16 | amalloy | i wonder if "pedantry" is a registered nick |
| 18:16 | brehaut | hah |
| 18:40 | arohner | has anyone built a contrib-1.2 that works with clojure 1.3? |
| 18:46 | amalloy | that seems unlikely to happen |
| 18:51 | arohner | amalloy: I'm in the middle of doing it myself |
| 18:52 | arohner | too many of my current deps don't work w/ 1.3, because they depend on contrib 1.2 |
| 19:37 | ibdknox | it appears clojurescript is about 3-4 orders of magnitude slower than native JS :( |
| 19:38 | amalloy | ibdknox: 3-4 orders of magnitude, or just 3-4 times? i'd be surprised if it were ten thousand times slower |
| 19:38 | ibdknox | orders of magnitude |
| 19:38 | ibdknox | amalloy: loop over 1 million items |
| 19:38 | ibdknox | js: 1-4ms |
| 19:39 | ibdknox | cljs: 3-4 seconds |
| 19:39 | ibdknox | simply iterating, not doing anything in the body of the loop |
| 19:40 | ibdknox | though to foil any special optimizations in the JS, I made it set a var to a value |
| 19:40 | ibdknox | only for the native JS code though |
| 19:41 | ibdknox | this came up while I was trying to implement the drawing of tiles for a canvas-based game |
| 19:41 | ibdknox | iterating over 144 integers is very nearly too slow for the render loop |
| 19:41 | amalloy | there still could easily be special optimizations. try adding up the numbers from one to a million |
| 19:42 | ibdknox | with the addition it goes up to about 15ms |
| 19:43 | ibdknox | looping over 144 items shouldn't take 5-10ms |
| 19:43 | ibdknox | lol |
| 20:47 | Cozey | ##handler-case |
| 20:47 | Cozey | &'handler-case |
| 20:47 | lazybot | ⇒ handler-case |
| 20:47 | Cozey | &'(handler-case :type (raise :type :foo :value 123) (handle :foo (println "error " (:value *condition*)))) |
| 20:47 | lazybot | ⇒ (handler-case :type (raise :type :foo :value 123) (handle :foo (println "error " (:value *condition*)))) |
| 20:48 | Cozey | i'm doing something wrong here :P |
| 20:48 | Cozey | &(handler-case :type (raise :type :foo :value 123) (handle :foo (println "error " (:value *condition*)))) |
| 20:48 | lazybot | java.lang.Exception: Unable to resolve symbol: handler-case in this context |
| 20:49 | Cozey | uh oh. I'm using condition-1.3.0-alpha4 and I get 'cannot bind non-dynamic var: *condition*. *condition* is defined with defvar.. i'm not sure why i get this error. |
| 20:53 | technomancy | Cozey: try slingshot instead: http://github.com/scgilardi/slingshot |
| 20:54 | Cozey | technomancy: but it's stencil package which is using condition - i just want to handle id properly |
| 20:54 | Cozey | so i can't decide what to use :/ |
| 20:55 | technomancy | hm; you'll need to file a bug with stencil then |
| 20:59 | Cozey | yep i guess. i'll check if nothing pulled contrib 1.2.. |
| 20:59 | Cozey | where is a website when i can track what revision should i put in my project.clj to be up to date with clojure 1.3? |
| 20:59 | Cozey | i use -alpha4 - perhaps it's old already? |
| 21:01 | amalloy | Cozey: -RC0 |
| 21:01 | amalloy | or do you mean what version of stencil? i guess i should wait until i understand the question, before answering |
| 21:01 | Cozey | amalloy: no.no - what version of clojure |
| 21:02 | tomoj | where's RC0? |
| 21:02 | Cozey | amalloy: hmm. perhaps i should follow github |
| 21:03 | amalloy | tomoj: in clojure's repo, whever that is |
| 21:03 | arohner | sounds like I have another user for my contrib-1.3-compat |
| 21:03 | tomoj | maybe http://build.clojure.org/releases is the old one? |
| 21:03 | tomoj | newest 1.3.0 there is alpha4 |
| 21:04 | tomoj | but isn't that where leiningen looks? |
| 21:04 | arohner | Cozey: following github is probably your best bet |
| 21:04 | tomoj | oh, no |
| 21:05 | Cozey | how about contrib? |
| 21:05 | amalloy | http://build.clojure.org/job/clojure/lastStableBuild/ |
| 21:05 | Cozey | the clojure.contrib is nwo split to differnt packages. i can't really get my head around it - where's contrib.trace? |
| 21:05 | Cozey | tools.trace? |
| 21:05 | clojurebot | eg, https://github.com/clojure/tools.logging is the new version of clojure.contrib.logging |
| 21:05 | Cozey | but this is empty: https://github.com/clojure/tools.trace |
| 21:05 | tomoj | strange, I don't see that in lein's source |
| 21:06 | tomoj | ah http://repo1.maven.org/maven2/org/clojure/clojure/ |
| 21:07 | technomancy | clojurebot: where did contrib go? |
| 21:07 | clojurebot | well... it's a long story: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go |
| 21:11 | devn | heh |
| 21:14 | Cozey | and the versions for those new contrib project are not in sync with clojure versions. ie [org.clojure/data.zip "0.1.0"] ? |
| 21:15 | amalloy | no, having them be in sync with clojure versions would be madness |
| 21:16 | amalloy | then you couldn't update either without updating the other - huge headache |
| 21:17 | Cozey | right, ok! |
| 21:18 | andar_ | When I'm using swank-clojure in emacs, and update my dependencies in lein, is there a way to update the classpath in swank/slime without needing to restart emacs? |
| 21:20 | carkh | hello |
| 21:20 | carkh | anybody having trouble withg lein 1.6.1 and windows ? |
| 21:21 | carkh | this kind of problem : Exception in thread "main" java.lang.NoClassDefFoundError: Files |
| 21:21 | carkh | on a simple : lein version |
| 21:22 | carkh | isn't the Files class a java 1.7 thing ? |
| 21:25 | tomoj | maybe it's in a plugin? |
| 21:25 | Cozey | what about clojure.contrib.prxml? it's not mentioned on the web site? |
| 21:26 | Cozey | or repl-utils ? |
| 21:27 | carkh | tomoj: hum actually my poor google skills only kicked in now, the solution to my problem is downloading the master version of the bat file and replacing the version number |
| 21:27 | amalloy | Cozey: data.xml |
| 21:27 | amalloy | but that still isn't released (chouser? looks like some kind of build failure, but i don't konw my way around hudson) |
| 21:28 | Cozey | yep, data.xml is missing from maven repo |
| 21:29 | amalloy | http://build.clojure.org/job/data.xml/ |
| 21:30 | amalloy | looks like indentation-settings test failed |
| 21:42 | amalloy | interesting. tests pass for me |
| 23:21 | icefox | When cljsc has a compiler error it spits out a java backtrace. Any way to turn that into something useful? |
| 23:22 | amalloy | look at it with your eyes? :P |
| 23:23 | icefox | Exception in thread "main" java.lang.RuntimeException: java.lang.AssertionError: Assert failed: Can't recur here |
| 23:23 | icefox | frame |
| 23:23 | icefox | at clojure.lang.Util.runtimeException(Util.java:153) |
| 23:23 | amalloy | it's the same message you get for compiler errors in clojure proper |
| 23:23 | technomancy | amalloy: I always look at stack traces with my heart. |
| 23:23 | icefox | Not sure how that applies to my code |
| 23:23 | mindbender1 | please how do I switch to swank buffer in emacs |
| 23:24 | technomancy | C-c C-z |
| 23:24 | amalloy | icefox: is that the only line in the entire stacktrace? if so, i agree that's pretty useless |
| 23:24 | icefox | amalloy: no there are a few hundred |
| 23:24 | amalloy | well then |
| 23:25 | icefox | It looks like an internal bug in the compiler? |
| 23:25 | mindbender1 | technomancy: it says undefined |
| 23:26 | amalloy | no. it looks like you doing (loop [x 1] (inc (recur x))) |
| 23:27 | icefox | yah I did add a loop, hmm guess this is one of those things to learn clojure you have to learn what errors happen to actually mean in your code |
| 23:27 | icefox | like g++ templates or whatnot :) |
| 23:29 | amalloy | icefox: just look through the the stacktrace for *.cljs files - i bet one of them is yours |
| 23:30 | st3fan | hmm question about sql/with-query-results .. how do i simply get a non lazy list of results back? |
| 23:30 | amalloy | &(doc doall)? |
| 23:30 | lazybot | ⇒ "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the ... https://gist.github.com/1228253 |
| 23:31 | st3fan | ah i was looking at doseq |
| 23:31 | st3fan | let me try |
| 23:31 | st3fan | yes awesome |
| 23:31 | icefox | amalloy: nope my test.cljs file is not mentioned in the backtrace, it is inside clojure.lang.Compiler.eval |
| 23:34 | mindbender1 | please how do I switch to swank buffer in emacs |
| 23:34 | mindbender1 | my swank server is freezing on clojure-jack-in |
| 23:35 | jao | mindbender1, C-x b *swank* |
| 23:36 | mindbender1 | It says "Couldn't find project.clj, which is needed for jack-in" how do I resolve this |
| 23:37 | technomancy | mindbender1: M-x clojure-jack-in must be run from somewhere inside a project directory |
| 23:37 | technomancy | if you want a standalone swank server you can do ~/.lein/bin/swank-clojure in the shell and do M-x slime-connect |
| 23:38 | mindbender1 | I did but deep inside a the project directory I believe it should still be able to run |
| 23:39 | technomancy | yeah, that should be fine. can you run "lein swank" from the shell deep inside the project? |
| 23:40 | mindbender1 | ok, errors exist |
| 23:40 | mindbender1 | WARNING: spit already refers to: #'clojure.core/spit in namespace: examples.utils, being replaced by: #'clojure.contrib.duck-streams/spit |
| 23:41 | mindbender1 | Exception in thread "main" java.lang.ExceptionInInitializerError |
| 23:41 | mindbender1 | at clojure.main.<clinit>(main.java:20) |
| 23:41 | mindbender1 | any idea what to do? |
| 23:41 | technomancy | you're getting that from swank? |
| 23:42 | technomancy | maybe gist project.clj? |
| 23:42 | mindbender1 | yes and I also tried from root of project it gives similar errors |
| 23:42 | choffstein | Hey all. Question: is there a way to eval something in a temporary namespace so that any requires or uses don't propogate and pollute the current namespace? e.g. can I do (eval `(use 'clojure.contrib.duck-streams)) and basically not have it pollute the namespace with the symbols from duck-streams? |
| 23:43 | mindbender1 | technomancy: gist project.clj? |
| 23:43 | technomancy | choffstein: slamhound does that |
| 23:43 | amalloy | technomancy: really? |
| 23:43 | amalloy | that seems outside the scope of what slamhound was for last time i looked (which was ages ago) |
| 23:43 | technomancy | choffstein: essentially: (binding [*ns* (create-ns `sand.box)] (eval [...])) |
| 23:44 | choffstein | technomancy: Alright. I'll just go digging through your code :) |
| 23:44 | technomancy | amalloy: no, it's absolutely central that it's able to attempt compilation inside a throwaway ns |
| 23:44 | technomancy | mindbender1: http://gisthub.com |
| 23:45 | amalloy | oh, i thought you meant he could use slamhound as a library to do this in his own code |
| 23:45 | mindbender1 | technomancy I see another line that says "Could not find the main class: clojure.main. Program will exit." |
| 23:45 | mindbender1 | Is there a way to check for conflicts |
| 23:45 | technomancy | choffstein: of course if all you're trying to do is load the code without bringing in all the vars of the namespace, you should just require instead of use |
| 23:45 | choffstein | technomancy: https://github.com/newfoundresearch/clj-doc-test/blob/master/src/clj_doc_test/core.clj |
| 23:46 | choffstein | Trying to replace the (use '[~name-space]) with something that won't pollute. I found clj-sandbox as an option, but was hoping there was something else |
| 23:46 | technomancy | this is only good if you need to run code that depends on the vars refered by use |
| 23:46 | technomancy | sounds like that would probably be the case hree |
| 23:46 | technomancy | here |
| 23:47 | technomancy | so... who wants to tie in http://travis-ci.org/ results into clojars? |
| 23:47 | clojurebot | contributing to clojars is a great idea! see http://groups.google.com/group/clojars-maintainers/browse_thread/thread/d4149ec96316d5b1 |
| 23:47 | technomancy | clojurebot: thanks for volunteering! |
| 23:47 | clojurebot | thanks for your suggestion, but as usual it is irrelevant |
| 23:48 | technomancy | dammit |
| 23:48 | choffstein | technomancy: can I reuse the same sandbox ns name? |
| 23:48 | mindbender1 | technomancy: here git://gist.github.com/1228282.git |
| 23:48 | technomancy | choffstein: I recommend calling remove-ns in a finally, in which case it would be fine |
| 23:48 | choffstein | ah, I like that. |
| 23:49 | technomancy | it's line 33 of slam/hound/regrow.clj if you want to look at my approach |
| 23:49 | technomancy | mindbender1: looks like a really old version of clojure-contrib is on the classpath |
| 23:49 | technomancy | can you also include project.clj |
| 23:49 | technomancy | ? |
| 23:49 | mindbender1 | ok |
| 23:50 | choffstein | technomancy: very cool. I hope you don't mind if I steal it :) |
| 23:51 | mindbender1 | technomancy: https://gist.github.com/1228282 |
| 23:52 | technomancy | mindbender1: that's not right |
| 23:52 | technomancy | the stack trace includes code from contrib |
| 23:52 | mindbender1 | you mean? |
| 23:53 | mindbender1 | I should include clojure-contrib in dep |
| 23:53 | technomancy | mindbender1: that stack trace should only be possible if clojure-contrib is in your dependencies in project.clj |
| 23:54 | technomancy | I guess it's technically possible there's an offender in ~/.lein/plugins; what's in that directory? |
| 23:54 | mindbender1 | I ran lein swank from the dir where project.clj is |
| 23:54 | mindbender1 | a min |
| 23:55 | mindbender1 | only swank-clojure-1.3.2.jar |
| 23:55 | technomancy | there must be something more going on here |
| 23:55 | mindbender1 | ok maybe it's version problem |
| 23:55 | technomancy | what you're describing is not possible |
| 23:56 | mindbender1 | seriuosly that's what I| did |