Fork me on GitHub
#clojure
<
2020-03-21
>
Steiner01:03:20

Hello,I want to know is there any useful libs for clojure operating file of binary and text??

seancorfield01:03:36

@steiner3044 The idiomatic approach would be to use interop and rely on the Java I/O libraries.

kwladyka09:03:15

I knew why, but I don’t remember. Why spec/assert doesn’t throw exception by default and this is solved by

(s/check-asserts true)
? I am thinking if I am going to use assert in correct way

Alex Miller (Clojure team)13:03:08

Assertions are a dev time feature, off by default

p-himik13:03:48

But at the same time, the regular assert is turned on by default, isn't it?

kwladyka17:03:38

also I found different data from assert and explain-data

kwladyka17:03:51

#:clojure.spec.alpha{:problems ({:path [:shop/uuid],
                                 :pred clojure.core/uuid?,
                                 :val "999",
                                 :via [:shop/uuid],
                                 :in [:shop/uuid]}),
                     :spec :api.shops.spec/shop,
                     :value #:shop{:uuid "999"},
                     :failure :assertion-failed}
vs
#:clojure.spec.alpha{:problems ({:path [:shop/uuid],
                                 :pred clojure.core/uuid?,
                                 :val "999",
                                 :via [:api.shops.spec/shop :shop/uuid],
                                 :in [:shop/uuid]}),
                     :spec :api.shops.spec/shop,
                     :value #:shop{:uuid "999"}}

kwladyka17:03:01

(comment
  (try
    (s/explain-data ::s-shop/shop {:shop/uuid "999"})
    (s/assert ::s-shop/shop {:shop/uuid "999"})
    (catch Exception e
      (ex-data e))))

kwladyka17:03:43

it always has 1 :via less

kwladyka17:03:57

so for direct check it has [] instead of [:shop/uuid]

kwladyka17:03:09

very not consistent

Nikolas Pafitis16:03:07

Hey guys, can i use datomic-free as a persistent database( Preferably over mysql) or is it available only as an in-memory database and i have to get the Starter edition in order to use persistent db?

jumpnbrownweasel16:03:26

You may want to try #datomic

michaelr20:03:36

hello everybody!

michaelr20:03:30

i'm developing an http proxy (between two services). which library/libraries would you recommend for evented io? i searched around and it looks like aleph is almost the only way to go..

Renzo Tomlinson22:03:33

anyone run into trouble when trying to post to an Incoming Slackhook? I can curl successfully with the code snippet they provide but I'm unable to make the same request using the clj-http library. I keep getting a 400 Bad Request. Double and triple-checked my url and that the headers and the json body are correct. I have no idea at this point but I'm probably missing something obvious. Will post some code

Renzo Tomlinson22:03:29

curl -X POST -v --http1.1 -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' https://hooks.slack.com/services/0000000000000/000000000000/000000000000000 works fine

Renzo Tomlinson22:03:53

(defn alert
  [payload]
  (client/post slackhook
               {
                :accept "*/*"
                :content-type :json
                :body "{\"json\": \"input\"}" ;(ch/generate-string {:hello "world"})
                :debug true
                }))
i've tried setting the headers explicitly. the body is hardcoded right now because i just want to make sure its working. no dice

Renzo Tomlinson22:03:51

400 Bad Request error is the response I keep getting

Renzo Tomlinson22:03:20

ah, i'm oblivious. there needs to be a "text" key in the body

dpsutton22:03:24

https://github.com/dakrone/clj-http/blob/3.x/README.org#post shows a different way to set the content type header

Renzo Tomlinson22:03:35

thanks, @U11BV7MTK . i tried both ways of setting the header and just confirmed that the way I was setting still works. My mistake was that my payload wasn't following the correct pattern. Something I overlooked but also probably could have been a little more explicit in the documentation

souenzzo23:03:40

how to "reify" abstract classes?

OrdoFlammae23:03:47

You use proxy to instantiate abstract classes.

OrdoFlammae23:03:55

It's pretty similar.

OrdoFlammae23:03:44

But it can instantiate non-interfaces (such as abstract classes).

noisesmith16:03:31

one thing to be careful of is proxy-super is the only way to invoke superclass methods, and it is not thread safe

noisesmith16:03:25

if two threads call proxy-super on the same proxy concurrently, the proxy itself can be replaced by an auto-generated instance of the superclass, which as you might expect, breaks everything