#clojure logs

2011-06-11

05:34no_mindis there a function to escape string before insertion in DB ?
05:35Vinzentno_mind, there is escape-html (and its alias h) in hiccup
06:34mduerksenhow could i do this more elegant: (-> 1 inc ((fn[x] (* x x))) ? i want to assign a name to some intermediate value during the processing of ->
06:35mduerksenbut i don't like the ((
06:52void_mduerksen: at least use short anonymous function: #( ... % ... )
07:20Cozeyhow to check if a symbol is a name of a java class imported to the namespace?
07:26tomojthis seems to work? ##(class? (resolve 'Math))
07:26sexpbotjava.lang.SecurityException: You tripped the alarm! resolve is bad!
07:26tomojright..
07:27tomojwell..
07:28tomoj(class? (resolve 'foo.bar.Baz)) will return true even if Baz isn't imported
07:30fliebelI'm looking to play with a GraphDB in Clojure and found tons of Neo4j wrappers. This one seems to be the most recent, but I wonder what you think about the rationale: https://github.com/wagjo/borneo#readme
07:42Cozeytomoj: thanks, will check this out
07:52Dranikhello guys!
07:52DranikI have published a small tutorial on how to develop a simple blog using clojure
07:53Dranikit is located here: https://github.com/dbushenko/ClojureBlog
08:05VinzentDranik, looks good, you should consider posting it on the google group
08:07Vinzentbtw, I'd rewrite map->soy function in this way: ##(into {} (for [[k v] {:a 1 :b 2}] [(name k) v]))
08:07sexpbot⟹ {"a" 1, "b" 2}
08:25hoeck$mail mduerksen (->> 1 inc (repeat 2) (apply *))
08:25sexpbotMessage saved.
09:35kephale,(clojure.set/map-invert {1 2, 3 2})
09:35clojurebot{2 3}
09:35kephale: X is there an elegant way to do something like merge-with but map-invert
09:36kephaleoh nvm… always look at the source on the API docs… map-invert is super concise anyway. I'll just write a custom fn
10:24fliebelOh noes! I'm coding some Python project, and I'm stuck in-between Java and Clojure for the design. Cognitive dissonance everywhere.
10:52VinzentWhat's the best way to split collection into two, where the first will contain elements for those predicate returns true, and the second - all others?
10:53halfprogrammer,(group-by even? (range 10))
10:53clojurebot{true [0 2 4 6 8], false [1 3 5 7 9]}
10:54halfprogrammerVinzent: think you are looking for group-by
10:54Vinzenthalfprogrammer, yes, thanks!
10:59ScorchinHow can I pass a function to be run multiple times? Currently I'm looking at something like this, but it's not working: (defn times [n op] (for [i (range n)] (op))) and it's being called as (times 5 (println "hello")) which only prints "hello" once
11:00VinzentScorchin, you should use doseq for side effects
11:00ScorchinI think the issue is that the (println "hello") is evaluated before it's passed in, but how do I stop it being evaluated?
11:01ScorchinVinzent: thanks, I'll look into it
11:02VinzentScorchin, and you should wrap println call in the function, e.g. #(println "hello")
11:02Vinzentalso, there is built-in dotimes macro that do exactly what you want
11:06ScorchinVinzent: yeah, just saw (dotimes) when looking for doseq
11:14shish_kabob,(find-doc "doseq")
11:14clojurebot-------------------------
11:14clojurebotclojure.pprint/get-pretty-writer
11:14clojurebot([writer])
11:14clojurebot Returns the java.io.Writer passed in wrapped in a pretty writer proxy, unless it's
11:14clojurebotalready a pretty writer. Generally, it is unneccesary to call this function, since pprint,
11:14clojurebotwrite, and cl-format all call it if they need to. However if you want the state to be
11:14clojurebotpreserved across calls, you will want to wrap them with this.
11:15clojurebotFo...
11:15shish_kabob,(find-doc "dotimes")
11:15clojurebot-------------------------
11:15clojurebotclojure.core/dotimes
11:15clojurebot([bindings & body])
11:15clojurebotMacro
11:15clojurebot bindings => name n
11:15clojurebot Repeatedly executes body (presumably for side-effects) with name
11:15clojurebot bound to integers from 0 through n-1.
11:56edoloughlinHow do I reference a locally-built JAR in Leiningen's project.clj? Webbit's clojar.org JAR dates from Feb...
11:59mefestoedoloughlin: you could use maven to install a jar into your local repository using the install:install-file target
11:59edoloughlinmefesto: Thanks, I'll try that. Would be nice if I could just point leiningen at my filesystem, though...
11:59mefestoedoloughlin: http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html
12:00mefestoI agree, or at least a leiningen install task
12:01mefestothis would be awesome: lein install some.jar [com.test/some "1.0.0"]
12:01Scorchinedoloughlin: you can grab the latest webbit jars here: http://oss.sonatype.org/content/repositories/public/org/webbitserver/webbit/
12:02Vinzentedoloughlin, also, you can just put it in the lib folder and all should works
12:02edoloughlinScorchin: Thanks. I've no problem building it locally. I would just like to be able to point Leiningen at it.
12:03edoloughlinVinzent: I'll give that a go!
12:03mefestooh that sounds handy
12:06Vinzentcan I clear the cache of memoized function somehow or should I use my own implementation for that?
12:07mefestoedoloughlin: looks like calling `lein deps` will clear out any jar that isn't listed in the project.clj
12:08Vinzentmefesto, there is some parameter in project.clj that prevents such behaviour
12:10mefestoVinzent: ahh ok: https://github.com/technomancy/leiningen/blob/stable/sample.project.clj#L54
12:10parasebamefesto: in fact, there is an install task in leiningen, and a native-path key in project.clj (at least in dev versions)
12:12mefestoparaseba: that can be used for installing a local jar file? i thought that was only for building and installing the current project into your local repo
12:13parasebamefesto: hum, I think you're right
12:14mefestoi tend to use mvn install:install-file so i don't have to keep any jars in version control, plus it's nice to have your deps listed in one place (project.clj)
12:23raekedoloughlin: which lib is it? are you sure it isn't in the maven central? (search at http://jarvana.com/)
12:26raekit has been my experience that often when a person wants to point leiningen to a jar file they are just not aware of that there are more repos than clojars :-)
12:53void_hello
12:53void_&(reduce (fn [x y] (+ x y)) [1 2 3 4])
12:53sexpbot⟹ 10
12:53void_&(reduce #((+ %1 %2)) [1 2 3 4])
12:53sexpbotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
12:53void_I want to write shorter anonymous function but it looks like I'm doing something wrong
12:54void_hmm and this works
12:54void_&(reduce #(+ %1 %2) coll)
12:54sexpbotjava.lang.Exception: Unable to resolve symbol: coll in this context
12:54void_&(reduce #(+ %1 %2) [1 2 3 4])
12:54sexpbot⟹ 10
12:57raekvoid_: ##(reduce + [1 2 3 4])
12:57sexpbot⟹ 10
12:57void_I love clojure
12:57void_thanks raek
12:58void_&(reduce + [1 2 3 4])
12:58sexpbot⟹ 10
12:58void_of course
12:58void_+ is a function that takes two arguments
12:58void_I can pass it directly to reduce
12:58raekvoid_: #((+ %1 %2)) is equivalent to (fn [x y] ((+ x y))). if you call the function with 1 and 2, you get ((+ 1 2)) -> (3) -> error
12:58raeksince 3 is not a function
13:01raekvoid_: and yes, functional programming rocks! :-)
13:04void_when I was 14 I learned about this operator in PHP: boolean ? something : something-else. It felt awesome. Learning Clojure, I have those moments every hour or so. :))
13:07ohpauleezclojurebot: ping
13:07clojurebotPONG!
13:07void_oh and this is cool: https://github.com/abedra/clojure-web
13:20s450r1any other clojure users at the SouthEast Linuxfest in Spartanburg, SC?
13:21midsvoid_: ah, thanks for that link
13:21s450r1I'd love to say hi if there are. I'm wondering around in a Clojure Conf t-shirt.
13:21s450r1well, wandering and wondering
13:30TimMcRecommendations on a relational database to use from Clojure?
13:30raekvoid_: note that the compojure version used there is not the latest. the compojure syntax has changed, so check the version if you find examples that don't seem to work
13:31void_TimMc: I'm enjoying working with MongoDB altough that is not exactly a relational database.
13:31void_but it works nicely with clojure, perhaps because its schemalessness
13:31void_*because of its ...
13:31raekthese kind of examples are really useful in a modularized world like clojure web programming
13:31mefestoTimMc: postgresql is quite a nice rdbms
13:31TimMcNot interested in document-oriented.
13:31TimMcmefesto: How is it with unit-testing?
13:32TimMcOr automated testing in general, really.
13:32mefestoTimMc: depends on your approach, we use the tx rollback approach
13:32TimMcSQLite seems to work really well for that, and that's what I've been using from Python.
13:32raekTimMc: I recommend checking out ClojureQL. (it is a library for using SQL, and not a database though)
13:33TimMcmefesto: How's that now?
13:34mefestoTimMc: you run your tests which modify the db in a transaction. after asserting your values the db is rolled back so you don't have to constantly refresh the data across test runs
13:35TimMcOK, sounds about right.
13:36TimMcIt's not quite appropriate for my purposes, but I'll keep that in mind.
13:36TimMcMy program takes an initial database and runs it through a sequence of modifications, which is a little different.
13:37TimMcThe schema actually changes in the process.
13:38TimMc...and now that I've put it that way, maybe I should be doing this all in memory anyway. >_<
13:39mefestowhen in production do you expect heavy load for this app?
13:40mefestoif so, mysql and postgres have memory tables that could be handy for local testing. then when deployed the schema uses innodb or normal tables
13:40TimMcI don't expect anything over 100,000 entries.
13:40mefestosqlite probably good enough then
13:42mefestoall this coming from someone that doesn't really know what your app is ... so ;)
13:44TimMcIt publishes a KPhotoAlbum database as an online gallery.
13:45mefestoout of curiousity, why does it need to change the schema?
13:46TimMcSpecifically, it reads a KPhotoAlbum database (metadata in an XML file) and discovers new/changed/moved/deleted files, reflects those changes into a database, a thumbnails directory, and a symlinks folder, munges the metadata (mostly taking the transitive closure of a tag DAG), syncs the symlinked images and thumbnails to Amazon S3, and overwrites the remote DB with the local one.
13:47TimMcmefesto: It might not need to change the schema, but I haven't really touched this code in 3+ years and there were some tricky little challenges I discovered while writing it.
13:48TimMcIn any event, the different steps of the process expect different assertions to hold true about the relationships in the DB.
13:50mefestoWith that said, would transactions be pretty important for this functionality?
13:51mefestoif so, then schema changes might not fit well. afaik, schema changes cannot be rolled back
13:54TimMcI'll have to ponder this for a bit.
14:08void_compojure sets encoding to iso-8859-1 by default
14:08void_~/Desktop $ curl -i http://127.0.0.1:3000/new
14:08void_HTTP/1.1 200 OK
14:08void_Date: Sat, 11 Jun 2011 17:41:14 GMT
14:08clojurebotI think you mean gnir.
14:08void_or jetty sets it
14:09void_anyway does anybody know how to change it to utf8?
14:21bortrebthis is rather basic I'm sure, but I can't seem to find it anywhere --- how do you robustly sanitize a String to give a valid filename for your platform?
14:22bortrebfor example, remove all "/" for linux, remove all ":" , etc for windows and replace "com" and "ptr" with something valid?
14:24TimMcbortreb: You want to convert a user-supplied filename to a valid system filename without yelling at them over invalid characters?
14:25raekvoid_: yes: add a charset attribute in the content type: "Content-Type" "text/html; charset=UTF-8"
14:25void_raek: so I have to do that for each route?
14:26raekvoid_: the servlet spec says that a servlet container must add ISO-8859-1 as the charset if it's missing :(
14:26TimMcew
14:26void_meh
14:26raekvoid_: no, add it to the response of the routing
14:26raekif all branches produce html
14:27raekvoid_: it's easy to do a middleware function for it
14:28bortrebTimMc: yeah, although they're not human supplied strings. I;m downloading many files from a website and trying to give them meaningful names by grabbing text from the same page as the file
14:28bortrebTimMc: so I just want the equivalent of HTML escaping for system filenames
14:29raek(defn wrap-utf8-html [handler] (fn [request] (let [response (handler request), content-type (get-in response [:headers "Content-Type"])] (if content-type response (assoc-in response [:headers "Content-Type"])))))
14:29Dranikvoid_, hi !
14:29TimMcThat's a good question!
14:29void_hi Dranik
14:29DranikI have published my blog to github
14:29void_awesome, paste link please
14:29hiredmanbortreb: http://download.oracle.com/javase/1.5.0/docs/api/java/net/URLEncoder.html
14:29Dranikit's here: https://github.com/dbushenko/ClojureBlog
14:29DranikI have supplied lots of comments
14:29Dranikmay be you'll find it usefull
14:30raekvoid_: or use (ring.util.response/content-type "text/html; charset=UTF-8") if you unconditionally want html
14:30TimMchiredman: THat doesn't protect from com1.txt, etc.
14:30void_raek: where should I put that snippet?
14:31TimMcWindows is disgusting that way.
14:33raekvoid_: sorry, the last example cannot be called like that. if you routes (more generally called a handler) is called 'handler', and the middlware function is called wrap-foo you get a handler wrapped in the middleware by calling (wrap-foo handler)
14:33bortrebTimMc: , hiredman: yeah, this would work for the linux box I'm working on, but I figure its a common enough problem that there's some apache library or something that handles all the edge cases
14:34void_raek: ok, well, I think I'm gonna look into some examples of using middlewares. Thanks!
14:35raekvoid_: I haven't used compojure for a while, but moustache (another routing library) has built in syntax for it: (app wrap-foo wrap-bar ["foo"] {:get get-foo} ["bar"] {:get get-bar, :post post.bar})
14:36raekit = adding middleware
14:36raekthe more manual way of doing it is (def handler ...) (def handler (-> handler wrap-bar wrap-foo)) ;; note the order
14:38void_yeah it's pretty simple in compojure too
14:38void_there's a function that creates handler from routes
14:38void_and I can add wrappers to handler
14:38void_I think .. :)
14:39raekvoid_: it's probably a good idea do make a function like this and use it in your handler: (use 'ring-util.response) (defn html-sucess [body] (-> body (response) (content-type "text/html; charset=UTF-8")))
14:39raekrather than making a middleware function that fills it in later
14:39void_raek: yes that seems like the best way. Altough, I was hoping utf8 would be question of changing some config setting :-/
14:40raekso yes, you do it for every route, but factor out the common parts
14:41void_Dranik: didn't you have to deal with utf8 encoding when building your blog?
14:41Draniklet me check it out..
14:42void_I'm asking because Azbuka probably requires utf8 :)
14:42Kratossthis might sound weird
14:42raekcyrillic?
14:43Kratossbut is there some kind of limitation on clojure sets and numbers
14:43Kratossthey don;t work for me
14:43raekKratoss: can you show an example?
14:43Kratoss,((into #{} [1 2 3]) 3)
14:43clojurebot3
14:43Kratosshm...
14:43void_raek: yeah, I thought Dranik had to deal with that, but maybe he built it in English so he didn't notice
14:44Kratosslet's say I have "sieve" function that returns a vector of primes
14:45Kratoss(def prime? (into #{} (sieve 100)))
14:45Kratoss(prime? 2) returns nil
14:45Kratossbut if I operate with strings it works fine
14:45raekstrings?
14:45Kratossyeah
14:46Kratoss(def prime? (into #{} (map str (sieve 100))))
14:46Kratossuser> (prime? "2")
14:46Kratoss"2"
14:46Kratossbut above example with numbers returns nil
14:46raekKratoss: are you interoping with Java? there is a problem with different types of boxed numbers (Integeres and Shorts aren't equal)
14:47raekKratoss: first, if you look at the set in the repl, does it contain 2?
14:47Dranikunfortunatelly, I haven't dealt with unicode...
14:47Kratossthey are java.lang.Long
14:47Kratossaccording to class fn
14:47Kratossyes the set contains numbers just fine
14:48Kratossit's confusing as hell
14:48raekah, so there is the problem. the set contains longs and you try to check for an integer
14:48raekthis issue has been worked in the 1.3 version of Clojure
14:48raekwhere does the longs come from?
14:48Kratossthe sieve function
14:49Kratossah, I just add the cast and we are good to go
14:50raekKratoss: one fix could be to do (def prime? (comp (into #{} (map long (sieve 100))) long))
14:50TimMcKratoss: Now just hope you don't get into BigInteger. :-)
14:50Kratossweird though, that clojure sets treat numbers differently
14:50Kratossbased on type
14:50raekbut in clojure 1.2, I think you should get Integers if the numbers fit in them
14:50Kratossyou know.... since it does hidden type changing through autopromoting
14:50raekKratoss: that's a problem inherited from Java
14:50TimMcKratoss: Blame Java for hashing numbers weirdly.
14:51TimMc,(.hashCode (int 4))
14:51clojurebot4
14:51TimMc,(.hashCode (long 4))
14:51clojurebot4
14:51TimMcWell, not that one.
14:51Kratossyou got told :P
14:51TimMcI shore did. :-?
14:51TimMccan't type today either.
14:51raekKratoss: but in Clojure 1.3 all boxed integer numbers are Longs and float numbers Doubles
14:51hiredman(.hashCode (Long. (long 1)))
14:51hiredman,(.hashCode (Long. (long 1)))
14:51clojurebot1
14:51hiredmanhuh
14:51hiredmanmaybe it is bigints that hash weird
14:52hiredmanyeah
14:52Kratossyou probably need to exceed the mod number in hash function
14:52Kratossto get any real effect
14:52hiredman,(.hashCode 1M)
14:52clojurebot31
14:52hiredmanthere
14:52hiredman^- nuts
14:52Kratoss,(.hashCode (long 100))
14:52clojurebot100
14:52hiredmancuckoo for cocoa puffs
14:52Kratosswell BigDecimal isn't just the number
14:53Kratossbut also magnitude and precision
14:53Kratoss2.00000 is not equal to 2.0
14:53Kratosslook at bigdecimal javadoc
14:53hiredman,(class 1M)
14:53clojurebotjava.math.BigDecimal
14:53Kratossso hashcode has to reflect that
14:54hiredmanhuh
14:54hiredmanI thought 1M was a biginteger
14:55hiredmananyway, at some point biginteger hashes different and does equality different from longs
14:56hiredmanwhich breaks things, and is why clojure has clojure.lang.BigInt
14:58void_I'm giving up on utf8, looks like the solution is not so easy: http://groups.google.com/group/ring-clojure/browse_thread/thread/b2c7cd4c9e045d6/70e622f6ce9b166e?lnk=gst&amp;q=encoding#70e622f6ce9b166e
15:02raekvoid_: didn't setting the header in the response work?
15:03void_raek: no
15:03void_this guys explains: "If you set only the content-type to "text/html; charset=utf-8", jetty
15:03void_will still encode the response to iso-8859-1. "
15:04void_I understand you have to call method on Java class, but Ring doesn't have any way to do it
15:04raekhrm. if the body is an InputStream, no recoding should be done
15:04void_well I'm using hiccup
15:04raekvoid_: what kind of body do you have in the response? a string?
15:04void_let me try just put a string in there
15:05raekiirc, hiccup will return a string
15:05raeksomewhere the string needs to be encoded into a byte stream (InputStream)
15:07void_so yeah, server is returning correct header, but characters are still messed up
15:07raekhttps://github.com/mmcgrana/ring/blob/master/ring-servlet/src/ring/util/servlet.clj#L72
15:08raekok, so the servlet container has a writer that is configured for some random encoding...
15:08raekugh. what a mess.
15:08void_yeah
15:09void_I wish there was utf8 by default
15:09TimMc,(map #(.hashCode %) ((juxt int long) -5))
15:09clojurebot(-5 4)
15:09void_it's 2011 :-/
15:10raekvoid_: at least the clojure file I/O (clojure.java.io) defaults to UTF-8...
15:10TimMcKratoss: Negative integers seem to hash differently as long vs. int.
15:12raekvoid_: what does `echo $LANG` return on your computer?
15:12void_sk_SK.UTF-8
15:13TimMcSKotland!
15:13void_:D
15:13void_no
15:13TimMcSweden?
15:13void_nope
15:13void_http://en.wikipedia.org/wiki/Slovakia
15:13TimMcSlovakia, says Google.
15:13TimMcCool.
15:13fliebelSweden??
15:14TimMcRight, Sweden is .se.
15:14TimMcfliebel: Do you highlight on that?
15:14raekSweden? no. we have sv_SE
15:14fliebelTimMc: No, just joined, wondered what it's about.
15:14antares_hi. Can someone tell me what the clojure.data.xml artifact line for leiningen is?
15:15antares_that project doesn't even have a README
15:15fliebel~logs
15:15clojurebotlogs is http://clojure-log.n01se.net/
15:16fliebelLogs should be real-time :(
15:16antares_anyone?
15:16clojurebotPlease 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.
15:17fliebelantares_: Look in the pom.
15:17TimMcfliebel: void_'s OS uses sk_SK.UTF-8 as $LANG
15:17antares_fliebel: what if I am not experienced with reading .pom files?
15:18hiredmanI'd suggest you complain on the clojure mailing list
15:19hiredmancontrib is very maven heavy while most of the clojure world uses project.clj based tools
15:21antares_hiredman: not sure if you are talking to me but I have been trying to find any documentation on data.xml or any "new contrib" library artifact for lein. I am certainly quite stupid but man, 20 minutes and no results. data.xml doesn't even have a README.
15:22hiredmanright, so please bitch about it on the mailing list, squeaky wheel and all that
15:22antares_I guess I simple won't be using clojure for this app, it is very sad that contrib libraries are maintained/documented so poorly. Scala projects somehow have at least some information.
15:22antares_hiredman: why would I? I simply won't use clojure.
15:22fliebelantares_: Looking at the pom it's [org.clojure/data.xml "0.0.1-SNAPSHOT"] now, reverse-engineer and do it yourself next time ;)
15:22antares_fliebel: that doesn't work
15:23antares_that was the 1st thing I tried
15:23antares_leiningen fails to find this artifact
15:23antares_anyway
15:23void_oh I got it working this encoding
15:24void_ (java.io.ByteArrayInputStream. (.getBytes "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'></head><body>ľščťžýáí</body></html>" "UTF-8")))
15:24fliebelantares_: Don't fogert to add the snapshot repo. https://oss.sonatype.org/content/repositories/snapshots
15:24void_return that instead of a string
15:24antares_fliebel: also, "do it yourself next time" is exactly kind of attitude Clojure community cannot afford. It is too small.
15:24void_I found same discussion in logs http://clojure-log.n01se.net/date/2010-08-12.html
15:24fliebelantares_: Oh, it;s fine if you aks, but the point is that you *can* do it next time.
15:25fliebelantares_: Does my repo comment help anything?
15:26raekvoid_: nice. so it is at least possible to reliably work around the problem...
15:28fliebelwait... he left?
15:35CozeyHello. Is it just me, or does anybody else has problesms with getting [org.springframework.security/spring-security-adapters "2.0.4"]
15:35Cozey?
15:35Cozeyit's present in mvnrepository here http://mvnrepository.com/artifact/org.springframework.security/spring-security-adapters
15:35Cozeybut cake fails to download it, although it downloads many other deps....
15:49Kratossthe cake is a lie
15:49Kratoss*obvious*
15:50void_no way
15:50void_raek: The problem was that I used Content-type instead of Content-Type
15:50__name__Yay, Portal references \o/
15:52Cozey:-))
16:35raekanyone have a recommendation for a sqlite jdbc driver maven artifact?
16:38edoloughlin1raek: Thanks for the pointer to jarvana.org for webbit earlier. (Wasn't around when you replied)
16:39raekedoloughlin1: so my intuition was correct? (you needed a java lib not on clojars) :-)
16:45raekhrm. why do so many libs forget to mention what namespace you're supposed to use? :)
16:48edoloughlin1raek: Yes, you were right. However, it was on clojars but it was a version from Feb.
18:28TimMcraek: Urgh, I hate that. *checks own libs...*
18:41pdkdo type hints have to be class names or interfaces as well
18:48dnolenpdk: ?
18:49pdkin function arg lists
18:49pdklike (fn [^Serializable x] ...)
18:49pdk,(fn [^Serlializable x] x)
18:49clojurebot#<sandbox$eval761$fn__762 sandbox$eval761$fn__762@5043d6>
18:49pdk,((fn [^Serlializable x] x) 1)
18:49clojurebot1
18:50pdk,((fn [^Serializable x] x) 1)
18:50clojurebot1
18:50pdkhm
19:08technomancyhah; the only thing in the readme of data.xml is "this is not intended for use yet"
19:11technomancyno wonder he couldn't find it
19:29hvis there a release schedule or something for clojure 1.3?
19:30seancorfieldpdk: you were asking about type hints - they are for java interop; they don't cause casts per se
19:31seancorfieldso (fn [^Serializable x] ...) is only useful insofar as operations on x don't need reflection
19:31seancorfield,((fn [^long x] x) 1.23)
19:31clojurebot1.23
19:32seancorfield,((fn [x) (long x)) 1.23)
19:32clojurebotUnmatched delimiter: )
19:32seancorfield,((fn [x] (long x)) 1.23)
19:32clojurebot1
19:32seancorfieldhth
19:37mabesdoes clojure ship with a function that maps a list's elements into a map with the keys being the original value? Something like this:
19:37mabes,(let [vals->map (fn [f vals] (reduce (fn [m v] (assoc m v (f v))) {} vals))] (vals->map inc [1 2 3]))
19:37clojurebot{3 4, 2 3, 1 2}
19:38mabes(just wondering for future reference)
19:39raek,(let [coll [1 2 3]] (zipmap coll (map inc coll)))
19:39clojurebot{3 4, 2 3, 1 2}
19:39raek,(into {} (for [x [1 2 3]] [x (inc x)]))
19:39clojurebot{1 2, 2 3, 3 4}
19:40raek,(into {} (map (juxt identity inc) [1 2 3]))
19:40clojurebot{1 2, 2 3, 3 4}
19:41mudgehello
19:41mabesraek: nice, that is much shorter.. I always forget about juxt
19:42mudgeI am new to clojure and have studied it a little and would like to develop a website with it, does anybody recommend any web development tutorials?
19:42mudgelike the newest up-to-date?
19:44mabesmudge: I don't know of any new ones but here is nice one: http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html
19:45raekmudge: this is very good: http://brehaut.net/blog/2011/ring_introduction
19:46seancorfield+1 raek
19:46raekthe clojure web world consists of many libraries so it can be difficult to know what to look for and where
19:46mabeshadn't seen that one, nice resource
19:46raekthat tutorial walks you though the libs you need to know about
19:46seancorfieldi'm porting my FW/1 MVC framework to Clojure :)
19:46mudgegreat, thanks guys
19:47mudgehave you guys heard of any book being written for writing web apps in clojure?
19:47seancorfieldnot specifically for web apps, no
19:47seancorfieldmudge: are you near the bay area, CA?
19:47seancorfieldamit rathore (clojure in action) is running a one day clojure web app course for $199 on June 25th
19:48seancorfieldhttp://www.meetup.com/The-Bay-Area-Clojure-User-Group/events/19931761/
19:48mudgecool
19:48ampleyflyraek: what's wrong with the colors o.o
19:48mudgei am in florida
19:48brehautraek: thanks :)
19:49raekbrehaut: didn't the site used to be even more yellow?
19:49brehautit did
19:49brehauttoo many people complained so i toned it back a bit
19:49seancorfieldmudge: ah, a bit far to come then :)
19:49brehautall remaining complaints can be sent to /dev/null
19:50mudgehey brehaut, the overview of the clojure webstack is written by you. cool
19:50mudgereading it
19:51mudgecool, i like that it is recent
19:53brehautmudge: thanks
19:57mudgeah, the ring SPEC explains so much: https://github.com/mmcgrana/ring/blob/master/SPEC
19:57mudgei didn't understand the clojure web terminology before
20:09tufflaxIs there something like an opposite of interleave?
20:11pdk(doc interleave)
20:11clojurebot"([c1 c2] [c1 c2 & colls]); Returns a lazy seq of the first item in each coll, then the second etc."
20:11pdktake-nth?
20:12offby1unzip?
20:12clojurebotunzip-with is http://paste.lisp.org/display/76458,1/raw
20:12offby1untangle? demultiplex?
20:13mudgeI understand everything in the SPEC: https://github.com/mmcgrana/ring/blob/master/SPEC except for :headers near the bottom
20:13mudgeA Clojure map of HTTP header names to header values. These values may be
20:13mudge either Strings, in which case one name/value header will be sent in the
20:13mudge HTTP response, or a seq of Strings, in which case a name/value header will be
20:13mudge sent for each such String value.
20:14chouser{
20:14chouser{"Content-type" "text/html"}
20:15mudgewhat does this mean: "in which case one name/value header will be sent in the HTTP response" ?
20:15raekI think it means that {"Foo" "bar"} becomes "Foo: bar" and {"Foo" ["bar" "baz"]} becomes "Foo: bar\nFoo: baz"
20:17raekthis makes sense since a key can only occur once in a map. so if you need multiple values associated with the same key, you need something like this
20:17chouseris there a pull-parser included with Java 1.5? What about 1.4?
20:17tufflaxpdk, offby1 thanks
20:17mudgeraek, that makes sense, thanks
20:18mudgeraek:, i understand it now because of your help so thanks
20:20mudgebrehaut: your clojure web tutorial is very helpful
20:21mudgeI just read the SPEC and for the first time I understand what a Handler is
20:21raekbrehaut: XML-RPC looks ridiculous simple to use with necessary-evil. impressive!
20:23raekwait what? <dateTime.iso8601> in XML-RPC is not even ISO 8601?
20:26mudgewhat is a clojure form?
20:27raeknow don't tell me the ANSI Windows code page is not an ANSI standard! ;-)
20:28mudgeraek, I won't tell you that
20:28raekmudge: my interpretation of the word "form" is the generalization of: variable, special form, function application and macro "call"
20:29tomojthe form of a form may seem to be function application
20:29mudgeraek, ah okay, so it is anyone of those?
20:29mudgeand all of them
20:29tomojbut '(foo bar baz) is a form even if foo, bar, baz don't resolve
20:30raekthose are the different cases of a form
20:30tomojand how about '[foo bar baz]?
20:31raekmudge: these guys can explain it much better (and have more knowledge about this teminology) than I: http://stackoverflow.com/questions/2877371/definition-of-lisp-form
20:32tomojhuh, they say it must eval
20:33tomojbut "form" used e.g. in the -> docs can't be that kind of form
20:34mudgeraek, thanks once again
20:34raekafter reading that I would interpret a Clojure form to be a piece of data built of clojure data structures and values that is well-structured (follows the syntax rules of any occuring special forms and macros)
20:35raekessentially, clojure data that passed the compilator
20:35raekdata meaningful as a clojure code
20:36brehautraek: as far as i can tell yeah, that date format is some random not quite any iso format. it has been an infuriating spec to implement
20:40raekbrehaut: seems like everything is nicely abstracted away from the user at least ;-)
20:41raekbrehaut: btw, what is your personal preference for the reverse of the word "parse"?
20:43brehautraek: i dont know :) unparse seems awkward
20:44raekfinding good names is the hardest part of programming :)
20:45brehautand cache invalidation
20:46raekfor string/line-based protocols, I lean towards "format"
20:47raekdoesn't feel quite right when it's not primarily for human reading
20:47raekso the search goes on...
20:52brehautagreed
20:56tomojI like encode/decode
21:00kornyHi folks - any tips on how to bind vars when doing stuff on a separate thread, i.e. using send-off ?
21:00kornyI found http://clj-me.cgrand.net/2009/01/20/bindings-and-send/ but it's a couple of years ago - wondering if there's a better way
21:01jaochouser, i'm a bit late, i know, but nice talk on the expression problem!
21:02korny... my concern with that approach is that I'd need to explicitly name some bindings that are made by libraries outside my call to send-off, which seems like excessive coupling. (For example I'm spawning threads within a (with-oauth) context, don't really want to have to hunt down all the bindings set up by with-oauth)
21:03dnolenkorny: I believe in 1.3.0 bindings are automatically propagated.
21:03kornydnolen: cool. Currently using 1.2 - I could upgrade, but it might be painful (especially as I believe congomongo doesn't support 1.3 yet)
21:04dnolenkorny: yeah, I don't think this improvement will get backported.
21:04dnolen1.2.0 -> 1.3.0 is not that painful IME.
21:14chouserjao: oh, thanks!
21:15chousersounds like there will be approximately 10x the Clojureness at Strange Loop this year.
23:07seancorfielddarn, just noticed korny was asking about congomongo and clojure 1.3.0
23:07seancorfieldi just made congomongo compatible with 1.3.0 the other day!
23:08seancorfieldof course, like c.j.jdbc it relies on a global DB connection and binding so it isn't thread safe in 1.3.0 (as i understand it?)
23:11seancorfieldi assume that was kornelius sietsma / kornys on twitter?
23:11tomojis the thread safety issue with the so-called "binding conveyance"?
23:12seancorfieldso i've been told... dynamic vars in 1.3.0 span threads so rebinding them is not thread safe
23:13seancorfieldif you only have one DB connection, it's fine i guess
23:13seancorfieldbut (with-whatever conn body) usually rebinds a global *conn* var so if conn differs across threads, that would be bad :)
23:14seancorfieldi haven't verified that - just what i've been told...
23:24tomojI wonder if the only way they span threads is through agent sends
23:34carllercheis it crazy to write a macro that looks arbitrarily deep for specific forms?
23:35pdkif it does the job
23:36pdkhell i found some year old code
23:36pdklooked at the macro i wrote at the top
23:36carllerchethe alternative would be to make multiple macros i guess
23:36pdkand just went "wtf does this even do"
23:41tomojcarllerche: sounds like clojure.walk may help?
23:42carllerchehuh, interesting
23:46tomojI think e.g. lamina uses that to rewrite stuff for async arbitrarily deeply