#clojure logs

2011-05-04

00:03technomancyamalloy: ah bugger; forgot it requires git master
00:17technomancyor not; it was a screw-up with the clucy lib needing ancient contrib
00:17technomancyanyway, should be ok now
00:18brehautdoes anyone know whats involved with getting sqlite going with clojure?
00:22dnolenbrehaut: not much, use the JDBC connector, setup your tables, querying w/ ClojureQL is fun.
00:23dnolenhttp://www.zentus.com/sqlitejdbc/
00:23brehautdnolen: thanks
00:23brehautno maven thing for it?
00:24dnolenbrehaut: supposedly it's here http://www.jarvana.com/jarvana/search?search_type=project&project=sqlite
00:25brehautdnolen: thanks
00:26dnolenactually those are different according to this, http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC
00:27hiredmanwhy not use derby or some other java embedded sql?
00:27dnolenbrehaut: in my case when I was playing around, I actually used the first link and just dropped the .jar in lib.
00:27technomancyiiiiiinteresting: http://www.cloudbees.com/foss/
00:27hiredmanthat you can get from maven
00:27technomancysc
00:27technomancycab
00:27technomancygeez emacs
00:28brehauthiredman: ive never even heard of derby; i'll check it out
00:28brehautdnolen: ok sure
00:30mreynoldsbrehaut: Also known by it's Brand "JavaDB"
00:34semperosif you know how to administer a db already, might as well use smth you know like sqlite
00:35brehauti dislike administering all the databases i know ;)
00:56semperos$findfn [1 2 2 3 1 4 5 6 6] [1 2 3 4 5 6]
00:56sexpbot[clojure.core/distinct]
01:02amalloy&((comp seq sorted-set) [1 2 2 3 1 4 5 6 6])
01:02sexpbot⟹ ([1 2 2 3 1 4 5 6 6])
01:02amalloy&((comp seq sorted-set) 1 2 2 3 1 4 5 6 6)
01:02sexpbot⟹ (1 2 3 4 5 6)
02:01matthias_hmm, why would lein repl open some random port? it used to always pick the same one
02:07amalloyif it did you could only have one lein repl open on your whole system at a time?
02:54matthias_oh, i was using lein repl instead of lein swank. don't know why :|
03:41fortxun$seen rhickey
03:41sexpbotrhickey was last seen quitting 4 days and 12 hours ago.
04:28Kototamahello, does anyone now why analemma has been removed from clojars?
06:17yayitsweihello, I'm getting "#<CompilerException while parsing a block collection expected <block end>, but found ?" in my REPL
06:17yayitsweianyone know what that error means?
06:17fliebelyayitswei: That you have a syntax error.
06:19yayitsweithanks fliebel. just realized it was a syntax error in a yml file I'm parsing. how could I have debugged that?
06:20fliebelyayitswei: By printing the stacktrace and looking for files that belong to your project.
06:20fliebelIt'll tell you line numbers.
06:20yayitsweiahh thanks. how do i print the stacktrace in the repl?
06:20fliebel(.printStackTrace *e)
06:22fliebeldevn: ping
06:24yayitsweigot it. thx
08:35fortxun$seen rhickey
08:35sexpbotrhickey was last seen quitting 4 days and 17 hours ago.
08:47clgv$seen fortxun
08:47sexpbotfortxun was last seen talking on #clojure 12 minutes and 19 seconds ago.
08:58@chouserfortxun: you could try the google group or his email address
08:59@chouseror I suppose knock on his door, if you know where that is.
08:59solussdAnybody here made it through the 'conjure' tutorial? I am stuck on 'scaffolding', getting: JdbcSQLException: Wrong user name or password
08:59fortxunchouser, what is his email address?
09:01chouserfortxun: I would think you could find it on here somewhere: http://groups.google.com/group/clojure-dev
09:09rak85hi guys
09:09rak85i have a list of vectors in the following format -> '([2 4] [4 343] [5 500])
09:10rak85and I want to compare the second index from each vector and return the maximum
09:10rak85in this case, i would return 500
09:10rak85how would you do that?
09:10rak85i'm using reduce...
09:11rak85any other approach?
09:11ejackson,(map (comp max second) [[2 4] [4 343] [5 500]])
09:11clojurebot(4 343 500)
09:11rak85hmmm...
09:11ejacksonno quite....
09:11ejackson,(max (map second [[2 4] [4 343] [5 500]]))
09:11clojurebot(4 343 500)
09:11ejacksonlol.... i should do this in my own repl....
09:11ejackson,(apply max (map second [[2 4] [4 343] [5 500]]))
09:11clojurebot500
09:12rak85i forgot to tell you something...
09:12ejacksonnow you sound like my clients
09:12rak85i may have nil values in the second index...
09:12rak85hahaha
09:12ejacksonthrow a map identity in there
09:13ejacksonfilter identity, rather
09:13rak85hmmm..thanks
09:13ejackson,(apply max (filter identity (map second [[2 4] [4 _] [5 500]])))
09:13clojurebotjava.lang.Exception: Unable to resolve symbol: _ in this context
09:14ejackson,(apply max (filter identity (map second [[2 4] [4 nil] [5 500]])))
09:14clojurebot500
09:14rak85ejackson: thanks!
09:14ejacksonnp
09:17raek,(reduce max (for [[x y] [[2 4] [4 343] [5 500]] :when y] y)) ;; Another approach
09:17clojurebot500
09:44clgv&(->> [[2 4] [4 343] [5 500]] (map second) (reduce max))
09:44sexpbot⟹ 500
09:51warpycan someone point me to clojure 1.2.1 changelog?
09:51opqdonut_https://github.com/clojure/clojure/blob/1.2.x/changes.txt
09:52warpythanks opqdonut_
09:52opqdonut_np
10:06__name__&(->> [[2 4] [4 343] [5 500]] (map second) ma)
10:06sexpbotjava.lang.Exception: Unable to resolve symbol: ma in this context
10:06__name__&(->> [[2 4] [4 343] [5 500]] (map second) max)
10:06sexpbot⟹ (4 343 500)
10:06__name__&(->> [[2 4] [4 343] [5 500]] (map second) (apply max))
10:06sexpbot⟹ 500
10:06__name__clgv: Is that not nicer?
10:08clgv__name__: why should it be? the question is: nicer to which "measure"? ;)
10:08__name__clgv: reduce seems a bit redundant because it is more function calls.
10:08clgvon a pure text comparison it's just recue exchange with apply ;)
10:09raekthe vararg version of max is implemented with reduce...
10:09clgv__name__: max with more the two arguments is also more than one function call ;)
11:59gfrlogso I'm using compojure and ring...
11:59gfrlogand I'm testing the server by sending it requests manually, since the server is a function...
11:59gfrlogbut I'm having trouble interacting with it the same way jetty does
12:00manutterwhat kind of trouble?
12:00gfrlogspecifically wrt form and route params
12:00KirinDave_gfrlog: Well yeah, jetty is a ton of environment and side effects underneath your code.
12:00KirinDave_gfrlog: The way I did it was I put a capture handler that dumped out ALL the data structures for a request to file.
12:00KirinDave_gfrlog: I'd reconstitute those for my tests
12:01gfrloghmm
12:01KirinDave_gfrlog: The only trick there is you need to manually handle the body of the post, which is an input stream.
12:01gfrlogwhat I was doing was just passing in the form-params as a map
12:01mattmitchellis the a nice way to create a hash-map from a 2 vectors, where one vector contains the keys and the other the values?
12:02KirinDave_mattmitchell: zipmap
12:02mattmitchellKirinDave_: excellent thanks!
12:02KirinDave_mattmitchell: Is there some sort of challenge or homework or something? You're probably the 5th person to ask that in 24 hours
12:02gfrlogKirinDave_: so I was asking because I was hoping there was a not-messy way to figure this out. It sounds like you're saying it's just gonna be messy?
12:02KirinDave_gfrlog: It shouldn't take too long.
12:03mattmitchellKirinDave_: no :) guess it's just a common problem to solve
12:03KirinDave_mattmitchell: Well, zipmap is the answer :)
12:03gfrlogKirinDave_: I wouldn't expect so, it just makes me feel gross and sticky :)
12:04manuttergfrlog: think of it as building a mock-jetty for testing purposes :)
12:04KirinDave_It's weird to me that there is zipmap but no zipwith.
12:04gfrlog,(zipmap (iterate inc 0) (iterate inc 1))
12:04clojurebotExecution Timed Out
12:04gfrlogmanutter: I think I was hoping that the code I was missing was in compojure somewhere rather than in jetty
12:04KirinDave_Ahh yes
12:04gfrlogor ring
12:04KirinDave_gfrlog: The answer is no.
12:04KirinDave_There is no default request content.
12:05KirinDave_But you'll see
12:05KirinDave_Once you have a few for inspection, you'll find modifying them is relatively easy.
12:05gfrlogKirinDave_: it's not all the boilerplate that I'm missing, it's the method of assembling the input
12:05gfrloge.g., the form parameters are duplicated in the :form-params key and the :params key
12:05KirinDave_"assembling the input"? I don't understand
12:05gfrlogwhere :params also has the route parameters
12:05KirinDave_Well that's because you put a handler there I assume.
12:05gfrlogand maybe the query parameters as well
12:05manutteryou mean to turn a map into an encoded string, ya?
12:06KirinDave_There is like a unified params handler.
12:06gfrlogKirinDave_: yes, the unified one works with browser/jetty
12:06KirinDave_If you're using that, params is assembled.
12:06gfrlogbut when I call the app directly, that doesn't get done
12:06KirinDave_I'm of the opinion params is dangerous, but also devilishly convenient. :)
12:06KirinDave_Indeed.
12:06KirinDave_Sorry, my greyhound needs walking.
12:06raekgfrlog: those are usually parsed from the :url or :body by some ring middleware, but maybe compojure handles that automatically
12:06gfrlogyou can't destructure as easily with form-params though, because it has string keys
12:06KirinDave_He states this by draping his body across my hands.
12:07manutterlol
12:07KirinDave_And I have to support his head with my wrists. Progressively increasingly difficult to type.
12:07gfrlogmaybe I will try encoding my form params into the body and see if it gets handled that way
12:07gfrlogKirinDave_: okay have fun :)
12:07gfrlogthanks for the help both of you. lunch calls.
12:07KirinDave_gfrlog: Why not just capture some request structures? Seriously. It takes all of 5 minutes. Use curl to hit a random endpoint with the kind of requests you want.
12:08KirinDave_Then you've got lightning in the bottle.
12:08gfrlogKirinDave_: I may not have explained myself well enough, because I don't think that's really the issue. But I think I understand things better now, so it'll be okay.
12:09dnolenraek: I fixed those issues from yesterday (I hope)
12:10devnfliebel: im here
12:11devnfliebel: sorry, would have gotten back to you yesterday but was too busy flopping around on the ground (seizure)
12:14Ramblurrin enlive, what is the proper way to do a conditional transform? e.g., [:selector] (if condition (content "success!") (some_other_transform))
12:19raekRamblurr: the form to the right should be a function that takes a node and returns a node, so you can do it like this (fn [match] (if (pred? match) ((content "success!") match) ((some-other-transform) match)), I believe
12:19raekoh, the enlive readme explains it even better: "Transformations (the right-hand parts of rules) are now plain old closures.
12:20raekThese functions take one arg (the selected node) and return nil, another node
12:20raekor a collection of nodes."
12:20Ramblurrah i saw that, it didn't click. so using a closure should work
12:20raekso 'content' is a function that returns a transform
12:22raekdnolen: ok, nice. then I don't have to move the issue to the correct location... :)
12:23Ramblurrraek: you mean 'content' is a function that returns a transform function
12:23Ramblurr..right? or a col of nodes?
12:23Ramblurrgonna try it out..
12:23raekyes, a transform function..
12:24raeksorry
12:27Ramblurrraek: ah ive got it working
12:27Ramblurri was trying to pass match to 'content' itself
12:27Ramblurrcause i thought it was content that returned the col of nodes
12:51noidi_Why doesn't the following form work in the ns macro: (:refer-clojure :exclude [*]) ?
12:51noidi_Unable to resolve symbol: * in this context
12:52noidi_excluding + doesn't work either
12:52noidi_but e.g. excluding assoc works fine
12:52noidi_is there something special about the math operators?
12:52technomancynoidi_: maybe because + and * are defined using definine?
12:54technomancydoesn't really make sense, but it's the only thing I can think of
12:54noidi_ok, thanks
12:56Raynesnoidi_: He meant definline
12:57noidi_they don't seem to work as method names in a protocol either :P
12:58noidi_so there's something special about them
13:03chouser(ns foo (:refer-clojure :exclude [*])) works for me
13:04chouserof course any attempt to use * after that results in Unable to resolve symbol: * in this context
13:04noidi_I'm using 1.2.0
13:05chouserhm, that was with 1.3-something. I'll try 1.2
13:05chousersame result on 1.2
13:07noidi_oddly enough the error disappears if I remove the (:import) form from the ns call
13:08noidi_so I have a syntax error that gets the macro confused
13:08noidi_*maybe*
13:10noidi_never mind that, the error was really caused by me calling * after excluding it
13:10noidi_:P
13:11noidi_I changed the protocol method's name from * since it didn't seem to work, but forgot to change the users back
13:15noidi_yay, everything works now
13:16noidi_I just had my REPL in a weird state after all the experimentation with the names
13:16noidi_sorry about that :)
13:22chousernoidi_: not a problem. glad you figured it out
13:28lawfulfalafelokay I am trying to do what it says on this page: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs and I can't get the M-x package-list-packages command to work
13:28lawfulfalafelI think the icicles mode is overriding it
13:28dpritchettlawfulfalafel, are you sure you have elpa installed?
13:29lawfulfalafelelpa?
13:29clojurebotelpa is a package manager for Emacs: http://tromey.com/elpa
13:30gfrlogany quick/easy way to encode a map as POST params?
13:30lawfulfalafelokay I ran that install script
13:31amalloyKirinDave_: isn't zipwith just a special case of map? ##(map + (range) (range 1 10))
13:31sexpbot⟹ (1 3 5 7 9 11 13 15 17)
13:31gfrlog,(doc zipwith)
13:31clojurebotNo entiendo
13:32amalloygfrlog: he means the haskell/scala/whatever zipwith
13:32gfrlogdangit I don't know those languages
13:32gfrlogis it my map-from-fn idea?
13:32KirinDave_amalloy: It's just weird to have zipmap but not zipwith. :)
13:32lawfulfalafeldpritchett: thanks
13:32amalloygfrlog: i don't know what idea you're talking about, but no
13:33manuttergfrlog: I wonder if clj-http has any form-encoding functions
13:33manutter(assuming I have the name right)
13:33dpritchettnp lawfulfalafel
13:33KirinDave_amalloy: I'm sure zipmap is just an implementation optimization for a common case.
13:34amalloyKirinDave_: i doubt it's an implementation optimization
13:34manuttergfrlog: https://github.com/mmcgrana/clj-http
13:34amalloy&(into {} (map vector (range) (range 1 10)))
13:34sexpbot⟹ {0 1, 1 2, 2 3, 3 4, 4 5, 5 6, 6 7, 7 8, 8 9}
13:34gfrlogKirinDave_: amalloy: it's not
13:34KirinDave_Weird.
13:35gfrlogthe source just uses (loop) and goes one by one
13:35amalloyKirinDave_: zipmap is doing a different thing than zipwith would
13:35KirinDave_amalloy: Because it's a reduce.
13:35amalloyright
13:35KirinDave_Still you could do zipmap in terms of zipwith.
13:35amalloyobviously. i just did
13:36KirinDave_I guess zipmap is just the belle of the zip family. :)
13:36KirinDave_So in demand, so famous, so glamorous.
13:36dakrone,(apply str (interpose "&" (map (comp (partial apply str) (partial interpose "=")) {"a" "foo" "b" "bar"})))
13:36clojurebot"a=foo&b=bar"
13:36manutterheh
13:37manutterI think you also need to map <space> to + and special chars to, what is it %xx; format?
13:37gfrlogdakrone: the escaping is the hard part
13:38dakronethat's true
13:38amalloydakrone: i like point-free as much as the next guy, but that partial stuff is kinda overdoing it ##(clojure.string/join "&" (map (fn [[k v]] (str k "=" v)) {"a" "foo" "b" "bar"}))
13:38sexpbot⟹ "a=foo&b=bar"
13:39amalloyanyway this is a wheel that has been invented a lot of times. that said, i was looking for it the other day and didn't find any convenient clojure wrappers for it
13:39dakrone:)
13:39gfrlogamalloy: what is point-free?
13:40amalloy$google haskell point free
13:40sexpbotFirst out of 93500 results is: Pointfree - HaskellWiki
13:40sexpbothttp://www.haskell.org/haskellwiki/Pointfree
13:40KirinDave_Point free is kinda pointless in lispy languages.
13:40amalloygfrlog: tl;dr: building functions by gluing together functions without mentioning their arguments explicitly
13:41amalloyKirinDave_: i see no evidence of that
13:41gfrlogthat is a good formalization of a concept that's been floating around my head for a while now
13:41KirinDave_amalloy: It's more trouble than its worth, in my opinion. Lisp's rules for application don't facilitate it.
13:41gfrlogwhen I create point-free expressions, it gives me a bigger programming high and makes me not want to be around when a clojure-n00b has to support the code
13:41gfrlogso I do it all the time
13:42KirinDave_amalloy: And also they tend to be longer in clojure because you gotta use (partial ...) :)
13:42gfrlogyeah partial is way too long
13:42S11001001gfrlog: well obviously you wouldn't have made any mistakes there, so said n00b knows to look elsewhere for problems
13:42amalloyKirinDave_: (defalias $ partial) :P
13:42gfrlogS11001001: yes, that is obvious
13:42KirinDave_amalloy: Ha.
13:42amalloyand then add some greek letters
13:42KirinDave_What could go wrong.
13:43gfrlogdon't tell jquery
13:43amalloyKirinDave_: what could go wrong is you could end up with hiredman's code-rewriting macro
13:43KirinDave_The upshot of a () wrapped partial call is that the binding order is way clearer
13:43KirinDave_amalloy: What does that look like?
13:43amalloyit looks pretty cool tbh, but not a lot like lisp
13:43KirinDave_I thought he super-hated macros.
13:43amalloyi can never find the dang thing
13:43KirinDave_I mean, it takes a few doubletakes to resolve what x = (f .) . g
13:44KirinDave_really does.
13:44amalloyKirinDave_: it takes me a few double takes to come up with (f .) . g when what it seems like i want is f . g
13:44hiredmanhttps://github.com/hiredman/odds-and-ends/blob/master/functional.clj#L126
13:44amalloyhooray, thanks hiredman
13:45KirinDave_hiredman: Whoah
13:45KirinDave_hiredman: Ha. At first i was like, "Clj doesn't have flip in the stdlib... ohhhh wait line 55)
13:45hiredmanuncurry is still completely the opposite of the name
13:46KirinDave_:)
13:46gfrlogadd an ignored argument?
13:51mattmitchelli know there is a "some" which will return the non-false return value from the predict. Is there anything that will return the item in the seq when the predicate returns true?
13:52amalloy(comp first filter)
13:53amalloyor, write your predicate differently
13:53mattmitchellamalloy: aye that's pretty simple. thanks!
13:53mattmitchellyeah i came up with this: (defn detect [f col] (some #(if (f %1) %1) col))
13:53mreynoldsI've been tending towards using (partial) instead of constructing functions on-the-fly #(), are there any caveats or idiomatic reasons not to do this?
13:54mattmitchellthen i can do (detect pred col)
13:57amalloymattmitchell: fwiw, i prefer (defn detect [pred] (fn [x] (when (pred x) x))) (some (detect even?) coll)
13:58amalloythen you're not tied to "some" and can reuse that adjusted predicate anywhere (and believe me, it's useful in a lot of places)
13:59amalloymreynolds: they're both fine. i like partial. but if you end up with more than a couple partials all in one place it tends to be hard to read, so split it up
13:59mattmitchellamalloy: ahh cool
13:59mreynoldsamalloy: Gotcha, yeah, I've been using that same pattern for readability. Thanks.
14:00chousermreynolds: fwiw, each literal #() in your code at compile time produces a new class, while (partial) does not.
14:01chouseron the other hand, a calling a fn created with partial may require an extra method call or two at runtime, but then again those are probably inlined away in any loop tight enough to matter.
14:01mreynoldschouser: Ahhh, nice to know. Have you heard of people running into problems with too many classes? I guess I could see the JVM choking on having to manage a few hundred thousand
14:02chouserI think the biggest real problem with lots of classes is the startup overhead for the JVM to validate all of them
14:03chouserbut again, that's probably something to be improved in a more systemic way, rather than replacing each of your uses of #() with partial. :-P
14:04mreynoldshehe, yeah. So far, I haven't seen it as a problem anyway. I'm using Clojure for services and server-side stuff where startup time hasn't been an issue, neither class GC/management.
14:06amalloychouser: surprisingly, i never realized partial doesn't need a new class for each use. it's clear if you think about it, but i never did
14:07amalloyi just saw core$partial$fn__3682 and was like, yep, there goes another anonymous class
14:07chouseramalloy: I mention it alot because it surprised me too when I first realized that difference
14:07chouseralot
14:07amalloyhaha
14:08chouseralots are always surprising me as they lumber on by
14:09gfrlogman I'm having this horrible time trying to test my compojure app without making my app code really clunky
14:09amalloy$dict alot
14:09sexpbotamalloy: noun: common misspelling of a lot.
14:09amalloynice
14:09gfrlog$dict cleave
14:09sexpbotgfrlog: verb-transitive: To split with or as if with a sharp instrument. See Synonyms at tear1.
14:09amalloyi was hoping it was some real thing, when you said they lumber on by
14:10gfrlogoh is somebody referencing hyperbole and a half?
14:10gfrlog$google hyperbole half alot
14:10sexpbotFirst out of 74500 results is: Hyperbole and a Half: The Alot is Better Than You at Everything
14:10sexpbothttp://hyperboleandahalf.blogspot.com/2010/04/alot-is-better-than-you-at-everything.html
14:10mreynoldsI should probably look at the return codes from functions more often to understand the impl better
14:10manuttersexpbot scares me on a daily basis.
14:10semperoslol
14:11amalloymreynolds: the return codes?
14:12gfrlogso compojure passes in four keys -- query-params, form-params, route-params, and params
14:12gfrlogthe easiest way to do bindings in compojure is straight out of params
14:12gfrlogbut if I call the app directly in my test, I can't set params up the same way that jetty? does it
14:12gfrlogbecause I don't have the route-params at that point
14:12gfrlogonly the form params
14:13gfrlogbinding to the form-params specifically in the app code is tough because it uses strings for keys
14:13gfrlogwhen they are merged into the main params map, they're converted to keywords
14:14amalloyoh my god i am in love with that article. thanks, chouser and gfrlog, for bringing it to my attention
14:14manuttergfrlog: by "jetty" do you mean the ring module that wraps the calls to the Jetty servlet?
14:14gfrlogmanutter: I could mean anything
14:14gfrlogthus the question mark
14:15gfrlogI don't understand at what point the things happen
14:15gfrlogbut apperently the app I get from compojure that I call from my tests does not include the functionality
14:15amalloygfrlog: isn't it ring.middleware.params/wrap-params that turns the query string into a keyword map?
14:15gfrlogamalloy: you're welcome. I'm honored to have contributed
14:15amalloyor a string map
14:16gfrlogamalloy: maybe? would you expect that to be included in the app then?
14:16amalloyyou can wrap your handler with that manually when you're testing
14:16amalloygfrlog: by app, you mean...?
14:16gfrlogI mean the function returned from...hmm
14:16gfrlogcompojure.handler/api
14:17gfrlogI think
14:17gfrlogis what I'm passing the routes to
14:17gfrlogso my app-function I am testing by calling it as such:
14:17mreynoldsamalloy: Er, sorry, the values as printed by pprint :) AKA function and object ids
14:18gfrlog(app {:request-method ..., :uri ..., :body "foo=bar"})
14:18amalloygfrlog: i think so, but you can look at the compojure source and see
14:19amalloyhttps://github.com/weavejester/compojure/blob/master/src/compojure/handler.clj#L15
14:23gfrlogamalloy: my app is seeing the :body attr exactly as I passed it in, and the :form-params attribute an empty map
14:24gfrlogamalloy: I guess this is enough to dig into it on my own, thanks
14:24amalloygfrlog: earlier you said you only had the form params, not the route params. which is it you have and which do you wish you had?
14:24gfrlogI as the tester only have the form params. so I want to pass them in either as a :body or as :form-params, and I want them to be merged into :params along with the :route-params
14:25gfrlogwhen I try this, my app only sees the :route-params included in the :params map
14:26gfrlog(on a side note, the alot article is apparently the top google hit for "alot")
14:27gfrloglooking at the wrap-params method in the ring middleware...
14:32amalloygfrlog: try just having your app output the request map it receives as the response map. then you can see exactly what it's getting and try fixing that
14:32gfrlogI can see exactly what it's getting
14:32gfrlogI am logging the request map
14:33gfrlogthe naive "fix" would be to just set "params" myself
14:33gfrlogbut then it would not include the route-params
14:35gfrlogmaybe I need to set the content type
14:35gfrlogand then it will decode the body for me
14:38gfrlogit will decode it for me if I make it slurpable
14:38gfrloghow can I use $findfn to figure out how to make (slurp (f "foo")) return "foo"?
14:38amalloy$findarg slurp (% "foo") "foo"
14:38sexpbot[]
14:38amalloyno, i guess not
14:39amalloystill, you probably want ##(slurp (StringReader. "foo"))
14:39sexpbotjava.lang.IllegalArgumentException: Unable to resolve classname: StringReader
14:39amalloystill, you probably want ##(slurp (java.io.StringReader. "foo"))
14:39sexpbot⟹ "foo"
14:39gfrlogvery good :)
14:39gfrlogthx
14:41gfrlogamalloy: I think all my problems just went away
14:41amalloyyou're just not looking closely enough. additional problems abound
14:41gfrlogif it's small, does it really exist?
14:42gfrlogman that's full of interpretations?
14:42gfrlogs/?//
14:48fliebeldevn: Still around? I was away all day. To bad about the seizure.
15:00devnfliebel: im here yes
15:00devnfliebel: (sort of) working remotely on some stuff in another terminal
15:02fliebeldevn: Okay, just that your website seems to be down, and that I am interested in the status of your baker. And while I'm asking questions anyway, could you shed some light on the defn/devn confusion?
15:12devnfliebel: ive moved to devn permanently
15:12devnfliebel: defn, although i used it before doing clojure, started to look a little fanboyish
15:12devnfliebel: and also, my twitter handle was devn, so there is some unity now in my handles
15:13devnfliebel: the status of my baker is...slow... im working with luke vanderhart on a templating library that i want to use, so what i have done so far is not very exciting
15:15fliebeldevn: What kind of templating? PHP style, or something exotic?
15:19carllercheWhat's the backing data structure for clojure's sorted set?
15:20fliebelcarllerche: Some sort of tree for sure… I think the sorted ones use something binary.
15:22devnfliebel: google closure templates
15:22devnfliebel: https://github.com/levand/scribe
15:24S11001001what should I call this? (fn [x & _] x)
15:24amalloycall it (comp first list)
15:25S11001001ick
15:25amalloycarllerche: red-black tree
15:25amalloyi think
15:25fliebelamalloy: The sorted ones?
15:25amalloyfliebel: yeah
15:26amalloyor at least, that's what java's is. i suppose there is probably some changes necessary to handle persistence
15:26fliebeloh, nice. But I was right about the binary tree:)
15:26amalloyfliebel: definitely
15:27gfrlog(defn (comp first list) [x & _] x)
15:28amalloyyeah, it's still red/black
15:28S11001001gfrlog: surely that only works with two-element lists whose firsts are 'setf
15:34gfrlog,(doc setf)
15:34clojurebotCool story bro.
15:43fliebeldevn: Oh, good luck with that. Not my taste of templating. I am of the opinion that if you want to invent mini languages (for a dynamic repl environment), you might as well write it in the language itself. Therefore I prefer systems like Genshi, Enlive or even whatever became of compojure.html.
15:45fliebelAh, Hiccup. I know it is terrible in a lot of ways, but I still love it.
15:50thorwilwhat are those terrible ways?
15:51brehautthorwil: it doesnt escape text by default
15:51fliebelthorwil: It becomes very unmanageable for larger projects I've been told.
15:52fliebelAnd while every list can be expressed as an xml structure, not every xml structure can be expressed beautifully as a list.
15:53thorwilah. so far i only stepped of enlive for a small snippet, where i simply used text to create tags
15:54fliebelthorwil: enlive != hiccup
15:54thorwilfliebel: yes, that one case just made me wonder if i should look into hiccup in addition
15:55fliebelthorwil: hiccup is for sure a lot less mind-bending than enlive for small snippets.
15:56thorwilmy mind will already never be the same again ^^
15:57thorwilthough i still havn't found out how to substitute the tags around desired content with enlive
16:07semperosthorwil: what do you mean by "around"? code example?
16:09thorwilsemperos: say i have <span>Previous</span> in my html template, and want to turn that into <a href="/foo">Previous</a> within an enlive html-snippet (depending on some condition)
16:10semperosunderstood
16:15thorwilgotta run, good night!
16:18mattmitchellsomeone wanna give me a hand with this? https://gist.github.com/955947
16:19semperosif thorwil had waited two more seconds...
16:19semperosnet.cgrand.enlive-html/substitute
16:19mattmitchelli'm close to whacking my head and going home if i can't figure this out! :(
16:22TouqenI think I'd just convert items into an actual tree datastructure, then figure out what I want to keep, and then re-flatten it
16:22semperosmattmitchell: could you explain the relationship between [1 2] and the other collection in your own words?
16:23semperosI see the result, but not sure I understand the exact relationship
16:23amalloysemperos: it's magic, duh
16:23mattmitchellsemperos: sure. the [1 2] are id values
16:23duncanmis there a way to tell lein uberjar to *not* clear out the lib directory?
16:23mattmitchellamalloy: and yes it's magic! :)
16:23duncanmi have a jar that i want to use, and i really don't want to go about putting it in my maven repo
16:23semperosamalloy: more in the line of my stupid questions :)
16:23amalloy$google lein disable implicit clean
16:23sexpbotFirst out of 413 results is: how to use a jar not in a repository or project.clj? lein jar ...
16:23mattmitchellsemperos: in otherwords... the [1 2] match the one of the :id values
16:23sexpbothttp://groups.google.com/group/leiningen/browse_thread/thread/6cee060588793e97
16:24semperosmattmitchell: ok, they correspond to the :id values
16:24amalloysrsly mattmitchell you're conflating too many concepts. separate out the "collapse parents and children" step from the "filter out IDs" step, i think
16:24mattmitchellsemperos: yes exactly
16:24semperosduncanm: if you have the source, you can put it in the "checkouts" folder of your project layout, and leiningen will treat that like a jar
16:25mattmitchellamalloy: i'm not sure what you mean (sorry)
16:25duncanmit's a java project from netbeans, with its own dependencies
16:25duncanmsemperos: so it's not that simple
16:25semperosit's not up in any repo?
16:25manuttermattmitchell: I just tried (into {} (map (juxt :id identity) items)) and got some results that might interest you
16:25duncanmsigh
16:25amalloymattmitchell: you want (magic-fn) to not only combine multiple entities into one, but also filter out entities that don't meet some criteria
16:26semperosduncanm: sorry if these are repeat questions
16:26amalloyif you separate this enormous task into smaller tasks it will be easier to work with
16:26duncanmsemperos: nah, i have it locally
16:26mattmitchellamalloy: i see what you mean, i will try to think of it that way
16:26mattmitchellmanutter: awesome i'll see what that does!
16:26amalloymanutter: isn't that clojure.set/index?
16:26amalloy&(doc clojure.set/index)
16:26sexpbot⟹ "([xrel ks]); Returns a map of the distinct values of ks in the xrel mapped to a set of the maps in xrel with the corresponding values of ks."
16:27amalloynot that i can ever read the #$% docs for clojure.set
16:27manutteramalloy: Is it? I'm such a noob!
16:27semperosduncanm: worst case scenario, you can always copy and paste whatever jars you need into your project's lib folder :)
16:27duncanmsemperos: that's what i'm doing, and if i run uberjar, it first cleans up the lib folder
16:27semperosyep
16:27semperosit sure does
16:27duncanmand so it doesn't work ;-(
16:27duncanmi was hoping there's a no cleanup flag
16:28manutterduncanm: wonder if you could make a separate lein project consisting only of the dependencies, "lein jar" that, and then use the result in your real project?
16:28manutteror lein install it
16:28mattmitchellamalloy: aye, could you give me an example of what you mean by separating things a bit?
16:28duncanmmanutter: still have to put it somewhere
16:28duncanmoh, maybe i can just lein install my java jar
16:28duncanmhmm
16:28duncanmsigh
16:29mattmitchellamalloy: you mean, for example a fn for only applying the parent code? and then another for attaching the parent items?
16:29duncanmi'm actually porting this clojure code from NetBeans/Ant to lein
16:29duncanmmaybe i should just go back to ant, sucky as it may be
16:30raekduncanm: you can put :disable-deps-clean false in your project.clj
16:30amalloy(defn find-parent-of [all-data the-element] (first (filter (comp #{(:parent_id the-element)} :id) all-data)))) or something
16:30duncanmraek: oh?
16:30duncanmnice!
16:30duncanmraek: false, or true?
16:31semperosdoh
16:31semperosI just found that in the source too :)
16:31semperosit's actually part of leiningen's project.clj
16:31semperoschecks for it here: https://github.com/technomancy/leiningen/blob/master/src/leiningen/uberjar.clj#L74
16:31raekhttps://github.com/technomancy/leiningen/blob/master/sample.project.clj
16:32raekI think this file contains all leiningen core options
16:34duncanmdoesn't seem to work, that option
16:34duncanmlein deps still clears the directory
16:35raekduncanm: which lein version are you using?
16:35duncanmLeiningen 1.4.2 on Java 1.6.0_24 Java HotSpot(TM) 64-Bit Server VM
16:35carllerchecan leiningen compile java classes as well (If I want a very simple java class?)
16:36carllercheoops, i should have RTFM closer :( sorry
16:36duncanmraek: i upgraded to 1.5.2
16:36raekduncanm: current stable version is 1.5.2. maybe this was added recently
16:37duncanmokay
16:37duncanmraek: yeah, upgrading worked
16:37duncanmthanks
16:37raekcarllerche: yes, if you set :java-source-path "src" in your project.clj, .java files in src/ will be compiled too
16:38raekyou can trigger the compilation with "lein javac", I think
16:38carllerchethanks
16:38semperosduncanm: did you set it to true or false?
16:38raek(this happens automatically when you do lein jar)
16:38duncanmsemperos: true
16:38semperosk
16:39raekoh, I accidentally inverted that one... sorry! :)
16:41semperosno worries, I didn't see that duncanm needed to upgrade his leiningen version
16:41semperosbefore I asked that question
16:43devnfliebel: link me to genshi?
16:43fliebeldevn: Not Clojure: http://genshi.edgewall.org/
16:44fliebeldevn: Basically, the template language is written with xml attributes.
16:50duncanmis there a way to declare required arguments using clojure.contrib.command-line?
16:55S11001001duncanm: make the default expr throw?
17:08devnfliebel: im sort of inclined to continue with my ridiculous idea i had awhile back
17:08fliebeldevn: Which one?
17:09devnfliebel: the idea of making each template its own ns
17:09devnor dynamically name a template based on its namespace or something like that
17:09devni have code...somewhere
17:09fliebeldevn: This is with the closure thing?
17:09devnnah, that's different
17:10devnGoogle Closure templates are a good fit for clojure because they're composable
17:10devnor...they will be
17:10devnwhen we're done with them
17:11fliebelthat sound cool, although I still don't like the mini language these templates invent.
17:11fliebeldevn: So what's with the namespaces? You want to (use 'template)?
17:11devnfliebel: im trying to remember now! :)
17:12devnfliebel: the idea was you write some piece collection of template pieces in different namespaces
17:13devnerr some collection of template pieces in a namespace
17:13devnso doctype, etc. falls under a namespace, and then you would mix in at a lower namespace
17:13xianHi, I installed slime, slime-repl and clojure-mode via ELPA (I am using the Emacs Starter Kit) on Emacs 23.2.1 and installed swank-clojure via leiningen. Slime and swank seem to work generally, but when executing C-c C-c (slime-compile-defun), I get a "no such namespace" error (details: http://pastebin.com/brsZ0pns).
17:14hugodxian, compile the file (C-c C-k) at least once to define the namespace
17:15devnor C-x C-e at the end of the (ns)| macro
17:15xianhugod: Compiling the file works, but unfortunately I get the same error again when calling slime-compile-defun.
17:16devnfliebel: really all i want it haml but with the ability to use clojure inside of it
17:16devns/it/is
17:16sexpbot<devn> fliebel: really all i want is haml but wish the abilisy to use clojure inside of is
17:16fliebeldevn: Sounds fun. I need to sleep now though. See you later. You might want to check these: http://thinkslate.com/ http://code.google.com/p/molehil/ https://github.com/nakkaya/static
17:16hugodxian, then slime has failed to parse the namespace declaration
17:17devnfliebel: why thinkslate? :)
17:17fliebeldevn: Because that seems to be your website, and it also seems to be down.
17:17devn:D
17:17xianhugod: I'm probably too much of a clojure noob, but I don't even have an explicit namespace declaration in my source file, just a single defun.
17:17devnfliebel: im migrating that domain to google apps
17:18devnfliebel: but yes you're quite right
17:18xianOh I mean defn of course, sorry.
17:18devni need to get my damned websites up
17:18devnxian: then you should be able to compile that into the user namespace
17:18fliebeldevn: Me too, that is why I'm doing bakers again :)
17:18devnfliebel: :)
17:18devngotta run, talk to you soon fliebel
17:18fliebelbye
17:19hugodxian, you need a (ns ...) form for C-c C-c to work
17:21raekxian: I think C-M-x work even without an ns form. it evaluates the topmost form that contains the point.
17:21xianAh all right. I just added (ns user) and it magically worked. Thank you both very much, hugod and devn, for helping a noob out.
17:21raek...but you should of course look into namespaces sooner or later
17:22raekthis is a great guide: http://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-ns
17:22xianraek: Yeah, I found out about that too, but I just like to use C-c C-c (it's quite easy to reach).
17:23xianI'm going to look into that, thanks.
19:29miwillhiteI'm brand new to clojure and trying to understand this:
19:29miwillhite(java.io.File. logs-path)
19:29miwillhitewhats with that dot after File
19:30brehautmiwillhite: it treats it as a constructor
19:30brehautotherwise java.io.File is a reference to the class
19:30miwillhiteso thats like instantiating a new File object?
19:30brehautthats exactly what it is
19:30miwillhiteand the dot triggers that?
19:30brehautyes
19:30miwillhitegreat, thank you
19:30miwillhiteis that a clojurism?
19:31brehautyes
19:31brehaut(java.net.URL. "http://example.com&quot;)
19:31brehaut,(java.net.URL. "http://example.com/&quot;)
19:31clojurebot#<URL http://example.com/&gt;
19:31miwillhiteah wow, cool
19:31brehauttheres also an older form you might enocunter in the wild
19:31brehaut,(new java.net.URL "http://example.com/&quot;)
19:31clojurebot#<URL http://example.com/&gt;
19:31miwillhitethe comma
19:32miwillhite?
19:32miwillhiteoh the 'new'
19:32miwillhitenm
19:32miwillhitewhats the comma do?
19:32brehautthe comma tells clojurebot to eval the sexp
19:32miwillhiteoh haha
19:33miwillhitewell thanks a lot
19:33miwillhiteI've found this room to be very helpful when I have questions
19:33brehautlikewise
19:34pdkyeah
19:34pdkwe've found you very helpful too like brehaut said :)
19:35brehauthaha
20:00lawfulfalafelI am trying to test code in the clojure repl and I keep getting classpath errors
20:00lawfulfalafelsuch as:
20:00lawfulfalafeljava.io.FileNotFoundException: Could not locate clojure/contrib/duck_streams__init.class or clojure/contrib/duck_streams.clj on classpath: (NO_SOURCE_FILE:0)
20:01lawfulfalafelI've tried creating a .clojure file that points to /usr/share/java/clojure-contrib.jar
20:01amalloy$google getting started with clojure raynes
20:01sexpbotFirst out of 72 results is: An indirect guide to getting started with Clojure » Bathroom ...
20:01sexpbothttp://blog.raynes.me/%3Fp%3D48
20:01amalloyargh. i always forget that url is broken
20:01amalloyhttp://blog.raynes.me/?p=48
20:02amalloylawfulfalafel: long story short, use lein or cake. even for teeny tiny one-file "projects", having a build tool makes your life easier
20:03miwillhiteAnother question if you don't mind…can someone explain the [x# ~x] in the snippet below?:
20:03miwillhite(defmacro dbg[x] `(let [x# ~x] (println "dbg:" '~x "=" x#) x#))
20:03miwillhiteI don't understand what the # does
20:03miwillhiteor the ~
20:04Somelauw# makes an anynomous function with implicit parameter %
20:04miwillhiteI've read that the ~ "unquotes", but I'm not sure I understand that either
20:04lawfulfalafelamalloy: really? I have never used one of those before, so it's hard for me to imagine the benefits
20:04lawfulfalafelwhich one would you reccomend?
20:05SomelauwBut I don't understand how it is used there either.
20:06miwillhiteSomelauw, I've seen #() as an anon function
20:06SomelauwI think it is just a regular variable.
20:06miwillhitebut never after a variable
20:06Somelauwwith a symbol in its name
20:06Somelauwso x# is the variable name
20:06miwillhiteah, I think you are right
20:06miwillhitethats weird
20:07technomancy,`x#
20:07clojurebotx__1650__auto__
20:07technomancygenerates a unique symbol to prevent accidental variable capture in a macro
20:10amalloyi've used cake for quite a while but i think i have to recommend lein
20:11miwillhiteuser=> `(1 2 (list 3 4))
20:11miwillhite(1 2 (clojure.core/list 3 4))
20:11miwillhiteuser=> `(1 2 ~(list 3 4))
20:11miwillhite(1 2 (3 4))
20:11miwillhiteuser=> `(1 2 ~@(list 3 4))
20:11miwillhite(1 2 3 4)
20:11miwillhitethat makes sense
20:11miwillhitelooking at unquote
20:36lawfulfalafelsorry, but how does one add the lein self-install bin to bash?
20:37lawfulfalafelI am trying to be able to do the "lein new blah" command
20:37technomancylawfulfalafel: just put it anywhere on your $PATH. /usr/local/bin/lein if you like
20:40lawfulfalafeltechnomancy: thank you
20:41technomancynp
20:52joshua__Ouch. It seems I don't have a summer internship =/ I'm a little surprised I didn't even get a phone interview anywhere.
21:41amalloyjoshua__: come work on 4clojure! nobody will pay you a cent but you can tell people you worked on 4clojure
23:24bhenryis anybody using this? https://github.com/overtone/live-coding-emacs
23:26bhenrythere is a rather annoying "feature" that shows lambdas and f(expr) notations. http://i.imgur.com/MvOHU.png
23:26bhenryi'd like to know where in .emacs.d i have to go to turn it off.
23:32tomojgrep -r λ .
23:44bhenrytomoj thank you. i couldn't figure out how to search the contents of .el files.
23:56amalloyfind -name '*.el' | xargs grep whatever
23:56amalloywould be a little more fine-grained