Skip to content

Instantly share code, notes, and snippets.

View kadamwhite's full-sized avatar

K Adam White kadamwhite

View GitHub Profile
@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 / ffmpeg-cheat-sheet.md
Last active December 15, 2024 22:39
ffmpeg command "cheat sheet"

ffmpeg cheat-sheet

Video

Compressing x265

ffmpeg -i INPUT_FILE.mkv -c copy -pix_fmt yuv420p10le -c:v libx265 -preset slow -crf 27 -profile:v main10 OUTPUT_FILE.mkv
@kadamwhite
kadamwhite / routes.php
Created November 15, 2015 21:47
WordPress routes with no backing content page: RFCodeReview
<?php
/*
THE GOAL:
Programmatically specify routes critical to the successful functioning
of the application, without any requirement for pages to be set up that
use specific templates or have specific names
THIS APPROACH:
@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 July 17, 2024 17:54
Bookmarklet: Annotate or circle things on the webpage
javascript:'use strict'%3B(()%3D>%7Bfunction l(%7Bx%3Ae%2Cy%3Af%7D)%7Bconst a%3Ddocument.createElement("div")%3Ba.style.position%3D"absolute"%3Ba.style.display%3D"none"%3Ba.style.border%3D"7px dotted hotpink"%3Ba.style.borderRadius%3D"1rem"%3Ba.style.display%3D"block"%3Ba.style.height%3D0%3Ba.style.left%3D%60%24%7Be%7Dpx%60%3Ba.style.top%3D%60%24%7Bf%7Dpx%60%3Ba.style.width%3D0%3Bconst b%3Ddocument.createElement("DIV")%3Bb.classList.add("annotation-label")%3Bb.contentEditable%3D!0%3Bb.style.background%3D"rgba(255%2C255%2C255%2C0.9)"%3Bb.style.transform%3D"translateY(-60%25)"%3Bb.style.color%3D"hotpink"%3Bb.style.display%3D"inline-block"%3Bb.style.minWidth%3D"100px"%3Bb.style.padding%3D"0.25rem 0.5rem"%3Bb.style.marginLeft%3D"0.75rem"%3Bb.style.fontWeight%3D800%3Bb.style.fontSize%3D"24px"%3Bb.style.whiteSpace%3D"nowrap"%3Ba.appendChild(b)%3Bb.addEventListener("pointerdown"%2Cc%3D>%7Bc.stopPropagation()%7D)%3Ba.addEventListener("contextmenu"%2Cc%3D>%7Bc.preventDefault()%3Ba.remove()%7D)%3Bconst g%3Dc%3D>%7Ba.st
@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 / data-cameraCount.csv
Created September 30, 2015 12:44
Processing line chart
date cameraCount
20120701 1
20130315 2
20130605 1
20130708 2
20131229 3
20140316 4
20140729 5
20150223 6
20150426 5
@kadamwhite
kadamwhite / tracking.js
Created April 23, 2012 13:41
A more flexible SiteCatalyst link tracking script wrapper
// Wrapper function for native Omniture SiteCatalyst link tracking (s.tl())
var trackLink = function (referenceObject, trackingData, targetReportSuite) {
if (typeof referenceObject === 'undefined' || typeof trackingData === 'undefined') {
// If you're missing your settings object or any variables/events to fire, you fail
return;
}
var linkTrackVarsArray = [],
// Get values out of the configuration object
tEvents = trackingData.events, // String || undefined
tVars = trackingData.variables, // Object || undefined
@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.
*/