Skip to content

Instantly share code, notes, and snippets.

View kadamwhite's full-sized avatar

K Adam White kadamwhite

View GitHub Profile
@kadamwhite
kadamwhite / summarize-altis-traefik-logs
Created February 10, 2021 19:34
Use like `docker logs docker_proxy_1 --follow | 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
kadamwhite / get-docker-ips.js
Last active February 10, 2021 18:00
Node script to print out all running docker containers by IP
#!/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
kadamwhite / ddr_test.pde
Last active January 31, 2021 19:30
Processing Sketch controlled by USB DDR pad
// PREREQUISITES!
//
// 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
kadamwhite / korosawa.sh
Created September 11, 2020 19:23
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 kurosawa.sh 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
MODE="$1"
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
fi
@kadamwhite
kadamwhite / convert-to-gif
Created March 9, 2020 17:25
Gif conversion script
#!/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
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
kadamwhite / store-provider.test.tsx
Created December 10, 2019 00:22
TypeScript Gutenberg connected component test
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', () => {
afterEach(cleanup);
@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