#clojure logs

2010-03-21

00:19DTrejodoes anyone use a combination of leiningen and counterclockwise?
00:19DTrejoI suppose it's not much of a combination since it's not really one or the other.. nvm
02:20JonSmithif anyone is awake, what do people use for video games in clojure (i'm not looking to make video games per-say, merely applications more interactive than swing or awt can do...)
02:23rfgJonSmith: I am using LWJGL for one project (a game) and JOGL for some scientific rendering in another project.
02:24rfgIf you want to use LWJGL, you should probably check out penumbra.
02:25JonSmithyeah i've played with penumbra it is pretty neat
02:25JonSmithi downloaded clj-processing and thatis cool too
02:25JonSmithkind of doing a survey to figure out what i want i guess
02:26JonSmithi want to do a GUI client type thing, but I want it to be more than just a plain old buttons and drop-downs GUI
02:27JonSmithi should take a second look at penumbra though as it has been a while since i used it
03:46psykoticcurrently there doesn't seem to be a way to merge futures
03:48psykoticfor example, if you have a list of futures and want to process them in 'finishing order'.
03:48hiredmanyou need a futureM
03:48psykotichm?
03:49psykotici noticed that you could use promises, since they allow you to check whether they have been delivered yet or not. but even then, i don't see how to write an _efficient_ merge.
03:49psykotici don't want to have a thread that spins until one of the promises is delivered.
03:50hiredmanyou can build a blockingqueue on promises, or just use from j.u.concurrent
03:50psykoticright, i've done this kind of thing with normal parallel primitives before. i was just checking whether this (bog standard) problem had a solution in core i overlooked.
03:51hiredmanI tend to use lbq a lot
03:52psykoticwith that, you can easily build a loop that processes the futures in completion order.
03:52psykoticwait for the next future to finish; remove it from the outstanding list, deref it, rinse and repeat, until no futures left.
03:53hiredmanno, best would be writing your own future macro that would stick the result into a queue when it's done
03:54psykoticblockingqueue looks nice
03:54LauJensenMorning crew
03:54hiredmanhello
03:57rfgHello
04:01LauJensenI'm suffering from these completely silent failures in futures, is there any way to fix that except running the code in the main thread?
04:03hiredman(future (try … (catch Exception e (-> e .getMessage println))))
04:04LauJensenlemme try
04:05hiredmanyou can also create a logging function or macro or use the logging stuff from contrib
04:06LauJensenYea, that would be last resort, but your example above works perfectly, thanks
04:06hiredman:(
04:06hiredmanpeople are watching lein-gae, I should delete it
04:07LauJensenI made an empty repo called Clabango - Had quite a few watchers as well :)
04:26LauJensenI know I'm stretching my luck here, but is there a javalib for capturing a graphics object and storing it as a frame in an animated gif ?
04:27LauJensen(if so, please send it to me with a lein-string attached)
04:36vyLauJensen: You'd have more luck in ##java
04:42LauJensenOr perhaps ##google
04:42LauJensenAnyway, doesnt hurt to ask
04:50LauJensenRecently I've been seeing this a lot when doing slime-load-file
04:50LauJensenswank.util.io.proxy$java.io.StringWriter$0 cannot be cast to java.io.PrintWriter
04:50LauJensenAnybody know what thats about?
04:58hiredmansome library somewhere expects *err* to be a PrintWriter
04:58hiredmanI forget the details
05:01LauJensenSo its a matter of waiting for an update for swank-clojure ?
05:02hiredmanhttp://groups.google.com/group/swank-clojure/browse_frm/thread/36cc0c9d325a9c76/e7602744e126102b?tvc=1#e7602744e126102b
05:03hiredman*shrug*
05:03LauJensengreat, theres already a patch and its only a problem when tracking reflections
05:52zabHi all. Just writing something that takes a Java InputStream and copies it to an OutputStream. Is this the idiomatic way of doing it in Clojure? http://paste.lisp.org/display/96708
05:53zab(I am unsure of using `def` to represent the Java object that will be returned.)
05:55rfgWhy not: http://paste.lisp.org/display/96708#1
05:55rfg?
05:55Chousukethat doesn't work
05:55rfgOh sorry
05:55rfgWait
05:55Chousukeyou need to use let
05:56LauJensenzab: As far as human possible, avoid modifying anything outside your functions body
05:56LauJensen+ly
05:57Chousukeso you should just do (let [os (ByteArrayOutputStream.)] (Streams/copy ...) os)
05:58zabThe return value of Streams/copy is not what I want returned from the function. I want the 2nd argument returned. The new ByteArrayOutputStream will be populated with the input stream.
05:59zabSo in Java, you would declare the OutputStream first, and then mutate it within the function call, and then return it. But in Clojure I do not know how to do the equivalent.
06:00zabLauJensen: Yeah I thought so. Hence my hesitation with the `def`. :( There has to be a better way?
06:00Chousukeuse let within the function
06:00Chousukeie. make the outputstream in the function and just return it
06:00LauJensenzab: What Chousuke said. If you define something within a function and mutate it there, its still considered a pure function in regards to the rest of your program
06:01Chousukethough that's not a pure function even if you did that
06:01zabChousuke, LauJensen: Ahh okay. I was unsure if that would work because I know you cannot rebind using let. But that wouldn't be rebinding anyway.
06:01Chousukebecause it presumably affects the inputstream
06:02zabChousuke: Would there be any way to achieve a pure function with my problem? Or is this something that I have to live with seeing as I am playing in Java land?
06:02ChousukeI don't think so.
06:02Chousukeit's pretty difficult to clone an inputstream :/
06:03ChousukeI mean, you can do it, but it will still have side-effects
06:04zabChousuke: Okay cool. I'll stick with this approach then. :)
06:04zabHow about function naming conventions. Is this function named right? `new-output-stream`
06:05Chousukebut not all of your functions need to be pure. if most of them are, you're doing good.
06:05rfg"What's in a name?"
06:05Chousukezab: what's the function for, exactly
06:06zabtakes an InputStream and creates a new OutputStream object for it
06:07Chousukeso it's like a unix pipe? I'm not sure if I understand the semantics of the copy operation right :/
06:07Chousukeit's not just creating a new output stream, it's copying stuff
06:07Chousukeand I think that should be apparent in the name
06:08zabyeah it's copying the InputStream to the OutputStream and returning that.
06:08zabjust a hoop I have to jump through to get it to play nice with app engine
06:09Chousukemaybe name the function according to what the outputstream represents instead
06:09ChousukeI think as it is, it may be a bit too generic.
06:10zabhmm okay. I see your point.
06:10Chousukeor you could name it make-output-from
06:10Chousukewhich would read pretty nicely
06:11zabNice. Sort of like how Objective-C methods are named, read like a sentence. make-output-from [input-stream]
06:12zabthanks for the help Chousuke, LauJensen, rfg :)
06:13rfgMy help was substandard, but thank you :)
06:13zabrfg: heh you gave it a shot
06:44patrkriswhat is the nicest way of checking a series of let-bindings that are serially dependent, i.e in (let [a expr1, b expr1] ...) b is dependent on a not being nil? I want sort of the behavior of if-let, i.e. the body is not evaluated unless both a and b are non-nil/non-false. Hopefully it makes sense.
06:45noidithe maybe monad does exactly that
06:45noidiafaik
06:45patrkrisnoidi: cool, will check it out
06:45patrkrisnoidi: in contrib?
06:45noidihttp://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure-programmers-part-1/
06:46patrkristhanks
06:46noidiso you want b to be evaluated only if a is non-nil, and the body evaluated only if b is non-nil?
06:47patrkrisnoidi: exactly
06:47noidi"Anyway, the idea is that whenever a computational step yields nil, the final result of the computation is nil, and the remaining steps are never executed."
06:47noidifrom the tutorial
06:47noidiso maybe monad should do the trick
06:49patrkrissounds like it!
06:49patrkrisi would have thought that this is such a common scenario that it would be in core
07:43ttmrichterI saw an interesting question on StackOverflow that I'm curious about the answer to myself: http://stackoverflow.com/questions/2486752/in-clojure-how-to-define-a-variable-named-by-a-string
07:44ttmrichterIs there a way to assign values to symbols generated from strings?
07:51psykoticyou can do it if the (parts of the) string are known at compile time
07:52psykoticand there is always eval when that isn't the case
07:52psykoticthough that's good to avoid :)
07:52Chousukethis time, it's restartable.
07:54Chousuke(def cont (second (read-one (seq "\"foo")))) -> (second (cont (seq "bar\""))) -> "foobar"
08:00ChousukeI'll need to find some way of managing the "continuations" if I want to make this feasible :/ right now I have a vector parser and a string parser and they both have a cond checking whether they need to "save" their state or not.
08:08ttmrichterWhoever sepp2k is on StackOverflow, thanks for the succinct and helpful answer. I completely forgot about the ~ construct.
08:08psykoticcan anyone recommend a good on the standard java API (io, net, collections, etc) that isn't just a reference but also a "best practices", tricks and pitfalls, etc, kind of thing?
08:08psykotica good book even
09:46ivanis there any sane way to write clojure while using variable width fonts in (any) editor?
09:47LauJensenivan: The font you use shouldn't affect your ability to write clojure-code :)
09:47Fossiwhy would one do that? :D
09:47Fossiwell, it helps the indention if it's mono
09:47ivanwell, variable width makes it impossible to align code in a dumb editor, yeah
09:48ivanand I think they're nearly all dumb
09:59ivanmaybe elastic tabstops, heh
10:00psykoticivan: i don't like proportional fonts, but as long as the "alignment" consists entirely of spaces, it works fine
10:00psykoticthe problem is when you have a mix of spaces and non-spaces
10:00Raynesivan: Emacs think's you're dumb. :|
10:01esjRaynes: emacs keeps proving that I'm dumb ;)
10:01ivanpsykotic: well, if I align things for my variable width font, it's be misaligned for most people
10:01ivans/it's/it'll/
10:01Raynesclj-sandbox keeps proving that I'm dumb.
10:04RaynesWaiting for an email is the most agonizing thing in the world to do when have absolutely nothing to do but sit.
10:04RaynesI wish everybody I knew lived in the same timezone as me. It would make this stuff so much easier.
10:05esjbut you live in your own timezone, waking up at 5pm :)
10:05Raynesesj: Yeah, and that's usually convenient because everybody else I know is waking up when everybody in my timezone is going to sleep. :|
10:07RaynesI swear, this timeout stuff will be the death of me.
10:36bobo_could someone take a peek at http://github.com/bobo/Retwis-clj/blob/master/src/retwis/view/view.clj and give me some tips on what to learn/do to improve the quality of the code?
10:48The-Kennybobo_: First of all: *Never* put the closing-parens in an empty line. That looks so awful
10:48RaynesThat's a Cism that doesn't work out in Lisp.
10:54Fossihmm. i try to compile a gen-class with lein, but it only says "All :namespaces already compiled"
11:01Licenser_greetings
11:04Licenser_,(loop [] (recur))
11:04clojurebotExecution Timed Out
11:05RaynesLicenser: Hai!
11:06RaynesLicenser: You should probably look at thunk-timeout in clojurebot's sandbox.
11:06RaynesI tried to fix it myself, but I faileded. :p
11:06Licenser_hrm hmr
11:06Licenser_ah you're the Raynes :) greetings
11:06RaynesGreetings, sir, and thank for you clj-sandbox. :>
11:06Licenser_yes I figured the problem, was trying out if clojure bot has the same problem, fortunately not
11:07Licenser_the s-seq function is the evil doer
11:07Licenser_and you're welcome :)
11:08RaynesLicenser: Once we get this fixed, I'll finish up what I'm doing and issue a pull request detailing what I've done. I think you'll like the modifications I've made. :>
11:09Raynescreate-sandbox and create-sandbox-compiler were just screaming for optional keyword arguments.
11:09Licenser_Yes you are totally right
11:09Licenser_I git attacked by the evil 'own purpose blindness' :P
11:09RaynesI:p
11:09Raynes:p*
11:11RaynesJust got your email.
11:11Licenser_*nods*
11:12RaynesLicenser_: Alright. I'll be watching for the push. Once that's out, I should be able to toss a pull request your way sometime tomorrow.
11:12Licenser_:) great!
11:17RaynesLicenser_: I'll also point out that most of the problems with the doc-strings were merely typos and not actual the result of your English.
11:18RaynesAnd the other ones really just needed to be reworded a bit.
11:18Licenser_Raynes: ^^ Thanks
11:19Licenser_lets see if this fixes the issue
11:20RaynesI thought about going ahead and dropping the class-tester function in there and adding some java.lang classes to the whitelist, but we might have different definitions of what is 'secure', so I figured I'd let you handle that.
11:20Licenser_My definition of secure is mostly 'what comes to mind'
11:21RaynesMost of what I added to my own whitelist are just java.lang.String and other similar classes.
11:24Fossilein is driving me nuts. should have a verbose option :(
11:33Licenser_Raynes: fixed :)
11:33RaynesAwesome!
11:33Raynes:D
11:34RaynesIn that case, I might be finished enough to send you a pull request tonight even.
11:34Licenser_I'll add another comment and then push
11:35Raynes:D
11:39Licenser_Raynes: pushed
11:39Licenser_I love the partial commit thing from git
11:39Licenser_that is so great
11:39Licenser_I really could make 3 atomic commits out of the changes I made to the file, much cleaner
11:39RaynesNeat.
11:41Licenser_now I'll take a shower, eat a burger and see if I add the class stuff next
11:56Licenser_,(loop [_ (def x 1)] )
11:56clojurebotDENIED
11:56Licenser_nice :)
12:25Licenser_hmm I really would need a second livetime :(
12:36RaynesLicenser: It still doesn't seem to be working right.
12:36RaynesWhen I tried (loop [] (recur)), it gave me a NullPointerException, and (range 1 100000000) just kept on going until the heap ran out of space.
12:38programblehello
12:38programbleis there a clojure equivalent to java's import java.io.* ?
12:39Licenser_Raynes: I tried the loop recure ad it worked, very odd
12:40RaynesLicenser: What about (range 1 1000000000)?
12:40Licenser_can you give me the exact code you ran (with creating the sandbox and all.
12:40RaynesYeah, one moment.
12:40RaynesLicenser_: http://gist.github.com/339388 This code is mostly from my bot.
12:40Licenser_thanks :)
12:41arohnerprogramble: there's no equivalent
12:41programble:(
12:42Raynesprogramble: (:import (java.package Class1 Class2 Class3)) is close enough.
12:45RaynesHuh. And now it seems to be throwing a security exception for every piece of code.
12:45RaynesThis is confusing.
12:46Licenser_Wow
12:46Licenser_Raynes: I'd love to fix this, but I need some kind of test case to work against :(
12:47RaynesLicenser_: http://gist.github.com/339394
12:47Licenser_ah sorry
12:47Licenser_I id miss that
12:47RaynesThat is with a clean pull from your repo.
12:47Licenser_meh
12:49RaynesLicenser_: Having all sorts of trouble today. :p
12:49Licenser_Raynes: that is good, allows me to improve the library!
12:49Licenser_do you have a .java.policy file?
12:49RaynesYeah.
12:50Licenser_okay
12:50Licenser_so that is not the problem
12:51RaynesLicenser_: You can't reproduce the example I pasted above? :o
12:51Licenser_Raynes: No, I had to make a .policy file myself :P
12:53Licenser_actually no I can't reproduce it o.O
12:53RaynesOh joy.
12:54Licenser_http://grab.by/3cLO
12:54Rayneshttp://gist.github.com/339397
12:55RaynesThe exact code I'm using and the exact error I'm getting.
12:56Licenser_Raynes: I don't know what is wrong with your copy
12:56RaynesNor do I.
12:56Licenser_http://grab.by/3cLR
12:57RaynesLicenser_: A hah!
12:57RaynesIt's working now.
12:57Licenser_aha?
12:57clojurebotPaul Graham is the creator of the other new lisp
12:57Licenser_what did you do?
12:57RaynesSomething must have happened to my clone.
12:57RaynesI just re-cloned the repo.
12:57LauJensenC evaluates math exprs left to right, right?
12:57Licenser_pew okay that makes me happy :)
12:57RaynesNow let's see if the loop example works now.
12:58Licenser_:D
12:58RaynesAlright (loop [] (recur)) times out correctly, but (range 1 1000000) does not.
12:58RaynesSo, everything is working except that.
12:59hiredmanwhat about (iterate inc 0)
12:59Licenser_Raynes: okay I'll work on the range
13:00Rayneshiredman: Same thing.
13:00Licenser_aha I think I know the problem!
13:00Licenser_:d
13:00Raynes:>
13:03Licenser_Raynes: actually for me it runs through :P
13:03Licenser_999999
13:03Licenser_no error at all
13:03RaynesI probably have a smaller heap.
13:04RaynesTest with (iterate inc 0).
13:04Licenser_*nods*
13:04RaynesSame thing.
13:04Licenser_not exactly
13:04Licenser_a Heap exception is expected if you eat too much heap
13:04Licenser_it seems to be 'fast enough' not to trigger a timeout
13:04hiredmanI imagine the lazy seq is being realized outisde of the sandbox
13:05Rayneshiredman: Bingo.
13:05Licenser_hiredman: yap it is, just fixed that :)
13:06Raynes:)
13:06Licenser_Raynes: I write a few tests and push a fix
13:07RaynesAlright.
13:07RaynesLicenser_: I'm going to have to redo the changes I made, but I wont be able to do that until later. However, expect a pull request later tonight.
13:08Licenser_Raynes: cool thanks!
13:24RaynesLicenser_: If you get a chance, ping me when you get that pushed.
13:24Licenser_Raynes: of cause i'll give you a qry OK?
13:25RaynesKay.
13:25Raynes<3
13:25RaynesThanks.
13:28Licenser_I'm found a box in the create sandbox code I'd want to fix before pushing
13:50programblehm...
13:50programbleoh nvm
13:55Licenser_Raynes: you'll like how I implemented the class stuff :)
14:58LauJensenIs there a nice little util where I can inject a (debug-here) to get a repl once that code is eval0red ?
15:23TobiasRhey :)
15:23TobiasRim kinda new to clojure and got some trouble with compojure anyone able/willing to help me out for a couple minutes?
15:25dnolenTobiasR: ask way
15:25RaynesLicenser_: Doing (loop [] (recur)) does timeout correctly, but it doesn't stop. I don't think the thread is actually being stopped.
15:26TobiasRi built clojure/clojure-contrib and compojure from source and put all jars into a lib folder (subfolder of my project folder)
15:26RaynesLicenser_: Do (loop [] (recur)) and then watch your cpu.
15:26dnolenTobiasR: any reason you are not just using lein?
15:27TobiasRi think i got confused by it somehow but no, no real reason
15:28LauJensen~google reddit clone in 91 lines of clojure
15:28clojurebotFirst, out of 64 results is:
15:28clojurebotReddit Clone in 10 minutes and 91 lines of Clojure | BEST IN CLASS
15:28dnolenTobiasR: if you decide to do things from scratch you'll learn a lot but it will definitely be more confusing than just using lein.
15:28clojurebothttp://www.bestinclass.dk/index.php/2010/02/reddit-clone-in-10-minutes-and-91-lines-of-clojure/
15:28LauJensenTobiasR: Go check that out :)
15:28TobiasRokay tyvm ill do that
15:38RaynesLicenser_: I'm going to toss you an email, just in case you don't get this.
15:48notallamai just put my monad library on git, because the contrib one isn't magical enough. http://github.com/hclarke/clojure_combinators
15:48notallamabasically, i hacked a bit of type inference on. examples and more combinators will come later, probably.
15:54jwr7So I've been trying to dig into enlive, but just doing (html-resource "home.html") gives me a NullPointerException (enlive_html.clj line 38). Hmm.
15:55dnolenjwr7: enlive looks up resources on the classpath
15:55jwr7incidentally, I also get a NullPointerException when doing a C-c C-c in SLIME. C-x C-e works just fine, though.
15:56dnolenjwr7: I usually make a directory called resources under src. I use lein to manage the classpath. if you're using netbeans or an IDE, it should handle this for you as well.
15:56jwr7dnolen: bingo! Thanks! Though it actually _was_ in the classpath... after I moved it to where my other clj files were, it worked.
15:57jwr7dnolen: I use SLIME. Actually, scratch that. I fight SLIME. By the way, what version of SLIME should I be using so that it works with swank-clojure and clojure-1.1?
15:58jwr7I've been having all sorts of issues and I wonder what people actually use.
15:58dnolenjwr7: I got tired of fighting. I use ELPA to install SLIME and swank-clojure
15:58jwr7dnolen: Hmm... I could try that. I got used to using SLIME from CVS when working with CL.
15:59dnolenone downside is you have to do some work to get the ELPA SLIME to work with other Lisps. I'm playing around with other CLs at the moment so it's a minor annoyance for me.
15:59dnolenI'm not playing around I mena
16:01jwr7dnolen: ok, thanks for the hints. I'll try using the ELPA versions and see where that'll get me.
16:01dnolenjwr7: should just work. usually take only a couple of minutes to setup.
16:02jwr7dnolen: it'll likely take more, as I have a huge baggage of .el customizations back from CL hacking days.
16:02jwr7…but I'll give anything for a reliable SLIME and swank-clojure.
16:04Licenser_Raynes: I'm here :)
16:05RaynesLicenser_: Hi.
16:05Raynes:)
16:05RaynesI'll be leaving for a while soon, so I sent you the email anyways in case you didn't get what I said earlier.
16:06Licenser_*nods* Just read it :) thanks for the hint I fear you're right
16:06RaynesLicenser: One good thing: I think this might be the last bug you have to fix for a while. :)
16:10Licenser_Raynes: that makes me a sad Licenser, fixing bugs means people are using the code which gives me the fluffy feeling of being needed :P
16:11RaynesHehe.
16:11RaynesLicenser_: clj-sandbox is really important to me at this point. It provides a clean solution for my bot.
16:11TobiasROne more (probably stupid) question. The reddit clone worked fine. now i cut out everything except the import and the basic server stuff. Renamed the file etc. Edited the project.clj. But when i try lein compile i get "All :namespaces already compiled." lein clean doesn't work either and if i run the jar from ueberjar it doesnt find the class. Any idea what i might be doing wrong?
16:11RaynesOtherwise, I would have had steal hiredman's sandbox.
16:12Licenser_:) Raynes, I did the stealing for you :P so actually I'd call it borriwing since I asked ^^
16:12Raynes:p
16:12Licenser_hrm
16:12Licenser_future-cancle isn't a solution
16:13RaynesLicenser_: You might have to do what thunk-timeout does.
16:13RaynesI'm not sure you can fix this with futures.
16:13Licenser_Raynes: I fear I might, but I'd had hoped that I would not have to get another peace from clojurebot, also I found the futures a cleaner less javaish solution
16:13RaynesIndeed.
16:14RaynesBut you need to be able to stop the thread.
16:14Licenser_I know
16:15RaynesLicenser_: I have to take off for a few hours. Good luck with the fixing of the code. :p I'll pull it and finish up when I get op.
16:15Rayneshome*
16:16Licenser_thanks, for the testing/help Raynes, I'll have the timeouts fixed by the time you get back :) take care and have a good time
16:17hoeckTobiasR: you could try to manually delete the classes and lib folders, and then try to lein compile or lein uberjar again
16:27TobiasRhoeck: did that already, still nothing
16:28TobiasRhoeck: i just run lein from the directory with the project.clj dont i?
16:28Licenser_Raynes: I fixed it, it seems future really isn't the solution, gladly hiredman solved the problem already, or actually Chousuke when I get it right from the comments
16:32Licenser_hmm how are futurs working exactly, it seems not usable to calce tasks, is that a feature or a bug
16:32Licenser_?
16:33dnolenLicenser: calce tasks?
16:33Licenser_cancel sorry
16:34dnolenit create a new Future object which has a cancel method from what i can see looking at the source
16:34dnolen,(source future-call)
16:34clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
16:38Licenser_hmm hmm
16:38Licenser_I tried feature-cancle but it didn't work
16:38jwr7Ok, so enlive is really, really cool. I'm trying to find out how to construct selectors at runtime and can't see a way to do it. I need to be able to select and do something to [:div.widget#widget-id], but I will know the actual widget-id at runtime.
16:39hoeckTobiasR: so your lein compile still gives the same "all :namespaces already compiled" message?
16:39Raynes~def future-call
16:39TobiasRhoeck: yeah it does
16:39TobiasRi created a new lein project now
16:39TobiasRhoeck:but still, i guess i configured somethign wrong
16:40RaynesLicenser_: About to leave, but chouser and rhickey told me why it didn't work yesterday, or the day before. They'll be able to tell you.
16:40Licenser_okay thanks Raynes :)
16:40hoeckwhen invoking a lein on already compiled files, it does not print anything here, just silently quits
17:23defnhello everyone
17:23defn'lo Licenser_
17:23Licenser_hi defn
17:23Licenser_how is your parser going?
17:23defnnot much new in the last day or so
17:24defnim gonna play with it right now i think
17:24Licenser_cool :)
17:24defnsince we last talked i did make it output HTML
17:25defni think my next move is to weight code blocks which were said by people who a contributors
17:25Licenser_that is discriminatig :P I'll sue you if you do that
17:25defn:X
17:25defn:)
17:26defnhehe yes i know
17:27Licenser_you could run the code and wight in if a exception is trhown or not ;P
17:27defnwight?
17:27defnohhhh i see what you mean
17:27Licenser_weight sorry
17:28defnyeah i actually considered that
17:28Licenser_I am writing a sandbox library right now if you want to do that :P </advertisment>
17:28defnas long as the code ran in a handy little sanbdox and didnt do anything like write to files or execute anything
17:28defnyeah!
17:28defngimme gimme Licenser_ !
17:28defn:)
17:28Licenser_http://github.com/Licenser/clj-sandbox
17:29defnawesome
17:33defnnow i just need to wake up
17:33Licenser_ewww I hate fish
17:34defnwhy do you think im smacking myself with one?!
17:34Licenser_you're a masochist?
17:34defnhaha
17:42Licenser_defn: so if you want to use the lib feel free to ask me or annoy me :P
17:47jneirahi folks!
17:48jneira@clojurebot
17:49Licenser_hi jneira
17:50jneira, (use 'clojure.contrib.json)
17:50clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/json__init.class or clojure/contrib/json.clj on classpath:
17:50jneirajum where is json in clojure-contrin 1.1.0????
17:51jneirai am a bit confused with that
17:51Licenser_jneira: json-read json-write
17:51Licenser_that are what the libs are called
17:51jneirajum thnx but then i have a problem
17:52Licenser_jneira: shoot?
17:53polypusstylistic question: when you want to write the empty list, say in a recursive function with it as a base case. what do you guys write; (), '(), (list), nil ?
17:55Licenser_polypus: I personally would go with '()
17:56defnyeah, that's my sense also
17:56polypusthat was my first choice. () seems a bit naked
17:56Licenser_yea I didn't even know that () works :P
17:56Licenser_and (list) seems unnessessary
17:57Chousukeand nil is not the empty list :P
17:57polypusno but it'll work as a base case for cons
17:57Chousukeright.
17:57Chousukein that case I usually use nil
17:57Chousukethough most often that ends up being implicit due to use of when or something similar
17:58Licenser_Chousuke: the thunk-timeout function comes from you right? I wonder do you know why it does not work with future?
17:58polypusk thx guys
17:58Chousukemaybe futures are run in a threadpool or something (guess) :P
17:59Licenser_hmm
17:59Licenser_+
17:59Licenser_and the thread pool won't terminate when I tell it to? Sneaky sneaky
18:00ChousukeI wrote that function a long time ago. I don't remember what I did :P
18:00Licenser_heh
18:00Chousukebut I do remember that the thing uses a deprecated API to kill the thread
18:00Licenser_:(
18:00Chousukeso if there is a threadpool involved, that might not work.
18:01ChousukeBut there's no way to kill a non-cooperating thread in java other than the stop method, which is deprecated :/
18:01Licenser_narf that is evil
18:01KirinDavehiredman: You around?
18:04technomancyfutures run in the agent thread pool
18:04Licenser_ah and the thread pool stuff prevents them from being stopped, sneaky
18:05technomancyshutdown-agents would stop them, but then there's no way to start them again
18:08Licenser_technomancy: but that would stop all agents right not only the one that runs my task?
18:08technomancyLicenser_: yeah, it's a shotgun approach
18:08technomancysorry, not paying attention to context
18:08Licenser_heh :)
18:08Licenser_technomancy: no worries your answers are helping a lot
18:09Licenser_that would be the shoting approach :P
18:10technomancybeats an EMP
18:11defnLicenser_: would you mind taking a look at something for me when you have a chance? I am getting weird java heap sapce problems in my walton code all of a sudden and dont know where they came from
18:11KirinDavenot for style points ;0
18:11Licenser_defn: I'd love to :)
18:11defn:)
18:12Licenser_ust drop me a link
18:12Licenser_*just
18:13Chousukethe shotgun approach would be to connect the computer to a machine that fires a shotgun.
18:13ChousukeI suppose that would kill the thread for sure :P
18:14technomancyChousuke: lots of edge cases to consider though
18:14Chousukeyes. it might also kill the operator
18:14technomancyrunning out of ammo; damage being absorbed by the keyboard and display, etc.
18:14defnLicenser_: http://github.com/defn/walton/blob/master/src/walton/core.clj -- I swear the stuff from extract-code -> was working before -- but for some reason it breaks my REPL every time i use it now
18:15Licenser_Chousuke: is there a Java API for shotgins? And more importently can we model a clean functional layer around a shotgin? After all they do have a state pretty directly
18:16defnif there is not a shotgun library we need to build one
18:17defn(defn pull-trigger [shotgun, direction] ...)
18:17KirinDaveugh. Annotations are the sand in my shoes.
18:17Licenser_defn: did you try to take a new repl?
18:17KirinDaveClojure + lots of interop annotations = misery.
18:17defnLicenser_: ive made a new repl like 4-5 times
18:17defnit breaks every time i call the extract-code fn
18:18defnfind-lines works, but extract-code breaks it
18:18defnbut as i said, this was working fine before or i wouldnt have committed it
18:19Licenser_okay just to get sure :)
18:19defn*nod*
18:22Licenser_defn: did you add the sorted set method just recently?
18:23Licenser_that means your entire map gets computed, I think
18:23Licenser_that can fill your heap quickly I guess
18:25defnLicenser_: yeah, although just running find-lines without limiting my *print-length* makes it go nuts
18:26Licenser_heh
18:27defni mean, i was able to run sorted-set before without any issue
18:27defnjust trying to figure out what changed
18:27Licenser_hmm
18:27Licenser_more data?
18:27Licenser_bigger search results?
18:27defnit should be the same data :\
18:27defncan you run that without it breaking on you?
18:28Licenser_let me clone that
18:29Licenser_do you have the link to the data still=
18:29defnyeah it should be in the README
18:29defnhttp://www.devinwalters.com/clojure-logs.tar.bz2
18:30Licenser_ah okay
18:30Licenser_*Gets the data*
18:32Licenser_defn: I get java.io.FileNotFoundException: Could not locate clj_html/core__init.class or clj_html/core.clj on classpath: (core.clj:1)
18:33defnyou ran lein deps?
18:33Licenser_ah yea :P
18:33Licenser_good point
18:33Licenser_narf
18:33defnhehe :)
18:33KirinDavehiredman: Reping
18:33Licenser_I hoped lein repl would do that :(
18:33KirinDaveuhg, bad word merge
18:33defnLicenser_: i got it to work after removing the sorted-set and reducing my print-length to 10
18:34Licenser_hmm
18:34defnah-ha, if i add sorted-set it breaks
18:34defnyou were correct
18:35Licenser_:)
18:35Licenser_I keep getting no results, I wonder why
18:35defnM-x slime-set-default-directory
18:36defnand then set the project root as your directory
18:36Licenser_you should not have your local thing as the defaullt ;)
18:37Licenser_better
18:38Licenser_and yes I got a OOM exception too
18:38Licenser_I guess you just find too much so it is odd
18:38Mecis it a problem to put a conditional before a call to swap! or do i need to put it inside the swap! call?
18:39Licenser_hmm hmm I even get it for an no hut situation
18:40Licenser_unless I'm mistaken and there is a lot of discussion about the concatcatcat function
18:41Licenser_I think apply might be the evil doer here
18:42technomancyMec: "a conditional" is pretty vague
18:42defni dont like evil doers
18:42technomancyMec: if the condition affects the atomicity of the change it should be inside the call to swap
18:43Mectechnomancy: sorry, i check if the map has a key, and if not then i swap! with assoc
18:43Licenser_nope happens with set too
18:44technomancyMec: in that case I think it's more correct to perform the check inside the swap to avoid (very unlikely) a race condition
18:45Licenser_wow I even get the problem when I remove the set thing
18:45defnLicenser_: yeah i just saw that as well
18:45Mectechnomancy: ok thanks, i thought so
18:45defnLicenser_: something is very wrong here....
18:45Licenser_aye and I wonder what :)
18:47Licenser_okay even when returning the sort results I get this error, which is odd
18:49defnLicenser_: yeah it is a very angry piece of code
18:49defn:(
18:49Licenser_we'll find the bad bad memory eater don't worry
18:49defnjunkies!
18:49defnjinkies! rather
18:51Licenser_defn: heh
18:52Licenser_it seems the data set is too big for the repl
18:52Licenser_(reduce + (map count parsed-logs)) creates a out of memory exception
18:52defnuh oh...
18:52MecIs there a pastie site specific for this channel?
18:53defnMec: everyone uses gists on github
18:53defnMec: they give nice syntax hilighting taboot aboot!
18:53Licenser_defn: if we can make it entirely lazy we should be happy
18:53defnLicenser_: yes, when does it become *un-lazy*
18:54Licenser_in the moment you search it
18:54defnoh! right! :)
18:54defnLicenser_: im able to use find-lines
18:54Licenser_you are?
18:54defni just need to make sure i have my *print-length* very low
18:55defni have it at 10 right now
18:55defn(set! *print-length* 10)
18:55Licenser_defn: I used (def _ (find-lines ...)) so no output should have been given
18:56defnmaybe print-level?
18:59Mectechnomancy: could you see if this looks right? http://gist.github.com/339625
18:59Licenser_defn: no it's not a print issue, def does not print anything
19:00technomancyMec: you might be able to perform the same thing with merge
19:01defnLicenser_: I just magically got this to work: (map #(re-find *regex* %) (find-lines "zipmap" parsed-logs))
19:01defnwhere *regex* is: (def *regex* (re-pattern (str "\\(.*" "zipmap" ".*\\)")))
19:01Licenser_defn: fixed it :)
19:01technomancy(doc merge)
19:01clojurebot"([& maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping from the latter (left-to-right) will be the mapping in the result."
19:01technomancymerge the hash with {location {}} in such a way that the original hash "wins"
19:02Mectechnomancy: ok, thanks
19:02defnLicenser_: i changed the map in parsed-logs to a pmap, but that's probably not that big of a difference
19:02Licenser_defn: making your search a global variable does not really seem like a solution :)
19:02Mectechnomancy: lacking a merge function is that how you would do it or is there a cleaner way?
19:02defnLicenser_: heh
19:03Licenser_give me a second and I post you something
19:04defnit seems like it is working now after i removed the (remove empty?...)
19:05technomancyMec: yeah, if I didn't have merge I'd do it like you pasted
19:05Licenser_0.5s to run the query and no heap problems
19:05Licenser_hardly eats any memory
19:06Licenser_I'll fork and change it :9
19:06defnapply sorted-set and remove empty? both absolutely kill it
19:07jneirawell people im stuck with java.lang.VerifyError: class xxx overrides final method meta.()Lclojure/lang/IPersistentMap
19:08jneirahi Licenser_
19:08Licenser_hi jneira
19:08jneiraand everyone
19:08Licenser_defn: o.o forgot about the sorted set, testing right now
19:08Licenser_1.5s but no heap problem
19:09jneirai think is related to versioning ..
19:09defni can live with that
19:09defnLicenser_: was it the with-out?
19:09defnim interested to see this
19:09Licenser_defn: no with everything :)
19:09defnhaha d'oh
19:11defnLicenser_: let me know when you make the pull request, and thank you again for helping me :)
19:11Licenser_defn: :) no worreis and yes I always wanted to try out that pull request thing :P
19:14ericthorsen_anyone know if the clojure assets on build.clojure.org are built with 1.5 or 1.6 ?
19:14defnhah Licenser_
19:15defni know the feeling
19:15Licenser_defn: sory that you are my guiny pig here :P
19:16defnLicenser_: Collaborating is fun
19:17Licenser_defn: yap, sadly I hand't had the change to recolaborate that often yet :) so I am happy to finaly try out this pull requests
19:17defn*nod*
19:19Licenser_defn: you got a pull request.
19:20jneirammm the error was caused for classes of a prev compilation
19:21jneirai guess
19:22jneirabut i think errors continue being unfriendly
19:22jneirain clojure
19:24defnLicenser_: pulled
19:24Licenser_defn: and working for you too=
19:26jneirayeah! (public-timeline) working with core/contrib 1.1.0
19:27Mecis there a keybind to eval a whole buffer in emacs?
19:27defnLicenser_: yes it is :)
19:27defnit was the with-out, huh?
19:27jneirac^c c^r
19:28jneirai think
19:28Licenser_without wat?
19:28Licenser_what?
19:28clojurebotwhat is short for ,(doc ...)
19:28defnLicenser_: errr with-open
19:28Licenser_defn: this opens a file and ensures it is closed at the end of the (with-open) form again
19:30Mecjneira: thats just giving me a weird error
19:30jneirajum
19:30defnLicenser_: tricky! added the sandbox! :)
19:30Licenser_yap ;)
19:30jneirafirst you hava to select all buffer
19:30Mecoh
19:30Licenser_just wanted to see if it works, and it actually does, with hardly 5 LOC
19:30defnawesome!
19:31Licenser_so I can't guarantee that it actually is secure, or will not block coreckt code
19:31jneiraM^< C^spc M^> and C^c C^r
19:31jneirawell you can select all buffer with ...i dont remeber
19:32defnLicenser_: I can live with that for now :)
19:32Mecas soon as i hit C-c it deselects the buffer
19:32Licenser_so it is kind of coll that you only get examples that work actually
19:32defnyeah although one of them may run some java code that deletes your / partition
19:32defn;)
19:33Licenser_defn: that is very unlikely :P
19:33jneirajum
19:33Licenser_if you enable jvm security it should block that
19:33technomancy(heading out for a while, but please msg or email me with your thoughts if you have a chance to review it.)
19:33Licenser_and in theory the sandbox is quite tight since it's only letting you use a whitelist of functions
19:34Licenser_and I did not (partition-hard-disk) in there
19:34jneiraC^x h to select all buffer
19:34Mecsame thing, after that C-c deselects it
19:34defnLicenser_: hahaha, touche
19:35Licenser_but you can add that yourself if you liek the trhill
19:36jneirammm C-c deselects? i am afraid not for me
19:36defnim all about the thrill Licenser_
19:36defn:
19:36defn:)
19:36Licenser_defn then you can use the debug-tester :P
19:37Licenser_that lets through all code
19:37defni think ill run it in a VM for now ;)
19:37Licenser_:P
19:38Licenser_defn: I /think/ even with that it should not whie your hard disk
19:38Licenser_so I have the feeling that 'thinking' is not good when it comes to security
19:38Mecjneira: ah i've got CUA turned on
19:39jneiracut & paste evil
19:41defnLicenser_: haha
19:42defnYes I think that thinking can be exactly the problem with security (I think)
19:43Licenser_don't think so much, just trust in the force!
19:43defnhahaha
19:43defnLicenser_: I am your father.
19:43Licenser_no you're not :P
19:44defnokay time to go play with this walton code now that it's not breaking my REPL :)
19:44defnthanks again Licenser_
19:44Licenser_you're welcome defn :)
19:54defnLicenser_: haha this sandbox is great
19:55defnLicenser_: it turns 106 lines of matched code into 40
19:55defnmuch better examples
20:07Licenser_defn: I'm really glad to hear that :D
20:07Licenser_There are so many applications for a sandbox that I just keep seeing them everywhere now
20:49Mecis there a way to use dissoc-in without it removing an empty map
20:51chouserthe purpose of dissoc-in is to remove (dissoc) something -- why behavior do you want instaed of removing?
20:51chousers/why/what/
20:52Meci want to remove the inner key/val but not the map if it results in being empty
20:53Mecso like (dissoc-in {:a {:b :c}} [:a :b]) -> {:a {}}
20:54chouseroh, I see.
20:54chouser,(update-in {:a {:b {:c :d}}} [:a :b] dissoc :c)
20:54clojurebot{:a {:b {}}}
20:56Mecoh nice, thanks
21:07MecI read the description of update-in but it was hard to grasp
22:14RaynesLicenser_: I'm about to issue a pull requestion.
22:14Raynesrequest*
22:25RaynesWhere is clj-io hosted?
22:25RaynesI sees it, but I don't has it.
22:36technomancyRaynes: I don't think there's much difference between clj-io and clojure.contrib.io (and hopefully clojure.io in the future)
22:38technomancyit's on clojars anyway if you don't want to pull in the rest of contrib
22:47Raynestechnomancy: I was asking because I had no idea what it actually was.
22:48RaynesNot because I wanted to use it. :P
23:22radswhen I try to use congomongo in a leiningen task, I get this error: Exception in thread "main" java.lang.ExceptionInInitializerError (coerce.clj:1)
23:22radsany ideas on what that means?
23:34technomancyRaynes: it was a way to propose clojure.io for inclusion in clojure itself before the clojure.lib idea came up