Skip to content

Instantly share code, notes, and snippets.

joemaller / call-exec.js
Created January 26, 2024 23:34
Mock child_process.exec in module in Vitest
import { exec } from "node:child_process";
export function callExec() {
return new Promise((resolve, reject) => {
exec(`ls -la`, (error, stdout, stderr) => {
if (error) {
if (stdout) {

News to Posts Migration

  1. Update the iop-theme to >2.28.0
  2. Update iop-data-model to >0.4.0
  3. Delete all existing Posts in wp-admin
  4. Change all News posts' post_type to Posts in phpMyAdmin:
    UPDATE `wp_posts` SET `post_type` = 'post' WHERE `post_type` = 'news';
  5. Update permalink Custom Structure to /news/%postname%/

How to run phpcs on WordPress-Develop files without installing PHP

I've been running all my dev projects via Docker to avoid the pitfalls of installing server software on my computer. This also lets me jump between macheines very easily since everything I need is wrapped up in dockerfiles, docker-compose files or package.json scripts.

WordPress development doesn't work like that. The default development environment expects PHP to be installed and will try to run PHPCS validation checks from a local instance of PHP.

Use Composer's Docker image

The official Composer Docker image is extremely versatile. It can run arbitrary shell commands if the passed argument isn't a Composer keyword.

joemaller /
Last active September 29, 2023 02:41
How WordPress includes minimized script snippets for blocks in use.

WordPress v6.3.1 inlines styles for used blocks via the wp_head hook. However there is an additional wrinkle. If the SCRIPT_DEBUG constant is set and truthy, then a minimized copy of the styles will be inlined. The minimized copy is pre-generated and included with WordPress.

Code for choosing to use the min variant is in wp-includes/blocks.php:

// Check whether styles should have a ".min" suffix or not.
$suffix = SCRIPT_DEBUG ? '' : '.min';
if ( $is_core_block ) {
    $style_path = ( 'editorStyle' === $field_name ) ? "editor{$suffix}.css" : "style{$suffix}.css";
joemaller / wsl-port-proxy.json
Created March 3, 2023 20:08
script and config file for configuring WSL 2 portproxy rules
"ports": [3000, 5173, 8000]
joemaller / conversion.js
Created November 15, 2022 15:48
Question about preferred code conversion
// Starting with an API returned data structure like this:
const Parameters = [
Name: "PASS",
Type: "SecureString",
Value: "cGFzc3dvcmQ=",
Version: 3,
LastModifiedDate: "2022-11-14T15:13:08.263Z",
ARN: "arn:aws:ssm:us-east-1:678000000000:parameter/PASS",
joemaller / curl-format.txt
Created November 8, 2022 20:13
Template for reporting connection times from curl connections. More here:
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
time_total: %{time_total}\n
joemaller / harrassment-training-bot.js
Created October 6, 2022 14:56
bot for helping test online training. Kind of garbage, but maybe useful in the future.
* For ADP's 2022 sexual harrassment training
cr = () => {
const next = $('')
if (next.length) {;
joemaller /
Created September 23, 2022 20:30
Case Conversion examples

Input: my name is bond

Name Sample
🐪 Camel case myNameIsBond
👨‍🏫 Pascal case MyNameIsBond
🐍 Snake case my_name_is_bond
👩‍🏫 Ada case My_Name_Is_Bond
Ⓜ️ Macro case MY_NAME_IS_BOND
🥙 Kebab case my-name-is-bond
joemaller / index.html
Last active September 9, 2022 16:28 — forked from d3noob/index.html
Add multiple markers in leaflet.js
<!DOCTYPE html>
<title>Simple Leaflet Map</title>
<meta charset="utf-8" />