#clojure logs

2012-09-24

02:21tomojamalloy: do you want a port of ordered in cljs, or should i
02:21tomojfork
02:22tomojI mean, do you want a cljs port in ordered, I guess
02:23amalloyi think i'd rather be a separate project, since none of us flatlanders do any cljs to speak of and shouldn't pretend to be maintaining it
02:24tomojcool, thanks
02:28tomojbizarre, (read-string "#ordered/set (1 2 3)") works but #ordered/set (1 2 3) at the repl gives "Unable to resolve classname: IPersistentMap" at Compiler$HostExpr.tagToClass
02:28tomoj..at the swank repl
02:29amalloyprobably the same problem REPLy has with reader tags
02:29amalloywell, maybe not, since the swank repl should be in the same jvm
02:30tomojsaweet, clojure.data/diff on ordered sets returns ordered sets :D
04:53clj_newb_234holy shit, I just got webkit to embed in java in clojure
04:53clj_newb_234this is like equivalent to 24 hours of work
05:01kralnamaste
05:02qerubGood morning.
05:10scottjclj_newb_234: so long as webkit is already installed on the system?
05:10qerubCould somebody give me a second opinion on http://dev.clojure.org/jira/browse/CLJ-1067? I'm note quite sure which semantics Stu is referring to.
05:31amalloyqerub: you answered your own question in the comment
05:32amalloythe type of the thrown exception changes, so code that used to catch the old type of exception will now break
05:32SgeoMaybe my problems with Eclipse+Counterclockwise are just not knowing how to use it properly?
05:32SgeoMy attempted usage was merely trying to expolore the UI, maybe that's ineffective?
05:37qerubamalloy: OK, that is what I guessed. Thanks for answering! Personally, I wouldn't mind breaking code (in a major release) relying on that Keyword.run throws UnsupportedOperationException because even if it is Runnable, it can never be run.
06:17piskettiHi, is clojure.contrib.mock deprecated? (or how should I use it with clojure 1.3?)
06:18piskettihttp://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go Doesn't list anything for it
06:18clgvpisketti: yeah. everything starting with clojure.contrib.* is ^^
06:18pisketti;)
06:18clgvpisketti: there are builtin macros that enabled some mocking. `with-redefs` and such
06:19piskettiLet me rephrase. Where can I find the equivalent functionality now?
06:19pisketticlgv: I know. I just would have liked to use the lib
06:20piskettiSo, what you are saying is that the whole mock lib is gone in 1.3?
06:20clgvpisketti: well, you can try to use it. you can copy that namespace and it might just run.
06:20piskettiwell, I wouldn't like to go there
06:20piskettiI guess I need to take a look at midje
06:21piskettiI've been postponing that since I just wanted to get stuff done :)
06:22piskettiIf midje is compatible with my current test suite, that won't be a problem.
06:22piskettiWell, thanks anyway
06:24clgvpisketti: well midje has some nice capabilities there too, which are more advanced than just mocking^^
07:45powrtochey ppl
07:46powrtocDoes nrepl support having multiple nrepl client buffers open?
08:54MrDevany core.logic wizards about? :)
08:54MrDevhttp://stackoverflow.com/questions/12563351/listing-unique-dag-parents-with-core-logic
08:56pandeirowhat would be the import statement to be able to use com.foo.Bar and com.foo.helpers.Baz w/o their full paths?
08:59chouser(ns ... (:import (com.foo Bar) (com.foo.helpers Baz))
09:00clgvMrDev: you could rewrite it to return the collection instead of single parents and impose a unique constraint on it
09:04clgvMrDev: or you need to build an analogon to a "visited state"
09:11pandeiroconfusing trying to re-implement java code that uses factories in clojure... http://code.google.com/p/subethasmtp/wiki/SimpleExample
09:21chouserpandeiro: do you have that figured out?
09:21clgvI get "CompilerException java.lang.IllegalArgumentException: Cannot assign to non-mutable: comm," when trying (set! comm a) although I declared ^{:volatile-mutable true} comm in the deftype definition
09:25chouserclgv: this works for me: (deftype T [^:volatile-mutable x] clojure.lang.IDeref (deref [_] (set! x (inc x)) x))
09:26clgvchouser: it's nested some levels deep. I currently try to add the code incrementally until it blows up
09:26pandeirochouser: could i show you what i got?
09:27pandeirochouser: http://sprunge.us/IiSC - i am about to run it now
09:29chouserpandeiro: I think that will work. Will you need to pass a Factory instance to something else eventually?
09:30pandeirochouser: honestly i don't know, i am at the very beginning of this, first time doing smtp, first time using a java lib like this
09:30pandeiroeventually i will need to parse multipart so i imagine it will become more complex
09:31chouser:-) ok. I would tend to recommend reify over defrecord in situations like this.
09:32pandeirochouser: ok cool, i will re-implement w/ reify
09:32pandeirogetting a class cast exception too :)
09:32pandeirofn can't be cast to MessageHandlerFactory
09:32chouserYeah, so you'll need an actual Factory
09:33pandeirohaving a tough time mapping that concept to clojure
09:33pandeiroi am a java ignoramus too which doesnt help
09:33chouserusing defrecord or deftype you'll end up with a couple deftypes, and an ever-growing list of instance fields
09:33chouserreify lets you use what amount to closures
09:34pandeiroso the factory would use reify as well?
09:34chouserso you can do: (defn mk-factory [] (reify MessageHandlerFactory (create [_ ctx] (reify MessageHandler (from [_] ...)))))
09:35chouserright
09:35pandeiroah wow
09:35pandeiroyou can nest like that, brilliant
09:35clgvchouser: this blows up https://www.refheap.com/paste/5264
09:35chouserclgv: ooo, catch block.
09:36chousernotoriously tricky to get right in the Clojure compiler
09:38chouserclgv: since you've done the work of creating a minimal example, that may be worth filing a bug about. Until/if that gets changed, I suspect you'll need a work-around.
09:38clgvchouser: so what did I do wrong? it works without the final statement
09:40clgvchouser: https://www.refheap.com/paste/5265
09:40clgvchouser: you think it is a compiler bug?
09:40chouserHm. I assumed so, but I'm surprised that second form compiles.
09:41clgvme too
09:41chouserThough it may be "unsupported" rather than a bug.
09:41clgvsomehow it seems as if the metadata of the symbol gets lost
09:41pandeirochouser: success! thanks a lot
09:41chouserpandeiro: ah good.
09:42pandeiroyes now for something beyond hello world :)
09:43chouser:-)
09:44pandeirojava version: 48 SLOC; clojure: 17 SLOC
09:44rabblerAnyone successfully run Overtone on OS X 10.8? My JVM crashes (both jdk 1.6 and 1.7) when it loads. Or is there a known issue?
09:54patiencerabbler: Overtone kills the JVM when it has errors with the audio system. I don't know how else to help you.
09:55rabblerpatience thanks for the response. I'll keep looking around. I'm probably doing something wrong. Perhaps I'll look for a demo and see if that runs.
09:56patiencerabbler: I'm not too familiar with Mac, but I do have it running on my Arch machine with Jackd.
09:57casionovertone discussion?
09:57clgvchouser: http://dev.clojure.org/jira/browse/CLJ-1075
09:57patiencerabbler: It could be some authentication problem, it could be that the version of overtone you're using is bad, or it could be the version of overtone is incompatible with the version of clojure
09:59beffbernardHow would you use an existing HttpServlet in compojure?
10:01rabblerpatience, at the moment, just doing (:use overtone.live) will crash the JVM.
10:02rabblerso, I'm going to pass that up for the moment.
10:02rabblerwas trying to hack in something fun to the app, but I have already wasted enough time. Thanks for the info.
10:02maleghastbeffbernard: I'm not even remotely aware of how you'd do that, but if you crack the nut I would love to know how you did it :-)
10:03rabblerpatience, now that I have actually used google, I see there are some of the same errors, I'll poke around soon and check it out.
10:04patiencerabbler: (-.-);
10:05beffbernardmaleghast: there is a servlet-holder function in compojure.servlet.jetty but I want something that's container agnostic
10:05rabblerpatience: google doesn't have human interaction though.
10:07chouserclgv: At macroexpand time, the environment still has the metadata
10:07clgvchouser: yep, I checked that
10:08clgvchouser: I rewrote that code. it seems to happen outside the catch as well
10:08chouseroh!
10:09chouserclgv: that's important. How do you get the error without a catch?
10:12clgvchouser: hmm implicit try-catch in a `locking` statement :(
10:13chouserah
10:14clgvdamn. only workaround is to implement it via an atom somehow.
10:15chouseryou can probably add a method that sets the field, and call that method from your catch block
10:20maleghastbeffbernard: I see… I think
10:21maleghastbeffbernard: Like I said, if you crack it I'd love to know, but in fairness you are talking at a levee I have yet to achieve with my Clojure / Compojure experimentation.
10:22maleghastbeffbernard: oops, levee = level ^^
10:22octagonhi, is there an example of tagged literals in clojurescript? i'm building my project using leiningen (lein-cljsbuild)
10:22clgvchouser: yes that seems to work
10:24chouserclgv: it might be nice to mention that in the ticket as well, for other people that stumble on to the same problem.
10:25beffbernardmaleghast: I guess what we need is a servlet to ring handler function, but unfortunately it doesn't seem to exist
10:25beffbernard:S
10:25pandeiroanyone know the modern equivalent of clojure.contrib.java-utils/as-properties ?
10:26clgvchouser: ok. added
10:28clgvchouser: oh you added black voodoo ;)
10:29chouserbut unhelpful :-P
10:30clgvchouser: so your intention was to add some noise so that the issue is perceived? ;)
10:30casionif I have a collection (atm likely a vector) that I want to pad to n items, what's the best way to go about that?
10:31chouserclgv: well, it seems like it could be helpful
10:31noidicasion, you could concatenate it with an infinite sequence of padding values and take n first
10:31chouserit shows that the metadata still exists on the binding inside the catch
10:31noidi,(take 5 (concat [1 2 3] (repeat 0)))
10:32clojurebot(1 2 3 0 0)
10:32casionnoidi: actually, I need to clarify then I think
10:32casionI need functions to pad to front and back
10:32clgvchouser: right. I did a macroexpand with binding *print-dup* to true
10:32chouseroh, ok. That's all I'm doing
10:32casionit's the front padding that's primarily confounded me atm, at least an efficient method is
10:33TimMcCan the output be a seq, or does it need to be a vector?
10:33casionTimMc: I will need fast random access in the future, so right now I'm trying to keep it in a vector
10:35jkkramer,(let [pad -1] (into (vec (repeat 5 pad)) [1 2 3]))
10:35clojurebot[-1 -1 -1 -1 -1 ...]
10:36TimMc&(-> (repeat 4 0) (into [1 2 3 4]) (into (repeat 4 0)))
10:36lazybot⇒ (0 0 0 0 4 3 2 1 0 0 0 0)
10:36TimMchaha, whoops
10:36casionI'm taking in a stream of 1 to 5 byte chunks that I need to convert to a vector of chunks of then nearest java primitive width
10:36TimMc&(-> (vec (repeat 4 0)) (into [1 2 3 4]) (into (repeat 4 0)))
10:36lazybot⇒ [0 0 0 0 1 2 3 4 0 0 0 0]
10:37noidihere's my take https://www.refheap.com/paste/5266
10:37powrtocDoes anyone know of any webgl frameworks that can be compiled with closure/clojurescript?
10:37powrtocin advanced mode that is
10:37casionso say I encounter a 3byte chunk I need to pad it either right or left, depending on the endianness of the stream, to 4 bytes
10:38casion1 byte to 2, 5 to 8
10:38casionso with that information, maybe I'm approaching it wrongly? or not :)
10:40noidicasion, maybe that would be easier using this library https://github.com/preon/preon
10:40powrtocOr a clojurescript API of the basic vector functions etc
10:41noidior maybe there's a clojure library for parsing binary data
10:41powrtocI mean matrix functions rather
10:41casionnoidi: there's gloss too
10:42casionthe problem is that even with gloss or preon, I stlii have to sanitize the stream's goofy 3 and 5 byte chunks
10:42casionat least as far as I've figured I do, maybe I'm missing functionality somewhere
10:43casionnoidi: your code gave me an idea though I think, thanks
10:52djanatynis there any way to have lein use ecj.jar instead of the JDK?
10:52grettkeQuestion: Anyone using Clojure or nREPL with JRebel?
10:52djanatynI'm using lein2, and I added :java-source-paths to my project.clj. I want to be able to play with my java code from clojure, with nrepl.
10:53djanatynhowever, I don't have the JDK installed on my computer. I can still compile java files with ecj.jar; is lein2 just looking for javac?
10:54chouserdjanatyn: it appears to be using (ToolProvider/getSystemJavaCompiler)
10:57djanatynchouser: thanks! I'll mess around and see if I can get anything working
11:00djanatynlooks like it wants the JDK specifically, and getting it working with ecj.jar would not be easy :\
11:43samlhey, is clojure-conj.org good conference to attend?
11:51nDuffsaml: Yes, the conj is well worth attending.
11:52samlare you coming?
11:53nDuffNot this time.
11:53nDuff...if it weren't for the personal-life stuff going on, though, I certainly would.
11:56samlcongrats nDuff
11:58nDuffsaml: Thanks. :)
11:59duck11231can you still get tickets to the conj?
11:59duck11231looks like you can, but $550
12:00nDuffOuch -- that's a pretty steep delta from the early-bird price.
12:03duck11231one of these years I'll be able to go
12:03duck11231maybe I should start setting $ aside for the next
12:03chouseryeah, it simplifies their planning to have people committed early, I think, so they reward that a lot.
12:03TimMcI could probably justify the early-bird price ot myself if it were no farther away from the Boston area than, say, NYC.
12:04TimMcAlthough, if we didn't have an active Clojure meetup group here I'd be a lot more willing to travel. :-P
12:05holohi!
12:06holowhere is the new address of shell-out, which was living in contrib?
12:06samlif i know almost 0 clojure, would conj be useful at all?
12:06duck11231you'd know a lot more by time it was done
12:07uvtcholo: I'm not familiar with shell-out, but if you want to ... shell out, there's clojure.java.shell, or else conch.
12:08scottjsaml: well you have time to learn quite a bit before it. but no, if you don't know any I don't think it would be worth it
12:08samli just want to spend company money to go to a useful conference
12:08samlbefore the end of year :P
12:09scottjsaml: in that case sure :)
12:09nDuffsaml: ...well, there's training before the conference, if there's still an opening, but that's _quite a lot_ of company money
12:09saml:P
12:09nDuffsaml: ...but the training *does* start pretty basic -- at least, when I took it, it seemed like a fair bit of review.
12:10holouvtc, any of them don't fork to a new process?
12:10nDuffholo: How would you do that without forking?
12:10holouvtc, i mean, forking and not leaving
12:10nDuffholo: I mean, if you didn't fork, you'd be doing an exec, which would terminate your process
12:10nDuff..."forking and not leaving", meaning doing a wait()?
12:11holonDuff, don't know what the wait() do, but i don't want the new forked process to be dettached from the terminal
12:11uvtcholo: I'm using clojure.java.shell at the moment, and although it uses futures internally for some purpose, it seems to block until the shell finishes what it's doing.
12:12duck11231pallet has pallet.shell (or it did, last I used it) that worked pretty well for me
12:12holouvtc, will try again. just a second. and thanks duck11231
12:13uvtcholo: Y'know, I haven't tried backgrounding a process that gets started by clojure.java.shell/sh ...
12:14holouvtc, in my situation it would be undesirable that it would be backgrounded
12:14hugodthere is also https://github.com/raynes/conch - I heven't tried it
12:15uvtcholo: Ha. Sorry, I read your message to nDuff incorrectly. :)
12:15clgv"conch" works pretty good. used it for interop with "R"
12:15hugodpallet is rather a large dependency to just get pallet.shell - I could split it out if there is interest
12:16duck11231I can't even seem to find that ns anymore
12:17hugodduck11231: it's there on the support/0.7.x branch
12:18nDuff...conch _does_ have helpers to copy content coming out of the redirected FDs to stdout
12:18nDuffwhich at least makes it *look* like what holo wants
12:18nDuffeven if it isn't really. :)
12:19nDuffholo: ...so it might be worth deciding _why_ you want what you want, and if having the code copy between the stdin/stdout pipes and real stdin/stdout is good enough.
12:21pandeirois there a way to combine several predicates that operate on the same value into one function call? besides writing another helper fn with (and ...)?
12:22jkkramerpandeiro: every-pred
12:23pandeirojkkramer: thanks
12:30holouvtc, i type (shell/sh "bash") and it returns to the repl prompt outputing {:exit 0, :out "", :err ""} . i guess this isn't what i want
12:31uvtcholo: that means it ran the `bash` command for you, then returned. I guess bash exited since you didn't have anything for it to do. :)
12:31holonDuff, i want be redirected to the prompt of the new process, so that i can insert commands, and see command output
12:32holouvtc, yeah, it seems so. but maybe i have something for it to do some seconds after
12:33uvtcholo: Right. Don't think I can help you there. I see that you want to run a bash shell from your Clojure program.
12:33nDuffholo: May I, out of curiosity, ask what you're working on? The projects where I need to do that kind of thing and the projects I use Clojure for don't tend to overlap much.
12:35nDuffholo: ...given as Java's Runtime.exec() doesn't appear to let you specify that you don't want a redirection, it may not even be possible.
12:35holonDuff, i need to automate the process of logging into a postgres shell
12:35nDuff(well, not without hackery that would prevent stdout from being a tty)
12:36nDuff...why use Clojure for that?
12:36nDuffThe psql command-line tool definitely works better when connected to a tty
12:36holonDuff, because the process is complicated enough to go and learn bash. i hate bash, thus i prefer to spend my time writting gorgeous clojure code
12:37nDuff...well, actually, it depends on just _why_ it's complicated
12:37clgvholo: if you want to write to and read from the process you should use "conch"
12:37nDuffand you haven't explained the details. But if you actually need to emulate a TTY, that leaves you with the TCL expect, Python's pexpect, or some other equivalent.
12:38holoi will explain the details
12:41holoi have an heroku .env with a DATABASE_ENV development postgres db that change according to each developer. i want to extract that url and run a psql with it's paramaters. this is a script, but the resulting paramater map is also useful for a project
12:41holothe script is already doing it's job, except that the process leaves
12:42holouvtc, thank you for your time and help
12:43nDuffDoesn't sound like there'd be anything complicated about doing this in bash.
12:44nDuff...happy to help you with that in #bash
12:45holonDuff, i'm not a bash regular. i already coded it. i wouldn't dare to ask you to waste time in this again :) i'm going to try conch first like clgv suggested
12:46nDuffconch is great, but it has the same limitations that everything using java's Runtime.exec() does
12:46nDuff...and it sounds like those aren't what you want
12:46nDuffbut... *shrug*.
12:49holonDuff, but in conch webpage it says "clojure.java.shell is designed to produce quick one-off processes. There is no way to interact with a running process over time. I've found myself needing to shell out and stream the output of an external process to things in real time and I wasn't able to do that with clojure.java.shell." isn't it the same i want?
12:49nDuffholo: conch lets you interact with the subprocesses _from your Java code_
12:50nDuffholo: You want to interact with the subprocesses _from the console_
12:50holonDuff, oh that sucks then :)
12:50uvtcnDuff: good distinction.
12:50technomancyholo: the JVM doesn't support interactive subprocesses. its process handling API is kind of a joke.
12:52uvtcDo the various conferences (Clojure/West, Strangeloop, and Clojure/Conj) usually happen on about the same date each year, respectively?
12:52uvtcAlso, I reserve the right to just tack on "respectively" to the end of any complicated sentence and expect the reader to figure out what I mean. :)
12:52clojurebotEqual Rights for Functional Objects is Baker's paper on equality and why it's impossible to define sensible equality in the presence of mutable data structures: http://www.pipeline.com/~hbaker1/ObjectIdentity.html
12:53uvtcclojurebot, you are a bot among bots.
12:53clojurebotthanks; that was delicious. (nom nom nom)
12:54holoi feel like whining :o
12:57duck11231I wonder if you could build something with lamina to pipe channels to the in/out of a process like that
13:00clgvdoes someone have an idea how I can make a socket to throw on a write attempt if the remote socket was closed? it doesnt seem to work on first write attempt but on the second
13:07ignacio@holo: can you used named pipes to communicate with the process?
13:07CheironHi, with Compojure. how to access path query for a URI such as? /tickets/users/:user-id/:ticket-id?page=1
13:08weavejesterCheiron: (GET "/tickets/users/:user-id/:ticket-id" [user-id ticket-id page] …)
13:08weavejesterThe parameters are taken from the :params key on the request map
13:09weavejesterWhich includes both parameters in the route, and in the query string
13:09Cheironweavejester: Oh Cool. Any experience with Liberator?
13:09weavejesterNaturally there's also keys for :route-params, :query-params, :form-params when you need more precision about where things come from.
13:10weavejesterCheiron: Unfortunately not. I've been meaning to take a closer look at it, but there are too many keys for my liking.
13:10Cheironpage query parameter is optional. it might exist and it might not. in this case, the vector [user-id ticket-id page] still valid?
13:14holoduck11231, ignacio, will look more into your suggestions
13:20jro__how do I set ring route to respond HEAD-requests properly, when resource is not found. Not it throws NPE in at clojure.lang.RT.intCast(RT.java:1065) ~[clojure-1.3.0.jar:na] at aleph.http.core$ring_map__GT_netty_response.invoke(core.clj:341)
13:20weavejesterCheiron: Yep. page will just be nil if it's not there
13:21jro__I mean compojure, HEAD with existing resources works perfectly with (compojure.route/resources "/")
13:21weavejesterjro__: There's some middleware called wrap-head to do this. The latest Compojure should add it by default to any routes.
13:22Cheironweavejester? what about these URIs? /pages/:id /pages/:id?AddAt=:pos /pages/:id/?append
13:23weavejesterCheiron: What about them?
13:24Cheironhow to declare the mapping and the vector of params for them ? after :id it might be ?AddAt=:pos or ?append . both of /pages/:id?AddAt=:pos /pages/:id/?append should accept POST
13:25ignacio@holo: how much interactivity do you need?
13:26weavejesterCheiron: Well the parameter names are AddAt and append
13:27langmartinI'm experimenting with building functions from runtime data, and it'd be sweet if I could name the generated functions. I'd rather not use eval, and I don't have the function names available at syntax time... is it possible to decorate functions with meta data so that a stack trace can return a meaningful name for a function created at runtime?
13:29nDuffCreating functions is by definition something that happens either at compile time or when using eval
13:29Cheironweavejester: sorry not following
13:30langmartinnDuff: (defn [x] (fn [] x))
13:30nDufflangmartin: yes, but the function is created at compile time, even then
13:31nDuffit's just _returned_ at runtime.
13:31weavejesterCheiron: Well, you have access to the query string, and the map of parsed parameters
13:31weavejesterCheiron: So I'm not seeing why you think changing the name of the parameter makes it different?
13:32langmartinnDuff: even though it's closed over different values of x?
13:32weavejesterCheiron: So for AddAt: (GET "/" [AddAt] …)
13:32nDufflangmartin: There's no recompilation involved in that.
13:32weavejesterCheiron: Although you might want to access the parameter map directly
13:32weavejesterCheiron: (GET "/" {params :params} …)
13:33Cheironweavejester: so in my case, the URI mapping should only be /pages/:id only I guess. AddTo=:pos at a page to a specific position. append will add a page
13:33langmartinnDuff: fine, but I get distinct objects iwth different values, which is fine
13:33nDuffYup.
13:33langmartinI want to say (defn [x] (with-meta (fn [] x) {:name "foo"}))
13:33langmartinand have that inner function use it's name when it breaks
13:33nDuffthey're distinct objects, but the class names aren't going to differ
13:33weavejesterCheiron: ?append isn't a valid query parameter, by the way. It won't be encoded in the query parameter map, but will be accessible via the query string itself.
13:34nDuffsee distinction between compile-time and runtime metadata
13:34weavejesterCheiron: But I'm not really seeing what you want. Are you trying to interface with a legacy system? Is that the reason for the strange query parameters?
13:35Cheironweavejester: yes
13:35Cheironas I said. /pages/:id?AddTo=:pos to set a page at specific index via POST. /pages/:id?append to add a new page via POST
13:36Cheironweavejester: do you suggest a better URI design?
13:36langmartinnDuff: fn itself uses with-meta to set the name of the generated function if it's provided, you're saying that with-meta does different things at compile-time (flattens it into a java class thing) then at runtime (stashes it in a map)
13:37nDufflangmartin: with-meta can't be used for compile-time metadata at all.
13:37weavejesterCheiron: Well, you can use that, but it's a bad design.
13:37weavejesterCheiron: Hang on, phone...
13:37jro__weavejester: thanks, adding wrap-head solved the problem
13:37holoignacio i need to insert commands from the keyboard, and read output from the terminal
13:37langmartinnDuff: what's it doing in the definition of fn then?
13:37Cheironweavejester: ok :)
13:38weavejesterCheiron: You know that Ring requests are maps right, and Compojure routes are functions that return nil or a response map?
13:38Cheironyes
13:38nDuffHmm. I'm probably wrong somewhere, then.
13:38nDuff(still can't do what you're trying without an eval somewhere, though)
13:39Cheironweavejester: yep i know
13:39weavejesterCheiron: So: (GET "/" {q :query-params} (if (= (q "AddTo") ":get") …))
13:39pandeiroi have this nagging feeling i should not be implementing multipart email parsing
13:39weavejesterCheiron: The if-statement will return nil if the parameter isn't there, and the route will then cascade
13:40Cheironweavejester: hmmm. actually I'm using Liberator REST toolkit that uses Compojure as the router. i need figure out how to do what you are suggesting
13:40nDufflangmartin: ...okay, straightened things out: with-meta can be used to attach metadata to symbols that are used during compilation and then thrown away.
13:40weavejesterCheiron: hang on...
13:41nDufflangmartin: Attaching name metadata to the fn won't do any good -- it's already compiled at that point.
13:41Cheironweavejester: okidokie
13:41nDuff...now, you can use eval to compile at runtime...
13:41nDuff...but you're stating that you don't want to do that.
13:42langmartinok, well it's fine
13:42langmartinI just wanted it for the stack trace
13:43langmartinand it looked like the namespace resolver went through enough of a trampoline kind of thing that it might still do a dynamic name lookup
13:43langmartinthanks for the help, nDuff
13:44weavejesterCheiron: Liberator doesn't replace Compojure routing
13:46Cheironweavejester: no it is not. I hope i'm not wrong but i said Liberator is using Compojure as the router. but not really digesting (GET "/" {q :query-params} (if (= (q "AddTo") ":get") …))
13:47weavejesterCheiron: Hm, oh, I see. Liberator supplies handling of GET and POST
13:47weavejesterCheiron: In which case, I think you might be using the wrong tool
13:47Cheironweavejester: yes exactly
13:47weavejesterCheiron: Liberator is designed for creating RESTful web services
13:47weavejesterCheiron: And you look like you want to create a non-RESTful web service for a legacy client
13:47Cheironweavejester: that is what I'm doing
13:48Cheironweavejester: hmmm. actually I'm trying to create a REST API
13:48weavejesterCheiron: The routes you've supplied aren't really RESTful though...
13:49Cheironweavejester: i have the permission to change the URIs. do you suggest a better design for the three previous URIs?
13:50weavejesterCheiron: Well, let me get a sense of the problem. It's possible I don't understand and I'm giving bad advice :)
13:50Cheironi will paste at pastie, just a minute
13:50weavejesterCheiron: Okay :)
13:53Cheironweavejester: thanks a lot! http://pastie.org/4792355
13:54Cheironweavejester: maybe AddAt and append should be prefixed with " : " ?
13:56weavejesterCheiron: When you add a page to the book at a specified index, will it replace the page there, or shift all pages after up a space?
13:56Cheironweavejester: replace it
13:58weavejesterCheiron: Okay, so in HTTP, when you want to overwrite a resource, that's usually a PUT, and when you want to add a new resource, that's a POST.
13:59Cheironweavejester: true
13:59weavejesterCheiron: Or to be slightly more accurate, a PUT is when you know the index of the item you want to write to, and a POST is when you want to create a new element with a generated index
14:00weavejesterCheiron: So I'd have written it more like: http://pastie.org/4792383
14:00weavejesterCheiron: The PUT is used to overwrite a page, and the POST is used to create a new page.
14:00ro_stweavejester: how do i know what env my ring app is in, from within that ring app? using lein2 and noir
14:01ro_sti'm inspecting the output of (System/getenv) but nothing's standing out
14:01ignacio@holo: i'm not advocating this as the best solution to your problem at a high level
14:01ignaciobut i think you can do what you want by doing something like
14:01weavejesterro_st: You don't really have environments in Ring. I guess you're asking this from the Lein-Ring docs? They're not very clear on the subject of environments.
14:01Cheironweavejester: a lot neater ! thanks a lot !
14:02ignacio(sh "bash -c "psql < in.cmd > out.cmd")
14:02ignacio(sh "bash -c \"psql < in.cmd > out.cmd\"")
14:02ro_stweavejester: i suppose i could just use my own env var and be done with it
14:02ignaciowhere in.cmd and out.cmd are pipes made with mkfifo
14:02ro_stthought perhaps ring/noir had some notion of environments built in
14:03weavejesterro_st: Nope. My advice is to not use environments, as in, don't have a single string that defines how your app acts.
14:03ro_styeah. better to use specific configuration to drive specific behaviour
14:03weavejesterro_st: Right :)
14:04weavejesterro_st: Have you come across Environ?
14:04ro_sti have yes, thank you
14:04weavejesterro_st: That's what I use along with Lein2 profiles
14:05ro_stmy particular use-case is actually just a stop-gap until we have user profiles with admin rights up: staff-mode
14:07weavejesterro_st: Perhaps something just like, :profiles {:dev {:env {:staff-mode true}}} ?
14:07ro_styup. that's pretty much what i've just done
14:08ro_stquestion. if i uberjar or uberwar a lein project, does running that project as a jar with lein2 still use profiles.clj?
14:09ro_stie, could i use profiles.clj to manage production configuration
14:18weavejesterro_st: If you run it with Lein2, then yes… but not if you create it with Lein2, and then run it directly.
14:18ro_stcool. we're using lein trampoline, i believe
14:19ro_stwe aren't using jars yet; we just run from disk for the moment. i just want to check we aren't painting ourselves into a corner down the line
15:37QUACKALPACATRON##(symbol? (symbol "I worship his Shadow"))
15:37lazybot⇒ true
15:37QUACKALPACATRONChousuke, fix that
15:48NegdayenI have a list of interwoven data, ( x y z c a x y z c a....). I would like to deinterlace into two lists ( x y z x y z x y z....) and ( c a c a c a c a ). I have a couple ideas that seem pretty sloppy (re: imperative). Is there a recommend approach or helpful function(s) for such a scenario?
15:50romain_p_Negdayen: partition-by?
15:51amalloydepends whether you intend to tell the items apart by value or by index, which your example doesn't make clear
15:53Negdayenthe values will be fairly random, I know before-hand that it will be 3 values of group a, then 2 values of group b, repeated.
15:53Negdayenromain_p_: nI think partition-by might do the trick, thank you.
15:54RaynesI don't think partition-by is what you want.
15:56NegdayenHmmm, yes, I suppose not--seems like that is better for when I can tell items apart by value as amalloy alluded to.
16:09RaynesNegdayen: https://www.refheap.com/paste/5271 is what I came up.
16:10amalloyRaynes: doesn't that return [[x y z] [a b] [x y z]] rather than [[x y z x y z] [a b]]?
16:11RaynesWell, yeah.
16:11RaynesBut hey, it's half way there.
16:12amalloyanyway, it's a tough problem, because a lazy solution is impossible
16:13NegdayenRaynes: Ah, that looks quite awesome. Thanks! I was just about to search for a split-at like function.
16:17Rayneshttps://www.refheap.com/paste/5272
16:17RaynesSequence manipulation after a good night's lack of sleep.
16:21eduard_Negdayen, Raynes: my try - https://www.refheap.com/paste/5273
16:23RaynesNice. I just hate multi-value reduce accumulators.
16:23RaynesThey never occur to me because I hate how the base accumulator looks.
16:24NegdayenLol, jealous of the mad list manipulation skills. I got a ways to go from my java'ish ways :-P.
16:25Rayneseduard_, Negdayen: https://www.refheap.com/paste/5274 formatted version of eduard_'s reduce.
16:25RaynesBoth of our solutions are around the same length. His has the benefit of being a self-contained reduce.
16:27RaynesYou'll still want to wrap that in a function if you use it though, which is why they're around the same length.
16:28eduard_can into changed to zip?
16:29eduard_also it's possible to write ->> z (partition 5) (map #(split-at 3 %))
16:29pandeirohow do i best go from input stream to byte array?
16:34TimMcamalloy: The question is really *how* lazy you want it to be.
16:34TimMcA partly lazy solution is no trouble.
16:54amalloyTimMc: ?
16:54amalloyi would like to see what a partly lazy solution looks like
17:01TimMcamalloy: As in, you don't believe it's possible, or you're just curious to see it?
17:01pingtimeoutHi #Clojure
17:01TimMcI'm not bored enough today to actually write it, you see.
17:08TimMcamalloy: Here's a (more complicated) example of a function that produces a lazy seq of lazy seqs by splitting an input collection: https://github.com/timmc/rand/blob/master/src/rand/core.clj
17:09thorbjornDXHi. I'd like to do map destructuring within a for binding something like this: (for [d seq-of-maps {:keys [a b c]} d] [a b c]), am I doing something wrong?
17:09hiredmanyes
17:09hiredmanyou are trying to destructure each key/value pair of the map
17:10thorbjornDXhiredman: I don't quite follow
17:10hiredmand is being bound to the map right?
17:10thorbjornDXcorrect
17:10hiredmandestructuring replaces the binding correct?
17:11hiredman,(for [a [{:foo 1}] b a] b)
17:11clojurebot([:foo 1])
17:11hiredman,(for [a [{:foo 1}]] a)
17:11clojurebot({:foo 1})
17:12hiredmaneach binding in a for presumes it is being bound to an element at a time to a seq
17:12TimMcthorbjornDX: You're thinking of the second for clause as if it is a let clause, and it isn't.
17:12thorbjornDXohhh, I follow now, it's treating 'd as a seq
17:13thorbjornDXso to do something like this, I would have to do (for [d seq-of-maps, a (:a d), b(:b d)..., correct?
17:15amalloyTimMc: the prefix? function appears to be making each partition eager, right, just like partition-by and friends?
17:15thorbjornDXer, actually, I'm not sure if this will work like I want it to. I would like to use an element of the d map as one of the bindings of the 'for', but that binding will only happen once on the first entry in 'seq-of-maps'.
17:19thorbjornDXhiredman: er, maybe I can do this: ##(for [d [{:a [1 2 3]} {:a [4 5 6]}] s (d :a)] [d s])
17:19lazybot⇒ ([{:a [1 2 3]} 1] [{:a [1 2 3]} 2] [{:a [1 2 3]} 3] [{:a [4 5 6]} 4] [{:a [4 5 6]} 5] [{:a [4 5 6]} 6])
17:20TimMcamalloy: Only eager in the length of the splitting subsequence.
17:22TimMce.g. if you are splitting (range) at the subsequence [5 6 7] and then ask for the second element, you have realized this much: ((0 1 2 3 4) (7 8 ...))
17:22TimMcI might be off by one, of course.
17:22sam__where's conj 2012 schedule?
17:37TimMcamalloy: Looks lazy in the subsequences: https://www.refheap.com/paste/5275
17:49amalloyTimMc: you should use rest rather than next here, so you don't realize 7 as part of (first b)
17:53austinhWhat is the secret to getting helpful stacktraces while developing a Ring app?
17:54austinhwrap-stacktrace rarely helps at all, and often doesn't print anything at all in my SLIME repl.
17:54austinhI'm getting the impression the Jetty adapter is also catching some exceptions; I'd love to be able to disable that, if that is the case.
17:55TimMcamalloy: All instances of next?
18:01TimMcHmm, that breaks it for sure.
18:05amalloyTimMc: no, certainly you can't change the ones in prefix?
18:06amalloyi meant in split-at-subs, and maybe also collapse-subs
18:11TimMcMmm, I think I can do it in prefix? if I change nil? to empty?.
18:11TimMcnot that it matters for the 'sub loop var
18:30nkozaif I destructure in this way: (let [{:as p} [1 2 3 4]] p) I get [1 2 3 4] as expected, but if I do (let [{:as p} '(1 2 3 4)] p) I get a map, {1 2, 3 4}. Why? I thought :as always bound to the entire init-expr (as the documentation states)
18:34casion,(let [[:as p] '(1 2 3 4)] p)
18:34clojurebot(1 2 3 4)
18:35casioninteresting
18:36nkozaI'm seeing some code that depends on this (undocumented?) behaviour, so I thought it was a common Clojure idiom
18:37casionthe documentation could be more clear, but it does seem to indicate that {} will be a map-binding
18:37casionand [] is a sequential binding
18:38emezeskeI think maybe a hint as to what's going on is that [] is an associative structure (indexes as keys) and '() is not
18:38nkozabut in the map-binding part it says "an :as key in the binding form followed by a symbol will cause that symbol to be bound to the entire init-expr", you can derive the [] and '() different behaviour from that sentence :)
18:39casionnkoza: read a few sentences back
18:39casionI think you're taking that out of context
18:39casionnot that the context is particularly clear anyway :|
18:41nkozaIs not clear in the documentation what the map-destructuring does when init-expr is not associative
18:43emezeskenkoza: It looks like it converts init-expr to an associative structure
18:44nkozaemezeske: yes, and the binding to :as is done after that conversion, thats the undocumented behaviour
18:44nkoza,(let [{x :b} '(:a 1 :b 2)] x)
18:44clojurebot2
18:45emezeskeIt's possible that the behavior is not defined because you're not supposed to use non-associative init-exprs with the map destructuring
18:46emezeske(I agree that it would be cool to mention that or throw an exception)
18:54SrPxHey guys, I have a task in which I must paste several thousands of pages of data from some files in some forms of a site, no other way to do it. Is there a Clojure library or something that allows me to open a site programatically, insert information in a form and click send? (Just sending requests won't work, they do some magic with the typed text.)
18:57zoldarSrPx: A short search gave me this: https://github.com/semperos/clj-webdriver
19:02SrPxzolder: thanks. Might I ask what did you search for?
19:03zoldarSrPx: for Selenium wrapper in clojure
19:06SrPxI am trying to understand what *exactly* is that selenium but the thing looks huge from the site. Anyway thank you, this is probably what Im looking for. zoldar
19:07antares_SrPx: browser testing automation tool
19:07nDuffSrPx: ...yes, it's huge, but it's also about what you're looking for -- a toolkit for automating actions taken by web browsers.
19:08SrPxI've got that, but what exactly? It's a tool that finds a browser open and interacts with it? Or a tool that opens the site internally in your favorite language and you can manipulate the browser with functions and such?
19:08SrPx(if it is exactly like the clojure wrapper I've got it, and yes, that's what I need and is awesome!)
19:09friothere are multiple ways to drive selenium
19:10frioyou can click through a site while it records, and the browser plugins can replay it
19:10frioyou can also script it via the WebDriver (i think it's called)
19:10friowhich integrates better with your build servers/solutions, but is also (we've found) quite janky
19:15SrPxfrio: ok, I see. It is huge.
19:15frioyep, massive
19:16frioive had more success splitting my Javascript out properly, and then using tools like phantom/jasmine to unit test the functions I can (leaving the UI glue untested, for now)
19:16friobut i've not had to make any UIs of significant complexity either
19:56hologoodnights
19:56holothere are more and more users on this channel
19:56austinhFor the record, my weak stacktraces in Ring were caused by this clj-stacktrace bug: https://github.com/mmcgrana/clj-stacktrace/issues/14
20:45justicefriesis Joy of Clojure still relevant or is it dated compared to programming clojure / clojure programming?
20:45justicefrieswhichs eem to be the most recent books
20:46brehautJoC isnt really a 'heres the standard lib, and how you use it'
20:47brehautkind of book
20:47brehautso its still good IMO
20:52holomaybe the books should also come with a git repository, and constant updates
20:53holoeach commit would have an update cost. doing pull would cost the sum of all the commits
20:54justicefriesnot a bad idea really
20:54justicefriesthat's good to know, brehaut
21:55casionI have a java array that I want to take a range of and end up with a vector, does it make more sense to use .copyOfRange and then vec, or vec then subvec?
21:57amalloy(vec (for [i (range start stop)] (aget arr i)))?
21:58casionwould that be more idiomatic?
21:58amalloy*shrug*
21:58casionseems like there's a dozen ways to do it
22:22holomy stock clojure from macports gets all excited Exception in thread "main" java.lang.NoClassDefFoundError: projs/app, whenever he is executed near a project.clj (like grandparent dir). did it happen to any of you?
22:24arohnerholo: don't use clojure from macports. Just install lein
23:01holoarohner, i just wanted to run a clojure script.. using lein for that?
23:11RaynesThat Clojure 'script' likely depends on other code. If it has a project.clj, you're going to want leiningen. You're always going to want leiningen. In that brief moment when you think you don't want leiningen, you definitely want leiningen.
23:13clj_newb_2345given a string, what is the correct way to 0 pad it?
23:29eggsbyclj_newb_2345: (format "%03" n)
23:29clj_newb_2345eggsby: nice, thanks
23:31eggsbyoops, %03d or %.3f, same as printf
23:40holoyeah, they are fiends from hell.. ants, nothing but ants -.-