Fork me on GitHub
#babashka
<
2020-03-31
>
sogaiu08:03:51

so that takes a leiningen project.clj and produces a deps.edn file with converted dependencies using babashka?

borkdude08:03:28

Andrea posted it

borkdude08:03:29

I'll add this link to it

borkdude09:03:31

done

πŸ‘ 4
mkvlr10:03:29

bb --classpath /Users/mk/.m2/repository/nrepl/bencode/1.0.0/bencode-1.0.0.jar --repl                                                                           ✘ 130 
Babashka v0.0.78 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require 'bencode.core)
Unable to resolve classname: clojure.lang.RT [at bencode/core.clj, line , column ]
user=> 

mkvlr10:03:34

should this work?

borkdude10:03:07

you are trying to use bencode itself from the interpreter? that doesn't work. should it?

borkdude10:03:57

I am using the bencode library in the nrepl-server branch, so we have a dependency on it anyway. we could just expose it to the interpreter if it makes sense...

mkvlr10:03:16

ok, and in general (for a lib you don’t already have included) I would do a fork and include it?

mkvlr10:03:55

is there cases when requiring a lib through the interpreter would work or does it never work?

borkdude10:03:07

@mkvlr a fork isn't always needed. there are several libraries out there that work out of the box: https://github.com/borkdude/babashka/#tools-and-libraries mostly when it's pure clojure, it works

borkdude10:03:48

oh, when you want to do built-in support for a library that doesn't make sense for bb in the general case, but for your specific use case, a fork makes sense

mkvlr10:03:02

ok, thanks a lot!

borkdude10:03:15

can I ask what you are trying to achieve?

mkvlr10:03:40

☝️ can better answer that

thattommyhall10:03:41

hey, I am relying on the fact bencode is a bijection to hash json files in a way thats cross platform and language

borkdude10:03:48

hash or encode/decode?

thattommyhall10:03:06

I did a thing in python for data pipelines ( https://github.com/binaryaffairs/a-la-mode https://www.youtube.com/watch?v=jjVp4QudLaw ) and I'd like to do the same trick to rebuild Packer images if the json describing it or the checksum of any input files changes

thattommyhall10:03:52

I take the SHA256 of the bencoded dictionary/hash

thattommyhall10:03:49

that would do for the SHA bit I think

borkdude10:03:22

why do you need a hash of a bencoded thing instead of the stringified thing itself? (I'm just asking to learn more about your use case)

thattommyhall10:03:44

that was for cross-language stability

thattommyhall10:03:11

json does not have a unique string representation

borkdude10:03:15

ah, so you encode from language X and Y into bencode, which then yield exactly the same bytes?

thattommyhall10:03:40

this is a nice-to-have for the current need, but yeah

thattommyhall10:03:54

if the clojure map hash fn is stable, I could use that

borkdude10:03:17

fwiw, I have bencode inside the nrepl-server branch and I needed to make a small tweak to it for GraalVM: https://github.com/borkdude/babashka/blob/b04f812d73b79124c51ad6db89059c14b74a7977/src/babashka/impl/bencode/core.clj#L319

borkdude10:03:59

which function do you need from bencode? I could try to expose that inside that branch

borkdude10:03:08

and then you could also use that branch for testing your use case

thattommyhall10:03:19

read-bencode write-bencode

thattommyhall10:03:58

its probs a weird use case tbh

borkdude10:03:06

@thattommyhall In the nrepl-server branch:

$ ./bb '(with-open [os (io/output-stream (io/file "out.txt"))] (bencode/write-bencode os {"a" 1})) (slurp "out.txt")'
"d1:ai1ee"

borkdude10:03:34

binaries will appear shortly in #babashka_circleci_builds

borkdude10:03:22

(the full namespace is bencode.core which is aliased as bencode)

thattommyhall10:03:23

thats lovely, cheers

borkdude11:03:39

the binaries have come in now on that channel

❀️ 4
πŸ™ 4
thattommyhall11:03:01

$ ./bin/build.bb 
d1:ai3e1:bi4ee

thattommyhall11:03:14

im fairly sure this will work for me now, cheers!

borkdude11:03:25

cool. I hope to release this soon-ish, there are a few details to iron out with the nrepl-server

borkdude13:03:36

Created an open collective for those who prefer it over Github sponsors. https://opencollective.com/babashka

πŸ’ͺ 8
jeroenvandijk13:03:05

Added a first contribution πŸ™‚

borkdude13:03:53

wow, thanks!

nate16:03:05

Had a quick bash script to collect information via ssh from multiple servers, rewrote it in babashka to use future/deref, and runtime went from 28 seconds to 2.5. babashka

babashka 16
borkdude16:03:57

did you also try spire already?

nate16:03:56

I really want to, haven't had a chance yet.