pleroma.debian.social

one thing I try to do in my comics is only write about things that either

a) I use all the time
b) I don't use, but I'm VERY sure are pretty popular (that's what all these polls I do here are about)

thinking about this because I was reading this sed page I wrote years ago and (while I think all the stuff in there is theoretically cool), I don't love that I've literally never used 70% of the stuff on the page

this is why when someone tells me "X exists" here I often reply with "do you use it?"

i have a kind of baffling interaction on here all the time where

1) I post about something
2) someone tells me “that thing has feature X” (which often I know already)
3) I ask them "oh do you use it?"
4) they say "oh, no, it's not that useful in practice"
5) I’m baffled

I'm always happy to hear about how people are using their computers (that's why I'm on here!) but I really wish every time someone told me about a feature/tool they also included an example of how they use it in practice

(2/?)

@b0rk I know right?

Every now and again I'm reminded of the column processing tools: col, colrm, cut, paste, join, column, comm, lam, rev, sort, et al and think they are really useful and cool, but then I only ever use cut & sort.

Makes me feel a bit guilt sometimes as I'm neglecting commands that someone spent a lot of time coding up.

@markd yeah same, I don't even use cut honestly

@b0rk would you happen to do all the crossed-out stuff in a text-editor, instead? or do you just not ever do the crossed-out stuff at all? I've ended up using a lot of sed/awk, but it's most often on remote servers on which I haven't/won't install emacs

@eigen yeah I use vim for a lot of semi-automated text editing tasks, I've gotten pretty good at vim macros

@b0rk I've used d with a number to delete changed keys from ~/.ssh/know_hosts and sed -n 's/…/…/p' to preview only the changed lines before running it with -i (but be careful to remove the -n and p!)

anyway I think there's just a real magic to sharing how people actually use our tools in practice, like the strace man page is not a bad man page but it doesn't tell you what kind of things people normally DO with strace, like this stuff: https://jvns.ca/blog/2021/04/03/what-problems-do-people-solve-with-strace/

(3/?)

@b0rk
I volunteer to be the guy in #2 for strace 😄
I recently discovered that you can alter the return of a syscall.
To answer #4 : it was to change setuid and setgid to 0 and "pretend" to be root to a gitlab runner. It might be linked to the fact is was a docker executor with podman

@Seb_Solon @b0rk strace has a --tips which makes a cute clippy give you an strace tip. i used it the other day because i forgot the content of an strace talk i watched.

@leftpaddotpy this is an incredible fact ty

@b0rk Certainly more sophisticated field extraction leans towards awk or perl -e or jq, which might be what you use, but 99% of the time cut is a good-enough part of my "sql-for-log-files" pipeline:

grep *logfile* | cut useful-field | sort | uniq -c | sort -k 1nr | head

Can pretty much produce any single field summary report that SQL can.

Hmm. Maybe that's a topic of interest? What are your go-to pipelines?

@markd yeah i think it’s probably true that I could replace 100% of my use of awk with cut, maybe one day I’ll even remember it exists in a case where it would be useful :)

@Seb_Solon that’s amazing I didn’t know that!

@b0rk I'm not even a developer, but have used strace a few times to troubleshoot why a particular program didn't work when its normal output wasn't particularly useful. I've done this on two separate occasions that I can remember to find out a game or program was simply having trouble finding a file or folder it needed.

@b0rk Be careful using -i with sed. In GNU sed, it’s cursed. In BSD sed, it takes an extension to use for the temporary file (so, if sed or the computer crash, or you run out of disk space, you can recover). You can provide a zero length extension to not create the backup (sed -i "").

The GNU version, as well as accepting a zero-length extension, allows the extension to be omitted entirely. This means that the argument after -i is either an extension or something else and it’s often ambiguous which it should be to a reader which was intended (and I’ve debugged cases where the person who wrote the invocation and the person who wrote the argument parser had different opinions).

@b0rk @markd cut always burns me because it expects fixed delimited columns and awk is more flexible about variable length whitespace when things are pretty-printed.

I do use sed -e '/foo/ d' -e '1d' -e '3 a bar' occasionally to clean up headers or comments or a few bad lines from output to make it parsable by something else, or valid in another format, eg turning something that has embedded JSON, or key=value, with pretty-printed headers and snipping out the machine readable parts to be used

@raven667 @markd ah that’s a great point, maybe that’s (subconsciously) why I always just use awk

@raven667 @b0rk Not sure what Unixen you're on, but FreeBSD/macOS cut has a -w option which is the moral equivalent of $field selection in awk.

But yeah, prior to that, or if you're on other platforms, whitespace fields are best selected with awk/perl.

@markd @raven667 ah yeah I’m on Mac right now but I spent ~20 years mostly on Linux so I guess that’s why

@markd
I use cut and sort all the time, join I used exactly once in 20+ years of being in computers...
@b0rk
replies
0
announces
0
likes
1

@b0rk did you ever build those strace exercises? I wrote these many years ago https://github.com/sit/handson-strace

@emilsit no, I tried a few times but never really found an approach I liked. will look at yours!

@b0rk my approach is to provide some mystery binaries to trace. I was thinking about updating my exercises recently so that they don’t require a local Linux machine, as so many devs have Macs now. I figure with all these cloud IDEs and stuff there must be a way to quickly spin up a container or something that can be accessed in a browser

@emilsit i got into trying to learn firecracker at some point to make lightweight VMs to do this but I ended up realizing that approach still needed a machine with a fair amount of CPU/RAM

@b0rk my two lines of mostly unexplored ideas were to 1) find something like distrosea.com or 2) use something like GitHub code spaces or stackblitz

@emilsit fwiw I've had a lot of success using bubblewrap on fly.io (for https://nginx-playground.wizardzines.com/ and https://memory-spy.wizardzines.com/), there are some permissions issues to work out sometimes but it's been working really well and I feel like it would be ok for strace

@b0rk An exception for me to your crossed-out line number addresses: sometimes (very sometimes) I want to edit the first line (a shebang, maybe) and then sed 1s/... can be useful.

But nowadays I default to using perl to start with. Some things are longer in perl but then you don't need to rewrite your one-liner when it turns out you needed to do something more complicated.