Fork me on GitHub
#beginners
<
2021-02-01
>
hiredman00:02:06

It is reliable enough if you are defining the function yourself, it can be unreliable for things from libraries

caumond00:02:44

ah ok, I control the functions, no issues.

Adrian Imanuel05:02:53

Hi Guys, i'm using doom emacs now, and I don't know the shortcut for : 1. how to make my cider repl move to right panel? 2. [C c M p] >> is this the correct shortcut to send code from buffer to REPL? much appreciated for the help 😄

pavlosmelissinos06:02:05

#emacs might be a better place to ask these questions Not sure about doom emacs but with vanilla emacs: 1. you can change the orientation with C-\ . 2. In general you usually don't send the code to the repl, but you evaluate it in place instead and the shortcut for that is C-c C-c or C-c C-e, depending on where the cursor is. From the https://docs.cider.mx/cider/usage/cider_mode.html: > Typically you'd begin your interaction with any source buffer by evaluating it with C-c C-k. Afterwards you'd normally evaluate just individual forms with C-c C-e (evaluate preceding form) or C-c C-c (evaluate current top-level form).

Adrian Imanuel06:02:28

ah okay, will ask there

Adrian Imanuel13:02:28

gotcha, 1. [SPC w v] to add window vertically 2. [SPC b B] to select the cider REPL poof we got buffer & REPL side by side vertically

🎉 3
pavlosmelissinos14:02:58

FYI most of the time you don't even need the REPL buffer in the foreground

Henry07:02:44

The deployment story of Clojure(Script) is very different than in JavaScript. On top of this, there are so many options that make beginners wonder which strategy to adopt. Experienced Clojurians, would you mind sparing a minute and share what you think are the state-of-the-art (or your favourite) deployment strategies? Any useful learning resources are also welcomed. Thanks a lot for sharing.

solf08:02:36

For clojurescript, shadow-cljs is usually the recommended way. It makes integration with the npm ecosystem (almost) transparent. - https://github.com/thheller/shadow-cljs - https://shadow-cljs.github.io/docs/UsersGuide.html - #shadow-cljs

Henry14:02:08

@U7S5E44DB Thanks for sharing. Shadow-cljs is indeed a fantastic tool for CLJS development and deployment. Do you use shadow-cljs with any other build tool for compiling CLJ, like into a uberjar, etc.?

solf14:02:17

shadow-cljs is cljs-only. For clojure the two options are either - lein (battery included, but falling more and more out of favor) - or deps.edn, the offficial tool (https://clojure.org/guides/deps_and_cli) I prefer deps.edn, but it's pretty barebone. Building a jar with lein is simple:

lein uberjar
With deps.edn, you need to use something like depstar (https://github.com/seancorfield/depstar) Also interesting read if you want to use deps.edn: https://github.com/seancorfield/dot-clojure

Henry14:02:48

Thanks a lot for helping. If you won't mind sharing, after you've got the frontend codes from shadow-cljs and the uberjar, how do you deploy to the web?

solf14:02:58

So you want to deploy both a backend (the uberjar) and front-end (shadow-cljs)?

solf15:02:54

An uberjar only needs a server with java installed, you upload the jar by any method and do java -jar uberjar-name.jar. For the frontend, it depends on your app: - either it's served by the backend, in which case it would be already in the jar or somewhere in the same server - it's only static files talking to your server API, in which case you can put them on a cdn, on a server behind nginx (or similar), etc... Frankly, "deploy to the web" is very vague, can't help more than that

solf15:02:11

You should ask another question describing more precisely what you're trying to do. In another thread, because it's 11PM for me and I'm going to bed 🙂

Henry15:02:24

That's very helpful already. Really appreciate your help at this hour. Following the docs, I already have a working demo on development mode, but crossing the chasm from dev to prod is a bit vague to me since I am not familiar with how JVM deployment looks like. Good idea to start another thread later with more precise question. Have a good night! 🙂

Marcus09:02:26

Anyone got this message when using deps.edn to include a git repo? Error building classpath. Destination path "<repo name>" already exists and is not an empty directory

Eamonn Sullivan09:02:07

Yes, that's a common error. I usually just rm -rf ~/.gitlibs and try again, but apparently you can also try -Sthreads 1 on the command line. The developers think it might be contention between download threads.

Marcus09:02:16

Ah nice! Thanks. That was the directory I was looking for

Adrian Imanuel13:02:21

I'm so happy right now 😄 within 3 day, I successfully : 1. installed DOOM emacs 2. at least know/pretty familiar with the navigation (key combinations) 3. Start REPL after some errors 4. Create a project & connect 2 ns inside 5. move on after stuck at ch 6 in http://braveclojure.com Thank you so much, for the support... I'll learn more, dig more

👏 36
💪 3
solf14:02:31

TFW people new to (doom-)emacs have a much nicer looking config than mine after 10 years of tweaks. But vanilla4ever

👍 6
clyfe14:02:31

Or Prelude?

kpav16:02:03

just install doom-themes and/or doom-modeline !

solf00:02:35

Yeah, trying out doom-themes has been in my backlog for a long time 🙂 A few years ago I had a emacs "theme bankrupcy", I removed all my aesthetic customizations and I'm now running the default light theme 😅

javahippie16:02:22

I am trying to connect my Clojure applications with an APM tool, that traces some variables and the execution time of functions in a nested way. So the HTTP call is the top span, then there are three SQL statements which are child spans, and so on. I created a function to wrap the calls I’d like to trace, and it’s at least working, but I wonder what the best and most idiomatic way would be. My initial approach was to return both the result and a trace-event (a map containing all the info) from each function and collect and send the events in the end, but this feels rather clumsy. Also, if something in the process chain there is an exception, I will lose trace events. Another way could be to pass a “send trace event” callback into the functions I want to trace, and invoke the callback from the inside. Which one would you prefer? Or are there other ways I am not thinking about?

noisesmith17:02:51

a classic lispy approach is to make wrapper functions that have identical return value but also trace your info:

(defn wrap-trace
  [f]
  (fn [& args]
    (some-tracer-pre f args)
    (let [res (apply f args)]
      (some-tracer-post f args res)
      res)))
that way you never need to mix tracing code into your other logic

👍 3
noisesmith17:02:26

so if you have foo, you can call (wrap-trace foo) to get a traced function with the same behavior in some cases you might want (alter-var-root #'foo wrap-trace) which replaces the root binding, but often you'd also want to attach the old value of foo to the var metadata (eg. think about what happens if you wrap a function that was already wrapped)

javahippie17:02:24

Then the first step was right, I have such a wrapper function. And it would be okay to invoke side effects in that wrapper? There would be no other way really, would it?

noisesmith17:02:04

right, that's the only way to do it - I assume that at the root your tool requires some mutation or side effect to work

noisesmith17:02:46

also, you mentioned exceptions - so you'd want to use try around the let body, likely with a special cleanup call in the catch

javahippie17:02:54

Yes, it’s sending network requests.

javahippie17:02:10

Thanks for the answer, that helped! 👍

noisesmith17:02:50

yeah - the cleanest way is if the individual usages of the API can remain idempotent, then the only side effect needed is the network request invoked from each wrapper, but you might end up needing client side coordination, in which case a thread plus a queue is probably simplest

javahippie17:02:38

That shouldn’t be a problem, it is the same request every time, with similar data, and there is already a java lib that handles all the calls non-blocking