Fork me on GitHub

Does anyone know of a library that I can use to rate limit certain routes? Ideally ring middleware


In clojure land, just because it's old doesn't mean it won't work


Give it a try, the code isn't particularly complex so you should be able to modify it if required


Yeah I’ve come to learn that. I’ll pick through the source a bit and give it a go 🙂.


If you have questions about “I need it to do X feature” we can help with that

🙌 1

How do I specify a global jvm-opts in deps edn? I am encountering unable to find valid certification path to requested target when I run clojure -X:deps find-versions :lib and I believe I need to add But adding it under {:jvm-opts ... } Of my .clojure/deps.edn doesn't seem to work


not supported in deps.edn, jvm-opts have to be added under an alias


Does this mean I can just alias the entire clojure command just adding the jvm-opts to it


Moving the jvm-opts under an alias and then using that alias alongside :deps should work (haven't tested it though). You don't have to alias the rest of the command. You could also use the -J flag, as described here: However, are you sure you need that flag? I'm getting the expected output on v1.10.3.986, maybe the real issue is elsewhere?

Mutasem Hidmi12:01:58

Hello everyone. I am using Malli to validate my request body. What is the right way to return an error that is readable for humans. I mean like a json because now I am getting an error like this {:schema [:map {:closed true} [:id_token [:string {:min 1}]] [:is_app :boolean]], :value {:is_app false}, :errors ({:path [:id_token], :in [:id_token], :schema [:map {:closed true} [:id_token [:string {:min 1}]] [:is_app :boolean]], :value nil, :type :malli.core/missing-key}), :transformed {:is_app false}, :type :reitit.coercion/request-coercion, :coercion #Coercion{:name :malli}, :in [:request :body-params], :request {:reitit.core/match #reitit.core.Match ...

Mutasem Hidmi13:01:59

I am using it as a coercion, but I cannot humanize the error


There is a way to pass in a encode-error function into the creation of the malli coercer

👍 1

Which can then be used to format the error as you wish


Here's the very questrion I asked nearly two years ago and was answered around the same topic 🙂


Feel free to drop by in #reitit and #malli for more help 🙂

Jungwoo Kim23:01:00

Thank you for your previous discussion. 🙂

Mutasem Hidmi06:01:36

Did it work for you?

Mutasem Hidmi06:01:45

Thank you @U11EL3P9U, but I think I am missing something where should I put this. I tried like this, and it didn't work.

(def custom-coercion (reitit.coercion.malli/create
               {:transformers {:body {:default reitit.coercion.malli/default-transformer-provider
                                      :formats {"application/json" reitit.coercion.malli/json-transformer-provider}}
                               :string {:default reitit.coercion.malli/string-transformer-provider}
                               :response {:default reitit.coercion.malli/default-transformer-provider}}
                :error-keys #{:type :coercion :in :schema :value :errors :humanized #_:transformed}
                :compile mu/closed-schema
                :encode-error (fn [error] {:errors (:humanized error)})
                :validate true
                :enabled true
                :strip-extra-keys true
                :default-values true
                :options nil}))


Answered in #malli

Jungwoo Kim07:01:55

not really. I’m moving to #malli too


Hello, I am currently trying to do some physics simulations and I want to plot out the data that comes out. I would like to use something that is not based on vega but rather something simillar to matplotlib.


I don't know, but you might want to try #data-science too


I usually just dump data out to gnuplot. I have in the past generated svgs of plots directly (xml is easy to generate and manipulate as data)


more recently I use

(defn plot [n]
  (when (> (count n) 1)
    (let [xmn (apply min (map :x n))
          xmx (apply max (map :x n))
          x-scale (/ (- xmx xmn) 20.0)
          ymn (apply min (map :y n))
          ymx (apply max (map :y n))
          y-scale (/ (- ymx ymn) 20.0)
          scaled-values (->> (sort-by :x n)
                             (map (fn [x]
                                    {:y (long (/ (- (:y  x) ymn) y-scale))
                                     :x (long (/ (- (:x x) xmn) x-scale))}))
                             (partition-by :x)
                             (map (fn [x] (apply max (map :y x)))))]
      (printf "%s\n" (java.util.Date.))
      (dotimes [_ 65] (print "-"))
      (printf "\n")
      (dotimes [r 21]
        (let [row (- 21 r)]
          (dotimes [col 21]
            (when (= col 0) (print "|"))
            (if (and (> (count scaled-values) col)
                     (= row (nth scaled-values col)))
              (print " * ")
              (print "   "))
            (when (= col 20) (print "|")))
          (printf "\n")))
      (dotimes [_ 65] (print "-"))
      (printf "\n")
at the repl


@UGHNF0CS3 incanter is actually what i have been trying to use but I cant find a comprehensible tutorial on how to use it to plot stuff


@U0NCTKEV8 thanks for the code example I'll definitly try it out

John Bradens19:01:07

Hey I have a question about learning. I am building a web app, and there's lots of things I want to add to it that I don't know how to add. Things like, I want to add a left side bar with links. I want to add a search bar. I want to add a basic recommender algorithm. The thing is, I have no idea how to do any of this. I'm learning Clojure as my first language. I've read some books about Clojure, so I've been able to set up a basic website, but when it comes to these little things, I don't know how to do it from scratch and I don't see any specific tutorials of people doing this stuff in Clojure. So... how do I go about figuring out how to add these features? There are tons of tutorials online on how to do it with Javascript. Should I just see how people do it in Javascript, and then implement it in Clojure? I feel like that removes the whole point of learning functional programming, if I'm just going to do stuff the OOP way. Do I just learn everything I can about Clojure and try to do stuff from scratch? What do you do, when you want to add a feature to your web app, and there aren't any tutorials on how to do it in Clojure? What steps do you take from the idea to completion?


I'd recommend breaking it down into smaller chunks, like server versus client. You can do all the server-side stuff with pretty much just Clojure and related libraries, but the front end stuff will require you to learn HTML and CSS as well. A basic understanding of JavaScript will be helpful as well, since that's what CLJS compiles to.


Then you get into client-side frameworks like React (or its CLJS grandchild reagent/re-frame).


Sounds like you've got a server running at least, so if I were you I'd focus on picking up HTML and CSS next, possibly in conjunction with Clojure libraries like Hiccup.

John Bradens19:01:50

I have some front end stuff set up too, like a navigation bar, and a form, and user registration. The thing is, all that stuff uses reagent, hiccup, etc, but the only reason I know how to do it, is because I read it in a book. Now I want to add more things, but I feel totally lost. Do I just have to understand the basics better? And then will I know how to add these things and build up from there? I feel like the way I learn best is through examples, but I feel like there are very few examples on building out features with clojurescript and reagent and all that, especially compared to all the javascript tutorials on youtube


Check out my JS app If that has the kind of things you would like to do, I have re-executed that using re-frame, pure reagent, and my own CLJS Matrix library. Look here for "rehiring" (re-frame) and "hiringagent", reagent. hth!

👍 1

and @U02387J8EKG just to tie this to the api discussion, @U0PUGPSFR most likely had to use the Hacker News api to get the data for his app to display. So he wanted an app to be able to search HN's Who's Hiring thread so the thought process probably went quickly to "Ok, HN probably has an API for me to use to ask and receive that data"

John Bradens19:01:33

@U9J50BY4C ah, cool thanks! That is really helpful to know


Sadly, the HN Firebase API is in fact a WIP the HN devs have not had the time to round into shape. I believe I started from some Clojure project showing how to scrape an HN page given a HN messageID. From there I used another clojure library to parse the HTML, and then I trotted out the JS version of my front-end library Matrix, so would host it. Prolly could have done it with CLJS, as well, come to think of it, but I was still learning the tooling. Anyway, Matrix let me handle the GUI, but it might be better for a CLJS noob to get familiar with re-frame or reagent, with which many here can offer great help.

👍 1

Hey @U02387J8EKG I also found this repo that has "recipes" for various web dev stuff in Reagent (one recipe is a simple sidebar for example):

John Bradens18:01:34

Thanks @U9J50BY4C I really appreciate this!

John Bradens19:01:38

Like I also have to learn how to get my pages on my site to show up on Google. I remember asking here and someone said I have to look into SSR, and all sorts of other things. It's just hard to know a realistic roadmap for actually completing that task, but people seem to do it all the time. I just don't know how?


Maybe just pick one specific feature you want to add, and ask about it here?

☝️ 1
John Bradens19:01:48

Ok thanks, that's a good idea. I'm going to read a little more and then I'll come back when I pick one. I appreciate your help @manutter51

👍 1

Is this the book you used? If not (I assume the other option would be Web Development with Clojure), I've found that it is a pretty good resource so far. I've been translating some of the earlier exercises there into using Reagent for it too (I think it actually uses Reagent later in the book). It is free online.


I am kind of in the same boat where I'm self taught and stumbled on to Clojure early but struggled because most resources assume you are experienced already, especially with web dev. So I have branched out. I did Harvard's CS50 which really improved my foundation and understanding on things and I've tried other languages and tutorials. I'm currently doing a web dev bootcamp course on Udemy and translating what I'm learning from there to Clojure while it's all fresh in my head.


Another cljs book I just saw mentioned over in that channel that I hadn't seen before:

John Bradens20:01:43

@U9J50BY4C Just saw these replies, thank you. Thanks for pointing me to the learn Clojurescript book, I hadn't found that and it looks great! I'm going to wrok through that. The one I have been using was Web Development with Clojure, and then I just got started with Professional Clojure. There's also one that is Hands-on reactive programming with Clojure, but I think that's way too advanced for me right now. I'll look into ClojureScript Unravelled too. I'm trying to consume all the books I possibly can!