Fork me on GitHub
quan xing05:06:48

Which open source Clojure project for beginner ?

quan xing09:06:24

thanks didibus

quan xing09:06:50

why are you call didibus?


Or some more involved web applications (but still very simple) here


Not sure where I should post this question. I’m comming from dynamic webdev languages and am not at all fluent in the JVM ecosystem. My usecase is basic image processing of web images, typically generated and uploaded by a user. I only need a small set of operations such as scale, crop, fit, common format conversions (jpeg, png, webp, base64...). This is for a side-project. My intuition from looking at github projects is that I could start with Java awt and go from there. Do you have any recommendations? I wouldn’t mind using a (preferably small) library that covers these operations or else, if you think the Java awt library is a good place to start and dig into.

practicalli-john11:06:46 looks promising little library for some image manipulation There is also which provides some nice documentation for image manipulation

🙏 2

I have line `

(def  map3 [ {:size 7 :color "blue" } {:size 8 :color "Orange" } {:size 10 :color "yellow"}  ])
how can I get the hash value of color of each map and do assoc inside each map ? ex - {:size 7 :color "blue" :hash 123456}


(fn [the-map] (assoc the-map :hash (hash (:color the-map)))) + map(v)?

Aviv Kotek14:06:49

what's the common way to skip a specific test? (using clojure.test) something like @skip (deftest.....)


you could add metadata to the var (deftest ^:skip test-name … and then teach your test runner to skip such tests. For example kaocha can do it out from the box -

Darin Douglass14:06:58

same for lein:

;; project.clj
(defproject foo
  :test-selectors {:all (constantly true)
                   :integration :integration
                   :default #(not (:integration %)})
;; foo_test.clj
(deftest ^:integration test-something-that-needs-something-else


or just comment the test with #_ if you want to skip it ?

👍 4

There is at least one problem with #_ as a test-skipper — it is not possible to get a warning that the code base has such tests 😉


I am reading re-frame doc ( regarding coeffects and find the sentence highlighted below. I think .getItem only read value and use js->clj to transform that data, which will not cause any change to the original data (Am I right ?), so the codeblock will not cause any side effect, right?


Yes, but it gets that value from a source external to the system/program, (that is to say that function does not only rely on its params to work) and that is a side effect


So you’re right (I think) saying it does not cause side effect, but it relies on one


Ok, thanks!!


you’re welcome

❤️ 2
Endre Bakken Stovner16:06:05

I'd like to communicate with my webserver by sending JSON-data. Never done that before. Never really needed to understand csrf-tokens either. Luminus has always taken care of that for me. But now I get Invalid anti-forgery token when trying to send JSON-data to my server. Anyone has any fixes to suggest? To begin I added a "/json" route for testing:

(defn home-routes []
   {:middleware [middleware/wrap-csrf
   ["/" {:get home-page}]
   ["/json" {:post #(constantly "some json")}] ;; added by me now
When I do curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"id": 1}' localhost:3000/json I get the error
<h1>Error: 403</h1>

    <h2>Invalid anti-forgery token</h2>
but I expected to see "some json". How do I fix this? I could add a "x-csrf-token" token to my header, but where would I get it from?


Not sure about this, (I know neither luminus or ring, complete clojure beginner here, so bear with me please) but having a look at the luminus guestbook example, it seems you can add it as a hidden field in your form as and then retrieve it with JS

Lance Erickson17:06:39

(Which has security implications but if it is just an experiment is totally cool)

👍 2

if you use selmer to render a page then this is for you. basically you send the anti-forgery token along with html page so that the script can pick it up with cljs/js code in the client browser


the token can be embedded in http header of post request or as a parameter in the post body

Endre Bakken Stovner13:06:04

I've read all your replies, thanks!

Endre Bakken Stovner13:06:05

It seems to me that csrf-tokens should be used for POST requests, but I do not see an easy way to get the csrf-token when I am sending requests from the command line. Perhaps this is a question for #ring rather


if you have to you could expose an api over http get to allow clients to get the token. i'm not sure one way or another if that's safe practice.

Endre Bakken Stovner14:06:42

I do not know either. Or since it is one user/one server I could add a password, but then I'd need to read up on how to send/store these safely.


is there a corollary of cond-> that will pass the piped value to a condition function?


Do you mean like condp-> described here ?


I guess you would know as you wrote it. 🙂 Looks like it.


Well, I wasn’t sure if that was actually the functionality you were looking for 🙂 but, yeah, we use it occasionally at work.


i was realizing i can't do this without a macro, or at least not as far as I can tell.


actually, partial might do it i guess.


usually I don't bother with fancy constructs like these (anymore) if they are not in core and will just write a let instead


We certainly don’t use the macros in ws-commons as much now as when they were first written so, yeah, I’m mostly in @U04V15CAJ’s camp these days. I think non-core macros can often make code less readable.


(we don’t use condp->> at all now and we only use condp-> in ten files out of nearly 800)


the code i'm writing -- the pattern will be followed for a lot of files, so trying to make it as clean/readable as possible, so i think i might try both to compare.