Skip to content

Instantly share code, notes, and snippets.

View kadamwhite's full-sized avatar

K Adam White kadamwhite

View GitHub Profile
@kadamwhite
kadamwhite / dashed_rectangle.pde
Last active April 24, 2019 02:03
Dashed Rectangle (Processing)
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 ) {
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
kadamwhite / convert-to-gif
Last active January 9, 2019 19:12
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`
#!/usr/bin/env node
/*
This script will clip a segment of a video file into a gif, using techniques
described in these resources:
https://engineering.giphy.com/how-to-make-gifs-with-ffmpeg/
https://video.stackexchange.com/questions/4563/how-can-i-crop-a-video-with-ffmpeg
https://askubuntu.com/questions/648603/how-to-create-an-animated-gif-from-mp4-video-via-command-line
https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo
@kadamwhite
kadamwhite / hmr-helpers.js
Created October 31, 2018 18:18
Gist of how I auto-load plugin and block code within a Gutenberg project.
const { blocks, plugins } = wp;
const { dispatch, select } = wp.data;
/**
* 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
kadamwhite / File Structure.md
Last active October 17, 2018 22:14
Helpers I use for local WordPress development.

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
kadamwhite / api-testbed.js
Last active March 18, 2019 19:39
wpapi lightweight testbed
/* 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;
@kadamwhite
kadamwhite / chassis-openssl-readme.md
Created July 3, 2018 20:12
Proposed roborourke/chassis-openssl README change (WIP0)

Adding the certificate to your keychain

To avoid the red "your connection is not encrypted" message, you'll have to add the generated .cert to your keychain.

macOS

sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain yourlocaldomain.cert
@kadamwhite
kadamwhite / scrape-gutenberg-handbook.js
Created May 22, 2018 21:44
Scrape Gutenberg handbook content to local markdown & images
/*
-------------
mkdirp usage:
-------------
var mkdirp = require('mkdirp');
mkdirp('/tmp/foo/bar/baz', function (err) {
if (err) console.error(err)
else console.log('pow!')
@kadamwhite
kadamwhite / albumArtSelector.js
Last active June 18, 2018 17:11
Paste into Dev Tools while running Plex to automatically work through your library and assign default album art.
var albumArt = (() => {
// Helpers
// (e.g. DOM shortcuts and class-checking utilities)
var qsa = ( container, selector ) => [ ...container.querySelectorAll( selector ) ];
var nodeHasClass = ( node, str ) => node.classList.toString().indexOf( str ) > -1;
var whereNodeHasClass = ( str ) => ( node ) => nodeHasClass( node, str );
var wherePropertyLike = ( obj, str ) => {
const key = Object.keys( obj ).find( key => key.indexOf( str ) > -1 );
return key ? obj[ key ] : null;
@kadamwhite
kadamwhite / .eslintrc
Created March 19, 2018 19:48
object-curly-newline-named-import-issue.js
{
"root": true,
"env": { "es6": true },
"extends": [
"eslint:recommended"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {