Fork me on GitHub
#babashka
<
2021-03-05
>
wilkerlucio13:03:19

🀯 3
awesome 3
πŸ‘ 15
borkdude16:03:20

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

flowthing17:03:16

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!

πŸŽ‰ 3
πŸ˜† 3
emilaasa18:03:26

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-

grazfather18:03:08

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

βž• 3
borkdude18:03:20

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 :).

grazfather19:03:17

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

πŸ™Œ 3
grazfather19:03:58

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 πŸ˜‚

grazfather19:03:32

oh, and then write a CSV

grazfather20:03:52

is there some function for quoting for shell?

borkdude20:03:09

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

grazfather20:03:33

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

borkdude20:03:12

something like:

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

grazfather20:03:55

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

grazfather20:03:00

right now it would break:

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

grazfather20:03:37

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

borkdude20:03:49

pr-str does that

grazfather20:03:43

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

ribelo22:03:40

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

ribelo22:03:14

for example, running a gui program from babahska

borkdude22:03:25

@huxley This works for me for opening VSCode:

#!/usr/bin/env bb

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

(p/process '[code])

nil

borkdude22:03:35

Not sure if it works for all programs

borkdude22:03:46

Launching Firefox also worked:

#!/usr/bin/env bb

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

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

nil

ribelo22:03:25

hmm, it's working πŸ˜‰

ribelo22:03:39

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

grazfather23:03:44

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

πŸŽ‰ 3