#clojure logs

2013-03-31

00:25olivergeorgeHello. I'm learning about zippers and parsing html. I can see that the xml zipper lets me go up but it seems like enlive doesn't do that.
00:26olivergeorgeAm I missing something?
00:26olivergeorgeMy use case is scraping ugly HTML
00:29olivergeorgeThis is an example of scraping the Hacker News homepage:
00:29olivergeorgehttps://github.com/swannodette/enlive-tutorial/blob/master/src/tutorial/scrape1.clj
00:30olivergeorgeIt does two independent selects, one for titles and one for points. I'd like to be able to do both at once which means finding one and then navigating (up, right, down… or similar) to the other.
01:06muhooi'm confused ny (listen! (by-id "submit") :click (fn [e] (validate-form e))))) in the modern cljs tutorial
01:06muhoowhy thr anonymous fn?
01:07muhoowhy not just pass validate-form? it only tskes one arg, the evt, anyway!
01:07tomojno reason
01:08tomojmaybe an oversight, maybe they wanted to show explicitly that the function receives a single event param?
01:09muhoohuh. weird. seems jarring to me
01:15tieTYT2I'd like to be able to rewrite this function named cookie-spec here: https://github.com/dakrone/clj-http/blob/master/src/clj_http/cookies.clj
01:16tieTYT2but it's defined with defn-
01:16tieTYT2can I do this with a with-redefs?
01:19muhoosounds monkey-patchy to me, reaching into some other ns and refefining private vars
01:20muhooi'm sure it's possible,but this ain't ruby
01:20tieTYT2exactly, i'm fixing an issue I have
01:21tieTYT2alternatively I could modify the project myself and use it until my issue is resolved
01:21tieTYT2My issue: https://github.com/dakrone/clj-http/issues/125
01:37muhoobest to fux the bug, xubmit a patvh, and use the patched version in themeantime
01:38muhoofix, not fux
01:38muhoodamn android keybozrd is POS
01:41tieTYT2i can try. This code does a lot of things I don't understand though
01:41tieTYT2anyway, thanks for the suggestion
01:42muhoogood catch on that though. good luck.
01:58tomoj(deftype Foo [foo bar] IFoo (-foo [this] foo) (-bar [this x] (bar x)))
01:58tomojsilly?
01:59mikeralooks sensible if you want ti implement IFoo
01:59tomojotherwise {:foo foo :bar bar} I guess
01:59mikeraIFoo will be faster.... protocol/interface dispatch is very quick, faster than map lookup
02:00mikera(marginally... both are very fast....)
02:01muhoocrossovers or cljx?
02:01muhoodecisions, decisions
02:02tomojbasically I just don't recall seeing functions (fn [x y]) where x, y match up with the two methods in a protocol
02:02tomoj(or [x y z] or whatever)
02:02tomojand where it just takes those args and slots them in to the protocol
02:03tomojmikera: btw, I noticed you said you'd proved that protocol dispatch overhead was negligible for the purposes of core.matrix, is that proof published?
02:03mikerayep let me find link
02:03tomojif it's in the group I can probably find it myself
02:04mikerahttps://groups.google.com/d/topic/numerical-clojure/_tuW6UaMsxY/discussion
02:04tomojthanks
02:06mikeraanyone here an expert with core.logic?
02:15muhoowow my project.clj for a clj/cljs web app is starting to get longer and more complex than my .emacs file
02:19tomojhaha
02:20tomojhmm, can you stick code in a project.clj?
02:20tomojlike, instead of writing 3 almost identical cljsbuild builds, can you generate them with code?
02:21muhooi'm pretty sure, i haven't tried it, but it's clojure and the ns gets compiled, so probably
02:21muhooin my case, i've just got piles of dependencies that keeps growing, and bunch of directives for cljsbuild
02:26hyPiRiontomoj: yes, though it's not exactly idiomatic Leiningen use
02:26hyPiRionnot yet at least
02:35muhoothis.... madness.... is what it's come to: https://www.refheap.com/paste/13140
02:37tomojhuh, cljsbuild is what's breaking trampoline repl?
02:37tomojmy hack for having `lein repl` jump directly into piggieback also seems to have broken
02:38muhootomoj: note the commented out line in that project.clj :-)
02:38tomojyeah
02:39tomojI don't have that though.. hmm
02:39muhoocljsbuild also hates not having a controlling terminal
02:39muhooi have to do lein trampoline repl </dev/null &
02:39muhoootherwise it hangs like a placerville judge
02:40tomojoh, I'm getting some exception, guess it's a different problem
03:34arne_hi, I just started learning clojure and I don't understand why (b) doesn't work. http://pastebin.com/GGpGPS7s It throws: "CompilerException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn"
03:35arne_using a vector instead of a list doesn't work either
03:35tomojwhat are you trying to do?
03:36tomoj( '(a) ) -- in idiomatic style, ('(a)) -- is a list as a function, which is an error
03:36tomojI mean, it's calling a list as a function
03:39arne_I want a function that returns a list of Persons
03:39tomojdef is for def'ing values, use defn for functions
03:40tomoj(defn people [] (Person. (Pos. 1 2))) or something
03:40tomojer, (defn people [] [(Person. (Pos. 1 2))])
03:40tomojthe [] after the name is the parameter list, so to call that you'd do (people)
03:41tomojif you really wanted a list for some reason, use (list ...)
03:41tomoj' means quote, so '(a) is just a list of the symbol a
03:42tomoj&(let [a 42] ['(a) (list a)])
03:42lazybot⇒ [(a) (42)]
03:42arne_I tried to simpliy the original source code. I'll try it, thx
03:45tomojhmm, cljs doesn't seem to give you ->Deftype functions?
04:31tomojfinally! https://www.refheap.com/paste/daefafbeb953e23d1d8dbd5ef
04:31tomojonly took me.. 1y2m :(
05:01tieTYT2i want to filter a list of strings if it contains x and does not contain y. How do I write this in an idiomatic way?
05:04tomoj#(and (.contains % "x") (not (.contains % "y"))) ?
05:05tomojI guess you have to do (fn [^String s] ...) if you care about performance..
05:05tieTYT2yuck
05:05danneuoh come on
05:05tieTYT2i was hoping to eliminate all those parens
05:06tieTYT2but ok
05:06tomojeliminate parens?
05:06tomojyou are aware this is a lisp..?
05:06tieTYT2yes
05:06tieTYT2and i suppose I'll learn to love it
05:09tomojthe more you look at them the less you see them. I have mine dimmed too..
05:11amalloytomoj: or just #(and (.contains ^String % "x"))
05:11tomojoh right
05:11amalloyon a tangent here, i wish (memfn ^String contains x) did the obvious thing
05:12danneupick whatever method you want to check if a string contains x, then you can just filter a coll of strings with this (every-pred has-x? (complement has-y?))
05:12tomojthe obvious thing being (partial (memfn ^String contains) x) ?
05:13mikera`(+ 1 2)
05:14tomojhmm, I don't even understand memfn
05:14amalloytomoj: no, i mean paying attention to the ^String hint
05:14tomojit looks like it does
05:14amalloyreally?
05:14tomojhttps://www.refheap.com/paste/faff0c719113d447c00045356
05:14amalloynice. i wonder how old that is
05:15tomoj2012-03-08
05:15tomojd15a1f0c
05:15tomoj(tassilo)
05:15amalloyyeah, i just found it too
05:15tomojoh, I see, the x is just there to tell it how many args it has
05:15amalloyright
05:16tomojand so you can typehint I suppose
05:16danneuhttp://clojure.org/java_interop recommends anonymous fn literals over memfn
05:16danneusometing i happen to remember reading
05:17mikera,(+ 1 2)
05:17clojurebot3
05:17mikera,(let [p (java.awt.Point.)] (set! (. p x) 2) (.toString p))
05:17clojurebot"java.awt.Point[x=2,y=0]"
05:17amalloytomoj: btw, it's a bit unintuitive but memfn could also work like (^String memfn contains x) or even ^String (memfn contains x)
05:18tomojaha, a use for &form!
05:18tomojI don't think I ever thought of one
05:18amalloytomoj: there are actually quite a few macros that, as things are implemented now, should use &form but don't
05:19tomojexample?
05:19clojurebotapi examples is examples
05:19amalloyeg, ^String (doto x println) expands to a form with no typehint
05:20tomojI see
05:20tomojthat sucks
05:20amalloyfor ages i've had a patch in that addresses that, but the details aren't quite thought out, and nobody at relevance was interested in accepting
05:21tomojI mean not that doto doesn't do that, but that many many macros would have to do that
05:21tomojor rather, should do that
05:22amalloyright. my patch isn't to doto, it's to Compiler/macroexpand
05:22amalloyhttp://dev.clojure.org/jira/browse/CLJ-865
05:24tomojah, great
05:25tomojI can stick that fix in my new defmacro and get the benefits on core when I reimplement all of core's macros :/
05:26mikeralooks like a useful patch amalloy, I could use that in some of my code!
05:31ambrosebsIs it possible to invoke a private instance method of a private class? I tried the setAccessible route, and it seemed to give an InvocationTargetException
05:38mikerashould be possible.... you are using the reflection route right?
05:41ambrosebsmikera: yes, I'll do a few more sanity checks.
05:51ambrosebsmikera: false alarm, didn't realise InvocationTargetException was the underlying method throwing an exception when invoked.
06:10danneuMany clojure.java.jdbc methods are marked with "deprecated since 0.3.0" even though the latest release is 0.2.4. Is that just conventional way to mark deprecation targets for a future release?
06:57jemafellerhello
06:57mikerahi
06:57danneuheya
06:57jemafelleri'm wondering what would be the possible ways to move an existing Ring application to be nonblocking.
06:58jemafellerfirst, i'm wondering if there's a built-in Ring async interface, then I saw aleph, and then http-kit.
06:58jemafellerit looks like Clojure folk are less obsessive over async web than Scala folk, i'm in the process of evaluating both approaches
06:59weavejesterjemafeller: The Ring 1.2.0 beta has split up its middleware to make integration with async stuff easier
06:59weavejesterBut fundementally there are two reasons you might want async
06:59weavejesterFirst, performance, if you have a lot of I/O driven calls for instance
07:00weavejesterAnd second to support long polling and other pre-websocket workarounds
07:00weavejesterIf anyone can think of a third reason I'm all ears, but those are the only two I can think of :)
07:01tomojmy third reason is cljs
07:01tomojand then I want a similar api in clj, so
07:02weavejestertomoj: Could you explain a little further?
07:02tomojnot particularly relevant to ring -- for that you'd have to imagine implementing ring for node.js
07:02weavejestertomoj: Ah, I see.
07:02tomoj(which I don't happen to care about..)
07:04tomojbut if you did do a ring-node, it would seem nice to be able to get a similar interface on the jvm but using netty or whatever instead
07:05weavejesterDoesn't node.js have some thread support now?
07:05tomojfibers?
07:06weavejesterI thought it had true thread support, but perhaps I'm just misremembering
07:06tomojdunno, maybe
07:06tomojI haven't paid much attention lately now that cljs is picking up steam
07:08tomojbut would people start writing threaded http servers anyway?
07:09tomojseems like node.js blasphemy
07:09weavejesterTrue… it's not very idiomatic node.js
07:10weavejesterBut then some of the node.js authors have a thing against promises as well
07:12weavejesterMost of the time asynchronous I/O is probably unnecessary in a HTTP server.
07:12weavejesterAnd it complicates things
07:12tomojthreads are evil, if you have threads you can only serve like ~10K req/s!
07:13weavejesterExactly :)
07:14tomojyeah, I agree though
07:14tomojI have my own thing against promises
07:14tomojand wonder if async http with better promises would be less complicating, but haven't thought about it much..
07:15tomojcertainly not as simple as (fn [req] res)...
07:15weavejesterYeah, it seems hard to beat a blocking function in terms of simplicity.
07:15weavejesterAnd with a smarter base than the JVM, one could make use of continuations.
07:16tomojwell, yeah, that's what I'm thinking -- what's the problem with the JVM?
07:16tomojjust a bunch more work to get continuations working without native support I guess?
07:17weavejesterYeah, I mean, someone made a macro that automatically turns a function into using continuation passing style
07:18weavejesterhttps://github.com/cjfrisz/clojure-tco
07:18weavejesterFor the purposes of TCO in this case
07:19tomojbut there's your extra complexity
07:19weavejesterYeah
07:20weavejesterIf you had native continuation support, you could have your async cake and eat it too.
07:22tomojis there an isomorphism between promises and continuations?
07:22tomojctco style
07:23tomojmy vague feeling has been that promises only give you part of the power of continuations, but looking at the ctco example I don't see how it's more powerful
07:25tomojactually I don't even not see that, just confused
07:26weavejestertomoj: Hm, well, the idea with CPS is instead of getting a value in return, you pass a callback.
07:26ambrosebsIs fireplace.vim supposed to take forever between cq* REPL commands?
07:27weavejesterSo… (fn [x y] (+ x y)) becomes (fn [x y c] (c (+ x y)))
07:28weavejesterFor recursion and the like, that means you can replace stack frames with continuations.
07:29tomojI guess the ctco README example is unenlightening since it's tail-recursive
07:30tomojer, or that's all ctco can handle? -- but fact there is already doable with recur
07:31weavejestertomoj: The author has a more in detail Clojure Conj talk, and a blog post on it: http://chrisfrisz.com/blog/Research/a-long-overdue-ctco-intro/
07:32weavejestertomoj: If you use CPS, you can essentially pause the execution at any point.
07:32tomojoh, nice, thanks
07:32pyykkis_weavejester, tomoj: are you familiar with any of the Promise/A implementations (JS land)?
07:33pyykkis_http://blog.jcoglan.com/2013/03/30/callbacks-are-imperative-promises-are-functional-nodes-biggest-missed-opportunity/
07:33weavejesterpyykkis_: Not in any detail.
07:33pyykkis_weavejester: Q has a lovely api: https://github.com/kriskowal/q
07:34pyrtsapyykkis_: Take a look at Clojure Futures.
07:34weavejesterpyykkis_: Yeah, and you can see a relation to CPS in that as well.
07:34pyykkis_pyrtsa: They start a thread or wait one from the thread pool, right?
07:36pyrtsapyykkis_: Yeah, I think so. But together with clojure.core/promise, they're pretty close already.
07:38tomoj"Promises, on the other hand, don’t care about time or ordering."
07:38tomojI think this is actually a big problem
07:38weavejesterThe functionality is roughly equivalent, but the mechanism is pretty different. Clojure makes use of blocking threads a fair bit.
07:38tomojpyykkis_: I'm pretty familiar with Q
07:39weavejestertomoj: Why is it a big problem?
07:39tomojwell
07:39jemafellerweavejester, do you think clojure folk are less obsessive about async and nonblocking than Scala folk?
07:40pyykkis_tomoj: one can of course synchronize with promise.then (serial) and Q.all (parallel)?
07:40weavejesterjemafeller: I don't know a lot about Scala's libraries on this front
07:40tomojI guess if I take the author's original meaning there, the problem is that promises DO still care about time and ordering
07:41weavejesterI do think async is unnecessary in most cases when working with plain HTTP.
07:41pyykkis_pyrtsa: as weavejester said, the underlying implementation is quite different
07:41pyrtsaRight.
07:41jemafellerweavejester, from my survey, almost *all* Scala web service libraries are async by default
07:42weavejestertomoj: It's more about cause and effect than time and ordering. If promise B depends on A, then B must block until A is ready, but any other calculations can be done in any order.
07:43weavejesterjemafeller: That seems overkill to me.
07:43tomojit looks like Q doesn't define a function which takes two source promises and returns a promise that resolves to whatever the first resolved source promise resolves to?
07:43jemafellerweavejester, exactly my feeling. however it is pretty natural for Scala people. I was pretty much mocked for wanting to do straight, normal, linear blocking.
07:44jemafellerthat is - read from a database, munge data, serve result
07:44weavejesterjemafeller: Blocking is generally a much simpler mechanism. It's hard to make (fn [req] resp) any easier.
07:45weavejesterAnd you get decent performance. As tomoj pointed out, 10K/s isn't bad for a single server.
07:45pyykkis_I kind of feel async is more of a fashion than actually needed. Sure, there are use cases for it, but async apis comes always with a cost. No matter if they are callback or promise oriented.
07:45jemafellerI agree. but i'm kind of getting a revelation here.
07:45jemafelleri've been doing Clojure and a bit of Scala, and even got a commercial product based on Clojure
07:46jemafellerbut I never bothered to stop. to go to basics and see what each platforms offered
07:46jemafelleri've been doing that for almost a week now and this is amazing - Scala is obsessed with async, while Clojure isn't.
07:46weavejesterI will say that it's easier to go from async to blocking than the other way around :)
07:47hyPiRionoh dear lord gah yes
07:47jemafellerfor Clojure you have Aleph which is on a distant island, and all the other frameworks are blocking on Jetty, on the mainland
07:47jemafellerfor Scala, all the frameworks on the mainland are async, and maybe one framework is on a distant island allowing blocking and Jetty
07:47hyPiRionEver tried to do a nonblocking read in Java/Clojure? Well, don't.
07:48jemafellerI keep wondering what does that mean
07:48jemafelleris Scala people prematurely optimizers? is Scala typically being used in a high-performance scenarios only? etc.
07:49jemafellerhyPiRion, truthfully, I don't think Scala's offering in the nonblocking section is much better
07:50jemafellerif you don't have something that async by nature (i.e. using IO completion ports / etc), shoving it into a Future is not the real thing
07:51jemafellerduring my survey I found a ton of Scala projects on github, just shoving every code they have in the request directly into a Future, does't matter if its blocking or not
07:51jemafellerin my eyes that is the same as blocking code on Jetty
07:53jemafellerSo I have the Scala crowd saying, "only do nonblocking", and no library support for real nonblocking IO in things like Cassandra, MongoDB. and a lot of people mis-applying Scala Futures as examples to learn from.
07:53pyykkis_weavejester, hyPiRion: Regarding async io, node.js streams are actually quite awesome, e.g., 'process.stdin.pipe(process.stdout);'
07:54pyykkis_works for files, networking, processes and whatnot with automatic backpressure etc
07:56pyrtsatomoj: "it looks like Q doesn't define a function..." <- No, it doesn't define such function directly, but Q.all([p1, p2]).then(function (ps) { return ps[0] }) gets you going.
07:57pyykkis_no waiting for sync responses, resolved promises or anything else. Piping database responses to slow mobile clients becomes trivial.
07:58tomojpyrtsa: I meant the first one to resolve, temporally
07:59tomoj(I think it's a good thing Q doesn't define such a function, it would break the semantics)
07:59pyrtsaOh, right. That would be Q.any if it existed.
08:00pyrtsaI don't see what semantics it would break.
08:03tomojwell, say you do Q.any(a,b) when b is resolved but not a, you get b. later, you do the same Q.any(a,b) after a resolves
08:05tomojQ.any would reveal the stateful part of a promise, that it goes from unrealized to realized
08:05arcatanmaybe that could be used for something like polling two database mirrors at the same time. the quickest one wins and you discard the other one.
08:06tomojyeah, if you only want "unamb" -- any where you know the results will be the same -- then no problem
08:06mpenetjemafeller: there is an async-ring-adapter too built on top of netty, I think it uses the same abstraction than http-kit (from the same author/maintainer)
08:06jemafellermpenet, indeed, thanks
08:07mpenetjemafeller: and some db lib have async support, I think monger has some, a few cassandra client as well, and well, all the http based stuff that you can easily build on top of some http client with async support (http-kit client, aleph, jetty 9 etc)
08:10mpenetbut it's rarely the default (it's not a bad thing imo)
08:19pepijndevosHow can I add a domain to all vars in a list? (core.logic)
08:21pepijndevosSomething like (fd/in ~@l domain)
08:24pyrtsatomoj: I think you can safely assume that when Q.any is used, the user doesn't care which thing is the one that completed. And the different result on later use issue is mitigated by using a temporary value: c = Q.any([a, b]); c.then(...); c.then(...).
08:26tomojfrom Q's perspective, you're probably right. still, it would be a hole in the otherwise seemingly very nice value-like semantics
08:28tomojit's OK to have holes sometimes if the user asks for one, but I want perfect value semantics AND the extra operations Q can't do :)
08:28pyrtsa:)
08:30pepijndevoswaaarg!
08:30pyrtsaAnyway, it was a very good point that Q.any would behave differently depending on the time called. :)
08:30pyrtsaBut how about if we had Q.any_n(n, promises) that would return the array of all fullfilled promises as soon as there are at least n?
08:31pyrtsa(Maybe it's time to take this discussion away from #clojure.) :)
08:33tomoja motivating example (outside the scope of Q, back closer to clojure-land): you can think of a lazy seq as being made up of conses where the 'rest' is a delay. if we replace the delay with a lazy version of Q's promises, we get so-called 'push seqs'
08:33tomojI actually wrote a library with map/filter/etc using Q like this
08:34tomojbut I want to be able to temporally merge two such seqs and always get the same answer
08:37pyrtsatomoj: What does merge mean here? zip?
08:38pyrtsa...or did you mean take values from whichever seq pushes more values first?
08:38tomojright, the latter
08:38tomojevery value from both seqs in the order that they appear
08:39tomojnot sure 'seq' is the right word -- you can't do that with normal clojure seqs...
08:39pyrtsatomoj: Do you have experience with FRP, Microsoft's Rx for example?
08:40tomoji.e. (lazy-seq (Thread/sleep 1000) [1 2 3]) and (lazy-seq [1 2 3]) are the same value
08:40tomojyeah did Rx for a while too. the motto "putting the F back in FRP" has been running through my head lately, maybe you can tell what I think of Rx :)
08:41pyrtsaI'm on your side. But having the imperative side there helps to pull those old-schoolers to the "F" side. :)
08:43pyrtsatomoj: There's a parallel in your idea of temporal merge to the example of Q.any, though. If you wanted the merge result to always be the same regardless ot the time called, the only way to have the already existing lazy-seq values merge the same way is to remember the timestamps the values were pushed.
08:44pyrtsa...and to then push the already evaluated values as sorted by their timestamps.
08:44pepijndevosCan I use print-table for just vectors of vectors?
08:44pepijndevosno headers
08:45tomojpepijndevos: you're gonna have to copy+paste :(
08:45pepijndevos:(
08:45tomojand/or patch? :)
08:47tomojpyrtsa: right, gets a bit tricky I think though
09:00tomojhmm, can it be that simple?
09:03jemafellerwhat's a good way to initialize a Redis pool? (Jedis) - I always see these ref/deref things for such initializations
09:08augustldoes Cheshire with "slime" (the binary format) support byte arrays as key values? I'm getting "Cannot JSON encode object of class: class [B: [B@7c4ccb2f" for (generate-smile {:foo my-byte-array})
09:09augustls/slime/smile
09:11pyrtsatomoj: Were you talking about the sorting based on timestamps? In that case, not in the general case with computation on multiple processors with independent clocks.
09:14tomojoi, I don't even want to think about that. assume we can serialize everything with one clock
09:14pyrtsaIn that case, I think it is that simple.
09:18tomojone minor wrinkle is something like (any (delay 1000 a) (delay 1000 b)), need to make sure there is no race
09:20pyrtsaYeah, but I guess your assumption about serializing everything with one clock kind of solves those races.
09:46mpenetjemafeller: some people prefer dynamic vars (yuk), others use regular vars and fn arguments. It's a matter of taste. A third option is a fn generator that will make you a fn that encapsulates the "pool" and that you use to call the redis commands later (kinda what aleph.redis does, even if there's no pooling going on).
09:46jemafellermpenet, thanks
09:47jemafellerhow about this approach https://github.com/jxa/resque-clojure/blob/master/src/resque_clojure/redis.clj
09:47mpenetjemafeller: check clj-redis, carmine, and aleph.redis, 3 redis clients with diff approaches to that
09:48mpenetjemafeller: using refs/atoms is problematic imo, you can only have 1 at a time...
09:48mpenetlet's say you want to support sharding later, you'll need to rewrite that.
09:48jemafellerhmm, make sense
09:50mpenetI tend to prefer clj-redis or aleph style, but that's just me.
09:50mpenetbut I use carmine in production so...
09:51mpenetjemafeller: relevant post btw: http://stuartsierra.com/2013/03/29/perils-of-dynamic-scope
09:53jemafellerinteresting.. then I guess my problem stems from the fact that I hold my "Redis" layer in the same file
09:53jemafellerso functions are using a pool being 'def'ed on the file itself.. I'm using the file as a module and its quite convenient
09:54jemafellerand I don't want to leak Redis specifics to the module that uses the 'Redis module', like the Pool
09:55mpenetusing something like clj-redis style (a pool argument), you can easily hide that to most of you code using partial
09:56Glenjaminmpenet: that's interesting - i've just taken a very similar approach to that in my app =/
09:56Glenjaminalthough the dynamic state i'm binding is just some values which are used to create an oauth header when making http requests
09:56Glenjaminrather than an actual resource
09:57Glenjaminnot sure if that falls into the "dangerous" category
09:57mpenetas stated in the post there are valid uses cases, when it's safe and when it prevents making the code very convoluted
09:58Glenjaminmm, but having read that i'm not entirely clear where the line is drawn
09:58mpenetI use dyn vars regularly, recently on a query generator to hold a stack of parameters for prepared statements, it's safe and prevented to add an additional arg to a dozen of fns.
09:59Glenjamini've got a compojure app, on request some middleware binds some auth credentials based on the cookie, and this is used to authenticate API requests to the backend during the request
09:59mpenetbut everytime I do, it does feel like I am doing something bad :), but as long as it doesn't hurt, it's ok
09:59Glenjamineg. (with-auth token (make-api-request))
09:59mpenetGlenjamin: I am not sure, but if you switch to an async server later you could have some surprises.
10:01mpenetcompojure used to do that at the beginning I think, hold a *session* var, but this went away
10:01jemafellermpenet, so you're saying to build something like (make-storage configuration) which will build a (let [pool (build the pool with config)] (fn [record] (actually-store pool record))) ?
10:01mpenetor maybe some other framework that built on top of it.
10:01Glenjaminyeah, it's similar to noir's *request*, but specific to what I know i'll pull out each time if i passed it around
10:02Glenjaminin an async server, what would be async?
10:02mpenetdepends, but in http-kit for instance a single thread manages many connections for instance
10:03Glenjamini suppose i'd only run into issues if a single request was handled via multiple threads
10:04mpenetjemafeller: use simple fns, and then build on top of it. ex (defn search [server query]) and in your user ns you can just create a var with (partial search "localhost") and use that
10:04Glenjaminoo, that's interesting
10:04pepijndevoswow, never had htis before: GC overhead limit exceeded
10:04Glenjamini could have the middleware drop partial functions into the request map
10:05jemafellermpenet, i'll have to lean about partial funcs, i'm looking..
10:05Glenjaminalthough i suppose there'd be an overhead of initialising a bunch of things i wont use on most requests...
10:05Glenjaminlots to think about :)
10:05mpenetaleph.redis has something like that, you create a "client" fn by passing options to a fn that generates it
10:05jemafelleri'll check that
10:05mpenethttps://github.com/ztellman/aleph/wiki/Redis#creating-a-redis-client
10:06mpenetI am not saying it's a silver bullet, but knowing of the alternatives is always good :)
10:06jemafellermpenet, yes i see that. I kind of did that with 'traditional' currying. they solved the case by specifying a command as part of the data structure passed to the client
10:07jemafellerwhich now affirms me its not a bad solution.. kind of implementing a class without a class
10:09Glenjaminon another subject, the dev.clojure wiki's coding standards mentions full branch coverage as a requirement
10:10Glenjaminis there a tool to derive this?
10:15pepijndevoscore.logic memory is sloooowly rising, after a long time causing the above GC error.
10:21jemafellerahh. love the smell of "done" :)
10:21jemafeller6600 req/s for an analytics service built with Clojure is not so bad eh? :)
10:48pepijndevoshm, I'm trying to find this graph of work done/time for programmers and other people. Where the one line goes gradually up, the other straight up and the horizontal.
10:52hyPiRionpepijndevos: thinking about the mythical man month?
10:53pepijndevosno idea where it's from
10:53pepijndevosit just randomly pop in and out of my internets
10:53hyPiRionhm
10:57Sonderbladepepijndevos: is it the one where it is claimed that output is n, but communication overhead is 2^n where n is the number of programmers?
10:59pepijndevosSonderblade, no, the one that shows that manually producing a result will be faster initially, but slower in the long term.
11:11xeqipepijndevos: https://plus.google.com/102451193315916178828/posts/MGxauXypb1Y
11:11pepijndevosxeqi, YES!
11:23hyPiRionxeqi: oh, that's a nice graph. I'll show it to people when they ask why I use so "much time" to setup my emacs config
11:27Glenjaminis there a core function with prints a value and returns it?
11:28hyPiRionnot afaik
11:34xeqinothing builtin, but ##(doto :x println) would work
11:34lazybot⇒ :x :x
11:35Glenjamini'm mostly using it to debug threading
11:36Glenjaminso (doto prn) is what i'm after, cheers
11:36Glenjaminbeen doing ((fn [x] (prn x) x)) every time :)
11:37Glenjaminbtw, i've got a couple more cookie-related bugs to report/fix in peridot
11:38hyPiRionoh, doto works for -> threading too
11:39hyPiRion,(-> 1 (doto prn) inc (doto prn) (* 10) (doto prn) dec)
11:39clojurebot1\n2\n20\n19
11:39xeqiGlenjamin: awesome
11:39xeqiI saw the timestamp pull and it looks great
11:39xeqi(from my phone)
11:40xeqiwill look at getting it merged later
11:40Glenjamincheers
11:40borkdudeyogthos I guess the reason the sample guestbook application creates the h2 db in the same directory as the jar when deployed is because noir.io returns nil, is this intended?
11:40xeqiGlenjamin: out of curiousity, what are you using it for?
11:41Glenjamingot a small app which talks to my accountant's oauth api
11:41Glenjamintesting the cookie handling of the middleware that tracks auth
11:42Glenjaminwill probably use kerodon when i get to building the actual app
11:44borkdudeyogthos|away it is a good place I guess
11:47Glenjaminxeqi: is there a way to do https requests in peridot?
11:49Glenjaminah, i need to pass a full url
11:51xeqiGlenjamin: yep, a full url should work
11:52xeqiI usually do a https proxy in front of my ring app
11:53Glenjamini've got :secure true in my cookie params
11:53Glenjaminit kept stripping it out :)
11:53xeqiah!
11:53xeqithat would be a good use case there
11:54Glenjaminwhich is where i found the other bug - :http-only cookies gets stripped from https requests
11:54Glenjaminbut http-only just means no javascript access
11:55xeqiheh, thats what I get for not reading the spec there
11:55xeqioops
11:57Glenjamincan't seem to find a neater way of expressing this than: (remove #(scheme {:http :secure :https :nothing})) in the ->> though
11:58Glenjamin(remove #((and (= scheme :http) (:secure %)))) maybe
12:03xeqiGlenjamin: yeah... maybe pull the remove out into a function like (defn maybe-remove-secure [scheme cookies] (if (= scheme :http) (remove :secure cookies) cookies)) ?
12:03xeqinothing is immediatly appealing
12:04xeqithough some of that code is ugly anyways
12:04Glenjaminended up with (remove #(and (:secure %) (= scheme :http)))
12:04Glenjaminwhich isn't too bad
12:04Glenjaminheh, " (sort-by (comp count first)) (map second) (apply merge) (map second)" could be doing anything
12:04xeqiyep
12:05xeqithats the part I was thinking
12:05xeqiwho wrote that uglyness... oh, me a year ago...
12:06Glenjaminheh
12:06Glenjaminsecond PR for the http-only thing sent
12:07Glenjaminthese libs make me feel right at home coming from ruby testing, nice job :)
12:16yogthosborkdude: with a jar you can't write to your resources folder
12:16yogthosborkdude: so you have to give it an external path
12:16borkdudeyogthos yeah, I know, or if it could it would be ugly to do it
12:16yogthosborkdude: pretty much yeah
12:17borkdudeyogthos would you have to do this manually I guess?
12:17borkdudeyogthos for examples I could make a directory "resources" in the same dir as the .jar file
12:17yogthosborkdude: yeah I'd just give it a path for the db
12:18yogthosborkdude: also you probably don't want it to reside in your public folder either :)
12:18borkdudeyogthos probably not :)
12:18yogthosborkdude: I find the situation with wars is much better, because then the whole things get unpacked into its own directory
12:19borkdudeyogthos hmm, now you mention it, it is a bit weird that the db gets created in the public folder now ;)
12:19yogthosborkdude: but yeah I couldn't think of any good way to handle that automatically with a war, should probably make a mention of this in the deployment docs
12:23rahcolalein repl gives "EOF while reading string" in a clean leiningen project under Windows 7
12:23rahcolaany ideas?
12:24muhoowha? -?> still hasn't made it into 1.5.1?
12:24muhooshocked it's still in incubator after like a year
12:25borkdudeyogthos say I would have this guestbook in production and I have some local data also using the same h2 database model, what is the easiest way to merge these two databases?
12:26borkdudeyogthos this is more h2 related than webapps, but maybe you would happen to know this
12:26yogthosborkdude: I probably wouldn't recommend h2 for that, it's an embedded db after all
12:27borkdudeyogthos what would you recommend?
12:27yogthosborkdude: it would be much better to setup an actual db at that point like postgres
12:27borkdudeyogthos what is the reason you have chosen h2 over other alternatives like sqlite etc for this example?
12:28yogthosborkdude: was recommended on this channel actually, I started with sqlite and people suggested h2 is more robust and has better drivers in java
12:29yogthosborkdude: also depending on what you need something like mongo might be a good option as well
12:30yogthosborkdude: if you just need a persistence layer and don't care about the relational aspect
12:30borkdudeyogthos yeah, I tried mongo, but it only works for tree-like data
12:30yogthosborkdude: yup
12:30borkdudeyogthos probably will look more into postgresql then
12:30yogthosborkdude: I definitely recommend postgres
12:31yogthosborkdude: if you're on os x this is very nice for testing http://postgresapp.com/
12:31borkdudeyogthos I am. It's the tooling which makes a big difference. tnx
12:35stuartsierramuhoo: -?> is in 1.5, it's called some->
12:52augustlanyone used cometd with a lein-ring app before? Not sure what's easier - ditch lein-ring and write my own servlet + jetty stuff, or figure out how to make a web.xml setup with both lein-ring and my own servlet for cometd.
13:00rebcabin,(def xs (map-indexed (fn [i x] (str i x)) (partition 2 '(1 2 3 4)))) -- stuck in lazy form; prints as ("0clojure.lang.LazySeq@3e2" ...) etc. (map doall xs) doesn't force
13:00clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
13:01rebcabinany hints on how to un-lazy out the sequences
13:02hyPiRionrebcabin: replace `str` with `apply str`
13:02hyPiRionwait, perhaps you'd like it to print as a list?
13:02rebcabinhyPiRion: oh my, that again /slaps forehead; ty
13:03rebcabinhyPiRion: yes, printing as a list would also be a great alternative
13:03hyPiRion,(map-indexed (fn [i x] (str i (-> x vec list*))) (partition 2 '(1 2 3 4)))
13:03clojurebot("0(1 2)" "1(3 4)")
13:04hyPiRionvec realizes the whole sequence, list* converts it back to a list again
13:04rebcabinhyPiRion, clojurebot: lovely
13:12rebcabin,(str "ignore: just testing clojurebot")
13:12clojurebot"ignore: just testing clojurebot"
13:13augustlis it possible to make lein-ring use web.xml when running it with "lein ring server"?
13:30augustllooking for general suggestions on how to combine a ring handler with a servlet :) The goal is to make it work with the lein-ring plugin
13:31augustlI could always roll my own -main that creates the servlets, but then I would need to implement dev mode reloading myself..
13:40stuartsierraaugustl: I don't think lein-ring even uses web.xml in development mode. It embes the servlet container directly.
13:40stuartsierra*embeds
13:40stuartsierraAnd for building a .war file, lein-ring generates both the web.xml file and the servlet class.
13:42chessguy'afternoon all
13:42chessguystuart, congrats on the release of pedestal, looks really interesting
13:43stuartsierraThanks.
13:43augustlstuartsierra: yeah it seems the web.xml part of lein-ring is only generating it + a war file
13:43chessguyyou guys just need a "how to build a chat client in 15 minutes" video, and you'll be all set
13:43stuartsierrachessguy: Well, there's already a chat sample app. We might make some screencasts soon.
13:44chessguystuartsierra: i know, that's why i picked it
13:44chessguyi've been playing with the chat code, and with the other samples
13:44chessguyit's also a good example for the space where pedestal's going to kick butt
13:45stuartsierraThat's the hope, anyway.
13:46chessguyi am kind of curious why you guys bundled it all together though. it seems like there could have been advantages to having, say, an interceptor library, and a application library, versioned separately
13:49stuartsierrachessguy: It's been both ways at different times.
13:49chessguyi see
13:49stuartsierraI expect we'll release some of the pieces independently in the future.
13:50stuartsierraTo get the alpha out in time for Clojure/West, we took the "easy" route of bundling it all together.
13:50chessguyas opposed to the simple route? :)
13:50chessguysorry, couldn't resist
13:52stuartsierraYes, actually, that was what I meant. :)
13:52stuartsierra"Simple" is hard.
13:52gfrederickshyPiRion: list* does _not_ convert back to a list
13:52chessguyagreed
13:52gfrederickshyPiRion: I guess that wasn't really the point though, nm
13:54chessguyi really hope to see some better documentation/tutorials soon. do you realize that the web site doesn't even really define what it means by "service" vs. "application"?
13:55stuartsierraoh yeah, lots more work to be done there
13:55chessguyi'd be happy to contribute too, once that's worked out
13:55chessguy(and i can get my brain around it)
13:55stuartsierraCool. We've got a CA process for the source code, I think there's one in the works for docs too.
13:57chessguyyeah, i need to get that sent in too
14:00hyPiRiongfredericks: I agree though, perhaps seq would be a better fit there.
14:06gfrederickshyPiRion: probably just doall?
14:06gfredericksRaynes: ping
14:07hyPiRiongfredericks: doesn't work
14:07hyPiRion,(str (doall (partition 2 '(1 2 3 4))))
14:07clojurebot"clojure.lang.LazySeq@8041"
14:08gfrederickshyPiRion: ahrighto
14:08gfredericks,(print-str (doall (partition 2 '(1 2 3 4)))
14:08clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
14:08gfredericks,(print-str (doall (partition 2 '(1 2 3 4))))
14:08clojurebot"((1 2) (3 4))"
14:09gfredericksit surprised me to learn that println prints lazy seqs the good way
14:09hyPiRionthe good way?
14:09hyPiRion,(.toString (partition 2 '(1 2 3 4)))
14:09clojurebot"clojure.lang.LazySeq@8041"
14:11gfredericksyeah rather than that way
14:11hyPiRionah
14:13gfredericksanybody use laser? I'm finding it weird that laser/document does both transformations _and_ conversion to an html string
14:13gfredericksno obvious built-in way to do just transformations
14:13hyPiRionI think Raynes uses it, since, you know, he built it and all
14:14RaynesI wouldn't use that nasty shit.
14:14RaynesOh wait.
14:14gfredericksI pung him and he didn't show up until I started complaining about specifics
14:14RaynesI didn't see a ping.
14:14gfredericksthey are small and quiet
14:15Raynesgfredericks: I'm in a new place with no cable internet and the mifi card I'm on is utterly worthless.
14:15RaynesIf I don't respond it's probably because the mifi card is tossing me around like a pizza crust.
14:15gfredericksRaynes: this project is slowly turning into a bunch of raynes libs; you seem to write only useful stuff.
14:15Rayneslol
14:15RaynesSo document.
14:15gfredericksyes that
14:15gfredericksI just took the source and wrote a `transform` but I had to use a private var to do it
14:16Raynesdocument is meant to be the top-level transformation that you build everything up.
14:16RaynesI wasn't expecting a scenario where you'd want to have more than one document call on the same thing.
14:16RaynesWhy do you need document to not return a string?
14:16gfredericksso it expects I'm doing all my transformations in one place?
14:17gfrederickswell if I want a top-level transformation to be a composition of several lower-level transformations, for example...
14:17RaynesWell, it expects that all of the transformations on that particular document would be done in a single call to document.
14:17Raynes(not saying that's a good assumption)
14:18gfredericksokay. so I'm not missing anything by thinking a transform function would be useful?
14:18RaynesI think there is one.
14:18RaynesAnd you just didn't find it.
14:18RaynesI'm looking.
14:19gfrederickslaser/document certainly doesn't use one
14:19augustlwhy do I get "No matching field found: foo" for https://www.refheap.com/paste/13152 ?
14:19gfredericksaugustl: you're trying to create a type that has a foo method?
14:19augustlyeah
14:19Raynesgfredericks: I think 'at' is what you want.
14:20gfredericksaugustl: I don't think proxy can be used to add arbitrary methods. it would have to be a method on the superclass or an interface
14:21augustlah
14:21gfredericksaugustl: it's a bit weird that it'll compile the proxy form without error
14:21Raynesgfredericks: If 'at' does work for you, one could probably write document in terms of it. I don't I just didn't care enough to try because document has a very short and simple definition.
14:22gfredericksRaynes: I think this looks promising, thanks
14:22augustlgfredericks: I thought the point of proxy was that method dispatch happened through a normal clojure map
14:22RaynesIs this code open source?
14:22gfredericksRaynes: no it's for static-generation of my website
14:23Raynesgfredericks: You could also use fragment for this, I think.
14:23augustl"proxy" returns the instance, right?
14:24gfredericksRaynes: yeah I noticed that looked useful too
14:25Raynesgfredericks: If you have any trouble let me know.
14:40chessguyerr, if i'm in just a straight clojure repl (not a lein repl), how do i load some arbitrary clojar?
14:55gfredericksyou can't within the same repl session
14:56gfredericksif by "straight clojure repl" you mean running the clojure jar from the `java` command, you can add any other jar to the classpath
15:05gfredericksRaynes: there's not a selector for the enlive-style :div#content.foo is there?
15:07Raynesgfredericks: Nope. One of my reasons for making laser is because I hated that. But I also want to implement something like that on top of the existing selectors.
15:07gfredericksso you hate it being the low-level thing you mean?
15:12Raynesgfredericks: More or less, yeah. I'd rather use the function-based selectors even if I had the other things.
15:42ghengisdoes an ingenious library exist for dealing with complex data structures (e.g. lists of maps of vectors of maps of lists, etc)? i'm getting a headache and wondering if someone has found a way to make performing updates/reads on such structures easier?
15:44stuartsierraghengis: Clojure has some built-in functions to help: get-in, assoc-in, update-in.
15:46ghengisyeah i'm aware of those, but still doing some awfully complicated stuff to get inside the structures..
15:46stuartsierraYou could also look at https://github.com/LonoCloud/synthread
15:46ghengishm, i might just have to rethink the structures themselves
15:46ghengisok, looking...
15:49ghengisyeah, this looks really nice
15:49ghengisthanks! i'll play around with it
15:58augustlhow do I call a macro that takes varargs with a list of args? (apply my-macro my-list) throws an error ("Can't take value of a macro")
16:00lucianaugustl: if you're calling it with apply, you probably want a function instead
16:00augustlyeah, I know, apply doesn't work for macros :)
16:00augustlso how do I call a macro that takes varargs with a list containing the args?
16:07amalloyaugustl: it is not possible
16:08amalloymacros operate on source-code forms, not runtime data values
16:14augustlamalloy: makes sense, thanks
16:25gfredericksRaynes: so you'd take a patch for a laser/css function?
16:25Raynesgfredericks: I wouldn't name it that if it was enlive's 'css'
16:25gfredericksI wasn't thinking of enlive
16:26RaynesIf it were a real subset of css, I'd take it.
16:26Raynes(with that name, I mean)
16:26gfredericksshall I open an issue for discussion?
16:26RaynesIf it were enlive-style I'd name it enlive-css or something.
16:26RaynesSure.
16:31RaynesI really object to the goal of "well, css selectors are shorter."
16:32RaynesBut other than that, sure.
16:32gfrederickswhy do you object to it?
16:32RaynesBecause CSS is a different language and isn't functions.
16:32gfredericksit's a DSL?
16:32RaynesThey're nice to have, so I want them, but I'm going to be sad when people use them.
16:33Raynes:p
16:33gfredericksyou sound very conflicted
16:34gfredericksdamn do we need a whole CSS parsing lib for this?
16:34RaynesYes.
16:34gfrederickscan we call it lacsser?
16:34Rayneslol
16:35gfredericksman this is why I don't write libraries. They always require several other libraries to also be written.
16:37RaynesWell, you aren't legally obligated to add this functionality. :p
16:39gfredericksso the next question is -- can we start with just the div#id.class1.class2 syntax?
16:40ivaraasenRaynes: my goal is to turn every single one of your repos into little, non-composable DSLs and package them as raynesLang
16:41amalloy(inc gfredericks)
16:41lazybot⇒ 17
16:41amalloyoh, i guess i meant ivaraasen
16:41Raynes(dec gfredericks)
16:41lazybot⇒ 16
16:41Raynes(inc ivaraasen)
16:41lazybot⇒ 1
16:41RaynesFixed.
16:41RaynesWow, poor ivaraasen.
16:41gfredericksI was a prime for 17 seconds
16:41Raynesgfredericks: Yes. That's what subset means.
16:41Raynes:p
16:42gfrederickshyPiRion: I'm about to push up a lib that does factoring
16:42amalloygfredericks: 27 seconds
16:42gfredericksRaynes: w00t this shit just got feasible
16:42amalloynot a prime number of seconds, alas
16:42gfredericksI'm thinking of using a regex so the next question is how I will solve the resulting two problems
16:43gfredericksamalloy: does your client show seconds?
16:43amalloyyes
16:43gfredericksthat's like magic
16:43gfredericksalso it's a cube which is nearly as good as a prime
16:43amalloytrue
16:43gfredericksI wrote some code for computing the smallest uninteresting number recently
16:44Bronsawhat's an interesting number?
16:44ivaraasenBronsa: 6.
16:44ivaraasenit's a perfect number
16:44gfredericksBronsa: that's determined by your supplied vector of interests
16:45gfrederickswhich you can iterate on once you figure out something interesting about whatever number you missed
16:46chessguy(inc Raynes)
16:46lazybot⇒ 26
16:46gfrederickse.g., 26 is a semiprime
16:47chessguybecause any tutorial that starts by referring to its readers as small animals has to be awesome..
16:47gfredericksyou don't have to get very far before you can say something interesting about every number below 100, which makes you quite a hit at parties let me tell you what.
16:48amalloygfredericks: i imagine you got desperate at some point, and your interesting fact about 43 is "the number of parties at which i've tried to tell interesting facts about numbers"
16:50gfredericksactually 40 was the first tricky one
16:50gfredericks43 is a prime
16:50Bronsaafer the first few primes, being prime is not interesting anymore though
16:50gfredericksit's *always* interesting.
16:51gfredericksthe bigger it is the more interesting it is.
16:51gfredericksit is a number which evades all attempts to arrange it into a rectangle.
16:51Bronsawell, then any number is interesting because it's the first and only number that can be factorized that way.
16:52gfredericksthat's not a very interesting definition of interesting
16:52Bronsanor is being the nth prime
16:52gfredericksactually I like the idea that any definition of interesting should result in a set with limiting density of 0
16:52ivaraasen19 - "prime. also, the number of blog posts in the last 48 hours trying to explain monads using a horrible metaphor"
16:53hyPiRiongfredericks: oh, you'll beat me to it then
16:53hyPiRionBetter just fork your and add in stuff if I need
16:54Bronsaalso gfredericks the first uninteresting number would be interesting because of that very nature of his, Hofstadter docet
16:54gfrederickshyPiRion: just as soon as I can figure out how to mount the damn vm share again
16:54gfredericksBronsa: yeah, that "paradox" is what got me thinking about this
16:55hyPiRiongfredericks: Well, no worries. I am not in an emergency situation where I need a factorization lib.
16:55gfrederickshyPiRion: my thought was that there isn't an appropriate-in-all-cases implementation
16:55gfredericksso I made a protocol
16:56hyPiRiongfredericks: what do you mean by that? Well, I guess I'll have to wait and see
16:59gfrederickshyPiRion: i.e., different amounts of memory usage might be appropriate
16:59gfredericksfor factoring one number versus multiples
17:07gfrederickshyPiRion: https://github.com/fredericksgary/numth
17:08hyPiRionoh, you've seen my prime lib, right? https://github.com/hyPiRion/primes
17:08hyPiRionJust in case
17:09gfredericksheck no
17:09gfredericksyours must be better
17:09gfredericksthought mine is theoretically broader
17:09gfrederickss/theoretically/hypothetically/
17:10hyPiRionIt doesn't factorize though, it's just doing one thing really.
17:12gfredericksfactoring and prime-checking and prime-listing are undecomplectable I think
17:14hyPiRionhmm
17:14gfredericksI also didn't want the lib to necessarily accumulate state in the background
17:14gfredericksif you don't want it to
17:15hyPiRionright
17:17gfrederickscould have a prime? implementation that just uses BigInteger#isProbablePrime
17:18hyPiRionyeah
17:19Glenjaminundecomplectable is an awesome word.
17:20gfredericksit's probably an oxymoronic word
17:21gfredericksif things are undecomplectable, are they really complected in the first place?
17:21hyPiRionmay be
17:22hyPiRionWell, it depends on the definition of undecomplectable
17:27bbloomi don't think it is possible to be uncomplectable....
17:36ivaraasenwell, you could view factorisation as a constraint-based search in a vector space, say R1, and prime number generation as the basis for this space. so you could perhaps decomplect them, should you for some reason wish to factorise different kinds of data (numbers, mathematical symbols)
17:38finishingmovewhen i'm writing a function that can be overloaded, am i limited to one comment or can i have a comment for each scenario?
17:44n_bYou mean like this?
17:45tomojhas anyone tried running something in the background in cljsbuild's notify-command?
17:45tomojwhen
17:45n_b,(def foo ("comment" [](foo 1)) ("returns bar" [bar] bar))
17:46clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
17:46n_bwoops
17:46tomojer, when I do `command-that-takes-3s &` in the shell script that I'm using for my notify-command, cljsbuild blocks waiting, apparently because of the 'pumper' stuff
17:46tomojeven `command-that-takes-3s 2>&1 >/dev/null &`
17:48tomojwhich doesn't make any sense to me, because `my-shell-script 2>&1 >test` returns immediately
17:48n_bfinishingmove: Seems to work.
17:51tomojah.. http://bugs.sun.com/view_bug.do?bug_id=4850368
17:51tomojhmm, it's closed though
17:56amalloytomoj: you probably meant `command-that-takes-3s >/dev/null 2>&1 &`
17:56amalloyor, i suppose, `command-that-takes-3s &>/dev/null &`
17:58tomojhmm
17:58tomojthat works! thank you
17:59tomojI guess I still had stderr coming out?
17:59tomoj(of stdout..)
17:59moominpapaVery good understanding, yes
18:00tomojhttps://www.refheap.com/paste/f7013fe4a77c02cf03abb0945
18:00tomojmy replacement for notify-send, which is incredibly frustrating with cljsbuild
18:01tomojsince 1) you can't configure how long it shows and 2) it always shows every message for the full time, causing a buffer you have to sit and wait through if you save many times in a row
18:03aaelonyi don't see c3p0 in clojars.org any longer, is it no longer recommended with clojure.java.jdbc ?
18:05aaelonye.g. "No results" for https://clojars.org/search?q=c3p0
18:07finishingmoven_b thanks
18:07tomojhttp://search.maven.org/#search%7Cga%7C1%7Cc3p0 ?
18:07tomojaaelony: ^
18:08aaelonyyes, it's in maven, but wondering if there is a reason it is no longer in clojars. Perhaps there is an opinionated way that is better?
18:09aaelonyjust curious ...
18:09amalloywas it ever on clojars? i can't think why it would have been
18:15aaelonyamalloy: never known you to be wrong yet.
18:15abeheya, any incanter folk here?
18:17aaelonyso… consensus seems to be using c3p0 is ok, thanks
18:17tomojclojure.java.jdbc isn't in clojars either, is it?
18:18amalloyneither is clojure :P
18:22aaelonywell things change and libs that were previously "blessed" sometimes fall out of favor with other libs being preferred. Just trying to get the pulse on c3p0 and see which camp it falls into
18:22hyPiRionneither is more or less anything related to Java only
19:03st3fanok i'm done .. http://stefan.arentz.ca/finding-your-way-home-with-clojure.html
19:07jasonjcknst3fan: cool
19:07jasonjcknst3fan: nice ui
19:08callenbotst3fan: Mozilla needs less Go and more Clojure :)
19:08callenbotst3fan: also holy hell who did the design on that?
19:08callenbotoh I see the name
19:08callenbotGAWD that is pretty
19:08Willyfrogreally nice, I'll check the code tomorrow
19:09Willyfroggood night, everyone
19:09st3fancallenbot: yes!
19:09st3fancallenbot: click the link under the screenshot and you will see the blog of my extremely talented colleague :)
19:09jasonjcknst3fan: is there a big clj community in toronto?
19:10jasonjcknst3fan: which companies?
19:10jasonjcknst3fan: i'm originally from newmarket
19:10st3fani'm not sure .. i think we have a lisp user group that also has a number of clojure folks
19:11st3fanbrb dinner cookin'
19:12miloshadziccallenbot: Mozilla makes/uses Rust, not Go
19:14callenbotmiloshadzic: Mozilla experiments with Rust
19:14callenbotmiloshadzic: it *uses* Go in production
19:15callenbotServo is still extremely experimental, don't be ridiculous.
19:15miloshadziccallenbot: where do they use go? first time I've heard about that
19:15callenbotst3fan: already did.
19:15callenbotmiloshadzic: Persona
19:15callenbotThey're not silly enough to use Node.js for something important to them :)
19:17tomoj:D
19:18miloshadziccallenbot: not looking to argue but I can't find a mozilla repo or whatever that they use go
19:22Glenjaminpretty sure persona is build on node.js
19:22Glenjaminor it was anyway
19:22Glenjaminthere's a mozilla node.js guy who works on persona at a javascript user group i go to
19:23Glenjaminand here it is: https://github.com/mozilla/browserid
19:31callenbotGlenjamin: it's entirely possible I was lied to, but I was told the backend stuff, including Persona, of late was Go.
19:32miloshadzicIt is april 1st, maybe it was a joke? :)
19:32Raynescallenbot: Ohai.
19:32RaynesLong time no chat.
19:33callenbotRaynes: indeed.
19:33miloshadzicwhois Raynes
19:33callenbotRaynes: my next task is to put together a (better) Clojure equivalent to Fabric.
19:33callenbotRaynes: how's life in the land of fake tits?
19:33RaynesMrh.
19:33RaynesMeh*
19:33callenbotas i suspected.
19:34RaynesLA is fine. It's me that has problems.
19:47gfrederickshyPiRion: holy jackwagon man you wrote java code with locking
19:48tomojhmm, my attempt at detecting the status of cljsbuild in notify-command obviously doesn't work :(
19:50gfrederickshyPiRion: also this primes thing makes me want to write an efficiently-indexable lazy sequential data structure
19:50tomojI guess the obvious solution is to allow a notify-fn that takes status info and returns a shell command?
19:55st3fancallenbot: most mozilla stuff is Python or Node (Persona is Node)
19:56st3fanwe have very little Go. AFAIK we don
19:56st3fan't have any Go code for public sites
19:56callenbotst3fan: weird. I have a Go nut to correct then.
20:09Rich_MorinI'm a noob at IntelliJ, trying to get La Clojure set up with the Community Edition. I'm getting a nastygram from the plugin manager; "Plugin is incomparible with current IntelliJ installation." Help?
20:12callenbotRich_Morin: IntelliJ version?
20:13Glenjaminis there a nicer way to do a 'reverse map' than this? (doseq [test tests] (test state))
20:13Rich_Morinlatest CE - 12.0.4
20:13Glenjaminie. call every item in a collection as a function, with the same arguments
20:14callenbotRich_Morin: last I used it was 11 or 12 worked fine for me insofar as any IDE works.
20:14callenbotRich_Morin: you're probably going to need to do the usual Google + bugging the developers kabuki dance.
20:14Rich_MorinI think restarting it may have done the trick. thx for responding
20:15callenbottypical IDE.
20:15callenbot"have you tried turning it off and on again?"
20:18hyPiRiongfredericks: oh, yeah, I wanted the speed. And yeah, I wish there were some lazy-vec out there in the wild
20:20gfredericksRaynes: laser/and is just every-pred I think
20:21gfrederickslikewise laser/or => some-fn
20:22Raynesgfredericks: Yes, but we still need them to exist in laser under these names.
20:22RaynesOtherwise people will never find them.
20:22gfrederickshaha
20:22RaynesA pull request would be nice for or though.
20:22Raynes(to use some-fn in the body)
20:22gfredericksbut not for and?
20:23Raynesgfredericks: https://github.com/Raynes/laser/blob/master/src/me/raynes/laser.clj#L155
20:23RaynesYou could change it to `(def and <docstring> every-pred)` if you want, gfredericks .
20:23gfrederickshyPiRion: also http://gfredericks.com/gfrlog/90
20:24gfredericksRaynes: oh I've been looking at 1.0.0 in my repl
20:24gfredericksRaynes: I will send a pull request so that I can trivially be a contributor which is all I ever wanted
20:27gfrederickswhy does `lein test` not accomplish `lein midje`?
20:27Raynesgfredericks: Because life doesn't work like that.
20:27hyPiRiongfredericks: because you forgot to set :alias {"test" "midje"}
20:28gfredericksRaynes: (def and <docstring> every-pred) kills the helpful metadata from defn :(
20:28gfredericksso I will leave it as defn
20:28RaynesIndeed.
20:30Raynesgfredericks: You remind me a lot of me when I get to be your age.
20:32hyPiRionRaynes: Where are you hiding that time machine of yours
20:36hyPiRiongfredericks: That was an interesting way of looking at prime generation. I'm just a low-level person who sacrifice memory and readability for locks and cache hits.
20:37gfredericksI don't know that mine is very readable
20:37gfredericksI tried to explain it to a clojure study group once and ended up just hanging my head in shame
20:38gfredericksRaynes: I'm working on the dang css thing but it can haz a bug
20:39gfredericksnow it doesn't have a bug
20:40`arrdemnow you see it now you don't, the heisenbug uncertainty principal remains.
20:40hyPiRiongfredericks: Well, I understood it fine. Then again, it's not unlikely that I've actually made a similar version, considering all those project euler problems I've tried to solve
20:40callenbotgfredericks: what?
20:42gfrederickscallenbot: what?
20:43callenbotgfredericks: what did you fail to explain to a clojure study group?
20:43callenbotgfredericks: where was this study group?
20:44hyPiRioncallenbot: a lazy iterative prime number generator
20:44gfrederickscallenbot: at Groupon
20:45gfredericksRaynes: https://gist.github.com/fredericksgary/5282642
20:46gfrederickshyPiRion: I expect it's not usefully fast; it just satisfied all my idealisms
20:46callenbotgfredericks: are you in the Yay?
20:47hyPiRiongfredericks: hey, we need one for Swearjure mister
20:47hyPiRionThey're pretty darn important
20:47gfrederickscallenbot: http://en.wikipedia.org/wiki/Yay
20:47callenbotgfredericks: bay area.
20:47gfrederickshyPiRion: well that's factoring which is slightly different
20:47gfrederickscallenbot: no, chicago
21:05dribnethaving trouble understanding how to extend the reader with a tagged literal in cljs
21:05dribnetanyone have any experience with this?
21:08callenbothyPiRion: Swearjure makes the baby jesus cry.
21:18ivaraasenmikera: ping
21:21bytechunky,(list? (cons 1 ()))
21:21clojurebotfalse
21:22bytechunky^^ this really got me by surprise
21:33dribnetso, like, data_readers.clj doesn't work for clojurescript...
21:35dribnetcljs.reader/register-tag-parser! seems to work fine, but not so much for the data reader used by the compiler...
21:37deanHi, I'm working on solving the sum product problem with core.logic. I've got the first two steps sort of working (http://pastebin.com/Txaz5e5B). At the minute I've restricted the domain to 17 to keep things fast and it does work but it returns 17 8 times. Anyone have any ideas why that is happening?
21:41dribnetis the cljs compiler data reader in clj or cljs space?
21:52bbloomdribnet: the compiler's reader is the clj reader written in Java
21:52bbloomdribnet: the runtime reader is written in cljs and only reads EDN, not source code
21:53bbloomdribnet: cljs may move to tools.reader, now part of contrib, which is written in clojure, but should be cross-compilable as cljs
21:53dribnetthx. do you know in clj I could hook into *cljs-data-readers*?
21:54dribneteg: (alter-var-root #'*cljs-data-readers* assoc ...)
21:55dribnetwhen I throw that into a clj file, I get runtime exception: Unable to resolve var.
21:56gfrederickswhy does (.printStackTrace *e) print nothing in nrepl? o_O
21:56bbloomdribnet: ignoring for a moment that this implies a shortcoming in cljs that you might want to file a bug on....
21:56bbloomdribnet: you need to reference the namespace that the var is in
21:57bbloomdribnet: try requiring cljs.tagged-literals
21:57bbloomdribnet: the fully qualified var is #'cljs.tagged-literals/*cljs-data-readers*
21:59dribnetright, thanks. that worked.
22:00dribneti guess the function i provide in this context needs to be a clj function and not a cljs one. that's too bad.
22:00tomojit's basically a reader macro :P
22:00dribnetcljs.reader/register-tag-parser! of course works with a cljs function...
22:00bbloomdribnet: you're modifying the read table for your SOURCE CODE, the source code is interpreted by a clojure, not clojurescript
22:02dribnetright. whereas when I call reader/read-string in cljs, that is interpreted by cljs and not clj.
22:08dribnethmmm. still not able to modify the read table for my source code as hoped...
22:08dribnet(ns tags
22:08dribnet (:require [cljs.tagged-literals :as t]))
22:08dribnet(alter-var-root #'t/*cljs-data-readers* assoc "js" identity)
22:11dribnet_hey bodil. what do you think of a cljs tagged literal for javascript?
22:12dribnet_so instead of the runtime (def jso (clj->js {:a 1 :b 2 :c [1 2 3]}))
22:12dribnet_there would be the more concise compile time option
22:13dribnet_(def jso #js {:a 1 :b 2 :c [1 2 3]})
22:13tieTYT2what's the difference between "(def ^:dynamic x 1)" and "(def ^{:dynamic true} x 1)"?
22:14amalloy&(binding [*print-meta* true] '(def ^:dynamic x 1))
22:14lazybotjava.lang.SecurityException: You tripped the alarm! pop-thread-bindings is bad!
22:14amalloyfeh. anyway, the point is they're the same
22:15tieTYT2ok
22:15tieTYT2thanks
22:15theophilusxReturning to play with clojure again and I find the emacs environment has moved from slime to nrepl - is that correct?
22:15ivanman do I hate bindings+laziness
22:15amalloy&(binding [*print-meta* true] (pr-str (read-string "(def ^:dynamic x 1)")))
22:15lazybotjava.lang.SecurityException: You tripped the alarm! pop-thread-bindings is bad!
22:16amalloy,(binding [*print-meta* true] (pr-str (read-string "(def ^:dynamic x 1)")))
22:16clojurebot"(def ^{:dynamic true} x 1)"
22:16callenbottheophilusx: yes
22:17theophilusxcallenbot: thanks.
22:17callenbottheophilusx: nrepl + nrepl.el is the standard way of going about this. Moved to that so that other environments could take advantage of the REPL server.
22:19theophilusxcallenbot: OK, the repl server was just getting going when I was last using clojure. Had to go off on some other work for a while, now back and finding a few changes. Nrepl + clojure-mode seems good. Running from elpa packages. Much easier than getting things working with slime etc
22:19callenbottheophilusx: it is easier to get rolling for noobies. I'm still using my dotfiles repo on github, so these sorts of things aren't a "problem" for me.
22:20callenbottheophilusx: I just integrate the code into my pharaonically constructed emacs lisp pile of code and then I'm off to the races.
22:21theophilusxcallenbot: yes. I still love how easy it is with lein and emacs elpa - after not doing this for a while, took me about 15 minuts to be back up and running and coding. Can't think of another environment that easy and fast!
22:21callenbottheophilusx: well - mine. I just clone my git repo and my entire work environment is installed.
22:22callenbotI don't recommend that you use it, just learn from it: https://github.com/bitemyapp/dotfiles/
22:22theophilusxcallengot: yes, must sort out my git setup better. Obviously an easy way to get things working - especially with mutiple environments etc.
22:23callenbottheophilusx: I use a single git-managed environment across like 6 machines.
22:25theophilusxHas anyone been using java.jdbc with Oracle 11g databases and if so, how reliable have they found it? I notice it is not one of the officially tested environments. I've got it working, but have run into a couple of 'oddities' (probably me not jdbc!)
22:29gfredericksRaynes: I'm having trouble figuring out how to take a fragment of html and add it as content to a full document
22:30gfredericksoh wait there is a whole section in the guide on "Documents and fragments" I shall read this using my eyes
22:30Raynesgfredericks: Show me your broken codeses?
22:30Rayneslol
22:30gfredericksI always expect I will endear myself to library authors by poking them repeatedly while ignoring their documentation
22:35amalloygfredericks: i just push "Fork" and follow the link to whichever fork i wanted to. this has the nice advantage that i can follow the same steps to go to a fork belonging to an organization i'm a member of
22:38tieTYT2http://stackoverflow.com/questions/15736960/what-does-dynamic-do-in-clojure
22:42gfrederi1ksRaynes: I think my problem was assuming the to-html function was a reasonable thing to use
22:44amalloyrecommended change: remove to-html so nobody ever makes that mistake
22:45gfrederi1ksI take it back I still have no idea what I'm doing
22:46gfrederi1ksmostly I am trying to get the transformation functionality of laser/document without the converting-to-a-string part
22:47gfrederi1ksneither laser/at nor laser/fragment seem to do that
22:47tieTYT2i'm thinking about buying a clojure book. Is the joy of clojure for someone who already knows clojure but wants to write idiomatically or is it for beginners like me?
22:49tieTYT2i think I can write a program in clojure, but I'm struggling with topics like meta-data, java interop, etc.
22:49tieTYT2actually I can't figure out if I'm a beginner or not
22:49callenbottieTYT2: get the cemerick book, not the JoC
22:50tieTYT2why's that?
22:50theophilusxtieTYT2: I think the Joy of Clojure is an excellent book for both beginner and for someone looking for a book to go back to as they learn and understand more. It is one of my two favorite clojure books - the other being Clojure Programming.
22:51tieTYT2are either of these viewable online?
22:52tieTYT2ah i can
22:52theophilusxtieTYT2: both are available as ebooks and both are available inside safari if your a member. I think both publishers offer sample chapters if you just want to see what the style is like.
22:53tieTYT2cool man, thanks
23:01Raynesgfrederi1ks: I needs to sees some codes.
23:18callenbothttp://blog.joda.org/2011/11/scala-feels-like-ejb-2-and-other.html