Skip to content

Instantly share code, notes, and snippets.

View kadamwhite's full-sized avatar

K Adam White kadamwhite

View GitHub Profile

Gutenberg grid gap bug reproduction

Minimal FSE theme showing that a Grid layout with both columnCount and minimumColumnWidth ignores a theme.json blockGap preset and computes its columns against a 0.5em fallback. Two columns with a gap larger than 0.5em don't fit, so they collapse to one column.

theme.json sets styles.spacing.blockGap to var:preset|spacing|32. The templates/index.html template renders the same grid twice: once relying on the theme gap (broken) and once with blockGap set on the block (control).

This gist represents a very minimal FSE theme, if you rename templates__index.html to templates/index.html.

@kadamwhite
kadamwhite / loom-transcript-to-srt.js
Created May 13, 2025 18:50
Convert a transcript from Loom into an SRT file which can be used with the video file.
#!/usr/bin/env node
/**
* This script is designed to receive piped content from a text file containing
* a loom.com video transcript, which is usually copyable on the free plan as
* a series of lines in the format
* 0:02 What I said then, etc etc etc...
*
* The output of the script is SRT-format subtitle text. It can be output into
* a .srt file for use in VLC or other subtitle-aware video players, or later
@kadamwhite
kadamwhite / reformat-wp-env-log-output.js
Last active May 6, 2025 19:47
reformat-wp-env-log-output: pipe docker output from `docker logs -f <container>` through this to clean up and simplify the output. Useful for WP-Env or VIP Dev-Env. Can filter out lines with `--suppress=string1,string2`.
#!/usr/bin/env node
// Run with `<command> 2>&1 | this-script` to capture and format log output.
const ipLogPattern = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} .*(POST|PUT|GET|HEAD|DELETE|OPTIONS)/
const logContextPattern = /^\[[^\]]+\] \[[a-z_]+:[a-z_]+\] \[pid[^\]]+\] (\[client [0-9][^\]]+\])?/;
const suppressionListFlag = /^--suppress=/;
const suppressionListArg = process.argv.slice( 2 ).find( arg => suppressionListFlag.test( arg ) );
@kadamwhite
kadamwhite / collapse-directory-structure
Created March 17, 2025 20:03
[Node based] CLI script to take a nested tree of files and render it into a flat list without breaking relative ordering
#!/usr/bin/env node
const minimist = function(t,e){var r={bools:{},strings:{}};"boolean"==typeof(e=e||{}).boolean&&e.boolean?r.allBools=!0:[].concat(e.boolean).filter(Boolean).forEach(function(t){r.bools[t]=!0});var s={};Object.keys(e.alias||{}).forEach(function(t){s[t]=[].concat(e.alias[t]),s[t].forEach(function(e){s[e]=[t].concat(s[t].filter(function(t){return e!==t}))})}),[].concat(e.string).filter(Boolean).forEach(function(t){r.strings[t]=!0,s[t]&&(r.strings[s[t]]=!0)});var o=e.default||{},n={_:[]};Object.keys(r.bools).forEach(function(t){a(t,void 0!==o[t]&&o[t])});var i=[];function a(t,e){var o=!r.strings[t]&&isNumber(e)?Number(e):e;setKey(n,t.split("."),o),(s[t]||[]).forEach(function(t){setKey(n,t.split("."),o)})}-1!==t.indexOf("--")&&(i=t.slice(t.indexOf("--")+1),t=t.slice(0,t.indexOf("--")));for(var c=0;c<t.length;c++){var f=t[c];if(/^--.+=/.test(f)){var l=f.match(/^--([^=]+)=([\s\S]*)$/);a(l[1],l[2])}else if(/^--no-.+/.test(f))a(u=f.match(/^--no-(.+)/)[1],!1);else if(/^--.+/.test(f)){var u=f.match(/
@kadamwhite
kadamwhite / KEYBOARD - Custom Mapping.xml
Last active August 28, 2024 00:03
VirtualDJ controller mappings
<?xml version="1.0" encoding="UTF-8"?>
<mapper device="KEYBOARD" author="Atomix Productions" version="850" date="2024-08-27">
<info>https://www.virtualdj.com/manuals/hardware/keyboard/index.html</info>
<map value="TAB" action="deck active select" />
<map value="CTRL+TAB" action="sideview +1" />
<map value="CTRL+SHIFT+TAB" action="sideview -1" />
<map value="SPACE" action="play_pause" />
<map value="SHIFT+SPACE" action="play while_pressed" />
<map value="ALT+SPACE" action="mix_now" />
<map value="CTRL+SPACE" action="automix" />
@kadamwhite
kadamwhite / annotate-page
Last active March 31, 2026 17:30
Bookmarklet: Annotate or circle things on the webpage
javascript:(function()%7B%2F**%0A%20*%20Annotate%20a%20page%20with%20writeable%20labels.%0A%20*%0A%20*%20Script%20variant%20that%20doesn't%20reposition%20the%20circle%20(which%20is%20a%20rounded%0A%20*%20rectangle%20this%20time)%20when%20you%20release%20the%20mouse.%0A%20*%0A%20*%20This%20version%20(copy%20the%20bookmarklet%20code%20from%20the%20file%20above)%20will%20add%0A%20*%20a%20label%20field%20to%20each%20annotation%2C%20and%20you%20can%20right-click%20an%20annotation%0A%20*%20to%20remove%20it.%0A%20*%2F%0A(()%20%3D%3E%20%7B%0A%20%20%20%20const%20id%20%3D%20'bookmarklet-annotate'%3B%0A%20%20%20%20const%20blanket%20%3D%20document.getElementById(%20id%20)%20%7C%7C%20document.createElement('div')%3B%0A%20%20%20%20if%20(%20blanket.id%20%3D%3D%3D%20id%20)%20%7B%0A%20%20%20%20%20%20%20%20%2F%2F%20Already%20in%20annotate%20mode%3A%20Remove%20blanket%20to%20exit%20annotate%20mode.%0A%20%20%20%20%20%20%20%20blanket.remove()%3B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%7D%0A%20%20%20%20%2F%2F%20Otherwis
@kadamwhite
kadamwhite / block-hierarchy-tracker.php
Last active October 8, 2023 19:55
Block Hierarchy Tracker
<?php
/**
* Plugin Name: Track Rendering Context
* Plugin Author: K. Adam White
* Plugin Description: A system for tracking the rendering of blocks on the page.
*
* USAGE
*
* Activate plugin, then on any page on the site, add ?blocks_log to the URL.
* The block hierarchy will be rendered to the error log.
@kadamwhite
kadamwhite / candy.zsh_theme
Created March 28, 2023 18:11
Customized Candy theme for oh-my-zsh
PROMPT=$'
$(git_prompt_info)[%{$fg[magenta]%}%m%{$reset_color%}%{$fg[white]%}:%{$fg[magenta]%}%~%{$reset_color%}]\
%{$fg[magenta]%}%D{[%H:%M:%S]} %{$reset_color%}%# '
ZSH_THEME_GIT_PROMPT_PREFIX="[%{$fg[magenta]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}]"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}*%{$fg[magenta]%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
@kadamwhite
kadamwhite / efficient-api-resource-fetch-demo.js
Last active February 19, 2023 05:56
Example of how to compose multiple API requests to efficiently fetch related resources.
/**
* WP Post object. Only properties needed by the code are included.
*
* @typedef {object} WPPost
* @property {number} id ID of post.
* @property {number} author Post author ID.
* @property {number[]} categories IDs of associated categories.
* @property {number[]} tags IDs of associated tags.
* @property {number} featured_media ID of featured image.
*/
@kadamwhite
kadamwhite / README.md
Created September 23, 2022 00:13
Cool bug (potential WP core bug?) where meta with multiple rows registered as "single" prevents REST update.

Reproduction Steps

  1. Clone these files into a plugin directory
  2. Activate plugin (will populate several postmeta table rows about most recent posts)
  3. Open that post in the editor
  4. See the textbox in the Publish Status panel with label "Edit me:"
  5. Put any string into that input
  6. Try to save
  7. Encounter error Updating failed. Could not update the meta value of example_post_meta in database.