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

Programming

Manually Trigger WordPress Heartbeat from Browser

Last updated on August 2, 2021 by Sal Ferrarello

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.

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

Filed Under: Computing, Dev Tips, Draft, Programming, Solution Tagged With: WordPress, WordPress Heartbeat

What are PHP Namespaces?

Last updated on January 28, 2023 by Sal Ferrarello

When two functions (or classes) have the same name, it triggers a fatal error in PHP. Namespaces are used to avoid these naming collisions.

Filed Under: Computing, Programming Tagged With: namespace

WordPress Hooks and PHP Namespaces

Last updated on July 22, 2021 by Sal Ferrarello

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.

Filed Under: Dev Tips, Programming, Recommendations Tagged With: PHP, WordPress, WordPress Filter

phpunit.xml vs phpunit.xml.dist

Last updated on April 20, 2021 by Sal Ferrarello

As a PHP programmer I’ve seen projects with a phpunit.xml file or a phpunit.xml.dist file (or even both, which is a mistake). These are configuration files for PHPUnit but why the two different file names? PHPUnit first tries to use phpunit.xml and if that file does not exist, then it tries to use phpunit.xml.dist instead. PHPUnit only uses one of these files, never both.

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

Filed Under: Dev Tips, Draft, Programming, Recommendations Tagged With: PHP, PHPUnit

JavaScript Or (||) Versus Nullish Coalescing Operator (??)

Last updated on November 3, 2022 by Sal Ferrarello

The “or” (||) operator and the “nullish coalescing operator” (??) can often be used in similar ways when reading a property from an object that may or may not exist. When dealing with strings you’re typically better off using “or” (||) and for numbers you’re typically better off using the “nullish coalescing operator” (??).

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

Filed Under: Dev Tips, Draft, Programming, Recommendations Tagged With: JavaScript

SemVer TLDR

Last updated on April 3, 2021 by Sal Ferrarello

Semantic versioning (SemVer) is a standard for defining the version numbers. A version number consists of three numbers separated by periods (X.Y.Z). The type of change being introduced (e.g. a new feature or a change that breaks backwards compatibility) determines which numbers are incremented.

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

Filed Under: Computing, Dev Tips, Draft, Programming, Recommendations Tagged With: composer, npm, semver

Building blocks representing two Git branches, one with a merge commit where the top commit has two parents.

Git Merge Commit with Blocks

Last updated on May 9, 2022 by Sal Ferrarello

We can’t do a fast-forward merge when the most recent commit on the receiving branch does not appear in the branch we are merging in. One of our options in this situation is to create a merge commit when we merge in our branch.

Filed Under: Dev Tips, Programming Tagged With: Git

What is a Git Branch?

Last updated on February 7, 2021 by Sal Ferrarello

While my mental model visualizes a Git branch as a stack of building blocks, in actuality a Git branch is a pointer to a single commit. Under the hood Git stores a text file for each branch and in the text file is a single line, which is the commit hash indicating the commit at the tip of that branch.

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

Filed Under: Dev Tips, Draft, Programming Tagged With: Git

What is a Git Commit?

Last updated on February 7, 2021 by Sal Ferrarello

A Git commit, represented by a single building block in my Git mental model, is a frozen moment in time for your project (sometimes referred to as a snapshot). Along with this snapshot Git stores metadata about the commit (e.g. the author of the commit). Each commit has a unique identifier called the commit hash (a.k.a. SHA), a 40 character long alphanumeric string that is often abbreviated to just the first seven characters (e.g. “2b3a38b”).

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

Filed Under: Computing, Draft, Programming Tagged With: Git

Building blocks representing two Git branches with the commit on one branch removed as happens in a rebase.

Git Rebase with Blocks

Last updated on March 4, 2021 by Sal Ferrarello

We can’t do a fast-forward merge when the most recent commit on the receiving branch does not appear in the branch we are merging in. One of our options in this situation is to rebase the branch we want to merge in.

Filed Under: Dev Tips, Programming Tagged With: Git, rebase

  • «Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to page 5
  • Interim pages omitted …
  • Go to page 18
  • Next Page»

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