Skip to content

Instantly share code, notes, and snippets.

@iandunn
iandunn / test-nearby-events.php
Last active May 11, 2017 18:09
mu-plugin to test nearby events
<?php
// type "error" into the city name field to simulate an HTTP request error
function nearbywp_trigger_error( $request, $request_args, $request_url ) {
$url_params = explode( '&', parse_url( $request_url, PHP_URL_QUERY ) );
if ( in_array( 'location=error', $url_params ) ) {
$request = new WP_Error( 'test', 'testing error condition' );
}
@iandunn
iandunn / qtmono.sh
Created June 5, 2017 02:07
Alias to convert a stereo recording to mono
# Alias to convert a stereo recording to mono
#
# $1 - The input filename
function qtmono {
basename=$(basename "$1")
filename="${basename%.*}"
extension="${basename##*.}"
ffmpeg -i $1 -codec:v copy -af pan="mono: c0=FL" $filename-mono.$extension
}
@iandunn
iandunn / web-crypto-password-generator.js
Last active January 18, 2023 16:23
Cryptographically secure random password using `crypto.getRandomValues`
// ⚠️ I have not verified that this is secure; I just cleaned it up to try it out.
// Use at your own risk. I ended up using https://www.npmjs.com/package/@automattic/generate-password instead.
/**
* Generate a cryptographically secure random password in the browser.
*
* This is a modified version of https://stackoverflow.com/a/43020177/450127 that aims to
* to improve readability, and increase the length and character pool. The results should be
* the same as the original.