This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-12
Channels
- # announcements (2)
- # babashka (26)
- # beginners (48)
- # calva (32)
- # cider (23)
- # clj-kondo (61)
- # cljfx (3)
- # clojure (93)
- # clojure-australia (2)
- # clojure-europe (23)
- # clojure-losangeles (1)
- # clojure-nl (5)
- # clojure-uk (4)
- # clojurescript (46)
- # cloverage (9)
- # code-reviews (1)
- # copenhagen-clojurians (1)
- # cursive (39)
- # data-science (6)
- # datahike (8)
- # deps-new (8)
- # depstar (2)
- # etaoin (1)
- # fulcro (2)
- # funcool (2)
- # graalvm (5)
- # jackdaw (3)
- # java (17)
- # jobs-discuss (43)
- # kaocha (2)
- # leiningen (25)
- # malli (8)
- # minecraft (1)
- # missionary (8)
- # observability (6)
- # off-topic (37)
- # other-languages (12)
- # practicalli (1)
- # reagent (4)
- # releases (78)
- # remote-jobs (1)
- # sci (9)
- # shadow-cljs (13)
- # spacemacs (6)
- # sql (1)
- # tools-deps (30)
- # xtdb (3)
Does anyone know of a library that I can use to rate limit certain routes? Ideally ring middleware
I found: https://github.com/FundingCircle/ring-venturi But it seems old and alpha
Give it a try, the code isn't particularly complex so you should be able to modify it if required
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 clojure.java-time/clojure.java-time
and I believe I need to add -Djavac.net.ssl.trustStore=...
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: https://clojureverse.org/t/how-to-pass-jvm-opts-to-clj-from-terminal/1940/3 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?
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 ...
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
Here's the very questrion I asked nearly two years ago and was answered around the same topic 🙂
Thank you for your previous discussion. 🙂
Did it work for you?
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}))
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 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")
(flush))))
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
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.
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 https://kennytilton.github.io/whoishiring/ 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 https://github.com/kennytilton for "rehiring" (re-frame) and "hiringagent", reagent. hth!
and @U02387J8EKG just to tie this to the api discussion, @U0PUGPSFR most likely had to use the Hacker News api https://github.com/HackerNews/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"
@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 http://github.io 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.
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): https://github.com/reagent-project/reagent-cookbook
Thanks @U9J50BY4C I really appreciate this!
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?
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
Is this the book you used? https://www.learn-clojurescript.com/ 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: https://funcool.github.io/clojurescript-unraveled/
@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!
Check out my JS app https://kennytilton.github.io/whoishiring/ 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 https://github.com/kennytilton for "rehiring" (re-frame) and "hiringagent", reagent. hth!