babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2021-03-05T10:38:17.021100Z

3
wilkerlucio 2021-03-05T13:25:19.021600Z

1
πŸ‘ 5
🀯 1
borkdude 2021-03-05T16:18:20.022800Z

Hi @uiltjesrups - that's a cool nickname ;)

flowthing 2021-03-05T17:53:17.023200Z

Getting there... https://tutkain.flowthing.me/tutkain-babashka.mov

πŸ‘ 2
πŸŽ‰ 1
flowthing 2021-03-05T17:56:16.023400Z

And when I do, all 0.8% of the world's Clojure developers using Sublime Text can rejoice that they can bask in the glory of Babashka!

πŸ˜† 1
πŸŽ‰ 1
emilaasa 2021-03-05T18:02:26.024700Z

Great experience using bb today for some elastic search queries and drilling around in the json response. Feels like a huge improvement over my old jq ways-

grazfather 2021-03-05T18:17:08.025300Z

^ I am waiting for this aha moment. I still do a lot of bash + jq

βž• 1
borkdude 2021-03-05T18:58:20.026200Z

It's hard to break old habits and if the hold habits work fine for you, then there's no reason to change. E.g. if you know the jq syntax from heart, keep using it. I certainly don't :).

grazfather 2021-03-05T19:01:17.026700Z

for JQ it isn’t bad, but I also do a lot of cut sort, etc. It’s a lot more fragile than having a smarter parser

πŸ™Œ 1
grazfather 2021-03-05T19:01:58.027300Z

I want to convert this: https://github.com/hugsy/gef/blob/dev/tests/perf/context_times.sh It’s pretty janky: bash to git checkout stuff, then invoke gdb, and in gdb invoke python, and then parse the output πŸ˜‚

grazfather 2021-03-05T19:02:32.027700Z

oh, and then write a CSV

grazfather 2021-03-05T20:36:52.028100Z

is there some function for quoting for shell?

borkdude 2021-03-05T20:53:09.028400Z

@grazfather can you give an example of what you want?

grazfather 2021-03-05T20:55:33.030600Z

Sure. See this line of bash? https://github.com/hugsy/gef/blob/dev/tests/perf/context_times.sh#L10

gdb -ex 'start' -ex 'pi import profile' -ex "pi profile.run(\"gdb.execute('context')\", sort=\"cumtime\")" -ex 'quit' \
        /tmp/pattern.out 2>&1 | get_context_time
The gdb.execute('context') is a string in python that is evaled, but also I am invoking it on the command line. So I am avoiding some escaping by using single quotes. I would like to safely quote a variable that would replace "gdb.execute('context')" and safely escape so that it’s a valid python string after it make it into gdb

borkdude 2021-03-05T20:57:12.031100Z

something like:

user=> (pr-str "gdb.execute('context')")
"\"gdb.execute('context')\""
?

grazfather 2021-03-05T20:57:55.031600Z

Yes, or if the client goes gdb.execute("context") (double quotes) it works

grazfather 2021-03-05T20:58:00.031900Z

right now it would break:

Python Exception <class 'SyntaxError'> ('invalid syntax', ('<string>', 1, 27, 'profile.run("gdb.execute("context")", sort="cumtime")\n'

grazfather 2021-03-05T20:58:37.032300Z

a naive replace of " with \" might get me pretty far

borkdude 2021-03-05T20:58:49.032500Z

pr-str does that

grazfather 2021-03-05T20:59:43.032900Z

oh i thought you were using a hypothetical function πŸ˜†

2021-03-05T22:25:40.033400Z

how can i create a process that survives the end of the script?

2021-03-05T22:26:14.033700Z

for example, running a gui program from babahska

borkdude 2021-03-05T22:30:25.034Z

@huxley This works for me for opening VSCode:

#!/usr/bin/env bb

(require '[babashka.process :as p])

(p/process '[code])

nil

borkdude 2021-03-05T22:30:35.034300Z

Not sure if it works for all programs

borkdude 2021-03-05T22:31:46.034600Z

Launching Firefox also worked:

#!/usr/bin/env bb

(require '[babashka.process :as p])

(p/process ["/Applications/Firefox.app/Contents/MacOS/firefox"])

nil

2021-03-05T22:34:25.034800Z

hmm, it's working πŸ˜‰

2021-03-05T22:35:39.035100Z

then the problem is with sway, because the scripts fired by the keyboard shortcut die together with the application

grazfather 2021-03-05T23:03:44.036300Z

Alright, so this is esoteric, but I got it working pretty well. Thanks for the help! https://gist.github.com/Grazfather/be5d5d15057fc985e3c6f03e26dd1aa5 Basically it lets you run a python statement within the context of GDB multiple times across different git commits. I used a similar bash implementation to profile whether certain changes caused performance regressions

πŸŽ‰ 1