Hi @uiltjesrups - that's a cool nickname ;)
Getting there... https://tutkain.flowthing.me/tutkain-babashka.mov
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!
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-
^ I am waiting for this aha moment. I still do a lot of bash + jq
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 :).
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
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 π
oh, and then write a CSV
is there some function for quoting for shell?
@grazfather can you give an example of what you want?
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 eval
ed, 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 gdbsomething like:
user=> (pr-str "gdb.execute('context')")
"\"gdb.execute('context')\""
?Yes, or if the client goes gdb.execute("context")
(double quotes) it works
right now it would break:
Python Exception <class 'SyntaxError'> ('invalid syntax', ('<string>', 1, 27, 'profile.run("gdb.execute("context")", sort="cumtime")\n'
a naive replace of "
with \"
might get me pretty far
pr-str
does that
oh i thought you were using a hypothetical function π
how can i create a process that survives the end of the script?
for example, running a gui program from babahska
@huxley This works for me for opening VSCode:
#!/usr/bin/env bb
(require '[babashka.process :as p])
(p/process '[code])
nil
Not sure if it works for all programs
Launching Firefox also worked:
#!/usr/bin/env bb
(require '[babashka.process :as p])
(p/process ["/Applications/Firefox.app/Contents/MacOS/firefox"])
nil
hmm, it's working π
then the problem is with sway, because the scripts fired by the keyboard shortcut die together with the application
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