Those were not programming tricks, but computing tricks or command line/sql tricks. Anyways I find it mind boggling how many useful actions are not known by „normal people”. Most people are really using computers in a very inefficient way. My idea is if we would spend time making people learn computers or software they use daily better - we wouldn’t need AI agents and we would triple GDP.
Maybe, but there's all sorts of habits and skills that would make us enormously more productive/healthy/etc. if only the masses would learn them. This is a very old problem.
Small programming tricks
201–210 of 211 posts
Re: Small programming tricks
#202Re: Small programming tricks
#203A lot more tricks can be learned from just watching AI work. Instead of allowing AI to work autonomously, go back to the old days where you manually approve every command the AI runs. Just recently while doing performance optimization work, I found Opus using the `perf` command in ways I didn’t know possible. Just give AI a real task and carefully read what commands are used by the AI to solve the problem; most likel…
--date=2026-09-16
--date 20260916
and all variations thereof. It's annoying enough to have to check which script expects what format that I probably should've wasted some time or tokens to align them all, or at least put it into an MD file. But it's just an illustration of how LLMs can make CLI commands more obscure than they need to be.
Re: Small programming tricks
#204bash: Ctrl-L to clear the screen
VSCodium: Shift+Alt+[arrows|mouse click] to select a rectangular block
scp for moving files (instead of ftp)
Re: Small programming tricks
#205`find` does a lot more things than that.
find -name '*.md' -and -not -type d
Of course, then it becomes more obvious why there are parens, why those parens must be escaped for the shell, etc. E.g., find '(' -name '*.md' -and -not -type d ')' -or '(' [...] ')'
I think once someone groks the nature of the expression args, then find becomes easier to start working with.The most messed up part in my mind though is that while most things in find are clearly helping the expression towards its goal of "true" or "false" on whether to include the file or not in the results, some, like -prune or -exec do so but with side-effects. And since they're usually invoked primarily for their side-effect, it isn't immediately obvious that they even return a value, or are participating in the expression itself. (-prune is true, and -exec depends.) And this is where it becomes important that `find`'s -and & -or are short-circuiting, too. (In a purely logical expression, it wouldn't really matter except as an optimization.)
People also sometimes omit -and, which I'm not a huge fan of the legibility of. (But using -and makes it not POSIX; you can do -a but ew. which brings me to the last bit…)
macOS: the find there requires the starting-point arg; so my examples above, on macOS, would all need to be,
find . [expression args...]
… which is lame. Brew install GNU find and be done with that.While I agree with globbing (or fd) for interactive use, I think for scripting I'd still say "you might want find"; there are limits to arg list lengths (see xargs) that (esp. recursive) globs can exceed; unless you know you'll never glob the world, find might be appropriate. Also:
echo *nope*
Globs will betray you on the zero-match case. (`man bash` & cf. `nullglob`.)Re: Small programming tricks
#206Re: Small programming tricks
#207The thing with a lot of these tricks is that you have to get into the habit of using them. I knew `Ctrl+r` for history since I learned about the command line. I even have a nice shell integration with fzf. But I still used the up/down arrow keys for years or scrolled up when I was looking for a previous command, because I never remembered the shortcut and just took the path of least resistance to find something. Usua…
I’ve read that if you’re trying to overturn a habit with a new habit, it’s best to undo whatever it is you did the old way, then redo it the new way. So if you want to use ctrl-r, but you’re using the up key, use the down key to navigate back to a clear line, then use ctrl-r. Do it enough times and your brain will work overtime to find a shortcut (aka just doing it the new way).
Re: Small programming tricks
#208Re: Small programming tricks
#209Those were not programming tricks, but computing tricks or command line/sql tricks. Anyways I find it mind boggling how many useful actions are not known by „normal people”. Most people are really using computers in a very inefficient way. My idea is if we would spend time making people learn computers or software they use daily better - we wouldn’t need AI agents and we would triple GDP.
There's no amount of skill/efficiency/productivity a human worker can reach that will make employers give up on the dream of one day replacing them with software. The AI companies looking to profit from renting out the collected works and creativity of humanity certainly wouldn't shut down if the GDP tripled either.
People should still take time to learn how to use computers though. As long as they're going to use computers they can save themselves a lot of trouble and anxiety by investing some time in learning about them a little. Same with many other things people use and depend on.
Re: Small programming tricks
#210A few tidbits I wish I had known about sooner: bash: Ctrl-L to clear the screen VSCodium: Shift+Alt+[arrows|mouse click] to select a rectangular block scp for moving files (instead of ftp)
Both rsync -avz /path/to/file user@server:/another/path/to/ or rsync -avz /path/to/file/ user@server:/another/path/to/file
Will create directory named /another/path/to/file which will contain all contents of the original directory (/path/to/file/*).
Basically, if you include the trailing slash in the source path, only contents of the directory will be copied (useful when you need to rename it).
rsync -avz path/to/old_dir/ user@server:/path/to/new_dir
If you omit the trailing slash in the source path, rsync will create the target directory for you. See man rsync for more info.