It’s sad, I used to love little tricks like this: optimizing my workflow, learning the keyboard shortcuts, reading the manual. But now I just prompt codex or cc. The appeal of “sharpening the axe” is greatly diminished. I fear much of this type of knowledge will soon be lost to time.
Small programming tricks
181–190 of 192 posts
Re: Small programming tricks
#182Earlier quoted context omitted.
I think that "everyday" would be a stretch, but i dont understand why youd think thats annoying, someone took the time to consider helping the rest of the engineering team grow, by posting something useful. I frequently do the same, but not everyday; only when i think its something actually useful/helpful beyond the everyday crap. Most recently, we have had a huge push to use ai (just like everywhere else), ive been…
Why just one each day then? Why not a shared knowledge base? Do you start with a "bag of tricks" and then hand them out one by one each day to remind people you're the guy with the bag of tricks? "Oh, yeah, I know a cool trick, but y'all have to wait until tomorrow to find out what it is." "Look! It's a way to evaluate SQL expressions with a select with a from! Oh, you already knew about it?" I have nothing against s…
Re: Small programming tricks
#183Re: Small programming tricks
#184I keep a ~/scratch.txt file and a bash alias "scratch" that will just grep it. Then I put a lot of relatively infrequently-used but often-forgetten command recipes in there, so that I can just do "scratch keygen" or whatever and it will find it. It persists longer than bash history. If anything, I wish I had paid a lot more attention to this in the early days and made a nicer shell environment full of my own utilitie…
Re: Small programming tricks
#185The 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…
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
#186Re: Small programming tricks
#187Earlier quoted context omitted.
I'm struggling to comprehend how branches can be avoided (or why one would want to, as they are the cornerstone of programming). I can only think how to obfuscate them, which is rarely useful.
What people refer to when they say "branchless code" is something very particular, and it refers to not triggering the CPU's branch prediction. That is, don't make the CPU have to guess which fork in the code you're going to take. This is usually accomplished in one of two ways: either bit twiddling hacks or specialized instructions that do not affect the CPU's branch prediction, such as the 'cmov' family in x86. If…
If you want to tell the Rust compiler that you're certain a branch predictor can't help here [be very sure, most often humans are wrong which is why historically these "I know better than the branch predictor" features get ignored by optimisers] you can core::hint::select_unpredictable(condition, a, b) rather than using a dedicated operator.
† That's not its actual name, some languages have an operator with three operands which does something else, such as fused multiply-add so in a multi-lingual context better to say explicitly you mean the ternary conditional operator.
Re: Small programming tricks
#188Earlier quoted context omitted.
Clearly I am missing some setting. On zsh on macOS and I tried what you just said and it doesn't work like this
FWIW I'm also on macos 15.7.9, zsh 5.9, oh-my-zsh - and I do get this behavior (TIL). type eg "rg" then up or down arrow, and the history shown is filtered by that rg prefix.
Re: Small programming tricks
#189Earlier quoted context omitted.
Clearly I am missing some setting. On zsh on macOS and I tried what you just said and it doesn't work like this
I was missing it too. Google says it's a builtin zsh feature but mac doesn't turn it on by default, so you add these to `~/.zshrc` bindkey '^[[A' history-search-backward bindkey '^[[B' history-search-forward So far it works. Thank you diath.
Re: Small programming tricks
#190Earlier quoted context omitted.
I found atuin way too hard/slow to use, I think I went two days before I nuked it and went back to pure omzsh. Has it gotten any better in the past 2ish years?
(hi! I work on atuin!) yes, it's improved a lot in the last couple of years! what in particular bothered you?