This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-29
Channels
- # babashka (64)
- # beginners (60)
- # calva (10)
- # circleci (3)
- # clj-kondo (62)
- # cljdoc (6)
- # clojars (2)
- # clojure (152)
- # clojure-europe (19)
- # clojure-nl (3)
- # clojure-uk (18)
- # clojurescript (50)
- # clojureverse-ops (12)
- # core-async (21)
- # cursive (6)
- # data-science (1)
- # datomic (17)
- # events (14)
- # fulcro (64)
- # graalvm (20)
- # graphql (5)
- # honeysql (14)
- # jackdaw (3)
- # jobs (1)
- # jobs-discuss (22)
- # kaocha (2)
- # lsp (9)
- # luminus (8)
- # malli (30)
- # meander (31)
- # other-languages (1)
- # polylith (8)
- # re-frame (15)
- # shadow-cljs (85)
- # specter (2)
- # sql (11)
- # tools-deps (56)
- # vim (39)
- # vscode (7)
- # xtdb (16)
(import '[javax.imageio ImageIO])
in a script is resulting in Unable to resolve classname
errors. I have an input stream and need to read it into a BufferedImage. Using this class appears to be the recommended way to do it. Wat do?
@borkdude idea was to write a little script to crawl r/wallpapers, and I realized that I could use babashka to query image dimensions in memory w/o saving to disk. http-kit works great, but I'm stuck here. Can you think of a workaround?
@doubleagent usually people shell out to other tools that can do this kind of stuff. on linux you could e.g. use identify
or imagemagick or so
e.g. Adam has built a wrapper for ffmpeg in this way: https://www.youtube.com/watch?v=0Ch-zNZ67go
There is a great library for this: https://github.com/helins/binf.cljc But then you would need to parse the headers with it yourself
I suspect parsing image metadata is going to take longer than an hour, lol. Thanks for the suggestion though. binf looks cool.
We could consider adding the class to bb, but I suspect that people would then also want java.awt, etc. and this could lead to an considerable increase in binary size. It's worth trying though and just see what happens.
If there's a guide for adding modules/classes to bb then I might look into submitting a pr
yeah, a PR is not the problem, it's more the research around it and gathering feedback from the community if this is really worth adding for everyone
Here are build instructions: https://github.com/babashka/babashka/blob/master/doc/build.md
so if you can build locally with and without this/these classes and report the increase in binary size, we have some useful information
Thanks, you're awesome! I completely respect your concern about binary size.
should shell
in bb tasks resolve an env var like $SOME_THNG
if you need to set an env var you can use :extra-env
or :env
in a map as the first argument of shell
Ah, because windows, I guess?
I’m trying something like (shell (str "scp -r src root@" (System/getenv "PROD_IP")))
but somehow it’s not happening 😅
nevermind, my bad
is there a better way than string concatenation for this type of thing?
perhaps format
would help a bit, or selmer
:
(let [prod-ip (System/getenv "PROD_IP")] (selmer/<< "scp -r root@{{prod-ip}}"))
:)If I have deps
specified in bb.edn
, how do I get babashka to install them? I vaguely remember that it used to happen automatically but it doesn’t seem to be anymore
I’m pretty sure my bb.edn is getting picked up because it’s finding my source files (I’m using the whole src/ structure thing)
they should be in bb.edn
. they were resolved by accident from deps.edn
in some previous version but this was never the intent
I'm seeing the same issue - no change if I remove .cpcache
Yup, I have that set
What should it be set to, in these cases? Or should the project I'm working in be added to the global classpath?
if you want bb to get deps from bb.edn, you should not use BABASHKA_CLASSPATH at all
unset BABASHKA_CLASSPATH
did the trickBabashka noob question: I use bb for running some processes that take rather long to complete. Hence I want to show time elapsed.
So for instance I have (run "yes | unminimize")
, that takes a long time, and currently it only prints $ yes | unminimize
, but it wouldn't show how long is the thing running. So I want it to print $ yes | unminimize .... 7:02m
and of course have the time update itself (shell has the \r
sequence which deletes what was already printed, I think that works here).
Now I can see there's an example in the bb book about that, but given that I really never have to deal with concurrency (only callbacks/promises in JS), I feel a bit out of the water.
Can anyone please tell me which macros/fns should I use?
@zikajk You could spawn a future
that prints in a loop and reads from some atom
. While the atom
doesn't contain a value, you keep printing in the loop, else you return from the loop. When your long running shell function terminate, you put a value in the atom
.
(defn- current-unix-time [] (quot (System/currentTimeMillis) 1000)) (let [result (atom nil)] (future (Thread/sleep 3000) (reset! result {:stdout []})) (future (let [start-timestamp (current-unix-time)] (loop [] (when-not (deref result) (Thread/sleep 1000) (print (str "\r" (- (current-unix-time) start-timestamp))) (flush) (recur)))))) (Thread/sleep 10000)
OK, this does it ... the last bit I'm not sure how to get rid off is the (Thread/sleep)
, the very last line. If I don't put it there, it just exits straight away.
How do I do something like Promise.all(future-1 future-2)
? As in wait once both futures has finished and then quit?
OK, solved with (run! deref [future-1 future-2])
I used to do this until I learnt about https://clojure.atlassian.net/browse/CLJ-2574 :)
Hmm ... but what's the alternative then @U055XFK8V ?