Fork me on GitHub
#babashka
<
2021-09-02
>
borkdude10:09:42

I don't remember who asked a while ago about image processing stuff in babashka, but now there is #nbb and e.g. rotating an image was pretty easy using jimp: https://github.com/borkdude/nbb/blob/main/examples/jimp/example.cljs

👀 4
👍 4
borkdude11:09:46

not for me?

Jakub Holý (HolyJak)11:09:22

that was weird. Now it works.

Jakub Holý (HolyJak)11:09:38

The Tasks talk https://youtu.be/u5ECoR7KT1Y?t=1281run, clojure use (do (run 'clean) (run 'uberjar)) I assume we could just and well, and perhaps more easily, write it as {:depends [clean uberjar]} right? Does it execute the dependencies in order (https://book.babashka.org/#_dependencies_between_tasks does not say?)? Though we risk to screw up if we run it with run --parallel so perhaps a bad idea...

borkdude11:09:25

yeah, that's the reason: the task dependencies will be run in order if you don't use --parallel, but if you do, then there is no defined order

borkdude11:09:12

also note that dependency order depends on topological sorting, e.g. :depends [x y z] doesn't always mean that y is before z, e.g. not if z is also a dependency of x

borkdude11:09:57

so to keep the order defined, just use run explicitly

👍 2
🙏 2
Jakub Holý (HolyJak)11:09:19

Question about Fish completions for tasks https://book.babashka.org/#_fish - there is

function __bb_complete_tasks
  if not test "$__bb_tasks"
    set -g __bb_tasks (bb tasks |tail -n +3 |cut -f1 -d ' ')
  end

  printf "%s\n" $__bb_tasks
end
so once I run this, the tasks list will be set forever. If I run it again in a different folder, I do not get that folder's tasks but the ones saved previously. Is that intended?

Jakub Holý (HolyJak)11:09:22

Hi @UFBL6R4P3 , you added ☝️ , right? I have fixed mine to simply not use a cache variable, I assume the (bb tasks ...) is fast enough for my needs.

Michaël Salihi22:09:11

Hi, yes it's me.

Michaël Salihi22:09:36

I'll try to reproduce and fix this issue 👍

Michaël Salihi22:09:14

Thx for the feedback

borkdude11:09:58

This was contributed by people other than me, I don't know fish, so I hope those people will respond/fix :)

Jakub Holý (HolyJak)11:09:15

ok! do you remember who?

borkdude11:09:51

you can see it in the commit history of the book

👍 4
Jakub Holý (HolyJak)11:09:53

@borkdude would it be possible to add a link to the https://www.youtube.com/watch?v=u5ECoR7KT1Y slide to the youtube description? 🙏

borkdude11:09:28

do you mean a link to speaker deck?

2
Jakub Holý (HolyJak)11:09:35

in the talk description at youtube. Yes, I guess it is Bruno who must do that 🙏

borkdude11:09:38

I think you should ask @bruno.bonacci to update the description, I don't manage that account

Jakub Holý (HolyJak)11:09:14

FYI again I got an error accessing the book page: > This site can’t be reached > Check if there is a typo in book.babashka.org.DNS_PROBE_FINISHED_NXDOMAIN after a reload it showed up. Something fishy going on with the server(s)...

Akiz12:09:59

Hi, I can see Lanterna mentioned in BB book but i can’t see it in https://github.com/babashka/pod-registry what’s the current status? Can it be used? Thanks

borkdude12:09:33

@zikajk The current state is a bit experimental I would say. I'm not actively working on it at the moment.

🙂 2
borkdude12:09:13

There is however a working tetris example

borkdude12:09:49

Perhaps you can also consider #nbb + reagent + ink for this kind of usage

👏 2
Akiz12:09:21

@borkdude Thank you. Ink is looking really interesting - new for me. It may be much better choice than lanterna.

Akiz12:09:27

Ahh, it depends on node.js which i cant install on that old and restricted server..

borkdude12:09:17

You're welcome to work on the lanterna pod. Afaik this is the main issue left: https://github.com/babashka/clojure-lanterna/issues/3

borkdude12:09:40

I could also just publish it to the pod registry and take things from there

borkdude12:09:56

I will trigger a build so you can just use it locally to play with

borkdude12:09:36

are you on linux or macos?

Akiz13:09:41

On macos, much appreciated

borkdude13:09:08

and that old restricted server is too?

Akiz13:09:42

No, i will target Linux servers. (but i am used to do uberscript on macos before deploying self-contained script to these linux machines)

borkdude13:09:23

load as: (pods/load-pod "./the-local-binary" {:transport :socket})

🙏 2
borkdude13:09:19

(EDIT: added {:transport :socket}, this is important)

👍 2
borkdude13:09:55

Then we can identify issues and perhaps release an initial version

borkdude13:09:19

If it's remotely useful, we could just release the initial, but somewhat not perfect version.

Akiz13:09:42

And this is the version that works until I will try to compile it with graalvm if I understand the github issue correctly?

borkdude13:09:17

this is already a graalvm compiled binary

borkdude13:09:36

the github issue just identifies something that doesn't work with lanterna 3 which did work with 2

borkdude13:09:00

we have an upgraded version of clojure-lanterna in the babashka org to lanterna 3. the original clojure-lanterna library is based on 2

borkdude13:09:05

which we use in the pod

borkdude13:09:17

So to back up a little: There is a clojure library called clojure-lanterna. https://github.com/MultiMUD/clojure-lanterna But this uses lanterna 2, while lanterna moved to v3 meanwhile. But the clojure lib seems unmaintained.

borkdude13:09:32

Since we didn't want to build a pod on an unmaintained lib, we tried upgraded clojure-lanterna to lanterna v3.

borkdude13:09:04

And at the same time we made a tetris game and compiled it to graalvm with both v2 and v3. The v3 one has some problems. While the pod seems to work ok. But this may an issue which needs to be fixed.

borkdude13:09:41

But if you get some usefulness out of the pod as it is, then I'm ok with just publishing it as v0.0.1

borkdude13:09:47

and then we can see after that what needs to be fixed

borkdude13:09:18

Basically: just use it and report if there are issues we can fix before v0.0.1 and if it works ok, then we'll also publish it as v0.0.1

🙏 2
Dig16:09:21

i am trying to do something like this with bb and running into issues

clojure --init "/full/path/to/bla.clj" --main bla arg1 arg2
what would be equivalent with bb?

borkdude16:09:59

BABASHKA_PRELOADS=$(cat /full/path/to/bla.clj) bb -m bla arg1 arg2 perhaps?

borkdude16:09:09

or BABASHKA_PRELOADS='(load-file "/bla.clj")', something like that

borkdude16:09:00

or make a bb.edn where you load this code in :init

Dig16:09:12

that works! awesome thank you! tried --file --eval but it did not work

borkdude16:09:45

like {:init (load-file "/bla.clj") :tasks {foo foo}}

borkdude16:09:33

we could introduce another flag to make --init behave like babashka-preloads from a file

Dig16:09:49

that would be cool!

borkdude16:09:20

could you make an issue where you describe your use case? since the official Clojure has this, I think it makes sense

Dig16:09:42

i use something like this in my one file scripts

#!/bin/sh
#_(-*- clojure -*- sorcery to allow to run this script as executable on Linux/Unix
       BABASHKA_PRELOADS="(load-file \"$0\")" exec bb --main bla -- "$@"
       #_exec clojure -J-Xms256m -J-Xmx256m -J-client -M --report file --init "$0" --main bla "$@")
(ns bla)

bherrmann20:09:03

Humm... I use.

#!/usr/bin/env bb
the args are in command-line-args

Dig16:09:05

yep will make case later, too crazy at work right now 🙂

2
aaelony16:09:28

Thank-you for writing babashka! As a longtime clojure user who hasn't written much clojure in the past 2 years, it was super refreshing to be able to look to bb for a simple task. Basically, I use a database at work that lacks the ability to output a "record view" where you can see the entire record one at a time, like \x in postgres. I came up with

cat mytabfile | bb -i ' (let [v (mapv #(clojure.string/split % #"\t") (vec *input*)) header (first v) rows (rest v)] (mapv (fn [row] (println (apply str "\nNEW ROW\n\t" (flatten (interpose "\t" (flatten (interpose "\n" (zipmap header row)))))))) rows ) )'
I'm sure this can be improved, but already it is a nice hack to have. Along these lines, is there a common repo somewhere of cool things folks have done with babashka ?

borkdude16:09:19

@aaelony Great to hear! There is an examples directory in the repo. I keep track of libs and projects here: https://github.com/babashka/babashka/blob/master/doc/projects.md and there is also this news page: https://github.com/babashka/babashka/blob/master/doc/news.md. There there is also the Show and Tell forum on Github Discussions.

👍 2
aaelony16:09:57

cool! I'll check it out 🙂