Fork me on GitHub
#clojure
<
2019-11-09
>
borkdude14:11:21

How can I get the same behavior of :aot :all with a tools.deps tool? I tried badigeon but it isn't clear to me how it supports the same feature

lread14:11:50

I am currently playing with badigeon and I don’t see an :aot :all feature there either.

borkdude15:11:45

I'v e fixed it now

Alex Miller (Clojure team)14:11:59

The :all is just about enumerating the namespaces in a project

Alex Miller (Clojure team)14:11:20

So tools.namespace can do that

borkdude15:11:34

Thanks, did it using that

lmergen15:11:15

hi all, i'm trying to write a macro that dynamically invokes let with a vector of key/value pairs, but i am a bit lost. to illustrate, this is my (poor) attempt at making this work:

(defn my-args []
  ['x {:foo :bar}])

(defmacro wrap-lets
  [& body]

  `(let [args# (my-args)]
     (let args#
       [email protected])))

(wrap-lets
 (println "x: " (pr-str x)))
note the line (let args# ..) -- it appears that at compilation time, args# is still a sym. unquoting it doesn't seem to work, any advice on what i'm doing wrong here?

borkdude15:11:06

@lmergen do you mean ~(my args)?

lmergen15:11:12

:thinking_face:

lmergen15:11:12

seems to be doing something but not exactly what i want either -- still x not found in the println statement

borkdude15:11:51

(defn my-args []
  ['x {:foo :bar}])

(defmacro wrap-lets
  [& body]
  `(let ~(my-args)
    [email protected]))

(wrap-lets x) => {:foo :bar} 

lmergen15:11:34

ok it works

lmergen15:11:37

what's the difference ?

borkdude15:11:38

this is not very idiomatic btw, to introduce magic bindings out of nowhere

cavan15:11:09

Hello, im interested to know if running 1. "lein with-profile test run" is the same as 2. running "lein uberjar" to create standalone jar and setting "PROFILE=test java -run myprogramstandalone.jar"

lmergen15:11:25

@borkdude yeah i'm aware of that, mostly for educational purposes

lmergen15:11:42

so the reason this didn't work is the intermediate args# binding ?

borkdude15:11:47

@lmergen this is just syntax quote doing it's job at macro expansion time

borkdude15:11:29

you can directly eval this:

`(let ~(my-args))
(clojure.core/let [x {:foo :bar}])

borkdude15:11:03

so it's "just data TM" and the data that is then generated by the template, gets eval-ed later

borkdude15:11:10

user=> (eval `(let ~(my-args) ~'x))
{:foo :bar}

lmergen15:11:24

what i'm trying to achieve here is a pytest kind-of fixture wrapper for clojure.test. pytest allows you to specify fixtures as arguments to tests, e.g. def test_foo(dbconn): .... -- i'm trying to make a lightweight library for clojure that allows you to do something similar, (deftest test-foo [dbconn] ..) and then load fixtures using integrant

lmergen15:11:51

and the let magic i'm trying to achieve here is to dynamically bind dbconn in this example

borkdude15:11:43

@lmergen I would just do that using normal functions + atoms or dynamic vars probably

lmergen15:11:58

yeah i suspected that would be the answer 🙂

borkdude15:11:13

did you manage to find out where your "missing test assertion" message was coming from the other day? maybe you could test this and paste the string? I can then try to find it in the CIDER source

lmergen15:11:37

one minute

lmergen15:11:00

so most definitely cider

lmergen15:11:00

seems to be coming from there

borkdude15:11:28

aaah it's in the emacs code

borkdude15:11:01

so it's a pretty crude test I guess

borkdude15:11:26

but effective 😉

borkdude15:11:45

does it still work when you have one other test that does an assertion next to it?

lmergen15:11:40

yes it's actually surprisingly reliable

lmergen15:11:56

unless i misunderstand what you mean

borkdude15:11:23

I mean, what happens if you run two tests in one run and only one has no assertions

borkdude15:11:33

it seems the check in the elisp is pretty global

lmergen15:11:40

then it will not warn

lmergen15:11:59

e.g. if i run all tests in the namespace, it will not tell me if a single test is missing any checks

borkdude15:11:31

that could be improved by handling this in the middleware on the JVM side

lmergen15:11:33

in that regard it's fairly crude

borkdude15:11:05

but I guess you mostly run a single test from CIDER. I haven't used this before. I mostly use (t/run-tests)

borkdude15:11:10

or just the command line

lmergen15:11:43

yeah for me i use single tests extensively, so it matches the workflow. clj-kondo has a totally different use case

lmergen15:11:38

yup, that's what prompted my comment about cider, right ?

lmergen15:11:44

oh yeah it's not kondo

borkdude15:11:55

right. that also works when you run lein test

borkdude15:11:01

or whatever other runner

lmergen15:11:06

that's pretty cool, useful for CI

borkdude15:11:21

it doesn't throw at the moment, only outputs a warning to stderr

borkdude15:11:28

I guess this is also how you can implement fail fast

paulspencerwilliams19:11:21

Does anyone have any good resources about implemented an OAuth2 / Open ID Connect Resource Server using Ring? I want to configure an api to trust signed JWTs from Okta.

lmergen20:11:20

@paulspencerwilliams as far as i can tell, it's still a bit of the wild west in clojure landscape; there are a few libraries that help you authorize oauth1/2 access tokens, but there are almost none for implementing an oauth server afaict

Clypto21:11:21

what's the best way to.. get the intersection of two lists?

Clypto21:11:53

I guess convert to sets and use intersection

andy.fingerhut23:11:00

Best way depends upon some metric (or metrics) of valuation to compare. Convert to sets and use clojure.set/intersection has the advantage that it is only a few characters to type, and relies on built-in well-tested code.

sova-soars-the-sora23:11:43

@clypto clojure.set intersection is fire for such things, yep.