Skip to content

Instantly share code, notes, and snippets.


K Adam White kadamwhite

View GitHub Profile
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:
View rotary-bar-chart.pde
float fillColor;
void setup() {
size(300, 200);
background(255, 255, 255);
fill(0, 0, 0);
// Draw one bar graph on the left, starting from the bottom and working clockwise
kadamwhite / store-provider.test.tsx
Created Dec 10, 2019
TypeScript Gutenberg connected component test
View store-provider.test.tsx
import React from 'react';
import { render, cleanup, fireEvent } from '@testing-library/react';
import { useSelect, useDispatch } from '@wordpress/data';
import '@testing-library/jest-dom/extend-expect';
import { storeProvider } from '../store-provider';
describe('storeProvider', () => {
kadamwhite / dashed_rectangle.pde
Last active Apr 24, 2019
Dashed Rectangle (Processing)
View dashed_rectangle.pde
import processing.pdf.*;
//boolean saveOneFrame = false;
int randomInt( int min, int max ) {
return floor( random( min, max ) );
void dashedHorizontalLine( int x1, int y1, int x2, int y2 ) {
if ( y1 != y2 ) {
View Thing.js
var { convert, svgify } = (() => {
function sum( collection, prop ) {
return collection.reduce( ( sum, item ) => sum + item[prop], 0 );
function testEq( a, b ) {
if ( a !== b ) {
throw new Error( `Expected ${ a } to equal ${ b }` );
kadamwhite / convert-to-gif
Last active Jan 9, 2019
Spider a directory and make a short gif from each one. Ensure convert-to-gif is in your path before running `node make-gifs.js`
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:
kadamwhite / hmr-helpers.js
Created Oct 31, 2018
Gist of how I auto-load plugin and block code within a Gutenberg project.
View hmr-helpers.js
const { blocks, plugins } = wp;
const { dispatch, select } =;
* When a selected block is being disposed during a hot module reload, persist
* its clientId so it may be reselected after the new module version loads.
* If the block being unloaded is currently selected, clear that selection to
* avoid a Gutenberg error that occurs when unregistering a selected block.
kadamwhite / File
Last active Oct 17, 2018
Helpers I use for local WordPress development.
View File

Local WordPress Core Development Helpers

This is a collection of scripts, bash functions, and config files that help me do WordPress core development.

Folder Structure

  • /wp: parent folder
  • /wp/svn: SVN checkout
  • /wp/git: Git checkout
  • /wp/{ git | svn }/wp-test-config.php: see attached file
kadamwhite / api-testbed.js
Last active Mar 18, 2019
wpapi lightweight testbed
View api-testbed.js
/* eslint-disable no-console */
* A little module that adds a wpapi() method to the window object.
* wpapi() takes an API path (e.g. /wp/v2/posts), optionally containing string query parameters,
* or a query-less API path and a hash object of query param objects.
( context => {
const { root, nonce } = context.WP_API_Settings;
You can’t perform that action at this time.