Fork me on GitHub
#beginners
<
2020-09-25
>
Kevin04:09:37

I'm having trouble deciding on a linter to use. Ideally I want the linter to be compatible with Intellij + cursive and vim environment, and my plan is to make an on commit check that runs the linter with GitHub actions. Any help would be great!

Kevin15:09:40

@U05254DQM I saw this clj-kondo, is it a good linter for running a commit check / GitHub actions and have you see any example repos that have it implemented as a github action?

seancorfield04:09:10

clj-kondo is far and away the most sophisticated and best supported linter for Clojure these days.

👍 9
clj-kondo 3
seancorfield04:09:34

Check out the #clj-kondo channel if you have any questions @kevin26428

Jelle Licht13:09:41

I have a (gen-class :name proj.translator.MyClass ...) in ns proj.translator . In proj.core, I refer to proj.translator.MyClass , which works fine in 'interactive use' (where :aot proj.translator is the only entry). When I run lein uberjar, I also set :aot :all , which leads to proj.core being compiled as well; it is at this point that lein complains with a ClassNotFoundException that proj.translator.MyClass is not found (as it hasn't been compiled yet). Is there anything I can do to make this work? Perhaps some import/require statement?

Jelle Licht14:09:42

it seems that compilation happens in alphabetical order, which is clearly not what I want. Is my only practical option to rename proj.translator to proj.aaaaaatranslator ? It works, but feels ridiculous 😕

seancorfield17:09:57

If your proj.core ns requires your proj.translator ns then it should get AOT'd in the correct order.

seancorfield17:09:16

(because AOT is transitive)

👍 3
Mark Wardle20:09:10

Hi! Does anyone have an easy way of injecting git commit info (e.g. result of ‘git rev-parse --short HEAD’) into a deps.edn build? I have found https://github.com/day8/lein-git-inject for leiningen. Thanks!

alexmiller20:09:11

I do, but it's not public yet :)

👍 6
Mark Wardle20:09:53

Thank you. Good to know!

Zebra22:09:06

How to restart a component, for example responsive for db pooling or amqp/kafka connections, when connection goes down for a few seconds? Im referring to Stuart Sierra Component

hiredman22:09:07

Usually a component will wrap something like a connection pool, not a single connection

hiredman22:09:44

And the connection pool creates new connections as required, so you don't restart the component

fabrao23:09:50

Hello all, I have this

(def active (atom true))

  (-> (proxy [Thread] []
        (run []
          (while @active
            (println "Loop")
             (Thread/sleep 1000))))
    (.start))
to stop it, I have to (reset! active false) Is there any way to control running process instead of using external atom?

souenzzo14:09:08

Using future-cancel

(def work (future (while (not (Thread/interrupted))
                    (println [(new java.util.Date) (reduce + (range 1e8))]))))
=> #'user/work
[#inst "2020-09-27T14:31:42.790-00:00" 4999999950000000]
[#inst "2020-09-27T14:31:44.070-00:00" 4999999950000000]
    (future-cancel work)
=> true
[#inst "2020-09-27T14:31:45.271-00:00" 4999999950000000]

hiredman23:09:57

But use future, or just pass function to thread's constructor (they are runnable)

fabrao23:09:25

@hiredman do you think it´s better using future with future-cancel ?

hiredman23:09:51

using an atom is best

fabrao23:09:28

is not that ugly way using atom?

hiredman23:09:49

you are using state shared between threads

fabrao23:09:21

you say that you can stop all thread once?

hiredman23:09:53

don't def a global of course

fabrao23:09:25

so, how to use it from inside proxy?

hiredman23:09:15

a. don't use proxy, as I said b. proxy, reify, fns, etc will close over locals

hiredman23:09:19

(let [stop? (atom false)] (future (while (not @stop) ...)) ... (reset! stop? true)) 

hiredman23:09:33

missed some parens

fabrao23:09:55

ok, sure, understood