Skip to content

Instantly share code, notes, and snippets.


K Adam White kadamwhite

View GitHub Profile
kadamwhite / trait-csv-report.php
Created Feb 11, 2022
A PHP trait to write data from WP-CLI to a CSV, in a memory-friendly and won't-lose-data-if-CLI-errors way.
View trait-csv-report.php
* Simplify progressive generation of a CSV output file. Permits a command to
* write each row to a CSV as records are considered, avoiding the need to
* maintain the entire dataset in memory.
/* phpcs:disable HM.Files.ClassFileName.MismatchedName */
// (HM's standards want this to be class-*, which is misleading.)
kadamwhite /
Last active Jul 26, 2022
ffmpeg command "cheat sheet"

ffmpeg cheat-sheet


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 / ExcludeMediaQueriesPlugin.js
Created Apr 22, 2021
A Webpack plugin to remove media queries matching certain patterns from a generated CSS file.
View ExcludeMediaQueriesPlugin.js
* This file defines the project-level Webpack production configuration. It
* combines configs from all relevant plugins and themes into one single
* array (a "multi-configuration" Webpack setup) and runs those builds in
* a single pass.
const { basename, extname } = require( 'path' );
const postcss = require( 'postcss' );
const filtermq = require( 'postcss-filter-mq' );
kadamwhite /
Created Mar 4, 2021
Bash script to run PHPCS against only files which have changed since branching off a specific base branch.
#/usr/bin/env bash
# Usage:
# Run this script (via an npm run alias) with no arguments to compute the
# issues in files changed since you branched from "development."
# npm run lint:php:changed
# Pass a specific branch name as the first argument to determine which files
kadamwhite / geo.js
Created Feb 16, 2021
Script to create an SVG visual representation of a page's DOM nesting
View geo.js
const equalPoint = ( x1, y1, x2, y2 ) => ( x1 === x2 && y1 === y2 );
const sum = nums => nums.reduce( ( sum, num ) => sum + num, 0 );
// See
const linesIntersect = ( x1, y1, x2, y2, x3, y3, x4, y4 ) => {
if (
equalPoint( x1, y1, x3, y3 ) ||
equalPoint( x1, y1, x4, y4 ) ||
equalPoint( x2, y2, x3, y3 ) ||
kadamwhite / summarize-altis-traefik-logs
Created Feb 10, 2021
Use like `docker logs docker_proxy_1 --follow | summarize-altis-traefik-logs
View summarize-altis-traefik-logs
#!/usr/bin/env node
const { match } = require('assert');
const { parse } = require('path');
const readline = require('readline');
const { getContainers, matchContainerByURL } = require( '/home/kadam/bin/get-docker-ips' );
// Figure out if we asked for a certain number of events, or else show the 20 most recent.
const [ , , flag, val ] = process.argv;
let eventCount = 20;
kadamwhite / get-docker-ips.js
Last active Feb 10, 2021
Node script to print out all running docker containers by IP
View get-docker-ips.js
#!/usr/bin/env node
const child_process = require( 'child_process' );
* Execute a command as a spawned process.
* @param {String} command A bash command string, excluding arguments.
* @param {String[]} args An array of argument strings for the provided command.
kadamwhite / ddr_test.pde
Last active Jan 31, 2021
Processing Sketch controlled by USB DDR pad
View ddr_test.pde
// 1. Plug in the controller before running sketch
// 2. Follow the steps below once to download the Game Control Plus library
// In the "Sketch" menu in Processing's menubar, go to
// Sketch > Import Library > Add Library
// Then search for "Game Control". You should find a library called "Game Control Plus";
// install it and let Processing download all the files.
kadamwhite /
Created Sep 11, 2020
A shell script to add "Kurosawa mode" (as implemented in the videogame Ghost of Tsushima) to your webcam, tested with a Logitech c920 on Ubuntu. Run "bash on" or make it an executable and run `kurosawa on` to activate high-contrast black-and-white; run with "off" to disable/reset.
#!/usr/bin/env bash
if [ $MODE = "on" ]; then
v4l2-ctl -d /dev/video0 --set-ctrl=saturation=0,contrast=190,brightness=105
elif [ $MODE = "off" ]; then
v4l2-ctl -d /dev/video0 --set-ctrl=saturation=128,contrast=128,brightness=120
kadamwhite / convert-to-gif
Created Mar 9, 2020
Gif conversion script
View convert-to-gif
#!/usr/bin/env node
This script will clip a segment of a video file into a gif, using techniques
described in these resources: