#clojure logs

2011-08-01

00:03jcromartieso, with compojure, (resources "/") does not work when running the handler from Swank or a regular REPL?
00:06amalloyuh, i don't understand what your question is, but the answer is "that is incorrect"
00:07jcromartieok
00:07jcromartieassume I have some routes
00:08jcromartie(defroutes my-routes ... (resources "/") (not-found "nope"))
00:08amalloyright
00:08jcromartiewhen running with lein ring, it serves up the stuff in resources/public just fune
00:08jcromartiefine
00:08jcromartiebut when I run lein swank and start my dev server that way, it doesn't serve them up
00:09jcromartie(files "/") will serve anything in public/ when running from swank
00:09amalloydunno, man. i never use lein ring, but it sounds like it may be doing some magic for you that you should be doing yourself
00:10jcromartieyes
00:10jcromartieI have to go, but the cursory look I gave to the source indicates that lein ring makes a war and reloads in on change?
00:11jcromartieI'll figure it out tomorrow
00:11jcromartieuntil then, (files "/")
00:11jcromartiebye!
00:42st3fanhm is there a function that merges a bunch of lists? like (foo [1 2] [3 4]) -> [1 2 3 4] ?
00:42dakrone,(concat [1 2] [3 4])
00:42clojurebot(1 2 3 4)
00:42st3fanah nice :)
00:43amalloythat makes it not a vector anymore, if that's a problem for you
00:44st3fannah that is fine
00:44st3fanb
01:07leonid_,(apply conj [1 2] [3 4])
01:07clojurebot[1 2 3 4]
01:08amalloyleonid_: :(. use instead ##(into [1 2] [3 4])
01:08lazybot⇒ [1 2 3 4]
01:10leonid_amalloy: awesome
01:11leonid_forgot that into does apply conj
01:11amalloyleonid_: it actually does reduce conj!
01:11leonid_ooh
01:11amalloybut the effect is the same
01:11leonid_yeah you are right
02:01MasseRSo majority of clojure datatypes are immuteable, but (def foo bar) creates a Var which is mutable? So I suppose (def foo bar) needs some consideration when used. (Not to mention that global values are usually a bit frowned)
02:02leonid_def is blocked on 4clojure
02:04MasseR4clojure?
02:06leonid_a site for 4clojure beginners
02:06leonid_to help them learn clojure
02:07leonid_it's a great site
02:07leonid_http://www.4clojure.com
02:07MasseROh, nice
02:22amalloyMasseR: (def foo bar) is generally fine at the top level, since it's creating (mostly) constants
02:23amalloyas a rule though, you shouldn't (def) anything at runtime. fine while you're developing to redefine things as you write better versions of def'd functions, but don't rely on it in finished code
02:23MasseROk
02:46hiredmantechnomancy: I've started on rewriting the scp bits in clojars to use apache-mina https://github.com/hiredman/clojars-web/tree/mina-sshd
02:47hiredmanit accepts files over scp and deploys them to /tmp right now, doesn't check credentials etc yet
03:29kostrikovhello from irssi
03:29ohwow_Hello
04:48fhdHi
04:48fhdIs anyone using ClojureScript with Maven yet?
04:51fhdAnd if not, can you point me to a typical Leiningen ClojureScript project?
05:00MasseRleonid_: Damn you for pointing out 4clojure :D
05:25MasseRHow does clojure handle IO concurrency? With explicit threads? Select? Something else?
05:36pyrhey
05:38_atoMasseR: Clojure core itself does not address IO concurrency. Yes you can use threads or select.
05:39_atoYou might find the Aleph library interesting for async IO: https://github.com/ztellman/aleph
05:39MasseROh :/. AFAIK haskell IO scheduler uses epoll automatically
05:40PupenoHello.
05:41pyrbuilding a mostly clojure backend for new company from infrastructure to storage to other parts if people are looking for work in switzerland, or maybe remotely, you can leave me a mail at pyr@spootnik.org
05:44_atoMasseR: Clojure doesn't have green threads, which is I assume is what Haskell uses epoll for
05:49MasseR_ato: So clojure threads are OS threads+
05:50MasseR_ato: What is the clojure thread performance? On haskell it's ok to create >100k threads
05:50luccayou can probably check performance reports for java threads.
05:52MasseRApparently, exhausting threads is an issue
05:53MasseRAnd the limit is relatively low
05:53MasseRBut I do see mentions about thread pools. Is it manual on clojure too?
05:54luccayou might need to use a different abstraction than on haskell.
05:55luccait's not too bad to turn many separate threads to instead be items in a queue of io operations handled by a small pool of worker io threads
05:55luccaI don't know of libraries for that, though
05:56MasseROn haskell I'd just 'forkIO' for every incoming request :P
05:57_atoMany Clojure concurrency primitives will use a thread pool by default, like agents and pmap. There's usually the (programmer's) option of creating a thread-per-job for jobs that you expect to block.
05:58_atoCurrently there's no automatic use of select/epoll though. Not a strong story in Clojure core for 100k connection I/O. But there are plenty of JVM libraries for doing that sort of thing like Netty which Aleph builds on top of
05:58MasseR_ato: How does the thread pool handle blocking io? A queue of jobs?
05:58_atoit doesn't
05:59MasseRs/handle blocking io/handle jobs/
05:59lazybot<MasseR> _ato: How does the thread pool handle jobs? A queue of jobs?
06:00_atoyeah basically. agents tasks queue per agent in the order they were sent. pmap queues well, it's a parallel sequential map so it just queues in the order of the sequence you're mapping over
06:01_atoetc
06:03MasseRSo the hype about clojure concurrency is about how easy it is to reason (STM), not necessarily the performance?
06:15raekMasseR: lock free reads might count as a performance argument
06:15raekbut program correctness for concurrent programs is a big thing
06:18raekI recomment checking out ExecutorService and related classes
06:18raekhttp://download.oracle.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html
06:19raekI made a small introduction on how to use them from clojure: http://blog.raek.se/2011/01/24/executors-in-clojure/
06:20MasseRthanks
06:21raekCompletionService might be useful too
06:22_atoMasseR: right. if you're after ultimate I/O performance there is going to be a lot of better choices than Clojure. Clojure's performance is pretty good (mainly thanks to the JVM's good JIT and GC), but using immutable persistent data structures is of course going to have some performance impact unless the problem is extremely read-heavy.
06:23raekbut to summarize: JVM threads are heavy so it might not be a good idea to create thousands of threads. but the java standard library has good support for thread pools and these intergrate pretty well with clojure
06:25raekMasseR: this book is _the_ book to read if you want to look at these things in detail: http://jcip.net/
06:25raek(Java Concurrency in Practice)
06:26raekyou can pretty much skip the chapters about coding in a thread safe manner, since clojure takes care of that for you :-)
06:28MasseRthanks for all of your help. I'm not looking to creating anything (yet), just trying to see how clojure compares :)
06:37_atowhen compared to Haskell I'd consider the huge JVM ecosystem (in terms of libraries, tools and ops team experience), simple and very cohesive language design, dynamic typing (which might be a con, depending on preferences) and being a Lisp (again a pro for some people con for others) the major comparison points rather than concurrency or performance as Haskell has a pretty good story for those too. Probably Clojure's concurrency model
06:37_atois better at certain things and Haskell's at others.
06:39MasseRmy take on it is the simplicity of clojure and the jvm
06:40MasseR(and also the simplicity of the syntax. erlang is bulky :/)
06:41fhdNow that it's more crowded here, I'll ask again: Does anybody know a nice Clojure + ClojureScript project template? Preferably Maven, but I'll take anything.
06:43_atofhd: I assume you've seen: https://github.com/maxweber/cljs-devmode ?
06:44fhd_ato: Nope, didn't know that, I'll take a look
06:45_atoI haven't tried it, just saw the announcement on the mailing list. I haven't done any Clojure + ClojureScript work yet, just stinkered with standalone ClojureScript a bit
06:45MasseRdoes clojure stm have retry and <|> combinators?
06:45fhd_ato: I found plenty of cljs standalone samples, but what I want to do, a Clojure + ClojureScript project, is nowhere to be found
06:48_atoMasseR: it will retry a transaction if there's a conflict, if that's what you mean. I don't know the terminology "<|> combinator"
06:49MasseRthe latter is if a fails try b
06:50MasseRand by retry I meant like "foo or bar or retry" (weird syntax but I'm on mobile atm)
06:52raekMasseR: I don't think you can trigger a restart manually in clojure
06:52MasseRok
06:53raekMasseR: this is a really good article about the STM: http://java.ociweb.com/mark/stm/article.html
06:54MasseRthanks
06:56triyoAnyone have some experience in building web pages with Enlive?
06:56triyoI love the decompiling it offers between the templates itself and the logic.
06:57triyohowever I have come across an interesting problem I am trying to find the best solution for.
06:58triyoI have a nav.html template for navigation. I have introduced an auth component to the web app and now wish to show/hide links depending on auth.
06:58triyoThis part seems to be a bit tricky at the micro level.
06:59triyoWhat would be a common way to do this in enlive?
07:00triyotypo *decompiling =decoupling
07:00thorwiltriyo: you could have just one link in the template and clone it depending on a map that is handed over by your controler
07:01thorwilor have all the links in the template and include/exclude with a list of booleans
07:02triyoI like the second approach, thanks
07:03triyoTo add to the second approach, I will have all links visible by default and let the template function just supply a list of *excludes*
07:04thorwilit's stuff like this that made me switch over to just hiccup, as i had to notice that the html templates alone are bulkier than corresponding hiccup and the enlive template functions i had to write grew in number and complexity
07:05triyothorwil: complexity is what Im starting to see slowly as my app is increasing in size and complexity.
07:05thorwilof course, this decision is based on the fact that i write everything myself, anyway
07:06triyoI guess the decoupling comes at a price
07:06_atoif you have lots of things to show and hide depending on an auth role it occurs to me you could make up a custom attribute to tag them with: <a href="..." role="superadmin"> <div role="manager">
07:06thorwildefinitively
07:06_atoand have enlive remove them as appropriate
07:07triyo_ato: exactly. However there is no doubt that it is a bit of a mind shift from traditional thinking when it comes to html templates.
07:07triyoThats the part I'm battling with a bit at this stage.
07:08triyoI think, if one builds the most common html template abstractions on top of enlive, then you are pretty sorted.
07:36triyoWhat is the simplest way to to remove/exclude elements from the template. So as _ato suggested, I marked my links with relevant roles (role="admin") and now wish to remove the admin roles when isadmin? auth predicate is false.
07:37triyoin *enlive* that is
07:38triyoI know how to create the right selectors, its the transformation step I am missing..
07:38MasseROn my last question. With haskell it's possible to for example `if count xs > 0 then return (head xs) else retry`, which returns the head of the list if there is something in there, or otherwise waits until some other transaction has finished. Is this possible with clojure?
07:40triyo(if (> (count xs) 0) (first xs) retry)
07:40triyothats the the same *if* form in clojure
07:41MasseRSo there is a retry function? ClojureDocs didn't find it
07:42manutterThe retry function itself does not exist, but there are transaction-oriented structures in clojure
07:42manutterdepending on the broader context of what you're trying to do, it should be possible.
07:42manutter(though I'm not sure off the top of my head how)
07:43MasseRRather, I remember Simon Peyton-Jones mentioning that just a simple transaction isn't enough, you need combinators such as retry and or-else, and that was the simplest example I could think of that uses those
07:46manutterI can envision a macro something like (defmacro with-retry [pred &body] `(while (?false ~pred) (Thread/sleep 200)) ~@(body))
07:46manutterwith the caveat that I'm not a very good macro writer, and I havent had any coffee in a very long time
07:46MasseRHeh
07:47manutterbut if you had a working version, you could call (with-retry #(> (count xx) 0) (first xs))
07:49manutterHmm, that would have limited usefulness, though -- if you had to do a certain amount of calculation before you knew whether a retry was needed or not, there'd be code duplication or other complications
07:50MasseRAnd unless I'm totally mistaken, that's not composable
07:50MasseRCompare to `foo or-else bar or-else retry`
07:50manutterYou're not mistaken, that's the gotcha with macros
07:50dnolenMasseR: seems like a use case better suited to other concurrency constructs? your example sounds like producer/consumer
07:51MasseRdnolen: I haven't done much concurrency, not to mention with STM. I have just played a little with haskells STM
07:52MasseRBut yes the example earlier is from a simple push/pop channel with lists
07:52manutterThe retry function reminds me of a conditional recur, so I'd expect it would be possible to write one, but it'd be hairy
07:52manutterI think the more idiomatic way would be to use the concurrency constructs, like dnolen is saying
07:53dnolenMasseR: yeah STM is overkill and inefficient (I think) for something like that. Java queues are designed for high performance consumer/producer
07:53MasseRdnolen: I agree. I wouldn't do that in production, but as a simple one-line example I think it's ok
07:54dnolenMasseR: I'm sure rhickey just left out features from Clojure's STM that aren't generally useful.
07:55manutterHeh, I'm reading thru _Clean Code_ by Uncle Bob Martin, and just got to Chapter 13: Concurrency
07:55dnolenor weren't solved (that is couldn't meet reasonable performance criteria)
07:56manutterThis should be fun :)
08:32ellsmorning to some, evening to others
08:35triyoI have a selector as follows in my enlive code.. [(attr= :role "admin")] (if admin? (content "xxx") (content)) ... I admin? is true, I wish to return just the content thats in the template and not "xxx" of course, if admin? is not true, I just return (content).
08:36triyoSomething doesn't seem right. How do I apply conditional login in enlive for a selector?
08:37triyoSo when condition is meat, it should just return what was selected as per selector.
08:37triyo*login=logic
08:38triyowell as a matter of fact, I don't need the else part (content) at all of course.
08:41raektriyo: content replaces the content
08:42raektriyo: I think you want unrwap or something
08:42raekalso, the right hand side should evaluate to a function
08:43raektriyo: (fn [node] (if (admin? node) (unwrap node) nil))
08:44raek"Transformations are closures which take one arg (the selected node) and return
08:44raeknil, another node or an arbitrarily nested collection of nodes."
08:44triyoOh see what you mean.
08:44raekyou could replace (unwrap node) with ((remove-attr :role) node)
08:45MasseRDamnit. Isn't it enough that haskell ruined php for me, but now even clojure made it even worse :D
08:47triyoraek: that worked of course, however, I had to remove the unwrap bit and just return the node if admin? true
08:47triyothanks
08:48raektriyo: you can use remove-attr as a separate transformation step to remove all "internal" markings of your elements
08:49raek[(attr? :role)] (remove-attr :role)
08:49triyoraek: ahh, yes to remove non-standard html before sent to the browser. Nice
08:50triyonon-standard element attributest to be exact.
09:12phenom_anyone know why records that implement a protocol dont have to implement all methods?
09:13dnolenphenom_: because that's not a good interactive programming experience.
09:43mattmitchellany opinions on testing in clojure, and specifically midje?
09:53jcromartiemattmitchell: I've been happy with clojure.test so far
09:53jcromartiebut, wow, midje sure is packed with stuff
09:54manuttermidje is kinda fun too :)
09:54mattmitchelljcromartie: yeah we're using midje now and liking it. some of the devs think it's a little too magical though, so wanted to see what others thought of that.
09:56manutter,(let [passed :), failed :(] (if (> 3 2) passed failed))
09:56clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Invalid token: :>
09:56manutter,(let [passed :), failed :( ] (if (> 3 2) passed failed))
09:56clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Invalid token: :>
09:56manutteroh well
10:03jcromartieI see, so midje lets you do *real* test-first
10:03jcromartiei.e. write and compile tests even if the api/functions don't exist yet
10:03jcromartieawesome
10:03jcromartiea la Smalltalk
10:03PupenoWhat does (JFrame.) do?
10:04MasseRI'd say it creates a new instance
10:04Pupenojcromartie: any dynamically typed language let's you do that.
10:04Pupenowell… almost… (just in case)
10:04MasseRHmph I think my lein is borked.
10:05jcromartiePupeno: I'm not sure dynamic typing is the main prerequisite there
10:05jcromartieyou can't compile Clojure code when the names don't resolve
10:05jcromartieso Clojure fails that
10:05thorwilwasn't the special thing about test driven devel in smalltalk that you can write the "fixes" inside the debugger?
10:06jcromartiethorwil: yes.
10:06jcromartieyou can implement missing classes and methods from the middle of atest
10:06jcromartieit's pretty incredible really
10:06jcromartieDon't tell Emacs I'm cheating...
10:13phenom_anyone interested in helping me out on an oss project?
10:15MasseRphenom_: I'm sure you'll find helpers if you tell what kind of project it is / show the project page / github
10:15mattmitchelljcromartie: yes, you can certainly test first like you mentioned, with midje
10:19phenom_sure, give me a shout if you're interested in mq's, nio and stomp http://github.com/djunforgetable/balrog :D
10:55MasseRWhat characters are allowed in function names?
10:55Chousukemost
10:56Chousukeif you can think of a character having some special meaning elsewhere then it's probably not allowed but all others are
10:56Fossii'd guess those that java allows minus some special chars that are used for the reader?
10:56ChousukeClojure allows more
10:56Chousukelike ? and ! and -
10:57MasseRGreat
12:22jkkrameri'm having problems reading data from resources on heroku. has anyone done this successfully?
12:23jkkrameri've tried referring to the resource with (str "resources/" filename) and (-> (Thread/currentThread) .getContextClassLoader (.getResource path)), both of which work locally but break when deployed
12:23hiredmanjkkramer: most likely you are passing the result of (resource ...) to something that can't handle a jar: url
12:24hiredman(most funs in clojure.java.io cannot)
12:24jkkramerhiredman: i'm passing it to (read-string (slurp ...))
12:24jkkramerit works fine when running on my dev setup
12:25hiredmanright
12:25hiredmansee what I just said
12:26hiredman(.openStream (resource …))
12:26raekbut clojure.java.io/intput-stream can handle jar urls, right?
12:27hiredmanI doubt it
12:27hiredmanclojure.java.io general blows up (and sometimes blows up very badly) on jar urls
12:27jkkrameri guess i'm confused about why it would work when running locally but not when deployed. the heroku environment seems to have some idiosyncrasies
12:28hiredmanI could be wrong
12:28raekjkkramer: using a filepath relative to the project path is probably not gioing to work, unless heroku unzips the jar
12:29jkkramerah right
12:29raekopening the resource from the classpath sounds like the right thing to do
12:31raekhiredman: (require '[clojure.java.io :as io]) (slurp (io/resource "clojure/core.jar")) works in my repl
12:31raekand slurp calls io/reader, iirc
12:31hiredmanraek: thats not a jar url
12:32hiredmanunless you have clojure/core.jar in a jar
12:32raek*core.clj
12:32hiredmanfine
12:32raek(io/resource "clojure/core.clj") => #<URL jar:file:/home/raek/.m2/repository/org/clojure/clojure/1.2.0/clojure-1.2.0.jar!/clojure/core.clj>
12:32raekthat was a typo, sorry
12:33raekI was surprised since I was sure that I had used this before
12:34raekjkkramer: does (read-string (slurp (io/resource filename))) work?
12:35raek(with-open [in (-> filename io/resource io/reader)] (read in)) <-- this avoids the intermediate string
12:36lobotomymorning folks. i'm at the point in my project where i think i might need... a variable. but i'm not sure how to proceed :)
12:37raeka mutable variable or would a 'let' be enough?
12:37lobotomyi'm porting my puzzle solver from java to clojure. in the java version i have a "wireframe" thing which is mutable, onto which are grafted the (clones of edges of) immutable pieces, while the solver proceeds
12:38lobotomyi'm thinking i could also do the wireframe immutably: insert new piece -> for each affected edge, create a new amalgamated edge, and update the next-edge pointers from the old to the new one
12:38jkkramerraek: still works locally but breaks on heroku
12:38lobotomyor i could do it mutably: insert new piece -> for each affected edge, just change its content and leave alone the next-edge pointers
12:39raekjkkramer: what does the error say?
12:39raekjkkramer: how do you give the app to heroku? as a jar?
12:39lobotomywell, in both cases i'd also have to change (in some cases) some of the successor edges, so hmm, immutability would seem to be more complicated here
12:39jkkramerraek: java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
12:40jkkramerraek: they have a git-based deployment process, with some server magic going on on their end. it's kind of a black box
12:40lobotomyso my question is: for a mutable wireframe, should i use a ref or an atom or what?
12:40raekjkkramer: ok. looks like io/resource returns nil here. that means that the file is not on the claspath.
12:40raekjkkramer: I suspect heroku is not aware of the resources/ convention
12:41lobotomy(eventually when i get to multiple threads, each thread would have their own copy of the mutable part of the thing, so i don't need to synchronise that part)
12:41raekjkkramer: does it work to have the files in src/ instead of resources/
12:41jkkramerraek: it runs the app via leiningen. i could try putting in some explicit project.clj directives...
12:41raekhrm. then that idrectory should be on the classpath
12:42raekassuming they use leiningen to construct the classpath
12:42raekwhich they might not
12:43raekplacing resource files in src/ shoud confirm or falsify this theory
12:44KeithWysslobotomy: if you truly don't need to synchronize changes across threads, think of using an agent.
12:44raekjkkramer: my theory is that heroku is does not use leiningen to build the classpath, but uses something hardcoded, like 'src/:classes/:lib/*', which does not include resources/
12:45KeithWysslobotomy: http://clojure.org/agents
12:46drewrlobotomy: also read through the ants demo code to get an idea of how rhickey solved a similar mutable-world problem (using refs)
12:48jkkramerraek: ah jeez, user error. the resource wasn't actually committed due to .gitignore. thanks for your help
12:52KeithWyssjkkramer: ouch. That's frustrating.
12:56PupenoAny ideas what I could work on, Clojure related, during a hack day at work?
12:57technomancyPupeno: I recommend clojars
12:57technomancythere's a thread about contributing here: http://groups.google.com/group/clojars-maintainers/browse_thread/thread/d4149ec96316d5b1
12:58technomancyit's probably the #1 highest-profile oss clojure project, but it doesn't get much attention
12:59PupenoI see.
12:59hiredmantechnomancy: I started a branch over the weekend moving to mina sshd (dunno if you saw my earlier msg)
13:00technomancyclojurebot: contributing to clojars is a great idea! see http://groups.google.com/group/clojars-maintainers/browse_thread/thread/d4149ec96316d5b1
13:00PupenoNot sure if it's the best as I'm not that knowledged on Java, jars, Maven and so on… but I'll take a look anyway.
13:00clojurebot'Sea, mhuise.
13:00technomancyhiredman: yes yes awesome. will try to take a look before thurs.
13:01technomancyPupeno: there are plenty of pure-clojure features that would be great to have.
13:02Pupenotechnomancy: I see.
13:06PupenoQuick question, do you know if you can just run clojars locally, without having to setup nginx and so on?
13:06technomancyPupeno: best to run it inside a VM. see the "vagrant" branch on my fork.
13:06technomancyhope to get it into mainline soon
13:11pyrwhen splitting up functionnality
13:11pyrsometimes it'd be nice to define defmultis in one namespace
13:11pyrand defmethods in another
13:12pyri.e for a caching layer: cache.clj and cache/redis.clj, cache/memcache.clj
13:12pyrhow do you handle dependency in that case
13:12pyrit seems the sub namespaces need to have the main one as a dependency
13:13pyrto know about the defmultis
13:13pyrbut then the other way around is true as well
13:13pyrand circular deps won't work
13:14pyrwait
13:14pyri'm stupid is all
13:14Pupenotechnomancy: what do you mean by VM? a Linux VM?
13:15technomancyPupeno: yeah. it's easiest to get going with vagrant, which uses virtualbox.
13:15technomancysince you need a bunch of system-level packages
13:16technomancyI don't know if you can populate the DB without running the scp server.
13:17Pupenotechnomancy: that would be a problem to code.
13:17PupenoI mean… to have a nicely populated db… for some things.
13:17hiredmanif I finish the scp stuff I'd like to move the db to apache-derby
13:17technomancythat would definitely help
13:17PupenoDo you code inside the DB?
13:17hiredmanthere is an sqlite dump you can download
13:18hiredmanclojars currently uses sqlite
13:18technomancyhiredman: but the dump has passwords wiped, so you can't use it out of the box
13:19hiredmanmmm
13:19technomancyyou could probably twiddle it, but I found it easier to just create a new account on a fresh db and do some uploads
13:30Pupenotechnomancy: do you code inside vagrant?
13:30Pupenoinside the vm I mean.
13:31sjlPupeno: Vagrant sets up a shared folder for you, so you can edit in the host OS and the VM will see it.
13:32technomancyclojurebot: oracle is currently at threat level yellow: http://steveonjava.com/wp-content/uploads/2011/07/threat-level.png
13:32clojurebot'Sea, mhuise.
13:32technomancyPupeno: I haven't done much with clojars, but for the day job I code mostly inside a vagrant VM
13:32technomancyPupeno: but it's easy to use the shared folder as sjl mentions
13:51technomancyPupeno: right now clojars is not the most contributor-friendly codebase; I actually hope to get a chance to smooth things over before the seajure meeting on thursday
13:51PupenoWhat is seajure?
13:51technomancyseattle clojure group
13:52technomancyclojurebot: seajure is the seattle clojure group: http://seajure.github.com
13:52clojurebotAck. Ack.
14:42kaiser,(println "test")
14:42clojurebottest
14:43kaiser,(println (+ 41 1))
14:43clojurebot42
14:43kephale,(println ",(println \"test\")")
14:43clojurebot,(println "test")
14:43kephaleaww : P
14:44kephale,(println "&(println \"test\")")
14:44clojurebot&(println "test")
14:44lazybot⇒ test nil
14:47kephalemmm friggin ⇒
14:49kephalewhich bot responds to ##(println "test")
14:49lazybot⇒ test nil
14:49kephaleah
14:53wwmorganI'm using enlive to get a piece of parsed HTML like this: {:tag :table, :attrs {:style "..."}}. What's the library or function to reverse this, and give me "<table style='...'></table>"?
14:55raekwwmorgan: emit, I think
14:56raekor maybe emit*
14:56wwmorganraek: aha. enlive's emit* is what I want. Thanks!
16:04zvrbahello. what resources could you recommend for learning clojure?
16:05tufflaxclojure.org personally
16:06tufflaxzvrba http://stackoverflow.com/questions/2578837/comparing-clojure-books
16:07zvrbaok, thanks!
16:08tufflaxzvrba also this http://news.ycombinator.com/item?id=2753467
16:44triyoNot sure if anyone will find this useful. In ClojureScript code, I have a config.cljs file with prod and dev tests like so: (def production? (js* "/yourprodsite.com$/.test(window.location.hostname)")) (def development?
16:44triyo (not production?))
16:44Pupenotechnomancy: I got clojars running on my mac following the four steps in the read me… what's the issue for using vagrant?
16:47technomancyPupeno: most people don't like to pollute their main machine with the services necessary to get things like that running, especially once you consider that with multiple services you often have conflicting versions required. but if it works in your case, then go for it.
16:47triyoI find it pretty neat when switching between dev and prod. I have quite a few public api ajax callouts, so in dev I just call up the mock json data and in prod it calls the live apis.
16:48technomancyPupeno: I guess the other thing is that it's easy for mac-specific problems to sneak in when you're developing on a different platform than you're deploying to. for instance, if you accidentally wrote code that relied on a case-insensitive file system, you would'nt know until it was deployed to clojars.org
16:49clojureExpertWanhello
16:49Pupenotechnomancy: I just run the jar… didn't have to polute everything.
16:50clojureExpertWanI am an extreme nub to this language, I would like to change that...
16:50technomancyPupeno: well presumably you had to install nginx and sqlite
16:50clojureExpertWanSooo could anyone help me with something I am having trouble with?
16:50amalloy~anyone
16:50clojurebotPlease 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.
16:50Pupenotechnomancy: sqlite I already had… no nginx.
16:50jcromartiehm, looking at FleetDB, it seems that it appends the whole DB when making a snapshot
16:50jcromartiethat could get quite slow, no?
16:50jcromartieinstead of appending each transaction to the log file?
16:52clojureExpertWan(do (def a ((. javax.swing.JOptionPane (showInputDialog nil "Hello World"))))) #<CompilerException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:1)>...I am trying to get input and it keeps saying this?
16:53technomancyPupeno: also unless you're no ubuntu you can't test the init scripts
16:53technomancy*on Ubuntu
16:53amalloytoo many (s after a
16:54clojureExpertWanno its saying the string cannot be cast...I tried the ^String but I do not know what I am doing obviously
16:55technomancyPupeno: it just depends on what level of fidelity you want re: mirroring production environment
16:55amalloy$javadoc javax.swing.JOptionPange showInputDialog
16:55amalloy$javadoc javax.swing.JOptionPane showInputDialog
16:55lazybothttp://download.oracle.com/javase/6/docs/api/javax/swing/JOptionPane.html#showInputDialog(java.lang.Object)
16:55technomancythe more differences there are between the dev environment and production, the more surprises are likely to sneak in at deploy-time.
16:56clojureExpertWanI am just trying to see if I can actually assign input from a dialog box
16:56amalloyyou can. you might have other problems, but one problem is there are too many (s after the a
16:57clojureExpertWanlol
16:57clojureExpertWanyou are right
16:57wtf__ftwIs there anyone that can help me debug a ns problem?: http://pastebin.com/599dR9sK
16:57clojureExpertWano my i am a horrible nub
16:57clojureExpertWanthank you for your help
16:57amalloywtf__ftw: drop the parens around your namespaces
16:58wtf__ftwwhat, like: "(:use my.game)
16:58wtf__ftw?
16:58amalloyclojureExpertWan: suggestion: when you come in saying "i don't know what i'm doing but X doesn't work", and someone says "do Y", don't respond with "no, Y can't be it"
16:58clojureExpertWani did...btw my name is supposed to be clojureExpertWannabe
16:58amalloyyes
16:58Pupenotechnomancy: I code web applications like this all the time… for a living… so yeah, there might be some differences and that's why I normally use staging servers.
16:58Pupenotechnomancy: what are these init scripts yo talk about?
16:59amalloy~ns macro
16:59clojureExpertWanyes I am sorry about that... I guess I thought that I knew better but thank you for being patient
16:59clojurebotcontains? is for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use the java method .contains
16:59technomancyPupeno: clojars uses upstart to manage its daemons
16:59amalloytechnomancy: dang it, where did you teach clojurebot to say useful things about ns
17:00technomancyclojurebot: ns form?
17:00clojurebotregular expressions is http://www.regular-expressions.info/tutorial.html
17:00technomancyclojurebot: botsmack
17:00clojurebotclojurebot evades successfully!
17:00technomancydang iiiiit
17:00tufflaxlol
17:00technomancyclojurebot: the ns form?
17:00clojurebotthe ns form is more complicated than it should be, but it's better-documented at http://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-ns
17:00Pupenotechnomancy: what daemons does it need? the app itself (I presume there's nothing like Phusion Passanger, yet); anything else?
17:00technomancyPupeno: the other part is the scp load balancer
17:01technomancyhang on
17:01Pupenotechnomancy: ah… sounds interesting and a pain in the ass.
17:01technomancyhttp://p.hagelb.org/clojars-deploy.html
17:01wtf__ftwamalloy, removing the extra parens gives this error instead: "java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol"
17:01technomancyPupeno: only a pain if you set everything up manually =)
17:01wtf__ftw4 hours of debugging tells me it comes from the ns macro form
17:01technomancyif you use vagrant it gets set up for you
17:02amalloypaste your current "fixed but still broken" version
17:05Pupenotechnomancy: I see.
17:05wtf__ftwamalloy, here's the new paste: http://pastebin.com/W2xEPyVT
17:06amalloylooks good to me. i think your error is elsewhere now
17:06technomancyPupeno: if you can do scp uploads on your main machine you probably don't need to worry about it, I'm just explaining why this method is what I'd recommend by default for folks getting started.
17:07Pupenotechnomancy: I understand.
17:07wtf__ftwamalloy, looks like I'm still getting the ISeq from Symbol error from above
17:07Pupenotechnomancy: can I ask you few more questions about it?
17:08technomancyPupeno: I'm about to get on the phone so I probably won't be too responsive, but _ato might be online soon, so it doesn't hurt to ask.
17:08amalloyyour namespace form is fine. you're either using stale versions of that code, or your problem is elsewhere
17:08PupenoOk.
17:09PupenoSo you upload these two files… then what happens? There's a process in clojars that is polling for files or something like that and adds them to the database?
17:10wtf__ftwamalloy, I've put up an updated paste: http://pastebin.com/8t52SPQL
17:10technomancyPupeno: it hooks up to nailgun which connects to a listener directly in the main web app process.
17:10hiredmanno, when you upload the files they are handed off to the clojure
17:10hiredmanclojars
17:10wtf__ftwit's the only other file I have my leiningen project
17:10hiredman(what technomancy said)
17:11amalloy(a) your first two ns forms are still wrong, (b) gen-class may or may not be right, i don't use that
17:11hiredmanclojars actually runs as a 'scp-shell' sort of thing and recieves the files directly
17:11hiredman(which is pretty nuts)
17:11_atobut it works :)
17:11wtf__ftwamalloy, the (a) part: which part looks wrong?
17:11_atoI am liking your rewrite of the scp code though
17:11Pupenohiredman: clojars is set as a scp-shell for a user?
17:12Pupenoas shell.
17:12hiredmanPupeno: yes (but ask _ato)
17:12technomancyit does work surprisingly well =)
17:12amalloywtf__ftw: everything. your paste at http://pastebin.com/W2xEPyVT is perfect, but your latest at http://pastebin.com/8t52SPQL goes back to the pre-fix version
17:12dnolenwtf__ftw: missing a closing paren on line 2
17:12_atoPupeno: nailgun is, which connects to the clojars process
17:12hiredman_ato: nuts and ingenious
17:12wtf__ftwah, hold on, Pastebin used the old version
17:12wtf__ftw... new version in a second
17:12PupenoI don't know nailgun, are you talking about http://www.martiansoftware.com/nailgun/ ?
17:13_atoyep
17:13PupenoIs there a way to trigger the upload process without having a user and so on?
17:13_atoso there's a small C client which connects via socket to the JVM process and pipes its stdin/stdout over that socket
17:13_atonot really
17:13wtf__ftwcorrected paste: http://pastebin.com/Sb2c2rB6
17:14amalloyeverything (except, again, the gen-class which i'm not going to try to figure out) looks perfect there
17:15wtf__ftwthat's helpful I guess, thanks amalloy
17:15wtf__ftwand dnolen
17:15dnolenwtf__ftw: what dev env r u using?
17:16wtf__ftwlein
17:16dnolenwtf__ftw: lein and a regular text editor? vim? emacs?
17:16wtf__ftwlein + emacs
17:16dnolenwtf__ftw: SLIME ?
17:17wtf__ftwI have swank turned off
17:17wtf__ftw(slime on my system is already configured for Common Lisp development under sbcl)
17:18dnolenwtf__ftw: debugging this kind of stuff is a bit painful with SLIME since you can't test individual forms.
17:18dnolens/with/without
17:18lazybot<dnolen> wtf__ftw: debugging this kind of stuff is a bit painful without SLIME since you can't test individual forms.
17:18wtf__ftwI hear that
17:19Pupenowtf__ftw: clojure-jack-in seems to be able to run SLIME with Clojure without changing your configuration… but don't take my word for it.
17:19Pupeno
17:20wtf__ftwhmm
17:20wtf__ftwI'll check that out
17:37jowagHi, how do I get the type of object in ClojureScript? I want to test if a specific object was created with my specific deftype or not
17:45wtf__ftwthanks for the help guys, I need to get going, but the newer version of clojure-mode w/swank should help
17:47jowagnevermind, found it, it is with function called "instance?"
17:49scgilardijowag: did the function type not work?
17:49scgilardi(type my-object)
17:50dnolenscgilardi: ClojureScript doesn't have type yet. JavaScript doesn't it make it easy to support either.
17:50scgilardiok, thanks
17:54krlhmm. can you have slime display errors that occur in other threads than the main one?
17:57triyoI came across this post that shows that in CLJS, one can compile third_party libraries. This post shows the details: http://groups.google.com/group/clojure/browse_thread/thread/f45efc0ead9c56b0/5eaa69d8f6d18711?lnk=gst&amp;q=clojurescript+src#5eaa69d8f6d18711
17:58triyoI get an error when calling the third part library though after running it through the compiler.
17:58triyoUncaught ReferenceError: Showdown is not defined
17:59triyoMeaning, it doesn't even find the top-level function of the library called Showdown
17:59triyoanyone tried to compile third-party libraries?
18:01ordnungswidrighi all
18:18gstampis there any easy way to clear out a namespace? At the moment I'm restarting swank every time I need to do this.
18:24FrozenlockIf you're using emacs: M-x slime-repl-clear-buffer
18:26amalloyuh, that's not what he wants
18:27amalloyyou want ##(doc ns-unmap) or ##(doc remove-ns)
18:27lazybot (doc ns-unmap) java.lang.SecurityException: You tripped the alarm! ns-unmap is bad!
18:27lazybot (doc remove-ns) ⇒ "([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace."
18:28FrozenlockOh, my apologies
18:40amalloyanyone know if clojure.contrib.def has been migrated to a non-monolithic contrib?
18:43technomancyamalloy: pretty sure it hasn't
19:07lynaghkHi everyone, I'm just getting into ClojureScript and I have a few questions about JavaScript interop
19:08lynaghkIn particular, how can I make native JS objects. Something like (range 3) -> [0, 1, 2]
19:09lynaghkprinting (range 3) to the JS console gives me an object of type cljs.core.LazySeq.
19:11lynaghk(.array (vec (range 3))) will work, but is that the recommended way to interop?
19:57RaynesAre there plans to implement letfn in ClojureScript?
20:03gstampamalloy: thanks (belated)
20:42NikelandjeloHi. I'm trying to use new Path class from jdk7. TO get path there are 2 methods get(URI uri), get(String first, String... parts). How can I call second method, not first one? It throws exception, that cannot convert STring to URI
20:43hiredmanjava varargs are arrays
20:47Nikelandjelohiredman: Thanks
20:56mjreedjava.lang.IllegalStateException: var: #'clojure.string/replace-by is not public
20:56mjreed? bogus message caused by some other problem, or was that function deprecated/replaced in 1.2.1?
21:11mjreedah, I was looking at contrib, not the promoted api. nm.
21:47currymjI'm trying to get Aquamacs set up for clojure development. I've installed leiningen, the emacs starter kit, and all the relevant packages, but M-x clojure-jack-in doesn't do anything, nor does M-x slime. I'm pretty lost. Can someone help?
21:48Scriptorcurrymj: have you tried doing lein swank from the project's directory?
21:48Scriptor(from a shell)
21:51currymjScriptor: i have, and it seems to start the swank server, but i have no idea what to do from there. emacs is sort of alien territory for me.
21:51Scriptorcurrymj: try M-x slime-connec
21:52Scriptor*slime-connect
21:52amalloyScriptor: aw, slime-connec would work fine. or slime-con, even
21:52currymjScriptor: it says "no match". is there another package i have to install besides clojure-mode?
21:56Scriptorcurrymj: just to make sure, do M-x package-list-packages and scroll to the bottom where it should list installec packages
21:56currymji have clojure-mode 1.10.0 and paredit 22 installed
21:58Scriptorcurrymj: what shows up when you do M-x clo and then hit tab?
21:59Scriptoramalloy: damn, so it just pretends you hit tab and runs the auto-completed command?
22:00amalloyScriptor: yes
22:02rufiusIs it ever appropriate to use a map to hold a set of parameters for a function rather than relying on just arguments. I've got a funciton that takes about 6-7 arguments but it is kind of ugly to call outright. Is there any reason I shouldn't use a map with all the values contained in that and pass it as the sole argument?
22:02currymjScriptor: http://pastebin.com/K7BmG8Tk
22:02amalloyScriptor: somewhere there's a package that does fuzzy completion of M-x. super-neat, but i don't have it installed at the moment
22:02amalloyrufius: please, do use a map
22:03Scriptorcurrymj: hmm, can't say to be honest, though I vaguely remember having the same problem
22:03Scriptortry restarting emacs if you haven't already?
22:03Scriptoralso, when you open a clojure file, do you still get syntax highlighting?
22:03rufiusamalloy: good to hear/read :). I'm just learning clojure but am still trying to gather what are considered "best practices" or idiomatic styles of writing code
22:06currymjScriptor: just restarted emacs, same problem, i have "lein swank" going in a separate window, and i get syntax highlighting/indentation just from opening a .clj file. i may just compile regular GNU emacs from source and see if that fixes the problem, but rich hickey uses aquamacs so i feel like it should work.
22:07Scriptorcurrymj: you can try carbon emacs too
22:08Scriptorit's supposed to keep the same bindings, while aquamacs makes them a little more beginner-friendly
22:11hiredmanaquamacs is not to be recomended
22:11hiredmanhttp://emacsformacosx.com/builds
22:12hiredmanget one of those
22:12hiredman(better yet build it yourself and apply the fullscreen patch, but that can wait)
22:22currymjokay, so with non-fancy emacs it seems to be functioning. i can launch a swank server using lein and connect. is there something i should put in my .emacs that might make this simpler? what do other emacs users do?
22:26currymjalso, how do i open a repl? :/
22:27Scriptorcurrymj: slime-connect should be the repl itself
22:28Scriptoralso, I think most now just use clojure-jack-in
22:36currymjdoes swank-clojure look for lein in a specific directory? mine is installed in /usr/local/bin and i'm wondering if i need a symlink. the problem appears to be that emacs can't find the lein command when it tries to invoke it.
22:37hiredmanah, that is an issue with osx, it doesn't start .apps with the proper env unless you do some findle with xml
22:38hiredmanso emacs won't have the right PATH
22:39tomojI have a 391mb jar which is part of an unmavenized project. I suppose I should _not_ push this to clojars.. :)?
22:42currymjhiredman: do you know how i do this? specifically in Lion, because the advice online seems to now be out of date
22:42hiredmantomoj: clojars won't accept anything over 19mb
22:43hiredmancurrymj: (setenv "PATH" …)
22:43tomojah, that is reasonable
22:46currymj"Connected. Hack and be merry!"
22:46currymjthanks, everyone, for all your help
23:31leonidhah
23:35iceyDoes this look like a stylistically correct way to do tests? https://gist.github.com/1119554
23:35iceyOr should I wrap all the tests in an "and" with a single "is" assertion?
23:36amalloyicey: you want lots of is's, so that when one fails you can tell which
23:36iceyamalloy: that's what I figured, but I wanted to make sure. Thanks!
23:36amalloybut there's also (are) for very repetitive tests like that
23:36iceyamalloy: reading up on (are) now, thanks!
23:37amalloy(are [email] (vali/is-email? email) "foo@bar.com" "etc@whatever.co.uk")
23:37iceyamalloy: sweet, that looks like exactly what i need
23:41iceyamalloy: oh yeah, that looks WAY better, thanks again (Here's what it looks like now https://gist.github.com/1119554)
23:59grant__maybe you should stop changing your name...