Fork me on GitHub
#beginners
<
2023-11-20
>
Marek Foo11:11:22

Is it good to start with neovim with clojure and do you have some nice guide to start off?

tomd11:11:49

If you're familiar with neovim anyway, yes it's fine to start with. The practicalli guides are pretty good: https://practical.li/neovim/

tomd11:11:58

There's also #C02PR4GM873 and #C0DF8R51A if you want some (biased) opinions 🙂

Marek Foo11:11:23

Big thanks, I'll dive into it 🙂

Alvydas Vitkauskas12:11:49

For me, Conjure on neovim was the best option. On vim, I like vim-iced best. Works nice.

Marek Foo16:11:46

After regular installation, during starting vim I'm having some error

Marek Foo16:11:47

Error detected while processing /home/linuxbrew/.linuxbrew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua: E5113: Error while calling lua chunk: vim/editor.lua:0: /home/linuxbrew/.linuxbrew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua..nvimexec2() called at /home/linuxbrew/.linuxbrew/Cellar/neov im/0.9.4/share/nvim/runtime/filetype.lua:0../home/ice/.local/share/nvim/site/pack/packer/start/aniseed/ftdetect/fennel.vim, line 1: Vim(function):E488: Trailing characters: stack traceback: [C]: in function 'nvim_exec2' vim/_editor.lua: in function 'cmd'

Marek Foo16:11:56

Have you met with that already maybe?

Daniel Shriki12:11:09

Hi, I have a REST application that uses compojure & ring middlewares. I’m trying to use Swagger to have a nice API for my clients, but so far I couldn’t understand how to use it. can someone help? Trying to make a basic example - to define a route “/api/v1” where the Swagger UI would be rendered.

danielneal13:11:32

I don’t know about compojure but if you use Reitit (see the #C7YF1SBT3) channel, it will auto generate the openapi3 specs for you based on your schemas and the route definitions. I think it’s great!

🙌 1
Daniel Shriki13:11:01

Hi. thanks but I’m not using Reitit - I’m running the server with http-kit, defining routes with compojure & ring

danielneal13:11:49

Yeah, I don’t know about that. I thought you might be at the beginning of the project with some flexibility in the router choice.

Daniel Shriki13:11:40

nope. unfortunately it’s not the case 😅

Matthew Twomey17:11:13

Is there any advantage to using letfn over let if you don’t need functions referring to other function names you are defining? For example is there any practical difference in this case here:

(defn r2 [names]
  (letfn [(name-reducer
            [names name]
            (let [feature-name (name :feature_name)
                  clean-name (clean-name feature-name)]
              (if (valid-name clean-name) (conj names clean-name) names)))]
    (reduce name-reducer [] names)))


(defn r3 [names]
  (let [name-reducer
          (fn [names name]
            (let [feature-name (name :feature_name)
                  clean-name (clean-name feature-name)]
              (if (valid-name clean-name) (conj names clean-name) names)))]
    (reduce name-reducer [] names)))

xbrln20:11:23

Need help in calling a list of urls in parallel (🧵see more details in thread)

xbrln20:11:30

I have a list of urls in the following shape.

(def items `({:url "valid-url"}
             {:url "valid-url"}
             {:url "in-valid-url"}))
There could be up to a couple of thousand urls in that list. I need to call each url and assoc the response status code into that list. What would be a realistic way to go about it ? So far I did this, but it is slow when I apply it with pmap to a list say above 1000 urls. Am using clj-http library to call the url.
(defn add-status-code
  "Call the url of the seo page and add response status code."
  [item]
  (let [status-code (-> (:url item)
                        (clj-http/get {:redirect-strategy :none})
                        :status)]
    (assoc item :status status-code)))

(pmap add-status-code items)

Sam Ferrell20:11:50

I would probably start by limiting the maximum number of simultaneous requests

Sam Ferrell20:11:19

pmap is OK for CPU intensive tasks but doesn't offer much control for IO tasks

hiredman20:11:10

Pmap gives you limited to no control over execution, and is linear, it can only process in order

hiredman20:11:38

The general structure you likely want is an input queue, a pool of workers, and an output queue

Sam Ferrell20:11:47

@U0NCTKEV8 do you know of any popular high level libraries for that kind of work? I know I've seen one or two before just forgetting the names

hiredman20:11:09

A simple implementation that satisfies that is an executor and a completionservice

xbrln08:11:10

Thank you all for all the inputs... 🙏 I think for now I'll try to split the call into multiple smaller batches.

SenyorJou10:11:37

Never used this lib before, but I think that code with promises will do the trick of performing concurrent calls ➡️ https://gist.github.com/senyorjou/9d6699c4d963c10da56c39c3c229106b