• 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 Dev Tips

Dev Tips

My Most Valuable Git Aliases are Shell Aliases

Last updated on September 24, 2023 by Sal Ferrarello

While Git supports aliases and I am a big fan of Git aliases, (e.g. ‘git lg’), the most valuable to me (and most used) aliases are shell aliases (e.g. ‘gc’ for ‘git commit’).

Filed Under: Computing, Dev Tips, Recommendations Tagged With: command line, Git, git alias, zsh

GitHub Tab Size Preference

Last updated on September 15, 2023 by Sal Ferrarello

As a WordPress developer, I deal with lots of code indented with tabs (rather than spaces). By default when viewing these files in GitHub, each tab is rendered as 8 spaces. On my personal machine, I render each tab as 4 spaces. This difference makes it less pleasant to view code in GitHub, however, I just learned I can set my preferred tab rendering in GitHub!

Filed Under: Dev Tips, Programming Tagged With: GitHub

Git Rebase and the Multiverse

Last updated on September 17, 2023 by Sal Ferrarello

In “Git Merge and the Multiverse” I looked at merging branches and how sometimes this results in a fast-forward merge and sometimes in the creation of a merge commit. Now let’s look at Git rebase (a.k.a. the power to rewrite history).

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

Git Merge and the Multiverse

Last updated on September 17, 2023 by Sal Ferrarello

If you’re a fan of science (or science fiction), you may be familiar with the concept of the “Multiverse”, the idea that there are multiple universes. In some science fiction stories, one universe can split, branching into multiple universes and then later collapse into a single universe, this is a surprisingly good analogy for Git and branching.

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

Set Number of Characters in Commit Hash for git log

Last updated on August 15, 2023 by Sal Ferrarello

When I’m writing examples, it is often nice to have very short commit hashes. The ‘–abbrev=3’ argument, passed after the ‘–oneline flag, allows me to reduce the number of characters in the commit to 3.

Filed Under: Computing, Dev Tips Tagged With: Git

GitHub Link to Commit instead of Branch

Last updated on August 15, 2023 by Sal Ferrarello

When linking to specific lines in a file to GitHub, it is preferable to link to those lines in the file for a specific commit (rather than for a specific branch). This is because the contents of a branch can change but the contents of a commit remain the same forever.

Filed Under: Computing, Dev Tips, Recommendations Tagged With: GitHub

Why PHP require autoload.php should be wrapped in is_readable()

Last updated on June 30, 2023 by Sal Ferrarello

When using Composer for PHP class autoloading, it is a good practice to wrap your require statement with an is_readable() check. Here are some notes on why this is an important thing to do.

Filed Under: Dev Tips, Programming, Recommendations Tagged With: composer, PHP

How to Close and Re-Open WordPress Gutenberg Sidebar

Last updated on June 30, 2023 by Sal Ferrarello

The sidebar gets a lot of use in the WordPress Block Editor, a.k.a. Gutenberg, but I found myself in a situation where I needed to programmatically close the sidebar and then re-open it later. This is how I did it.

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

Get Last Modified Value of a WordPress Post

Last updated on June 19, 2023 by Sal Ferrarello

When reading an article online, I find it helpful to know when the article was last updated. Not all blogs display the last updated value however even when the last updated value is not displayed, the value is accessible via the WordPress REST API. This is how I retrieve the last modified value from the WordPress REST API.

Filed Under: Computing, Dev Tips, Programming, Solution Tagged With: JSON, REST API, web browser, WordPress

Pretty Print JSON URL

Last updated on May 20, 2023 by Sal Ferrarello

I work a lot with JSON endpoints and having a browser extension to pretty print the JSON response is invaluable. However, sometimes I’m using a different machine (or guiding someone on their machine) and rather than asking them to install a browser extension, I use this trick. If the user is on the page displaying the JSON response, running this command in the browser console will pretty print the response await (await fetch(window.location.href)).json().

Filed Under: Dev Tips, Solution Tagged With: JSON, REST API, web browser

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 22
  • Next Page»

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