• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (deprecated)
You are here: Home / Archives for Computing

Computing

Add Element to Array if It Does Not Already Exist with jq

Last updated on March 24, 2026 by Sal Ferrarello

This is how I use jq to conditionally add an element to an array only if it doesn’t exist there already. In other words, add an element to an array only if it doesn’t create a duplicate in the array. This is particularly helpful when I’m scripting a JSON transformation and want to make it idempotent.

Filed Under: Computing, Dev Tips, Programming, Solution Tagged With: jq

Write Slack Posts in Markdown

Last updated on January 14, 2026 by Sal Ferrarello

By default, Slack provides you with a Formatting toolbar and a WYSIWYG editor. I’m a big fan of writing in Markdown rather than WYSIWYG and use it everywhere I can. Fortunately, I can configure Slack to write in Markdown (or more accurately Slack’s subset of Markdown).

Filed Under: Computing, Recommendations Tagged With: slack

Filter Meta in WordPress Gutenberg Block Editor

Last updated on January 10, 2026 by Sal Ferrarello

I work with WordPress sites that have lots of meta fields exposed through the REST API. Within Gutenberg, I’m often checking those values by querying the “meta” attribute in the data. Sometimes the larger number of meta fields makes it difficult to find the specific fields I’m interested in. To make my life easier, I’ve put together a code snippet that filters the keys in the meta object that is returned.

Filed Under: Computing, Dev Tips, Solution Tagged With: Gutenberg, WordPress

Vim Increment Number With Dash

Last updated on November 4, 2025 by Sal Ferrarello

In Neovim, I’m a big fan of CTRL-a to increment a number (and CTRL-x to decrement a number), however when I have dash before the number (e.g. “sprint-23”), this is interpreted as a negative number so incrementing the value
goes to 22 (because -22 is one greater than -23). We can fix this.

Filed Under: Computing, Solution Tagged With: neovim, vim

xargs: warning: options –max-args and –replace/-I/-i are mutually exclusive, ignoring previous –max-args value

Last updated on August 1, 2025 by Sal Ferrarello

This threw me for a loop so I’m writing this down to help others (and likely me in the future). I swear I’ve used “xargs” with both “-I” and “–max-args” in the past but now I’m getting this warning and things are behaving improperly. It turns out there are two version of xargs, (FreeBSD xargs and GNU xargs). FreeBSD xargs is installed on BSD systems (including MacOS) and GNU xargs is found on on Linux systems. This warning (and the incorrect result you also get) indicate you’re running GNU xargs.

Filed Under: Computing, Dev Tips, Solution Tagged With: command line, xargs

Git Editor Roulette

Last updated on July 4, 2025 by Sal Ferrarello

A question came up about setting the Git editor to a bash function, which I could not figure out. I was, however, able to set the Git editor to a bash script. As a proof of concept, here is a bash script to randomly choose an editor (nano or vim) when using Git.

Filed Under: Computing, Dev Tips, Solution Tagged With: command line, Git, git log

Git Squash Back To

Last updated on July 31, 2025 by Sal Ferrarello

Often in my work, I’ll create a number of commits before I craft my correct solution. Having these missteps in separate commits doesn’t provide any real value and adds noise so I’ll often squash these commits into a single commit. Historically, I’ve used a Git interactive rebase to do this but as I was reminded on Mastodon, it seems like there should be a quicker way, so I’ve created a Git alias, “git squashbackto”, to do this.

Filed Under: Computing, Dev Tips, Solution Tagged With: command line, Git, git alias, rebase, vim

Mac Maximize Window with Alfred

Last updated on June 22, 2025 by Sal Ferrarello

One of the things that frustrates me about Apple Macs (macOS) is clicking the green sizing button in the upper-left hand corner makes a window full screen. I almost never want to go full screen. What I typically want is to maximize the window (fill up the entire area while leaving the toolbar visible). This can be done by holding down “Option” while you click the green button (but I find I mess that up often enough that I wanted another solution).

Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Computing, Dev Tips, Draft, Solution Tagged With: Alfred

Get GitHub PR Number from Current Branch

Last updated on June 3, 2025 by Sal Ferrarello

When scripting a task using the GitHub CLI, I found I needed the Pull Request (PR) number for my current branch (technically my current commit). I was able to use “gh pr view” to get the information.

Filed Under: Computing, Dev Tips, Solution Tagged With: bash script, command line, GitHub, GitHub CLI

WP CLI Get Current Theme

Last updated on October 30, 2024 by Sal Ferrarello

I thought retrieving the currently active theme on a WordPress website with WP CLI would involve the “wp theme” command but I was wrong. The correct command to get the currently active theme is “wp option get current_theme”.

Filed Under: Computing, Dev Tips, Solution Tagged With: WordPress, WordPress Theme, wp-cli

  • Page 1
  • Page 2
  • Page 3
  • Interim pages omitted …
  • Page 14
  • Next Page»

Copyright © 2026 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in