beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
Kevin 2020-09-25T04:09:37.094200Z

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!

practicalli-john 2020-09-25T10:20:21.095900Z

All the editor integration you could want with clj-kondo https://github.com/borkdude/clj-kondo/blob/master/doc/editor-integration.md

Kevin 2020-09-25T15:57:40.102Z

@jr0cket 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?

practicalli-john 2020-09-25T16:13:39.102600Z

I havent used yet, but there seems to be solutions on the GitHub marketplace https://github.com/marketplace/actions/setup-clj-kondo Or you can just include clj-kondo in your own GitHub action https://rymndhng.github.io/2020/04/03/Integrate-clj-kondo-with-Github-Actions/ https://github.com/marketplace/actions/clj-kondo-checks

Kevin 2020-09-25T17:13:04.102900Z

Thanks!

seancorfield 2020-09-25T04:41:10.094700Z

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

๐Ÿ‘ 3
1
borkdude 2020-09-25T14:35:19.101800Z

Thanks

seancorfield 2020-09-25T04:41:34.095200Z

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

Jelle Licht 2020-09-25T13:59:41.100600Z

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 Licht 2020-09-25T14:04:42.101600Z

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 ๐Ÿ˜•

seancorfield 2020-09-25T17:25:57.103100Z

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

seancorfield 2020-09-25T17:26:16.103300Z

(because AOT is transitive)

๐Ÿ‘ 1
Mark Wardle 2020-09-25T20:31:10.105200Z

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!

alexmiller 2020-09-25T20:33:11.105400Z

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

๐Ÿ‘ 2
Mark Wardle 2020-09-25T20:33:53.105700Z

Thank you. Good to know!

2020-09-25T22:15:06.108700Z

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

2020-09-25T22:18:07.109600Z

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

2020-09-25T22:19:44.110800Z

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

fabrao 2020-09-25T23:32:50.112500Z

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?

souenzzo 2020-09-27T14:32:08.197900Z

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]

2020-09-25T23:40:10.112800Z

No

2020-09-25T23:40:57.114100Z

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

fabrao 2020-09-25T23:53:25.114700Z

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

2020-09-25T23:53:51.115Z

using an atom is best

fabrao 2020-09-25T23:54:28.115800Z

is not that ugly way using atom?

2020-09-25T23:54:49.116600Z

you are using state shared between threads

2020-09-25T23:54:50.116800Z

atom

fabrao 2020-09-25T23:55:21.117900Z

you say that you can stop all thread once?

2020-09-25T23:55:36.118200Z

what?

2020-09-25T23:55:53.118600Z

don't def a global of course

fabrao 2020-09-25T23:56:25.119500Z

so, how to use it from inside proxy?

2020-09-25T23:57:15.120700Z

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

2020-09-25T23:58:19.122100Z

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

2020-09-25T23:58:27.122300Z

errr

2020-09-25T23:58:33.122500Z

missed some parens

fabrao 2020-09-25T23:58:55.122800Z

ok, sure, understood