A common programming pattern when using WordPress filters is the early return pattern (also know as the “short-circuit” pattern). This pattern is useful when you want to allow a filter to override a value that is “expensive” to calculate.
QMK 65% Esc and Backtick
When I downsized to a 65% keyboard I knew I was giving up function keys and a number pad but what caught me off-guard was the loss of my backtick (a.k.a. grave accent(`)) key. Because my keyboard runs QMK firmware, I’ve tried a number of modifications.
QMK Drop Alt
I replaced my keyboard of many years with a Drop.com Alt keyboard. This keyboard uses QMK firmware, which allows you to create modified firmware and run it on your keyboard. These are my notes about how I built a copy of the firmware locally and pushed it to my keyboard.
zsh alias with fallback
In my zsh configuration I define a number of aliases. One particular zsh alias maps gl to my custom Git alias “git lg”. Since my zsh configuration is portable, I want to define a fallback if my custom Git alias does not exist on the machine.
Manually Trigger WordPress Heartbeat from Browser
When developing code related to the WordPress heartbeat, it is frustrating to make your code changes and then wait for the next heartbeat to occur. You can trigger the WordPress heartbeat in the browser manually to eliminate this delay.
What are PHP Namespaces?
When two functions (or classes) have the same name, it triggers a fatal error in PHP. Namespaces are used to avoid these naming collisions.
WordPress Hooks and PHP Namespaces
While PHP namespaces allow you to refer to a function in file without using the fully qualified name, there is a catch when adding a WordPress hook or filter. The PHP __NAMESPACE__ magic constant can be helpful in this situation.
Shampoo Bottle Protocol
One day I realized that the last 10% of the shampoo bottle lasted at least as long as the first 90%. I suspected this was because most of the time I was using too much shampoo but as I neared the end of the bottle I used a more appropriate amount. How could I trick my brain to always use the appropriate amount?
Brady Bunch Achievement
The “Brady Bunch Achievement” is when you have exactly nine people on a video call. When this happens, viewing all participants in a grid looks like the intro to the Brady Bunch.
Remove newline at end of text file
Sometimes when I’m working with files in Git, I find myself with a change in a file that says “No newline at end of file”. This occurs when my editor adds the missing newline at the end of the file. While you should have a newline at the end of the file, you may have a reason for not wanting to add this change. In that case, you can remove the newline from the end of the file.