Programming Leftovers
-
Bash one liners
I have a graveyard of one-time-use bash one-liners that become either aliases or get wrapped by shell functions in my .zshrc file. I often justify the effort of polishing them and adding to my dotfiles with the excuse that they will be used again in the future. Even if they are never used again, they serve as a library of examples. For every new command, there is always an old one that did a similar thing.
More importantly, these bash one-liners are really fun to write. What once started as a thought to build a new command line application, was first challenged with a “could it be a simple bash script?” and then finally it was reduced to “could I write it one line?”. It’s like my own personal code golf challenge, where I keep trying to make the line smaller and smaller.
-
The tangled problems of asking for people's '(full) legal name'
One response to my entry on the problems with 'first' and 'last' name data fields is that one should make forms that (only) ask for someone's legally recognized name, which should be unambiguous and complete. While superficially appealing, this is a terrible minefield that you should never step into unless you absolutely have to, which is generally because you are legally required to collect this information.
-
Flat in-order binary trees
This article is an in-depth guide to the flat in-order representation of binary trees. We derive efficient operations to navigate these trees, such as finding the tree root and computing the parent and children for each node. We then use this flat representation to implement a novel efficient data structure: extensible segment trees.