Skip to content

Instantly share code, notes, and snippets.

View chrisdavidmiles's full-sized avatar
💙

Chris David Miles chrisdavidmiles

💙
View GitHub Profile
@chrisdavidmiles
chrisdavidmiles / cdm-custom-uploads-directory-by-file-type.php
Last active August 24, 2022 00:49 — forked from blainerobison/gist:e802658da007e6e806b1
WordPress Plugin: Custom Uploads Directory By File Type
<?php
/**
* Plugin Name: Custom Uploads Directory By File Type
* Plugin URI: https://gist.github.com/chrisdavidmiles/a7f3fbf09616b4c445a45310c0f88e05
* Description: This plugin automatically sorts uploads into a folder corresponding to their file type. Images go into <code>/img</code>, documents go into <code>/docs</code>, video goes into <code>/img</code>, and the rest goes into <code>/misc</code>. Note: This code doesn't work with 'browser uploader'.
* Author: Forked from Blaine Robison
* Author URI: https://gist.github.com/blainerobison/e802658da007e6e806b1
* Version: 0.2
*/
@chrisdavidmiles
chrisdavidmiles / cdm-automatically-set-featured-image.php
Last active August 24, 2022 00:39 — forked from mestrewp/gist:2820465
WordPress Plugin: Automatically Set the Featured Image
@chrisdavidmiles
chrisdavidmiles / wmms.sh
Created September 24, 2021 04:54
Windows Movie Maker Shitposting Script
#!/usr/bin/env bash
#
# Windows Movie Maker Shitposting Script by @chrisdavidmiles
#
# This script generates a video of text in the style of 2007 era Windows Movie
# Maker youtube tutorials. I'm not really sure why I made this script tbh.
#
# This script requires ffmpeg and imagemagick to run.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
@chrisdavidmiles
chrisdavidmiles / 404.html
Created April 30, 2022 03:06
Internet Explorer 4 - Default 404 Page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>404 - Page Not Found</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" />
<style type="text/css">
<!--
body { background-color: white; color: black; }
#container { width: 400px; }
@chrisdavidmiles
chrisdavidmiles / 720p.sh
Last active January 19, 2022 01:41
A utility for resizing windows from the command line on OSX.
#!/usr/bin/env bash
#
# 720p
# A utility for resizing windows from the command line on OSX.
# Taken from: https://lostechies.com/derickbailey/2012/09/08/screencasting-tip-resize-your-app-to-720p-1280x720-in-osx/
# Archived copy: https://archive.is/5kr9m
# Archived code: https://gist.github.com/chrisdavidmiles/1b786c4ea62e1883ba31117ca357a838
#
echo "Setting $1 bounds to 720p"
@chrisdavidmiles
chrisdavidmiles / bitnami_aws_wordpress_image_setup_notes.md
Last active December 7, 2021 18:06
Bitnami AWS WordPress Image Setup Notes
@chrisdavidmiles
chrisdavidmiles / cloudflare-ddns-update.sh
Last active November 29, 2021 18:45 — forked from Tras2/cloudflare-ddns-update.sh
A bash script to update a Cloudflare DNS A record with the external IP of the source machine
#!/usr/bin/env bash
#
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine
#
# Proxy - uncomment and provide details if using a proxy
#export https_proxy=http://<proxyuser>:<proxypassword>@<proxyip>:<proxyport>
# Cloudflare zone is the zone which holds the record
zone=example.com
@chrisdavidmiles
chrisdavidmiles / tor-redirect.js
Created July 3, 2017 22:52
Detect Tor Browser users and redirect them to the .onion version of my site.
var myoniondomain = 'chrisdm326o2d7iq.onion';
var thecurrentdomain = window.location.hostname;
if (myoniondomain != thecurrentdomain) {
function isTorBrowser() {
var img = document.createElement('img');
img.src = 'data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==';
var canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
var ctx = canvas.getContext('2d');
@chrisdavidmiles
chrisdavidmiles / continue.sh
Created October 13, 2021 04:11
Press ENTER to continue (bash)
continue_prompt () {
echo "Press ENTER to continue"
read -n 1 confirm
if [ ! "$confirm" = "" ]; then
exit
fi
}
@chrisdavidmiles
chrisdavidmiles / PostMessageToSlackChannel.php
Created June 6, 2020 22:06 — forked from nadar/PostMessageToSlackChannel.php
Post a message to a slack channel with PHP
<?php
/**
* Send a Message to a Slack Channel.
*
* In order to get the API Token visit: https://api.slack.com/custom-integrations/legacy-tokens
* The token will look something like this `xoxo-2100000415-0000000000-0000000000-ab1ab1`.
*
* @param string $message The message to post into a channel.
* @param string $channel The name of the channel prefixed with #, example #foobar