Fork me on GitHub
#clojure
<
2016-09-20
>
richiardiandrea00:09:01

Has anybody's used https://github.com/kumarshantanu/espejito for latency timing? is there any other lib out there?

richiardiandrea01:09:14

looks like I need to pay Peter a lot of drinks šŸ» šŸ˜„

Shantanu Kumar03:09:04

@richiardiandrea We are using Espejito at Concur in several web services in production ā€” we log the metrics report when the total latency crosses a threshold. We also trigger it on-demand when perf tuning.

richiardiandrea03:09:09

Good to know, I will need to explore more in depth both libs and then decide which one to use, thanks for pitching in!

lxsameer09:09:49

I'm looking for a small, easy to use, and relatively fast server application, which one is better http-kit, Immutant v2+, nginx-clojure, Aleph?

tomjkidd12:09:56

@lxsameer do you need websockets?

tomjkidd12:09:30

If not, I've used ring-jetty-adapter and it is simple and fast. If so, ring-jetty9-adapter adds it in there, and is what I'm using now.

Lambda/Sierra12:09:57

@lxsameer Try Pedestal 0.5. Lots of optimization work has gone in recently. New docs site: http://pedestal.io/

robert-stuttaford13:09:20

when did that doc-site go up, @stuartsierra ?

Lambda/Sierra13:09:12

within the last 3ā€“4 weeks

robert-stuttaford13:09:36

very nice. not having this was quite a drawback for pedestal. stoked it's up!

Lambda/Sierra13:09:21

I can take no credit for it šŸ™‚

lxsameer13:09:10

@tomjkidd @stuartsierra I want to use sente , so I need a server app which sente supports

Alex Miller (Clojure team)13:09:08

Michael Nygard did the bulk of the work on the new Pedestal site

tomjkidd13:09:39

@lxsameer hmm, http-kit is the only other one I've used. It is simple enough. http://www.parens-of-the-dead.com/ uses it in their podcast too, so you could get a feeling for how its used (and even learn some other cool tricks...)

tomjkidd13:09:34

by podcast I mean video series

john.carnell13:09:53

hey guys I am running into an interesting problem. I have a microservice written in clojure. When I deploy my service and run it as a jar I am getting intermittent stackoverflow errors coming from the flatland/useful/experimental/delegate.clj. When I run the code locally on my machine it seems to work alright. When I get to the bottom of the stack trace I see references to my endpoints.clj file (line 1), but there is nothing here to tell me what is setting off the stackoverflow. Here is the start of the trace. Anyone have any ideas where to start debugging this: xception in thread "main" java.lang.StackOverflowError, compiling:(flatland/useful/experimental/delegate.clj:54:27) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6875) at clojure.lang.Compiler.analyze(Compiler.java:6669) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856) at clojure.lang.Compiler.analyze(Compiler.java:6669) at clojure.lang.Compiler.access$300(Compiler.java:38) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6269) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868) at clojure.lang.Compiler.analyze(Compiler.java:6669) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856) at clojure.lang.Compiler.analyze(Compiler.java:6669) at clojure.lang.Compiler.analyze(Compiler.java:6625) at clojure.lang.Compiler$IfExpr$Parser.parse(Compiler.java:2797) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868) at clojure.lang.Compiler.analyze(Compiler.java:6669) at clojure.lang.Compiler.analyze(Compiler.java:6625) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6001) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6319) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868) at clojure.lang.Compiler.analyze(Compiler.java:6669) at clojure.lang.Compiler.analyze(Compiler.java:6625) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6001) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5380) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3972) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6866) at clojure.lang.Compiler.analyze(Compiler.java:6669) at clojure.lang.Compiler.analyze(Compiler.java:6625) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3766) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6870) at clojure.lang.Compiler.analyze(Compiler.java:6669) at clojure.lang.Compiler.analyze(Compiler.java:6625) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6231) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868) at clojure.lang.Compiler.analyze(Compiler.java:6669) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856) at clojure.lang.Compiler.analyze(Compiler.java:6669) at clojure.lang.Compiler.analyze(Compiler.java:6625) at clojure.lang.Compiler$IfExpr$Parser.parse(Compiler.java:2792) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868) at clojure.lang.Compiler.a

Pablo Fernandez14:09:17

I'm trying to use http://github.com/profesorfalken/jProcesses. I tried (import org.jprocesses.JProcesses) and many variations and none worked. I always get classNotFoundException.

Pablo Fernandez14:09:30

What's the correct way?

coyotespike15:09:55

Howdy y'all. The basic Buddy auth example for JWE tokens doesn't seem to be working for me. I'm using Boot and System with Sente to send the POST request to login, and it returns success. But I always get unauthorized when I check with buddy/authenticated?

coyotespike15:09:05

I'm guessing the problem is that Buddy only checks the :identity key in the Ring map, but the example puts the token elsewhere? Ahdunno, tried this for a few hours yesterday.

coyotespike15:09:22

It's possible to check for the existence of the token wherever it's puts, but I kind of want to use the Buddy middleware because I figure it will easily tell if the token has expired.

coyotespike15:09:53

Does anyone know of an example of rigging your own timeout check for the token, as a possible solution?

uwo15:09:51

Is there a way to use the java xor operator, since clojure doesnā€™t have a non-bitwise one?

uwo15:09:54

@coyotespike gotcha. so youā€™d recommend implementing our own (with the help of examples)?

uwo15:09:31

I had read those, however I was wondering if interop was a viable route

coyotespike15:09:23

I'm not experienced at Java interop, sadly

coyotespike15:09:07

I would be rather surprised if it wasn't possible though. Are you thinking it might be more direct?

uwo15:09:24

Just more at hand, I suppose. Thereā€™s no issue with grabbing any of those implementations, surely.

markwoodhall16:09:11

Hi everyone, I'm looking at ways to take a vector and remove items based on another vector, the only caveat is that the first vector may contain duplicates and I only want to remove one instance of the items with duplicates. The second vector will contain only distinct items. I've come up with this wacky idea https://gist.github.com/markwoodhall/7b76adc715ac3f21e9bfe747678aee58 but I'm interested in other examples, not necessarily the most readable, just interesting!

dfan16:09:14

@markwoodhall Are the duplicates in contents guaranteed to be contiguous? i.e. do we never see [123 123 456 123]

markwoodhall16:09:58

@dfan for this example we will only ever see continuous duplicates.

Geoffrey Gaillard16:09:53

@markwoodhall nice example ! I have this solution. Loop based & straightforwardā€¦ā€¦ but working and in O(n)+n*O(logā‚ƒā‚‚m) (+ 2n ?), maybe interesting ā€¦

(defn mask-remove-one
  [from to]
  (persistent!
    (loop [bads (set from)
           accu (transient [])
           goods to]
      (if (nil? goods)
        accu
        (let [val (first goods)]
          (cond
            (contains? bads val) (recur (disj bads val)
                                        accu
                                        (next goods))
            :else (recur bads (conj! accu val) (next goods))))))))

dfan16:09:31

That is basically the approach I had in mind

markwoodhall17:09:41

@ggaillard Nice example, thanks.

aaelony18:09:38

does clojure support destructuring maps with namespaced keywords?

aaelony18:09:26

e.g. (mapv (fn [{:keys [x/k1 x/k2]}] ) coll)

quoll18:09:49

yes, but it drops the namespaces on the keywords

quoll18:09:20

=> (let [{:keys [x/a y/b]} {:x/a 1 :y/b 2}] [a b])
[1 2]

aaelony18:09:58

that's fine though... thanks @quoll

hiredman18:09:08

user=> (let [{:foo/keys [a b c]} {:foo/a 1 :foo/b 2 :foo/c 3}] [a b c])
[1 2 3]

hiredman18:09:24

the 1.9 alphas have some new stuff

quoll18:09:57

speaking of whichā€¦ I need to push the boss on the 1.9 alpha, so we can start on Spec. Iā€™m sure 1.9.0 will be stable by the time we try to put anything out

idiomancy20:09:44

Okay, so I have this project, right? Its got two primary public functions, one of them is defined in foo.bar namespace, the other is defined in foo.baz namespace, but I want users of this library to only need to require them from foo.core what do i do?

idiomancy20:09:05

the following does not seem to work:

(ns foo.core (:require [foo.bar :refer [func1]][foo.baz :refer [func2]]))

idiomancy20:09:27

that doesn't "forward the import" like I want to

Alex Miller (Clojure team)20:09:16

yeah, that doesnā€™t do what youā€™re trying to do - it just func1 and func2 to be understood when in the namespace foo.core

idiomancy20:09:35

yeah šŸ˜• do i have to def them in that namespace?

Alex Miller (Clojure team)20:09:39

some people use potemkin to import vars for things like this

Alex Miller (Clojure team)20:09:51

I personally donā€™t like that - I would define them in the namespace you want

Alex Miller (Clojure team)20:09:01

but itā€™s a matter of taste I suppose

idiomancy20:09:45

Yeah. I'm from python, where you build logical units of functionality in separate modules, then you forward the api to the parent package

Alex Miller (Clojure team)20:09:49

Clojure doesnā€™t really favor encapsulation anywhere :)

idiomancy20:09:23

haha, yeah seems that way! I guess I'll just redef them. Not a huge deal either way. Thanks for the input, Alex. You are, as always, the man.

Alex Miller (Clojure team)20:09:30

ā€œencapsulation of information is follyā€ - http://clojure.org/reference/datatypes - thatā€™s a little different context but gives an idea

idiomancy20:09:41

you mean to say the negation is true, not simply that the affirmative is false

idiomancy20:09:03

they dont just "not favor encapsulation" they "favor not encapsulation"?

idiomancy20:09:16

thats interesting, I did not know that.

idiomancy20:09:00

Thats a departure from my ingrained beliefs, I had no idea it was a contested concept. I'm super excited to learn more

idiomancy20:09:13

man, i barely even understand what that sentence means

idiomancy20:09:22

"encapsulation of information is fully"

idiomancy20:09:26

thats some heady stuff

idiomancy20:09:51

I guess it makes sense in the context of Rich's big effort (which you are a big part of, I hear @alexmiller) to reduce code's focus on aggregate data

idiomancy20:09:07

wow, man, I cant even... like, clojure core uses defn- and private methods. What is the difference between private methods and encapsulating data? What are the criteria for putting any information anywhere if not by logical separation?

Alex Miller (Clojure team)20:09:45

even private functions can be found and invoked

Alex Miller (Clojure team)20:09:58

I treat them as more like guides to use

idiomancy20:09:20

they can be, but they are still /marked/ as private. whats the difference between using defn- as a guide and using namespaces as a guide?

Alex Miller (Clojure team)20:09:38

they are both tools to convey intent

Alex Miller (Clojure team)20:09:53

the idea (with data at least) is that data is just data. when itā€™s immutable, there is no ā€œdangerā€ about letting a consumer see that data and even manipulate it (because you donā€™t affect the original)

Alex Miller (Clojure team)20:09:29

instead of wrapping things, just make them as directly observable and manipulable as possible

Alex Miller (Clojure team)20:09:06

I think the always-read capability of stateful constructs like atoms, vars, agents, refs in similar way

idiomancy20:09:38

I see, I think the confusion is that perhaps you thought I wanted things forwarded into core in order to obfuscate the dependent libraries, and only expose the things I wanted people to play with

Alex Miller (Clojure team)20:09:39

and to some degree vars in a ns as well - if they are different, Iā€™d say thatā€™s not because they are functions, but because vars are stateful

idiomancy20:09:53

I meant it more as a "heres a convenient import shortcut"

Alex Miller (Clojure team)20:09:00

thatā€™s how I read it, yes

idiomancy20:09:03

so you dont have to require a million things

Alex Miller (Clojure team)20:09:15

yeah, I think thatā€™s a non-goal personally

idiomancy20:09:23

yeah, gotcha. that makes sense

Alex Miller (Clojure team)20:09:39

requiring stuff is fine and tells users where to find the things they use

Alex Miller (Clojure team)20:09:06

the problem with these forwarding kinds of vars is they foil helpers like doc and source and confuse IDE tooling

idiomancy20:09:28

oh, wow, yeah that is a significant cost for no real benefit whatsoever.

Alex Miller (Clojure team)20:09:05

well, thatā€™s my opinion, but opinions differ among people I respect :)

idiomancy20:09:28

I mean, I'm pretty well on board. Organization is good, but encapsulation (data hiding) is bad.

idiomancy20:09:42

Its actually a pretty liberating concept

Alex Miller (Clojure team)20:09:51

I think I wrote a post about levels of hiding somewhere

idiomancy20:09:34

the corollary to the above might be "and dont build in shortcuts to circumvent your organization, it breaks things and gains nothing"

idiomancy20:09:22

I love this, man. David Hume would be so pumped about the direction programming is taking.

Alex Miller (Clojure team)21:09:46

canā€™t find the blog post, maybe itā€™s in Clojure Applied

seancorfield21:09:01

@idiomancy When I got started with Clojure (back in 2010), I carried over a very OOP mindset so I not only used defn- "religiously" but I also tended to have a namespace mything.foo for the "API" and mything.foo.core for the "implementation" (the latter had to have public functions so the API ns could require them). Iā€™ve pretty much moved away from private functions completely now and I no longer try to second guess users of my namespaces by trying "hide" the implementation in another namespace.

seancorfield21:09:05

Now I try hard to have namespaces that all actually mean something and could all be reasonably used by client code, and I try to make everything public (unless there really is a good reason not to).

seancorfield21:09:51

I do still tend to make data private and expose it via a public function but thatā€™s mostly for consistency of the API ("everything is a function").

seancorfield21:09:34

(although thereā€™s an argument that data that is a hash map could be directly exposed "as if" it were a function)

idiomancy21:09:45

I think old beliefs of mine die at a rate of multiple per week since I started doing clojure professionally instead of just as a hobby

seancorfield21:09:11

It can be very hard to let go of OOP thinking. For most devs thatā€™s what theyā€™re taught out of the gate and itā€™s how nearly all mainstream languages work. Plus itā€™s been the mainstream way of thinking for about three decades now.

idiomancy21:09:29

I really like clojure's brand of opinonation. After some thought, I end up agreeing with pretty much all of it, with varying speeds of adoption. The only problem is that sometimes the reasoning is only kind of alluded to until you find The Blog Post, or The Podcast that discusses it

seancorfield21:09:01

(I was lucky, I did some FP way, way back before I even learned OOPā€¦ but Iā€™ve been doing OOP professionally now since ā€™92 so Iā€™m still unlearning some deeply ingrained bad habits!)

idiomancy21:09:22

and pretty much the only one who knows where they are is alexmiller, and so he gets stuck directing people to them!

Alex Miller (Clojure team)22:09:12

itā€™s like, literally, my job :)

fellshard22:09:40

Sounds like a great blog post. Or aggregation blog. šŸ™‚

Alex Miller (Clojure team)22:09:04

And I'm doing a new edit of Programming Clojure, Stu's book