• 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 Programming

Programming

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

Sleep Inside JavaScript Async Function

Last updated on March 31, 2025 by Sal Ferrarello

Typically, the point of a JavaScript async function is to not block execution but occasionally I do want to introduce a delay in an async function (e.g. as part of a delay before retrying a remote call).

Filed Under: Programming Tagged With: JavaScript

unregisterFormatType() for Specific Block Type in Gutenberg

Last updated on February 17, 2025 by Sal Ferrarello

The WordPress block editor (a.k.a. Gutenberg) allows formatting in RichText fields via the Formatting Toolbar API](. Each type of formatting (e.g. Bold and Italic) is a “formatType”. Here we’ll look at removing one of these formatTypes from a specific block type (e.g. removing Bold from the core paragraph block).

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

PHP class_exists() check without the Fully Qualified Class Name

Last updated on June 28, 2024 by Sal Ferrarello

Sometimes you need to write PHP code that includes a check that the class you want to use exists. Because you need to provide the fully qualified class name (the namespace and the classname) our code can end up looking a little messy – but there is a better way.

Filed Under: Dev Tips, Programming, Solution Tagged With: PHP

Loop Through WordPress Multisite Blogs with WP CLI

Last updated on September 3, 2024 by Sal Ferrarello

When working on a WordPress multisite with WP CLI, it can be helpful to loop through all of the individual sites.

Filed Under: Dev Tips, Programming, Solution Tagged With: wp-cli

Pure Functions – The Secret to Writing Easily Testable Code

Last updated on June 1, 2024 by Sal Ferrarello

Unit tests are a wonderful tool for programmers. They allow you to ensure an individual part of your code base performs exactly the way you intend. Unit tests are ideal for testing pure functions and therefore it is beneficial to write pure functions.

Filed Under: Computing, Dev Tips, Programming Tagged With: unit-test

Replace Local Git Branch with Branch on GitHub

Last updated on March 30, 2024 by Sal Ferrarello

There are times when I want to dispose of my local branch and replace it with the version on GitHub (the upstream version). For example, when I’m reviewing a teammate’s pull request and they rewrite history (e.g. perform a rebase or amend a commit), I don’t have any work on that branch and I only want their updated version.

Filed Under: Computing, Dev Tips, Programming, Solution Tagged With: Git, git alias

Is Git Branch Up to Date

Last updated on February 23, 2024 by Sal Ferrarello

I often want to determine if my current Git branch is up to date with some other branch. One specific scenario is when I want to check if my current “feat/” branch is up to date with “main” (i.e. no new commits have been introduced in “main” that aren’t in “feat/”).

Filed Under: Computing, Dev Tips, Programming, Solution Tagged With: Git, git alias

Get Jira Issue Title via REST API

Last updated on February 11, 2024 by Sal Ferrarello

I wanted to programmatically retrieve the title of a Jira issue in a script I was working on. These are my notes on how I did it.

Filed Under: Dev Tips, Programming, Solution Tagged With: Jira, REST API

Quick and Dirty WP CLI

Last updated on January 19, 2024 by Sal Ferrarello

During development or troubleshooting I often find myself wanting to run something through WP CLI. These are some notes on running code through WP CLI.

Filed Under: Dev Tips, Programming Tagged With: WordPress, wp-cli

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

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