Fork me on GitHub
#clojure
<
2020-02-16
>
Jakob Durstberger11:02:22

Hey I am trying to use amazonica on AWS lambda but library is too large. The recommendation is to exclude some SDKs like this:

:dependencies [[org.clojure/clojure "1.7.0"]
               [amazonica "0.3.48" :exclusions [com.amazonaws/aws-java-sdk
                                                com.amazonaws/amazon-kinesis-client]]
               [com.amazonaws/aws-java-sdk-core "1.10.49"]
               [com.amazonaws/aws-java-sdk-s3 "1.10.49"]]
But that looks like leiningen to me. Does anyone know how I can do that with clj-tools using the deps.edn file?

Jakob Durstberger11:02:40

facepalm I've been reading the wrong page. https://clojure.org/reference/deps_and_cli The reference mentions that :exclusions is supported

p-himik12:02:35

Also, if you don't really need some more or less advanced features of the full AWS SDK, maybe you could use a much more lean and sensible https://github.com/cognitect-labs/aws-api/

👍 4
Jakob Durstberger19:02:36

I only now saw your message, thank you looks very promising 🙂

vlaaad12:02:50

I'm working on a clojure tool, what do you think? https://twitter.com/v1aaad/status/1229021375249240065

👍 28
flowthing12:02:31

Looks fantastic! Looks like it's integrated to IDEA/Cursive, is that right?

vlaaad17:02:26

No, it's a separate window that is integrated into jvm — you will get the same window no matter the editor

flowthing20:02:10

Even better. I'm guessing you can tap> values into it? The video might show it, but it's a bit hard to tell because it's a bit small. 🙂

vlaaad22:02:20

Yes, tap> is going to have similar behavior to prn: results appear in output window

didibus05:02:49

Isn't that what REBL does? Though your ui looks way better

vlaaad06:02:46

It is similar to rebl, but not quite the same

Kamuela15:02:10

Which official Docker images are y'all using to host your uberjars?

jumpnbrownweasel19:02:18

Question on file/line metadata attached to forms (not vars) by macros, see thread

jumpnbrownweasel19:02:09

The output forms of a macro may not look at all like the input forms, but I notice that exceptions for code using macros like -> have accurate file/line numbers in the stack trace. So I'm trying to figure out how to make my own macros do the same. The answer seems obvious when I look at the -> macro. It's copying the metadata of the input form to the output form like this:

(with-meta `(~(first form) ~x ~@(next form)) (meta form))
So I assume that line/file metadata is present, during compilation anyway, on every form. But by searching I can't find any confirmation or doc on this. Is this true and do you see any problem with using the same approach in my own macros?

seancorfield19:02:56

Yes, file/line number is present in metadata on forms passed to macros. I don't know how well documented that is.

jumpnbrownweasel19:02:21

Thanks for confirming Sean.

seancorfield19:02:51

So, yes, if you want to pass the macro invocation's metadata into the result, that's reasonable I think .

seancorfield19:02:38

Testing libraries deal with this explicitly -- look at the source of clojure.test for example (or my expectations.clojure.test).

chrisn20:02:02

IF someone is going to dive into ASM generation in clojure, should we use the raw asm.ow2 interfaces or the clojure.asm namespaces? I guess more specifically are the clojure.asm.* interfaces considered private?

chrisn20:02:30

Hmm. Or just tools.analyze.jvm which seems a lot better than anything else.

plins20:02:07

is there an easy way to apply a function to all the elements between {} in a string? lets say I want to prefix foo to (or anything really) all occurrences like "/math/plus/{parameter-x}/{parameter-y}" -&gt; "/math/plus/{foo-parameter-x}/{foo-parameter-y}"

phillippe21:02:33

(string/replace "/math/plus/{parameter-x}/{parameter-y}" #"\{" "{foo-")

plins21:02:25

thanks 🙂

ghadi21:02:24

@chris441 clojure.asm is considered private

👍 4
lvh21:02:14

I'm trying to find something I know I've seen before but I'm unable to find: I'm writing a tiny HTTP=>(S)CGI translation layer; Ring of course does a great job of turning HTTP into Ring requests which is easy enough to turn into SCGI, but SCGI means the underlying app produces a complete HTTP request byte stream that I want to return verbatim, so I want to tell ring (well, I guess technically jetty or whatever the underlying server is) "no, don't serialize a response, literally just whistle these bytes into the socket"

lvh21:02:25

I think I never want to modify the response so I don't care about parsing it

lvh21:02:55

I'm pretty sure I've seen exactly this API but I can't tell if I'm misremembering or if it was in aleph or maybe http-kit or something else

lvh21:02:06

maybe the easier way to do this is to use aleph, start from tcp, and see if I can do the http parsing bits a la carte

ghadi23:02:38

ring accepts an InputStream as a body, so whatever you have, you can wrap in something like a ByteArrayInputStream @U07QKGF9P

ghadi23:02:28

Hello again :) I’m listening to our Cognicast interview tonight

👋 4
lvh02:02:54

Unfortunately the CGI response is the entire HTTP response including headers, so I’d still need to parse that

lvh02:02:09

I guess I can read until 0d 0a 0d 0a

lvh02:02:31

But I don’t like to write software that will earn me honorary mentions in CVEs a few years from now :)

dominicm08:02:45

I don't have a helpful solution, but there is a http parser kicking around for java that's pretty lightweight. It operates on a stream I think.

dominicm09:02:01

You could use that to create a ring response.

ambrosebs22:02:14

how would you write the spec for clojure.core/list*?

ambrosebs22:02:36

nvm, I got myself confused. s/* is what I want I think

alfredx23:02:56

Does anyone know whether I can get string content back (rather than exception thrown or from the exception object) when (cheshire.core/parse-stream reader) fails because the content being parsed is not valid JSON? (I could convert reader to string and then use parse-string, but supposedly parse-stream is faster)

vemv02:02:10

wdyt of this logic?

(try
  (parse x)
  (catch Exception _
    (str x)))
The only concern would be performance; i.e. you cannot catch many exceptions per second

andy.fingerhut02:02:14

I do not know whether something like the TeeInputStream class mentioned on this page would let you have two different readers for the same data source, one being cheshire.core/parse-stream, the other being a reader that puts the result into a string: https://stackoverflow.com/questions/5034311/multiple-readers-for-inputstream-in-java

alfredx03:02:40

@U45T93RA6 I think (str x) won’t work if x is a reader/stream. @U0CMVHBL2 This might slow down overall performance if 98% is happy case where we do not need access to the string when json parsing is successful. But this sounds quite valid approach and I can’t think of any other approach unless rewrite aother json parser.

vemv03:02:51

there's StringReader... between that and TeeInputStream or some other logic you might be able to achieve a working try/catch

vlaaad17:02:26

No, it's a separate window that is integrated into jvm — you will get the same window no matter the editor