Given a string like “2022-01-01 13:00:00”, which represents a time in the “Europe/Paris” timezone, how can we get the corresponding Unix Timestamp in JavaScript? This problem is sufficiently complex that in my opinion leveraging a third-party library is the best solution.
Dev Tips
Local by Flywheel from Sub-Directory
I was recently working on a project that loaded WordPress from a sub-directory. The result of which is if I cloned the project into the “public” directory, the WordPress files and directories were one level deeper (in “public/wordpress”).
WordPress Gutenberg Notice in JavaScript
You can display four types of notices in the WordPress Block Editor (a.k.a. Gutenberg) using JavaScript: error, warning, info, and success. This blog post contains an example of each.
Disable Core WordPress Update Notice
When working on projects, I often want to strictly control the version of WordPress that is running. However sometimes one of the other administrators on the site sees the “WordPress 5.9 is available! Please update now.” message and clicks it, thereby prematurely updating to a newer version of WordPress core. This notice can be disabled.
git reset –hard vs git checkout -f
I recently had a conversation about “git reset –hard” vs “git checkout -f”, and it turns out they do the same thing. This is one of the tricky things about Git, there are often multiple ways to do the same thing.
git alias tab completion for functions
When creating a Git alias that points to a function, sometimes Git provides the wrong tab completion by default (e.g. filename completion instead of branch name completion). This is how we can tell Git, which type of completion to use.
git reset vs revert
Conceptually, “git reset” is erasing your last change while “git revert” is adding a new change that undoes your previous change.
Check CORS Value from Command Line
I was checking a number of URL endpoints for CORS restrictions today and I wondered if I could check from the command line. Here are some example curl statement that get me the information I’m looking for. I think there is an opportunity for a custom function here but for now, these notes will do.
Display Keyboard Shortcut in WordPress Gutenberg
In Gutenberg (a.k.a. the WordPress Block Editor), keyboard shortcuts are displayed differently on Apple devices and other devices, e.g. ^H on an Apple device and Ctrl+H on other devices. This is accomplished with wp.keycodes.displayShortcut.
Using jq and nvm to set Node version
The nvm command allows you to switch between versions of node. Often a project will include a .nvmrc file to specify the version of node to use. Even if a project does not contain an .nvmrc file, you may be able to read the preferred node version from package.json and use that value with nvm.