Skip to content

Instantly share code, notes, and snippets.

@lstellway
lstellway / timer.sh
Last active Mar 2, 2022
Shell-based timer for `bash` and `zsh`
View timer.sh
# Read a message using the OSX `say` command
#
# In my opinion, the best voices for American English seem to be:
# 'Daniel', 'Karen', 'Rishi', 'Tessa'
export TIMER_COMMAND="say -v Karen --interactive=bold '%s'"
# Hide tty input while command is running
_timer_tty_off() {
[ -t 0 ] && stty -echo -icanon time 0 min 0
}
@lstellway
lstellway / update-mysql-letsencrypt
Created Feb 23, 2022
Helper script to update MySQL / MariaDB TLS after renewing LetsEncrypt certificate
View update-mysql-letsencrypt
#!/bin/bash
DOMAIN="$1"
SOURCE="/etc/letsencrypt/live/${DOMAIN}"
DESTINATION="/var/lib/mysql/pki"
USER="mysql."
# Validate provided domain
if [ -z "${DOMAIN}" ] || [ ! -d "${SOURCE}" ]; then
printf "Please enter a valid domain (provided '%s')\n" "${DOMAIN}"
@lstellway
lstellway / macos-change-ssh-port.sh
Last active Feb 11, 2022
Change the default SSH port on macOS
View macos-change-ssh-port.sh
# Setup SSH port
ssh_set_port() {
# Ensure a port is specified
if [ -z "$1" ]; then
printf "No port specified...\n"
return 1
fi
# Ensure original file exists
@lstellway
lstellway / operator.yml
Created Feb 4, 2022
PlanetScale.com - Vitess Operator for Kubernetes `v1.21.1`
View operator.yml
# Version: 20200918: 25ca1bc881f433d2a42c3b5f59da416f4ef6dc44
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.4
creationTimestamp: null
name: etcdlockservers.planetscale.com
spec:
group: planetscale.com
@lstellway
lstellway / synology-dsm-getcert.sh
Last active Feb 23, 2022
Shell utility to help find the certificates used by a specified FQDN on Synology NAS
View synology-dsm-getcert.sh
#!/bin/sh
# Help
if [ "$1" == "-h" -o "$1" == "--help" ]; then
SCRIPT="$(basename ${0})"
cat <<EOF
${SCRIPT}
Shell utility to help find the certificates used by a specified FQDN on Synology NAS
Usage
@lstellway
lstellway / NGINX Config - IP Address JSON
Created Jan 15, 2021
Simple NGINX config to return real client IP address
View NGINX Config - IP Address JSON
map ":$http_x_forwarded_for" $IP_ADDR {
":" $remote_addr; # Forwarded for not set
default $http_x_forwarded_for; # Forwarded for is set
}
server {
server_name example.com;
listen 80;
listen [::]:80;
View wp-graphql-meta-queries.php
<?php
/*
Plugin Name: GraphQL Meta Queries
Plugin URI: https://loganstellway.com
Description: Extends WPGraphQL to allow meta queries on post connections
Version: 0.0.1
Author: Logan Stellway
Author URI: https://loganstellway.com
*/
View wp-graphql-meta-queries.php
<?php
/*
Plugin Name: GraphQL Meta Queries
Plugin URI: https://loganstellway.com
Description: Extends WPGraphQL to allow meta queries on post connections
Version: 0.0.1
Author: Logan Stellway
Author URI: https://loganstellway.com
*/
@lstellway
lstellway / Google Spreadsheet Post
Created Jun 25, 2020
Post data to a Google Spreadsheet
View Google Spreadsheet Post
/**
* @see http://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
* @see https://gist.github.com/willpatera/ee41ae374d3c9839c2d6
*/
// Sheet name
const SHEET_NAME = "Submissions";
// Property service
const ScriptProps = PropertiesService.getScriptProperties();
@lstellway
lstellway / GIF-Screencast-OSX.md
Created May 30, 2020 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF
View GIF-Screencast-OSX.md

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: