#clojure logs

2012-04-05

00:01dnolenjonasen: I'm not sure if there's a good general solution for that, definitely one to ask around about.
00:04dnolenjonasen: perhaps one way is to just handle all cases of ground not ground - https://gist.github.com/2307725
00:07unlinkeggsby: ah. yeah, I've never had much luck with OpenJDK myself.
00:08treehugunlink: our prod systems are openjdk-6. no problems encountered except in an old version of c3p0 that assumed the java.version property would not have "iced tea" in it
00:18rlbWhat's currently the best way to launch and communicate with a (long-running) subprocess? i.e. I'd like to just end up with a writer I can print to when necessary.
00:20Raynesrlb: https://github.com/Raynes/conch
00:20Raynestoot toot
00:21rlbRaynes: thx
00:29wei_I'm trying to write a leaky-filter function- filter unless 3 items don't match the filter, in which case return the next thing. e.g.: (leaky-filter nil? [nil 1 2 nil] ) -> [1 2] but (leaky-filter nil? [nil nil nil nil 1 2 3]) -> [nil 1 2 3]
00:30wei_I'm using it for a series of http calls. regular "fliter" will just hang if the server happens to be down
00:40johnkpaul-afkdoes anyone have any experience extending leinigen? I am trying to get something to run after a particular task
00:41johnkpaulafter repl-listen, I want to preload some code into the repl
00:41johnkpaulso it changes the namespace beforehand
00:41eggsbyhmm, does lein have event hooks? that'd be a nice feature
00:42dnolenjohnkpaul: you might want to take a look at how ClojureScript One does this
00:42johnkpauloh, dnolen, I didn't think that clojurescript one did do that, but I'll look into it now
00:43dnolenjohnkpaul: they don't use cljsbuild, but it might give you some ideas
00:46johnkpaulok, thanks
00:46johnkpauleggsby: it does have event hooks, but seemingly only for a specific set of tasks
01:04xeqijohnkpaul: lein uses robert.hooke for extending in that way
01:05johnkpaulrobert.hooke? that's a namespece in leinigen?
01:05xeqiits a library
01:05xeqihttps://github.com/clojurebook/ClojureProgramming/blob/master/ch08-lein-mixed-source/project.clj
01:06xeqithats an example where they want to compile java after clojure
01:06xeqiyou might be able to do something similiar, where you hook cljs.repl/repl
01:06xeqiand call cljs.repl/add-namespace first
01:06xeqi* cljs.repl/load-namespace
01:09johnkpauloh I see
01:10johnkpaulso I have to figure out how to hook this into lein-cljsbuild
01:10johnkpaulin order to run this code after that task
01:10johnkpaulor actually, that's just a quoted list, maybe it's really straightforward
01:13xeqiits a generic mechanism, but requires konwing where to hook at
01:15johnkpaulso that would need to go inside my project.clj file, right?
01:21xeqiit can, you can also add :hooks [namespace] to your project map to load it from there
01:23xeqior stick it in a plugin
01:24johnkpaulat the moment, I'm going to stick it in the plugin
01:25johnkpaulwhat's the difference between defn and defn-?
01:27xeqidefn- adds private metadata
01:29johnkpauloh ok
01:29johnkpauland the backtick?
01:29johnkpaulI can look that up
01:30johnkpauloh, it's a quote
01:30johnkpaulin the current naespace
01:32muhooi'm having log4j tsuris
01:32muhooi'm using a java library that requires log4j. but i'm also using noir, which uses netty, which has its own log4j
01:32muhooso there are competing log4js
01:32wei_anyone know why I can't call this function? the correct arity is 2:
01:33wei_https://gist.github.com/2308223
01:34muhoowei_: where's the source to run-threads?
01:34xeqiwei_: the first line calls the function, but errors on miss-calling an anonymous function inside
01:34wei_oh, i see
01:35wei_i think that's enough to debug the problem. just needed some insight on interpreting the output
01:35wei_thanks!
01:52rlbRaynes: clj-time has worked well, but how do I format the time *in* a particular timezone?
01:52rlbi.e. (to-time-zone (now) (default-time-zone)) always formats as UTC, but
01:52rlb(from-time-zone (now) (default-time-zone)) shifts
01:52rlbI must be overlooking something obvious -- might be time to call it a night...
03:20wei_in case anyone was curious about my previous question about leaky-filter: https://gist.github.com/2308710
03:23andyfingerhutI am missing something very basic when it comes to Leiningen and profiles. I've just downloaded and installed version 1.7.1, and have a line ":profiles {:dev {:dependencies [[org.thnetos/cd-client "0.3.4"]]}}" in my project.clj. Should I need to use "with-profiles dev" on the lein command line to activate the dev profile?
03:26andyfingerhutAnd of course I find the web page I've been needing for the past 15 minutes, but only 1 minute after asking my question to the world :)
03:26andyfingerhuthttps://github.com/technomancy/lein-profiles
03:26Raynesandyfingerhut: Use the 'user' profile.
03:27Raynesandyfingerhut: Also, technomancy is saying to beware of that project. It is apparently outdated. I'd encourage you to try out lein 2 preview. It's stable enough for real projects.
03:27andyfingerhutRaynes: Are you recommending that so that I can avoid making the change to each project's project.clj file separately?
03:29Raynesandyfingerhut: Mostly because there are probably bugs in lein-profiles or outofdateness that I don't know about.
03:29RaynesOh, you're asking about the 'user' profile recommendation.
03:29RaynesYeah, I thought you said your ~/.lein/profiles.clj.
03:29andyfingerhutSo if I were to go in front of a group of Clojure users of varying experience levels tomorrow night and recommend how they should set this up, what would you recommend? I'm thinking perhaps it might be simpler to say "If you aren't using Leiningen 2 yet, add :dev-dependencies [[org.thnetos/cd-client "0.3.4"]] to your project.clj". Would that be reasonable?
03:30RaynesI think that would be reasonable.
03:30andyfingerhutAnd perhaps mention on the side that :dev-dependencies is deprecated in Leiningen 2, but save that issue for later when they upgrade?
03:31Raynesandyfingerhut: Just tell them that when they upgrade, be sure to read the upgrading guide. It clearly explains all of that.
03:33andyfingerhutRaynes: Thanks. I think giving the Leiningen 1.x short answer is a good idea, with a side comment that Leiningen 2 early adopters probably have already learned they need to do it a bit differently.
03:42andyfingerhutfranks42: You, sir, have motivated me to stay up an extra hour getting ready for a Clojure documentation presentation to a San Francisco user group that will be held Thurs evening. I'm just about to play with clj-ns-browser in hopes I can demo it and other things there.
03:47kralhi pals
05:04wei_^ so, I just uploaded to clojars a java project built with maven. but it has other dependencies that aren't included in the jar (e.g. org.json.JSONObject). how do I specify those dependencies?
05:05clgvwei_: you can check whether the dependencies are already specified in the pom.xml
05:08clgvwei_: ok, if it is org.clojars.yayitswei/java-channels-api then there is no dependency listed
05:09clgvwei_: clojure dep would look like that in the pom.xml: <dependency><groupId>org.clojure</groupId><artifactId>clojure</artifactId><version>1.3.0</version></dependency>
05:09wei_I created that pom manually-- just added the dependencies from the original project and re-uploaded to clojars
05:12wei_hmm, it didn't seem to overwrite the old pom
05:16clgvwei_: it did. it added "-1" and "-2" postfixes. maybe you can increase the version to make sure it works
05:17wei_what does that mean, -1 and -2 postfixes?
05:17clgvwei_: have a look here http://clojars.org/repo/org/clojars/yayitswei/java-channels-api/0.1-SNAPSHOT/
05:19wei_I don't see any dependencies though? I added this: https://gist.github.com/2309408
05:25wei_oh nevermind, I see it
05:26jpophello. I seem to be missing how doto works. I expected (doto 1 (+ 2) (+ 3)) to return 6. why does it return 1?
05:27wei_I think you're looking for ->. (-> 1 (+ 2) (+ 3))
05:29jpopthanks, I think I got the difference
05:29jpopmacroexpanding helped
05:31wei_clgv: is it correct to increase the version number for clojars if the java project hasn't actually changed version? thanks for all the help by the way.
06:16jpopso the only thing doto does is it inserts the object in all the forms, and then returns that same object?
06:19clgvwei_: it's under your groupid. you can as well add a fourth digit for your integration changes
06:19babilenjpop: Sounds about right. Did you expect more?
06:20clgvjpop: 'doto is intended for java interop with mutable objects.
06:20wei_I believe it's for side effects
06:21babilenIt is
06:21clgvjpop: it is very hand with swing gui.
06:21jpopyeah I agree it's handy
06:21babilen(Or with any other Java Object that you have to deal with)
06:22stevenfx/quit
06:22stevenfxsorry
06:28wei_clgv: thanks for the clojars help; that worked well
06:28clgv:)
06:28wei_goodnight everyone!
06:41progogood day
06:45cemerick*crazy* OT, but hopefully there's a CSS master in the channel. How can I make the image portholes on the left look decent in webkit browsers (they look great in Firefox): http://www.clojurebook.com/
06:48Raynescemerick: Remove the padding.
06:50Raynescemerick: That looks like the simplest solution. You lose the pretty border around the images, but they look really good to me without it.
06:50RaynesThat's about as far as my CSS skills will take you.
06:51cemerickRaynes: Further than I got. Never thought the padding would impact the geometry of the images.
06:51cemerickThanks :-)
06:51cemerickAnd whoa, Raynes giving CSS advice? :-O
06:51Raynescemerick: FYI, figuring this out involved me removing styles until something nice happened.
06:51RaynesNothing clever.
06:51cemerickCSS is real science, huh?
06:51RaynesIndeed.
06:54cemerickactually, leaving the padding and dropping the border radius is great. Should have thought of that before.
06:56Raynescemerick: Yeah, my other option was to say "Why are you being daft and using a border radius? Are you looking out of a boat or something? Srsly."
06:56cemerickhah
06:56cemerickit was my poor attempt at aping the OS X Lion login screen
06:56cemerickMy general design strategy is: find something pretty, copy it.
06:57RaynesHaha, likewise.
06:59bradwrightcemerick: I'm good with CSS, what exactly are you trying to achieve?
07:00cemerickbradwright: Nothing anymore, but thanks. :-) I've already pushed a tweak that "fixed" the problem.
07:00bradwrightcool
07:00RaynesFixed as in did it properly.
07:02cemerickThere are CSS-only mocks of the Lion login screen, but I wasn't able to transplant them properly.
07:02cemerick50+ properties, 3D stuff, etc.
07:03RaynesFrightening.
07:15gregoriusjust tepped over a nice tutorial: http://www.lisperati.com/clojure-spels/casting.html
07:15ChironHi all. how to use a clojure protocol from java?
07:18clgvChiron: afaik you will have to AOT compile it and then you can just use the interface it generates
07:19Chiron(defprotocol ValueOriginBuilder (as-origin [any]))
07:19Chirondefprotocol generates the ValueOriginBuilder interface, so I can implement that. But how to ask clojure for an implementation ?
07:20clgvChiron: erm what? you want to define an implementation in clojure? or you want to use a java implementation of the protocol interface from clojure
07:21ChironI want to have in Scala: val valueOrigin = ValueOriginBuilder.as_origin( something );
07:29sattvikChiron: For that, you have to create an implementation using deftype.
07:29Chironwould you please explain more? thank you
07:30clgvChiron: (deftype VOB ValueOriginaBuilder (as-origin [any] 42))
07:30clgvoops, should be (deftype VOB [] ValueOriginaBuilder (as-origin [any] 42))
07:31Chironwhat is the value 42?
07:31progothe Answer, of course.
07:32clgv:D
07:32clgvChiron: the return value of the method implementation
07:33sattvikNow, you have to be sure not to forget the 'this' argument in the protocol and the type.
07:34clgvsattvik: right
07:34Chirondeftype is new to me, I will check it
07:35sattvikAnd it won't create a static method. In Scala, you'd have to do something like val origin = new VOB().as_origin(something);
07:44kahlinhey, i'm looking for a usable logging framework... found clj-logging-config, has anyone used it?
07:47zamateriankahlin, have you looked at clojure.tools.logging ?
07:50kahlinzamaterian: yes, a little bit. clj-logging-config seems nicer to configure which is the main reason I'm thinking of using it.
07:50kahlinzamaterian: have you used clojure.tools.logging?
08:52makkalothi, does someone have the slides and code of that talk : http://blip.tv/clojure/clojure-concurrency-819147 ?
09:09jaleyso, it just dawned on us that we can write our mongodb queries in clojurescript... can't see anything on the google about someone doing this already. has anyone here tried it?
09:11cemerickjaley: And run them from the browser?
09:12antares_jaley: I have been experimenting with this for monger (https://github.com/michaelklishin/monger). Unfortunately, the CS compiler is still not very useful as a library. cemerick may be the only person who knows how to do it ;)
09:12cemerickoh, I see; so mongo allows you to write queries in javascript then?
09:12jaleycemerick: that's right, the second one :)
09:12cemerickok, that's much more sensible then!
09:13jaleycemerick: so our plan is to use cljs.closure/build to get a javascript string
09:13cemerickThere's a port of clutch to clojurescript around somewhere that allows you to connect to a couchdb instance from the browser. 'course, you need to ship your database credentials to your users, but… :-O
09:13cemerickjaley: see https://github.com/clojure-clutch/clutch-clojurescript
09:13cemerickantares_: ^^
09:15jaleycemerick: yikes! that's neat - we're nowhere near the browser though, we're just excited about writing queries in cljs instead of js. wondering if i've missed some obvious huge hurdle though
09:16cemerickjaley: Nope, the approach works well, at least for CouchDB. clutch-clojurescript actually has some number of users using it for real stuff, so…
09:16jaleycemerick: awesome
09:16antares_cemerick: yes, that's what I am talking about. clutch-clojurescript is the only real world example right now :(
09:16cemerickjaley: note the caveat in the README
09:17antares_and CLJS compiler has version numbers weirer than Hadoop :/
09:17antares_*more weird
09:17cemerickI suppose if the mongodb js engine is slow/persnickety/etc, it might have a rough time with ~40K of js per view. Hopefully they're using something sane.
09:18cemerickantares_: There's cljsbuild. Same thing, I'm just gathering the code up and munging it in a couple specific ways to make it useful in couch.
09:21jaleycemerick, antares_ : thanks for tips guys. that's enough encouragement for us to persist with playing :)
09:21cemerickantares_: and yeah, the cljs versioning is something to…get used to, I guess. It's moving very quickly though; I need to get clutch-clojurescript on travis so as to keep an eye on the changes
09:22cemerickantares_: speaking of, if travis could trigger builds when upstream maven dependencies are updated… ;-)
09:25antares_cemerick: they use spidermonkey with an option to build with V8
09:25antares_cemerick: libv8 and google closure compiler probably play well with each other ;)
09:26cemerickantares_: couch uses spidermonkey as well, so you should be good
09:27antares_cemerick: plus, you don't use JS for views with mongodb. Typically only map/reduce or arbitrary code execution.
09:27antares_cemerick: so code can be "installed" on app boot
09:29cemerickeven better then w.r.t. code-loading/startup costs
09:53ocis there a good "rainbow"-style parenthesis completion for vim?
09:55fdaoudoc: yes, I use clojure.vim with g:clj_paren_rainbow
09:57Wild_Catall of this reminds me I need to try out Counterclockwise.
09:58babilenoc: I recommend vimclojure -- https://bitbucket.org/kotarak/vimclojure best clojure integration IMHO. I do, however, prefer emacs + evil (http://emacswiki.org/emacs/Evil) for Clojure development
10:00gfredericksis continuing to use lein-cljsbuild after abandoning lein for maven non-trivial?
10:00gfrederickss/non-trivial/hard\/impossible
10:02jsabeaudryI have a character device that behaves fine (blocking read) when I `cat` it, however if I pass the input stream to Jetty I get an "Illegal Seek" exception when the read should just block, is there a better way?
10:07TimMcjsabeaudry: What happens if you wrap it in a buffered stream?
10:08fdaoudgfredericks: why are you abandoning lein? (just curious.)
10:10jsabeaudryTimMc, isn't clojure.java.io/input-stream already a buffered stream?
10:10TimMcIntegrating into an existing Maven project, perhaps?
10:10TimMcjsabeaudry: Hum, maybe. Hey, is this that embedded device project?
10:11jsabeaudryTimMc, yes it is, you have good memory :)
10:12jsabeaudryTimMc, the fpga is working and I'm pretty much done writing the driver, time to stream that data :)
10:12TimMcIs there an equivalent sort of character device on a standard Linux that I could experiment with?
10:13dgrnbrgjsabeaudry: I notice that you're using an FPGA w/ clojure?
10:13jsabeaudryTimMc, /dev/random
10:14jsabeaudrydgrnbrg, Well let's say the two are part of the same project yes
10:14gfredericksfdaoud: wasn't my decision; team lead wants compatibility with other projects or something
10:14dgrnbrgjsabeaudry: I'm actually working on a system to program FPGAs in clojure
10:15dgrnbrgI have a working cycle simulator and type system that takes into account the bit-layout of structures
10:15TimMcjsabeaudry: The same thing happens with /dev/random in your program? Or is the data important?
10:15fdaoudgfredericks: ah ok.
10:15dgrnbrgand it supports tagged unions and structures, and clojure's destructuring syntax for synthesizable types
10:15jsabeaudryTimMc, Ah excellent idea, let me try that right away
10:19TimMcjsabeaudry: When I try to .skip on a FileInputStream on /dev/random, it skips 0 but does not throw.
10:22TimMcI guess that one won't block readily, though...
10:22jweissa co-worker wants to know why he should leave groovy for clojure. I pointed out macros, but I'm struggling to find him a concise example that will show why they're so great. I thought of with-open, anyone have a better example?
10:23zamaterianjweiss, look at clojure-clutch the with-db*, with-db and defdbop macroes
10:23TimMcjweiss: core.match is made of macros.
10:24Wild_Catjweiss: logging. Macros make logging 10 times more awesome
10:24llasramjweiss: all of core.match maybe?
10:25johnkpaulHow can I set a dependency for leinigen itself, when it is interpreting project.clj?
10:25johnkpaulI am trying to require leinigen.cljsbuild inside project.clj, but it can't find it
10:27TimMcjsabeaudry: Playing with mkfifo now. Intriguingly, the FIS constructor blocks until someone writes to the fifo.
10:28jsabeaudryTimMc, /dev/random seems to block too
10:28jsabeaudrythere must be something missing in my driver
10:28TimMcjsabeaudry: OK, got Illegal Seek on a fifo when I tried to skip.
10:29TimMcmkfifo foo; echo "blah" >> foo
10:29TimMcand then (.skip fis 5) fails
10:29jsabeaudrybut (.read blocks?
10:30bhalbertgfredericks: i seem to recall that lein will emit a POM for you (as a starting point perhaps)
10:31TimMcjsabeaudry: Hmm, no -- EOF. (returns -1)
10:32jsabeaudryhmm, I'll try providing a non-default implementation of llseek see if I can get somewhere with that
10:34groovemonkeyhi guys, newb here -- I'm getting an error when I try using java's getAbsolutePath with a string in Clojure. Anyone know what i'm doing wrong?
10:34groovemonkey(.getAbsolutePath "/home/path/to/test")
10:34groovemonkeyIllegalArgumentException No matching field found: getAbsolutePath for class java.lang.String clojure.lang.Reflector.getInstanceField (Reflector.java:289)
10:35gfredericksbhalbert: I'm not sure how that helps with running lein-cljsbuild? unless lein-cljsbuild has a maven interface...
10:36zamateriangroovemonkey, (. getAbsolutePath (File. "/home/.."))
10:37groovemonkeythank you! trying it now...
10:37zamateriangroovemonkey, the java.lang.String has no getAbsolutePath method, If your in doubt which calls an object has use type (type "/home/..")
10:38zamaterians/calls/methods
10:40johnkpaulis there a different irc channel for lein help?
10:40groovemonkeythank you. Sorry, i took that from an old clojure peepcode tutorial.
10:41bhalbertgfredericks: err, sorry. was skimming and just saw "abandoning lein for maven"
10:41zamaterianjohnkpaul, the #leiningen channel
10:42johnkpaul:) thank you
10:42yoklovanybody know of a good complex number package for clojure?
10:43jsabeaudryTimMc, thanks for you help it is now streaming! let's see how fast it can go now :D
10:45TimMcjsabeaudry: What solved it?
10:47jsabeaudryTimMc, providing a non-default llseek implementation in the driver of which I share the code with you: "return 0;" ;)
10:51TimMcheh
11:05yoklovthat actually might be my biggest annoyance with clojure, lack of complex number support
11:16gfredericksalso where do I look for a maven replacement for lein-ring?
11:16lynaghkibdknox: In Waltz is a state's `in` function supposed to run if you set to that state while you're already in it? I'm seeing that behavior, but intuitively it seems like it should only run when first entering that state.
11:19franks42andyfingerhut: sorry that I kept you from a warm bed - clojure tend to do that to you ;-) - hopefully that clj-ns-browser was worth it... too bad I cannot make it tonight to the SF-meetup - good luck with presentation (love your cheatsheet!)
11:19cemerickgfredericks: which part of lein-ring do you need?
11:19cemerickpart(s)
11:20konrCan you point out some cool things that you can do with IDEs other than Emacs to Clojure?
11:25unlinkHow do I get the request URI in a ring application without the leading context path?
11:26weavejesterunlink: If you've compiled a war using lein-ring, a :path-info and :context key will be added to the request
11:26unlinkakin to .getPathInfo()
11:27cemerickkonr: what are you looking for in particular?
11:30unlinkweavejester: ok. I'm using run-jetty in development. Is it possible to make those keys accessible then?
11:31weavejesterunlink: In development, there is no need for a :path-info key. You could write a quick function like...
11:31RickInGAcan anyone point me to an example of using radio buttons with noir/hiccup?
11:31weavejesterunlink: (defn path-info [req] (or (:path-info req) (:uri req)))
11:31konrcemerick: nothing in particular, just brainstorming things to be considered to my IDE proposal for GSoC. People often mention Textmate's useful templating system, and I bet those big IDEs must have good debugging/profiling integration
11:32weavejesterunlink: Also, Compojure handles :path-info/:uri automatically in routing.
11:32unlinkweavejester: I could, but what I really mean is request.getPathInfo(). (I'm not using compojure.)
11:32weavejesterunlink: And therefore Noir does too.
11:32cemerickkonr: well, being able to set breakpoints without altering sources is handy.
11:32weavejesterunlink: When using an adapter, the path-info is always equal to the uri
11:33weavejesterunlink: The path-info is really only relevant when deployed as a war, or using something like the Compojure context macro
11:34unlinkweavejester: so then it would make sense to have a middleware at the site of run-jetty that assocs in :path-info based on :uri.
11:35weavejesterunlink: It would be easier to create a path-info function, I think
11:35gfrederickscemerick: lein-ring I can probably emulate well enough; it's lein-cljsbuild that I'm particularly worried about
11:35johnkpaulhow can I add a dependency for a leiningen hook?
11:36weavejesterjohnkpaul: Add it as a :plugin
11:37johnkpauloh, that will run with the right things in the classpath?
11:37johnkpaullet me try that
11:37johnkpaulhere's the file I'm using http://pastebin.com/fwunbczK
11:38weavejesterjohnkpaul: Why did you call your namespace "leiningen.hook"?
11:38cemerickgfredericks: well, `ring uberwar` is baked into maven's war packaging; `ring serve` is `mvn jetty:run` (assuming proper configuration of the maven-jetty-plugin
11:38weavejesterjohnkpaul: And what does it do? Which package is it from?
11:39johnkpaulno good reason, just trying to get that to work
11:39johnkpaulI'm trying to hook into cljsbuild's repl-listen
11:39cemerickgfredericks: cljs support is, as you say, a whole 'nuther can of worms
11:39johnkpaulI mean, eventually, right now that hook just prints "hey, it hooks"
11:39cemerickgfredericks: maybe you can exec out to cljsbuild somehow? :-P
11:39weavejesterjohnkpaul: Which package is the hook coming from?
11:39gfrederickscemerick: I was thinking a lein plugin for maven would be cool :)
11:40gfrederickswait
11:40gfredericksI mean a maven plugin for lein
11:40weavejesterjohnkpaul: And what does your hook namespace look like?
11:40johnkpaul./src/leiningen/hook.clj
11:40gfredericksyou know: `mvn lein cljsbuild once`
11:40johnkpaul(ns leiningen.hook (:require [robert.hooke]))
11:41weavejesterjohnkpaul: If it's in your src, you'd need a :eval-in-leiningen true in your project map
11:41cemerickgfredericks: you might want to look at zi as a first step: https://github.com/pallet/zi
11:41cemericka zi:cljsbuild goal may not be too tough
11:41johnkpauloh ok, maybe I'm going about this incorrectly
11:41gfrederickscemerick: I'll check that out, thanks
11:41weavejesterjohnkpaul: Take a look at the installation for my environ plugin: https://github.com/weavejester/environ/blob/master/README.md
11:41johnkpaulshould I be doing that
11:41johnkpauloh ok, thanks
11:42cemerickplugging lein up into maven sounds…tricky ;-)
11:42weavejesterjohnkpaul: And at the corresponding hook: https://github.com/weavejester/environ/blob/master/environ.lein/src/environ/leiningen/hooks.clj
11:43weavejesterjohnkpaul: Leiningen has effectively two separate environments; one for Leiningen itself, and one for your project. Hooks need to be evaluated in Leiningen, which means they need to be a dev-dependency, or (for Lein 1.7 and above) a plugin.
11:43johnkpaulooh, I didn't realize that's how it works
11:44johnkpaulso if I want to be hooking _another_ plugin, I need to be evaluated inside leningen
11:44johnkpaulok, so it seems that changing the word "hook" to "plugin" in my project.clj, got everything running with no errors
11:44weavejesterjohnkpaul: The :eval-in-leiningen effectively treats your src directory as like a plugin
11:44unlinkweavejester: Why not assoc path-info and context-path in ring.util.servlet (rather than leiningen.ring.war)? They seem like application-level concerns to me.
11:45weavejesterjohnkpaul: You need two steps: include the dependency as a plugin, and then add the namespace as a hook.
11:45weavejesterunlink: Because adapters have no concept of path-info or context
11:46hugodgfredericks, cemerick: I started this a while back https://github.com/pallet/zi-cljs
11:46weavejesterunlink: Ring is all about providing the minimal possible interface, and then building on that with middleware.
11:46unlinkweavejester: Right, and I am fully behind that philosophy.
11:46unlinkweavejester: But don't adapters give you real HttpServletRequests?
11:47weavejesterunlink: No. You can't rely on adapters giving you HttpServletRequest access, because adapters might not be based on top of an existing Java servlet engine.
11:47weavejesterunlink: Ring uses Jetty as it's default adapter, but that's an implementation detail.
11:48weavejesterunlink: Besides, if you're using an adapter, then the URI and the path-info are always equivalent.
11:48unlinkweavejester: To me, path-info versus uri is an application-level concern, and should be part of the real application HTTP gateway (i.e. ring) API. If the adapter doesn't give you path-info, then the adapter is the place for the facade, not the app
11:49johnkpaulweavejester: so in my current project.clj, the plugin that I want to wrap is a dev dependency, is that just the old name for plugins?
11:49weavejesterjohnkpaul: dev-dependency is basically the old name for plugins, yes. It's a little more complex, but that's the gist.
11:50weavejesterjohnkpaul: Pre 1.7, Ring deps were a little messy. After 1.7 they're divided into two clean parts: ones for Lein, and ones for your project.
11:50johnkpaulah ok, cool, I'm continuing to work on it
11:50johnkpaulpaulfryzel: hey
11:51unlinkweavejester: Is there an abstraction in Ring for prefix-based dispatchers in middleware?
11:51weavejesterunlink: Ring is an interface to incoming HTTP requests. It isn't an application layer in the same way that Java servlets are.
11:51weavejesterunlink: Straight Ring you basically just get the raw HTTP request. Anything more than that is beyond the Ring spec.
11:52weavejesterunlink: There isn't, but I've been considering a wrap-context for Ring 1.2
11:52unlinkweavejester: It would be very helpful to have something analagous to SCRIPT_NAME versus PATH_INFO for both of these purposes.
11:53weavejesterunlink: Why?
11:53unlinki.e. uri === (str script-name path-info)
11:54weavejesterunlink: What's your use case, exactly?
11:54unlinkweavejester: Then I could write my application in such a way that it doesn't care whether it is (a) run directly by an adapter, (b) dispatched to by a prefix-dispatching middleware, or (c) run in its own context prefix by tomcat.
11:55weavejesterunlink: That's really a routing problem though, and therefore a problem for your routing library.
11:57johnkpaulhmm, so weavejester, I somehow accidently created a new task, rather than wrapping an existing task
11:57johnkpaulI keep getting this exception java.lang.Exception: Unable to resolve var: leiningen.cljsbuild/repl-listen in this context (hook.clj:7)
11:57johnkpauleven after adding eval-in-leningen true
11:57weavejesterjohnkpaul: Leiningen looks for: leiningen.<task>/<task> to handle tasks
11:58johnkpaulwhere? inside project.clj?
11:58weavejesterjohnkpaul: If you run "lein foo", then Leiningen will look for leiningen.foo/foo in the project classpath.
11:59johnkpaulah ok
11:59unlinkweavejester: Why should my application care whether its router is called by run-jetty, tomcat, or dispatched to by some other middleware?
11:59weavejesterjohnkpaul: If you want a hook, you need to write an "activate" function
11:59johnkpauloh, really?
11:59johnkpaulI'm using this as an example...
11:59johnkpaulhttps://github.com/clojurebook/ClojureProgramming/blob/master/ch08-lein-mixed-source/project.clj
11:59weavejesterunlink: It shouldn't, which it why your routing library should check :path-info, and then :uri.
12:00weavejesterjohnkpaul: This style is preferred: https://github.com/weavejester/environ/blob/master/environ.lein/src/environ/leiningen/hooks.clj
12:00johnkpauloh, so where do you call activate?
12:01weavejesterjohnkpaul: Leiningen calls it when you add the namespace as a hook.
12:01johnkpauloh, I see
12:01unlinkweavejester: If routing libraries need to do that, that is a sign to me that :path-info belongs in some commonly agreed-upon spec for HTTP applications. Why should routing libraries know about the implementation of who deployed them?
12:01johnkpaulso that I understand, but in your example, you wrap #'leiningen.core.classpath/resolve-dependencies
12:01johnkpauland that is part of the core, so it's found
12:02johnkpaulI am trying to wrap #'leningen.cljsbuild/repl-listen
12:02johnkpauland even though leningen.cljsbuild is in dependencies and dev dependencies and plugin, it's still not found
12:03unlinkweavejester: without being in the Ring spec, :path-info is merely an implementation detail of libraries which offer war-based deployment. Now my routing library needs to incorporate knowledge of the implementation of those war adapters in order to give a generic interface to applications.
12:03unlinkweavejester: And this still leaves open the issue of composable routing libraries.
12:04weavejesterunlink: At some point we may want to formally document it. Currently it's a defacto standard, and defacto standards are not necessarily bad. It doesn't belong in the Ring SPEC, because HTTP requests have no concept of :path-info or :context.
12:05weavejesterunlink: It's also a single key designed primarily for compatibility with legacy applications, although the context macro in Compojure is kinda useful.
12:06unlinkweavejester: Perhaps what we need then is another spec which formalizes commonly useful keys for interoperable and composable HTTP middleware, then.
12:06weavejesterunlink: It's worth pointing out that standard keys like :params and :cookies are also not in the Ring spec.
12:07weavejesterunlink: :path-info is really only useful for internal routing and legacy compatibility.
12:07unlinkweavejester: Except that will end up looking just like Ring, but with path-info added. The prior art here, of course, is WSGI and Rack, which both distinguish between SCRIPT_NAME and PATH_INFO.
12:10weavejesterunlink: It's important to understand that the Ring SPEC describes an abstraction over HTTP and nothing further.
12:10weavejesterunlink: path-info ans script-name are not an intrisic part of HTTP, therefore should not be part of the SPEC
12:10weavejesterunlink: In Ring 1.2, I may add some wrap-context middleware to core
12:11weavejesterunlink: But adapters won't intrinsically add :path-info
12:11unlinkweavejester: Right, but I contend that HTTP makes a fine spec for HTTP, and what is really needed is an abstraction for HTTP-based middleware.
12:12weavejesterunlink: Which would just be :path-info and :context, presumably?
12:13weavejesterunlink: I'm not certain there needs to be a specific spec for :path-info and :context. There isn't one for parameters, cookies, sessions or file uploads.
12:14weavejesterunlink: The way the core middleware behaves effectively defines standard keys and behavior
12:14unlinkweavejester: an example of SCRIPT_NAME in action: https://github.com/lukearno/selector/blob/master/selector.py#L135
12:14weavejesterunlink: We haven't seen anyone deviate from that, yet. No-one's writing their own parameter or cookie middleware that's incompatible.
12:15weavejesterunlink: WSGI handler delegation is just another term for "routing library", at least in Ring terms.
12:15unlinkweavejester: Well, informally specified standards for middleware is fine except that omitting path-info from the ring adapters encourages middleware developers to depend on :uri and thus author non-composable middleware
12:16unlinkespecially since application developers will also be depending on :uri.
12:16weavejesterunlink: Hm. Most of the time middleware doesn't need to directly access the URI, however.
12:16unlinkweavejester: Right, it's only when you're doing any redirecting when the full URI is useful.
12:17weavejesterunlink: In the case of wrap-resource and wrap-file, but aside from static file handling...
12:17johnkpaulso weavejester, I'm using trampoline
12:17johnkpaulso I don't think that eval-in-leiningen works
12:17weavejesterunlink: What I could do is add a ring.util.request/path-info function to Ring 1.2...
12:18weavejesterjohnkpaul: There's no point in trampolining if you're evaluating in Leiningen.
12:19johnkpaulyeah, I know, but I don't really care about evaluating in leiningen, I just want the end result to wrap cljsbuild's repl-listen
12:19johnkpaulwhich, according to their docs, should be launched by using lein trampoline cljsbuild repl-listen
12:19unlinkweavejester: Whatever you do, the goal as I see it is to encourage middleware and application developers to consume path-info, and avoid uri (except for redirecting)
12:19johnkpaulI didn't realize what trampoline meant until now
12:19johnkpaulif it's another JVM, how do I get hooks into there
12:19sattvikweavejester, unlink: I'll just mention that path-info is not servlet-specific. It's part of the CGI specification.
12:20weavejestersattvik: That's a different spec to Ring, however. Ring operates at a lower level. The Ring SPEC is just concerned about HTTP requests.
12:21weavejesterunlink: Hm… What sorts of middleware, beside ones serving static resources, would need the path-info or the URI?
12:22weavejesterjohnkpaul: As far as I'm aware, hLein ooks are just for hooking into Lein itself, not into subprocesses.
12:22unlinkweavejester: Application-level middleware that checks for a logged-in user and redirects to a login page would want to know the URI, for example.
12:23johnkpauloh ok, so in order to wrap tasks that are trampolined, I'd have to modify the original plugin?
12:23weavejesterunlink: So for absolute redirects. Hm, I could see that being the case.
12:23sattvikweavejester: Sure, I understand. I'm just saying that a lot of legacy applications/frameworks rely on these things. To someone who is starting with ring/compojure/noir, it can be confusing.
12:24johnkpaulI will go feature request cljsbuild, and for now just do some of this manually
12:24weavejesterjohnkpaul: If you want to hook into something outside of Lein itself, then yes. I believe lein-cljsbuild adds a cljsbuild dep and runs from that.
12:25johnkpaulwhat do you mean?
12:26weavejesterunlink: I'll put some standard functions in to Ring 1.2, I think… if we have a practical problem after that, we can consider a guide or spec.
12:26johnkpaulsorry, I don't know all of the terminology
12:26johnkpaulso the plugin lein-cljsbuild has it's own project.clj and adds iself as a dependency?
12:26bobbywilson0Is there access to an "index" in a sequence?
12:26unlinkweavejester: The most compelling argument I see for augmenting the ring spec itself, inasmuch as it is expressly not aiming to specify a middleware API is the fact that many production environments (including newly deployed ones) only expose the context path as a deployment concern...i.e. it is out of the hands of the developer
12:26weavejesterjohnkpaul: Okay, so the project.clj file is converted into a map by Leiningen, and this map is passed to Leiningen plugins like lein-cljsbuild.
12:27weavejesterjohnkpaul: If these plugins want to do anything in the classpath of the project, typically they'll assoc a new dependency into the project map, and then run "eval-in-project" with the altered map.
12:28johnkpaulooh, I see, I didn't realize that's how the plugin system worked
12:29unlinkweavejester: A slightly less compelling argument is that developers coming from other platforms (including Java) expect a somewhat higher-level API to develop their applications against, which incorporates routing concerns in the specification of the gateway API.
12:29weavejesterjohnkpaul: When you "eval-in-project", you're evaluating in the context of the project's dependencies, rather than Lein, which is why I don't think you can hook into it.
12:31unlinkweavejester: Naturally that does come with practical benefits, namely that deploying on top of tomcat looks like like being run by an adapter, or being mounted under another Ring routing library.
12:31johnkpauloh, so in order for me to do this cljsbuild would need to provide their own hooking functinoality
12:32weavejesterunlink: The Ring SPEC won't be augmented with keys that can't be directly derived from the HTTP request map. Good Clojure practise is to keep things simple, i.e. something that does only one thing. Complecting the SPEC isn't the right solution, I don't think.
12:32johnkpaulthanks so much for your help weavejester, I need to work on something else for a bit, but I'll be back with more questions I'm sure
12:33weavejesterunlink: If we need another spec that builds on Ring, okay, but for now the defacto standards don't seem to be causing any issues.
12:35weavejesterunlink: Ring is deliberately a low-level interface. Protocols and standards work best when they're layered on top of each other. Try to do too much and you get something horrible like Java servlets.
12:36unlinkweavejester: But perhaps Ring is slated as a lower-level tool than it is actually used for. cf. lein.ring.war which must generate code to step over Ring so your application knows what path was intended for it.
12:37unlinkweavejester: Unless there are native "ring containers" I don't know about which compete with tomcat, glassfish & kin.
12:38weavejesterunlink: Ring containers are just handlers.
12:39weavejesterunlink: And layering additional functionality using middleware, as lein-ring war does, is good practise
12:41unlinkweavejester: I agree that middleware should send middleware-specific information downstream in that manner. What I don't agree with is the notion that uri versus path-info is incidental to consumers of the Ring API.
12:42weavejesterunlink: The Ring SPEC is *just* about abstracting HTTP requests. If we want anything more, then we should build something on top of that spec, not extend it.
12:43weavejesterunlink: Well, HTTP requests and responses.
12:45unlinkweavejester: For certain, HTTP has no notion of path-info versus URI. The practical matter, however, is that Ring API consumers are not primarily useful in a pure HTTP environment. If you were starting from the ground up, it may make sense to have a separate protocol specifying best practices around routing middleware conventions. But as it stands, Ring applications live in a world of context-root-aware deployments. It just so happens to be the case th
12:47weavejesterunlink: It depends what environment you're talking about, there is a trend toward using smaller web services with their own subdomains.
12:48weavejesterunlink: However, regardless of how useful it is in practise, it is not a good idea to take two standards that have two different purposes, and try to combine them in the same spec
12:48weavejesterunlink: That way lies madness, and Java servlets, and other horrors.
12:49unlinkweavejester: By informally specifying the distinction between URI and consumed-unconsumed path in lein.ring.war, you are simply moving that informal specification to the absolute root of the middleware stack.
12:49weavejesterunlink: But in practise, that hasn't been a problem so far.
12:49weavejesterunlink: If it becomes a problem, then we can create guidelines or additional standards.
12:49unlinkweavejester: For sure, mixing of concerns is the root of all evil. My contention is merely that HTTP isn't the right concern to be concered about (but it is damn near close).
12:50weavejesterunlink: A HTTP-application spec would be built on top of a HTTP spec, so there's no reason to join them together.
12:50unlinkweavejester: Well, I'm not sure that is quite true. Every other language's analog to Ring I know of makes this distinction, and I have seen this issue raised about Ring a couple times in the past (and I experience it as well).
12:51weavejesterunlink: Then let's try adding in some standard functions in Ring 1.2 to encourage people in the right direction
12:52weavejesterunlink: But aside from a few questions, I haven't seen any indication it's a significant problem.
12:52weavejesterunlink: Both Noir and Compojure support it without issue.
12:52unlinkweavejester: Yes...at a certain point, the spec is merely an implementation detail. What truly matters is what middleware and application developers write.
12:54weavejesterunlink: I think I agree that we at least need a path-info function in Ring 1.2, and to make wrap-resources and wrap-file context-aware.
12:56unlinkweavejester: I admit I am not using any static-file-serving middleware... I just leave that to Tomcat (or nginx, depending)
12:59unlinkOn a completely unrelated note, how should I troubleshoot wrap-reload? I am getting it to detect changes at the module level, but not inside my handlers.
13:00weavejesterunlink: wrap-reload looks through a directory tree (default "src") for modified files, and then reloads all the namespaces that use that file
13:00weavejesterunlink: What do you mean by "detect changes at the module level"?
13:02unlinkweavejester: If I have a naked (println "hello") at the top level of the namespace, it will execute that the first time I make a request after updating the file. However, changes to the handlers themselves are not picked up on (within the same file).
13:02weavejesterunlink: Oh, I see. You'll need to pass in your handlers as vars
13:02weavejesterunlink: Otherwise they're passed in as values, so Clojure won't update them if their definition changes.
13:03weavejester(wrap-reload #'your-handler) should do it
13:03unlinkweavejester: aha. I was missing a level of dereference.
13:04weavejesterunlink: It's easy to miss. I accidentally factored out that behavior in lein-ring for a few versions, until someone pointed out the mistake.
13:07unlinkweavejester: great, it's working now.
13:10unlinkweavejester: As I understand it, lein ring server-headless should not open a browser window, correct?
13:10unlinkIt is for me, with lein-ring 0.6.2.
13:10weavejesterunlink: Yes, but there was an issue with that, that was only fixed in 0.6.3
13:11unlinkWell, aren't I behind the times.
13:11weavejesterunlink: If you don't want that behavior, you can also add a :ring {:open-browser? false} to your project.clj
13:11unlinkthat's better.
13:12weavejesterunlink: Or, if you have lein2, you can turn it off in your ~/.lein/profiles.clj for all projects
13:12unlinkI have to admit I'm not quite ready to take the plunge O:-)
13:15technomancynice hat
13:16unlinkthanks. up here we call them halos.
13:56ocwhats the name of the jline + colours + other extensions to the repl that comes with homebrew?
13:57technomancyoc: I don't know what homebrew has, but you should use reply
13:57technomancyhttps://github.com/trptcolin/reply
13:59octhats the one, thought i installed it with brew at work :)
13:59octhanks
14:02ocacctually on second look it's not the same, but this seems good
14:05technomancyreply is the best
14:10jtoycan anyone recommend a clojure library that will get me the domain from a url like twitter.com from twitter.com/asdas/dasd/sadsadsad and google.com from google.com/asdasdas/asdasd/sadsa/d?123123=12321 ?
14:11technomancy(.getHost (java.net.URL. "http://twitter.com/asdas/dasd/sadsadsad&quot;))
14:11technomancy,(.getHost (java.net.URL. "http://twitter.com/asdas/dasd/sadsadsad&quot;))
14:11technomancy
14:11technomancy
14:11technomancyoops
14:11antares_jtoy: urly
14:11antares_jtoy: but yes, for simple cases java.net.URI is sufficient. Just in case: https://github.com/michaelklishin/urly
14:12jtoyok, i was thinking in clojure because i've never even programmed in java, and i don't plan to really even though clojure is on top of java
14:14antares_jtoy: then just use urly
14:14llasramHonestly, I'm not sure how feasible that is general, at least in the sense you seem to mean it. Clojure is designed as a hosted language, and depends on the hosting platform for a variety of features
14:15antares_jtoy: (host-of "https://google.com&quot;) should do what you want. It can also work with java.net.URI, java.net.URL and some more inputs
14:15llasramYou can't even do most string operations without calling methods on java.lang.String instances
14:15jtoyllasram: yeah, I'm avoiding it as much as a can, yeah I've had to use a couple of simple string methods from java unfortunately
14:15technomancyjtoy: calling java methods is not programming in java
14:15technomancythere's nothing unfortunate about that
14:16antares_llasram: I think the point is that some people are not familiar enough with JDK APIs. urly wasn't created to hide JDK classes from you, but it also may be a bit nicer for someone who never used java.net.URI.
14:17antares_jtoy: I am the creator of urly, so if you run into issues, let me know
14:17llasramantares_: Right. That's why I added "in general" :-) Urly looks to add some useful extra features, but using it just to avoid directly using URL/URI is probably not beneficial
14:17jtoyantares_: cool, thanks
14:17antares_llasram: I agree. urly covers areas JDK classes do not. I absolutely did not intend to discourage java.net.URI usage, etc.
14:18jtoyits unfortunate that if you don't program java, and as someone who wants to leaner a cool new language like java, they must essentially learn 2 languages
14:18jtoylike clojure
14:19technomancyyou don't need to learn Java
14:19technomancyyou need to learn some Java libraries
14:19hiredman*shrug* java is not very hard to pick up
14:20emacsenhiredman, yeah, it kinda is :)
14:20technomancyemacsen: to write, maybe
14:20emacsenthere are still some concepts I'm fuzzy on, like "Interfaces"
14:20jtoyhiredman: it doesn't matter if its hard or not, the goal is to learn and program clojure, adding more things to learn and do slows you down no matter how easy it is
14:20llasramAnd it's not even really "Java libraries" -- it's more "JVM libraries." You can completely ignore anything about e.g. generics. Although maybe that makes it harder for someone completely new to the environment?
14:20hiredmanemacsen: compared to what?
14:20antares_jtoy: that's another side of having all the Java ecosystem tools and libraries at your disposal. I think over time there will be more and more tools and libraries that require 0 Java knowledge. But learning JDK APIs is still very very helpful.
14:20emacsenhiredman, Python, Ruby, even Clojure
14:20technomancyllasram: right; if you didn't have that, then Clojure itself would be a much larger language
14:21technomancyor a much less useful language
14:21antares_llasram: not having to worry about generics or checked exceptions is definitely a good thing for newcomers :)
14:21hiredmanemacsen: in what way is java harder to pick up then either of those?
14:22llasramantares_: Oh man. I like to forget checked exceptions even exist.
14:22emacsenhiredman, I just find it harder. harder to read, harder to grok. More concepts, more verbose. harder to debug
14:22technomancycertain Java codebases are difficult to read if they go nuts with patterns and crazy abstractions
14:22hiredmanemacsen: that is hardly objective
14:22technomancyas are ruby codebases that go nuts with method_missing and metaprogramming
14:23technomancyeven though I would find it very tiresome to write, having classes specified everywhere actually helps a lot in reading code
14:23hiredmanyou can write clojure to generate your java source!
14:55devni wrote clojure to generate my ruby source
15:03ocoh. the joy of having 1200 reminders dumped into your mailbox.
15:04ocany of you put in a suggestion for a talk @ JavaZone 2012?
15:06megano :(
15:08oconly see Stuart Sierra; need more! Go submit talks at www.javazone.no :)
15:09ocIt's the same week as CUFP and ICFP... 1 hour flight! Do a tour!
15:16octechnomancy: can't promise anything, but if it happens to be another debate on build tools, I'd like to see leiningen represented :)
15:31rlbIs there some idomatic way to run something every N minutes, or would java executors be a reasonable choice?
15:31amalloyexecutors
15:32antares_rlb: if you need more power, Quartz (and quartzite) is a good option. Here's my Clojure DSL on top of Quartz: https://github.com/michaelklishin/quartzite
15:32antares_rlb: but scheduled executors is very often all you need
15:34rlbok, thanks
15:47chouserdoes anyone have an opinion about redefining ->Foo to take different args and/or do non-default things to construct and instance of record type Foo?
15:47chousers/construct and/construct an/
15:48konrHi! I've submitted my proposal for GSoC. Can you check if there's something missing, or in case you have a specific request? http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/konr/29002
15:49amalloychouser: my opinion is that you should just add a different function to do that, like make-Foo-the-easy-way
15:50Rayneschouser: My opinion is that amalloy's opinion is sound and that I'd be likely to throttle you if you did what you were thinking of doing.
15:51llasramchouser: I'd worry it could be confusing, but how often do people actually use the ->Foo constructor functions?
15:51llasram(the ones defined by `deftype`, that is)
15:51llasramEr, defrecord even
15:51chouserall good points
15:52llasramIf people don't use them often, I think it could make sense to replace it. Make a new Clojure convention that ->Foo is your default factor function for Foos
15:53llasramWhat do people see as the normal convention right now?
15:53chouserI don't think there is one
15:53chousermake-Foo, new-Foo, and create-Foo are all relatively common, afaik
15:54llasramYeah, and `mk-foo`. I've been doing just `foo` (lowercase) myself, but maybe there are pitfalls there?
15:55chouserllasram: that's actually common in clojure itself. nouns used as a verb create the thing
15:55chouseratom, agent, hash-map, vector, etc.
15:55llasramAh yeah! I must have picked up on that subconsciously :-)
15:55chouserBut you can't do that with a class name. Foo is the class, not a function that creates one.
15:57llasramBut if you want to treat the class as an implementation detail, then I think having a function `foo` which creates a Foo makes sense
15:58llasramOr maybe it makes things impossible to read on large code-bases. None of my Clojure projects are very large yet
16:13sjlI thought I remembered someone in here saying they were working on a Django-like templating library a while ago... am I going crazy or does that exist?
16:16devncan cl-format convert back from roman numerals to digits?
16:17devn(cl-format nil "~something-magical" "III") => 3
16:32mrb_bkdnolen: whattup buddy
16:35mrb_bkdnolen: wondering if you have resources re: zippers that we were talking about with undo/redo
16:41oskarthUsing clojure with mongodb and I want to store dates. MongoDB suggests ISODate (standard 1970 second time) but the only clojure date function I found is java.util.Date. Is there any harm done in using the java one?
16:41technomancyclojurebot: java.util.Date?
16:41clojurebotexcusez-moi
16:42technomancyoskarth: yes, java.util.Date is the worst class in the JDK. look at clj-time
16:42oskarthit speaks french but not java
16:42oskarthtechnomancy: thanks for the heads up
16:42technomancyclojurebot: java.util.Date is the worst class in the entire JDK.
16:42clojurebotRoger.
16:42oskarth:D
16:43antares_oskarth: no
16:43unlinkHow would you say this more concisely? (fn [m] (assoc m :x (or (:x m) y)))
16:43unlinkassoc-if-missing
16:43antares_oskarth: if you go with Monger (https://github.com/michaelklishin/monger), it has a way to store JodaTime dates, too
16:43antares_unlink: maybe-assoc
16:44technomancyunlink: (merge {:x y} m)
16:44unlinkah, much better. thanks.
16:45oskarthantares_: using congomongo at the moment, but will check it out too, thanks
16:50ocCould anyone suggest a couple good and inspiring Clojure speakers to me? (besides Rich ;)
16:52dnolenmrb_bk: probably best to looks a libs that use zippers for undo/redo, http://fhcrc.github.com/taxtastic/refpkg.html, here's a Python one.
16:53dnolenmrb_bk: and, also yo! JSConf was good times.
16:53justin`I think I'm missing something stupid. I'm trying to change an atom in cljs. Anyone know why (def a (atom nil))(swap! a identity "hello")(js/alert @a) isn't working for me?
16:55hiredmanidentity takes a single argument
16:56dnolenjustin`: you probably just want reset!
16:56justin`dnolen: doh! exactly, thanks!
17:07mrb_bkdnolen: thanks!
17:07mrb_bkdnolen: yeah, was a balst
17:51antares_oskarth: if you don't need clojure.data.json or joda time integration, congomongo is probably
17:51antares_oskarth: monger is much better in my opinion but I am biased because it's my project :)
17:51antares_oskarth: oops, congomongo is fine is what I was saying :)
17:52oskarthantares_: how hard is it to switch? thinking about heroku/mongolab integration
17:52oskarthI used to use karras, but ran into problem when trying to remote connect, so I followed some example with congomongo. Would've given monger a shot otherwise
17:52antares_oskarth: should be pretty easy, both are pretty small libraries
17:53oskarthantares_: roger, will check it out
17:53antares_oskarth: monger should work fine on heroku. If there are ways to be more heroku friendly (like using some env variables for connection), I will happily add it
17:54antares_oskarth: we do this to support neo4j on heroku with neocons, another my project: http://github.com/michaelklishin/neocons, and langohr, my AMQP 0.9.1 client (http://github.com/michaelklishin/langohr) uses heroku's RABBITMQ_URL
17:54antares_so, adding stuff for heroku is very welcome
17:54antares_I am just not sure what else heroku users may need
17:54oskarthantares_: cool, currently I use a MONGOLAB_URI env which gets splitted into db, host, port etc
17:55antares_oskarth: ok, I think if you give me an example, I can add it over the weekend.
17:55technomancyon the library level it's best to just support configuring the connection as a string
17:55antares_oskarth: we can iterate over env variables present, like MONGOLAB_URI or MONGOHQ_URI
17:55technomancyand have the application pass in the value of (System/getenv "whatever")
17:55technomancythe key is to support a URL as well as a map
17:56antares_that's trivial
17:56antares_technomancy: with mongo it is a bit more tricky, though
17:56technomancyhttps://github.com/clojure/java.jdbc/commit/690296ba858c2d0e0f04bcd981addd48fa39c03f
17:56antares_technomancy: mongodb has mongo options most complex apps have, a way to configure client thread pool and such
17:56antares_it cannot be passed in as a string
17:56antares_but everything else can and I will make sure monger supports it
17:56technomancyoh, sure
17:56oskarthantares_: I use something very similiar to http://blog.markwatson.com/2011/10/experimenting-with-clojure-13-and-noir.html
17:56technomancybut that's different from connection parameters
17:57antares_oskarth: ok, well, technomancy is suggesting making it a bit easier on app authors and I agree
17:57oskarthI don't think that approach is anything mongodb-driver specific though
17:57antares_monger should accept URIs for connection
17:57antares_oskarth: it's not
17:57oskarththat would be great
17:57antares_but it's not the easiest thing possible
17:57oskarthindeed :)
17:58oskarthadded monger to watch list
18:05sivajaghi
18:05sivajagas anyone used compojure with clojure 1.3?
18:08seancorf`who is going to the Bay Area Clojure meetup tonight?
18:09technomancy~anyone
18:09clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
18:09seancorfieldLOL
18:09seancorfieldwell, i know you are _not_ going to seajure tonight :)
18:09technomancyseancorfield: hah; no that was for sivajag
18:10sivajag:)
18:11weavejestersivajag: You might want to post the error you're getting
18:11weavejestersivajag: I don't believe it's Compojure-specific.
18:12sivajagwhen I use compojure with clojure 1.3
18:12sivajagi am getting this error
18:12sivajag (use 'compojure.core)
18:12sivajagNoSuchMethodError clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V clout.core/request-url (core.clj:53)
18:12sivajagwith 1.2.1 it works fine
18:12hiredmanabi compat issue
18:12hiredmancode compiled with a different version of clojure than what you are using
18:12antares_sivajag: something loaded Clojure 1.2
18:13Raynesrm -rf classes/
18:14sivajagRaynes: tried doing … same error
18:14sivajagantares_: let me check my dependencies …
18:15antares_sivajag: it may be something like tools.cli or data.json, you need to exclude clojure dependency for them like so: [org.clojure/tools.cli "0.2.1" :exclude [org.clojure/clojure]]
18:16weavejesterWouldn't a dependency have to be something like "[1.2.1]" to force an earlier version of Clojure?
18:17seancorfieldantares_: all the new contrib libs are source only so those should not cause ABI issues?
18:17antares_seancorfield: my experience shows that they do
18:17antares_seancorfield: it may be an interplay between how leiningen loads things but something used to drag 1.2 onto the classpath, it hit several of my OSS projects
18:18antares_I think one of org.clojure/* artifacts was republished to retroactively add 1.2.1 compatibility
18:18antares_and because all my projects are 1.3.0+, I had exactly this issue several times
18:19antares_I have seen this on travis-ci.org multiple times, too
18:19antares_and helped a few projects pin point problematic dependencies
18:20antares_sivajag: can you share your dependencies list via gist or refheap?
18:20sivajagantares_: ok
18:21sivajagantares_: http://pastebin.com/wweTw6B7
18:23antares_sivajag: try adding :exclude like I pasted above for compojure and ring
18:23antares_sivajag: I see compojure has 1.2.1 dependency
18:23sivajagok let me try
18:24weavejesterantares_: In theory that shouldn't matter unless the dependency is "[1.2.1]"
18:24Raynessivajag: Can you confirm what Clojure version is in lib/
18:24Raynesweavejester: You're right, it doesn't.
18:24sivajagok
18:24antares_sivajag: also, I suggest that you try clj-http 0.3.6, it is definitely 1.3.0-ready while 0.2.3 may not be
18:24antares_*may be not
18:25sivajag clojure-1.4.0-beta3.jar
18:25RaynesIs that the only clojure jar?
18:25sivajagyah
18:25dakroneclj-http 0.2.3 is compatible with clojure 1.3, but you should use 0.3.6 regardless since there have been bugfixes
18:25RaynesIf so, the excludes aren't going to help and one of your dependencies has AOT'd code that was compiled against Clojure 1.2.
18:26sivajagRaynes: how do i find them?
18:26sivajagdakrone: updating clj-http and let me try
18:27sivajagdakrone: same error
18:28dakronefrom the original exception, it looks like an issue with clout
18:28RaynesPretty sure it is clj-oauth2.
18:28Raynesclj-oauth2 is AOT compiled for some reason and uses an ancient version of most everything.
18:29RaynesThere is a newer version of it though.
18:29Raynes0.2.0
18:29RaynesI'd try that and see what happens.
18:30sivajagok first let me try removing it
18:30sivajagand then I will try updating it
18:33sivajaguser=> (use 'compojure.core)
18:33sivajagNoSuchMethodError clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V clout.core/request-url (core.clj:53)
18:33sivajagnow I have dependencies only to [org.clojure/clojure "1.4.0-beta3"]
18:33sivajag [compojure "1.0.1" :exclude [org.clojure/clojure]]
18:33sivajag [com.datomic/datomic "0.1.2753"]
18:38sivajagFound the issue
18:38sivajagI had storm in my dev dependencies
18:38sivajagonce I removed it works fine
18:40aaelonywhat is the best way to repeat the first element of a vector 5 times, then the 2nd element 5 times, ..., nth element of the vector 5 times ?
18:41sivajagthanks guys
18:42Raynes&(mapcat (partial repeat 5) [1 2 3])
18:42lazybot⇒ (1 1 1 1 1 2 2 2 2 2 3 3 3 3 3)
18:42RaynesDamn him.
18:42aaelonywow... sweet
18:42aaelonythanks, raynes!
18:42RaynesOh, you're still here.
18:42Raynes:)
18:42aaelonyhaha yah
18:42RaynesI saw your ghost leave.
18:42Raynes:p
18:43aaelonyi realized i had another box on
18:47mkhow can I rewrite (bin3 v (fn [x] (bin3 (fa x) fb))) so that it doesn't have the fn, or is otherwise pretty?
18:52S11001001mk: (bin3 v #(-> % fa (bin3 fb)))
18:54mkS11001001: can that be done without the anonymous function?
18:56S11001001mk: I couldn't possibly tell you, not knowing what bin3 is. A function allowed to treat any function arguments as having indefinite extent (see the reader and state monads for exceptionally good examples of the power this gives you)
18:56S11001001but the result is that in general the translation from a program that uses closures to one that doesn't is not trivial, and requires deep knowledge of the underlying functions
18:56mkS11001001: indefinite extent?
18:58S11001001mk: may continue to live effectively forever (in reality, until GCed), as opposed to dynamic extent, such as you get with references to stack-allocated objects in C++
18:59mkS11001001: do you just mean that clojure has closures?
19:00S11001001mk: it's more than that; a closure may have dynamic extent and still be a closure
19:01S11001001it is just not as interesting
19:01mkS11001001: I'm not sure how a closure that expires very quickly (if I'm understanding you right) counts as a closure
19:02S11001001because it still refers to the lexical bindings in effect when it was created
19:02S11001001so, the thing is, bin3 can call the function you give it any number of times, or it could even return a result that includes it wrapped in some other bits
19:03mkyes - I see no problem so far
19:03S11001001you can write combinators like comp, partial, and flip that take functions and produce functions
19:03S11001001but the result probably won't be prettier
19:04S11001001(bin3 v (comp (partial (flip bin3) fb) fa))
19:04mkS11001001: the function there is just a test of the 3rd monadic law
19:04S11001001at this point I would say the version with lambda is clearer
19:05mk(= (bin3 (bin3 v fa) fb) (bin3 v (fn [x] (bin3 (fa x) fb))))
19:05S11001001oh, ok
19:05S11001001in that case, you might want to restate your laws in terms of fmap and join
19:06mkI'm trying to get my head around it, and I'm bogged down in the clojure syntax
19:06mkS11001001: how might I do that?
19:09dnolenibdknox: btw, playing with optimization stuff a lot more recently.
19:10dnolenibdknox: removing truth tests will help, but I'm realizing that one of the biggest things burning us now are related to how we handle complex expressions to if.
19:11S11001001mk: restate fmap as lift, and prove that (= ((lift (comp f g)) v) ((comp (lift f) (lift g)) v)) for functors, and so on
19:11S11001001the laws for join are different from the ones for bind
19:12S11001001but the result is the same
19:14mkis (= ((lift (comp f g)) v) ((comp (lift f) (lift g)) v)) the third monad law in its totality?
19:14S11001001it's associativity for functors; there are further laws related to join
19:14S11001001not having curried functions means that lambda expressions are much more useful in clojure than they otherwise would be
19:16S11001001if you prefer let, consider (letf [(name [args] result)] expr)
19:16S11001001ta ta
19:16mkthanks
20:27jtoyhow would you guys recommend to do url unrolling in clojure or in java?
20:28the-kennyIs there a fix/workaround for `lein swank' when Emacs locking tokens (.#foo.clj -> user@host...) are in the src-tree? It always throws a java.io.FileNotFoundException when I have unsaved files in emacs.
20:28dnolenjtoy: why would you need to do that in Java?
20:28dnolenjtoy: well unless there a library you want to use or something.
20:28jtoydnolen: because clojure is built on java? I'm new to both so not sure how people do it in either language
20:30dnolenjtoy: there's little need these days to write anything Java if you're using Clojure.
20:30jtoydnolen: string splitting!
20:31jtoydnolen: but yeah, i agree, i was asking how to do something earlier today and people were telling me to use java
20:31dnolenjtoy: huh. What was that?
20:31jtoyfinding the root url from a url
20:31technomancyjtoy: I don't think you understood what was being said earlier.
20:31jtoy (.getHost (java.net.URL. domain)
20:32technomancycalling java methods is not "writing java"
20:32dnolenjtoy: do you mean they meant you should call into Java libs? that's normal.
20:32jtoytechnomancy: yeah, i get that
20:32jtoydnolen: yes, thats what i meant by in java
20:32jtoymy bad wording
20:32dnolenjtoy: ok, sorry I was confused then. Yes, you can often save yourself some time by calling into a Java lib.
20:33jtoyso what is used for finding an unrolled url in clojure or called java?
20:34amalloy(.getHost (java.net.Url. domain)) sounds pretty good so far
20:34amalloyyou have some reason it's awful?
20:35dnolenjtoy: and if you like, you could write a simple wrapper over to get a more idiomatic interface.
20:35dnolen(:host (url domain))
20:35jtoyamalloy: that is different, unrolling is finding the real url, following all the redirects
20:35amalloyso far you haven't told anyone that's what you want to do
20:36jtoyamalloy: that is what url unrolling is
20:37technomancy,(.getPort (java.net.URL. "http://clojure.org&quot;))
20:37clojurebot-1
20:38jtoyseems like to do unrolling i do need to call a bunch of java :( http://stackoverflow.com/questions/2659000/java-how-to-find-the-redirected-url-of-a-url
20:39dnolenjtoy: the solutions look simple and easy to do.
20:39technomancyif you only need to "unroll" HTTP URLs, you can use clj-http
20:40jtoyyeah probably is, i have never written any java though
20:40jtoytechnomancy: cool, i will use that
20:42jtoytechnomancy: btw, not sure if that link is the best way to do it with regular java, but that fits into my definition of needing to write/know java
20:43technomancyit's a bunch of objects and the methods to call on them
21:12muhooanyone seen random crashes with noir on heroku? i'm getting this: https://refheap.com/paste/1826
21:27jtoytechnomancy: what version of clj-http are you using?
21:33muhoowh, nevermind, found it: https://devcenter.heroku.com/articles/dyno-idling
21:36muhooa clj app that takes 60+ seconds to compile and start up doesn't seem very compatible with heroku free 1-dyno tier, unf. my bad.
21:38muhooi am impressed though that so much of the heroku docs seem to use clojure as an example. i suspect i see the handiwork of technomancy in this :-)
21:39dsantiagodnolen: What is truth inlining in cljs?
21:47hiredmanclojurescript currently has to emit code to emulate clojureish behaviour for truthy tests in if, I imagine inlining is trying to get rid of that extra code
22:01technomancymuhoo: you can shift compilation to the build phase by doing "heroku config:add LEIN_BUILD_PHASE="compile :all" and enabling user_env_compile: https://devcenter.heroku.com/articles/labs-user-env-compile
22:01technomancythat should make dyno boot much quicker
22:08muhoothanks!
22:10muhooso it'll kind of aot compile, basically?
22:12muhoonm, i'll try it and find out.
22:17senthilhow do I install a plugin?
22:18senthiluse 1.2.1, want to install https://github.com/clojure/tools.trace
22:22muhoosenthil: in lein 1.7, i've been doing: lein plugin install pluginname "version"
22:22muhooi dunno about lein2
22:27senthilmuhoo: does it usually install without any output?
22:29muhooi don't remember. but you can check your ~/.lein/plugins directory to be sure
22:30senthilmuhoo: it seems to be installed, but i'm not able to load it in "clj" repl
22:31muhooif you type "lein classpath", what do you get?
22:31senthilCouldn't find project.clj, which is needed for classpath
22:32muhooyou're not in the project's directory
22:33senthilmuhoo: err, what project is that? .lein ?
22:33muhoooh, you haven't started a project yet, ok.
22:33muhooi dunno, for fun, just do "lein new someprojectname", cd into it, type "lein classpath", see if your plugins are showing up in there
22:34senthilmuhoo: yea they're
22:34muhoothen try "lein repl", and try to (use it.
22:35jayHi
22:36senthilmuhoo: lein repl works, but "FileNotFoundException Could not locate clojure/tools/trace__init.class or clojure/tools/trace.clj on classpath: clojure.lang.RT.load (RT.java:430)"
22:36muhoowat?
22:37muhooi dunno then. i'm pretty new to clojure myself, haven't seen that one.
22:37jayunit100So - im noticing that the if-let and when-let macros have [] rather than a function as the first form.
22:37senthilmuhoo: https://gist.github.com/2316211
22:37jayunit100seems like strange syntax... Why do these macros couple the "let" to the "if" ?
22:38muhoosenthil: ah, are you sure that's a plugin?
22:38muhooit doesn't look like one
22:39muhoosenthil: i'd try this: remove the plugin from your ~/.lein/plugins dir
22:39muhoothen instead, do as the git page says, add [org.clojure/tools.trace "0.7.3"] to the :dependencies of your project.clj file
22:41muhoosenthil: like this: https://refheap.com/paste/1828
22:41xeqijayunit100: to avoid writing something like (let [x ..] (when x ..))
22:41senthilmuhoo: got it, I assume I've to install it somehow
22:42muhoowell, if you type "lein deps", it will do that
22:42muhooor if you type "lein repl", it'll do that automatically AFAICT
22:43senthilmuhoo: awesome, thx!
22:44muhoosenthil: np, glad to be able to help