Skip to content

Instantly share code, notes, and snippets.

View rosswintle's full-sized avatar

Ross Wintle rosswintle

View GitHub Profile
@rosswintle
rosswintle / Stats.php
Created May 17, 2017 08:42
Simple Laravel Service Container/Provider example
<?php
// This is the Stats class I wanted to create. It lives in app/Stats.php, but could be anywhere that the AutoLoader will recognise it
namespace App;
use App\Action;
use Carbon\Carbon;
/**
@rosswintle
rosswintle / mysqlbackup.sh
Created January 10, 2018 10:38
MySQL backup all database script
#!/bin/sh
#
# This dumps all MySQL databases if you give it a root database login. You can specify the directory.
# It creates a date-and-timestamped sub-directory and individual files in there for each database.
#
HOSTNAME='localhost'
MYSQLUSER='root'
MYSQLPASS='password'
TIMESTAMP=`date +%F-%H%M%S`
@rosswintle
rosswintle / gdpr-resources.md
Last active January 11, 2019 16:50
My public list of GDPR resources (slightly focussed on UK-based charities and non-profits rather than businesses)
@rosswintle
rosswintle / keybindings.json
Created February 13, 2018 14:18
Better terminal toggling keybindings in VS Code
[
// Focus/unfocus terminal with ctrl+` and toggle it with ctrl+shift+`
{
"key": "ctrl+`",
"command": "workbench.action.focusActiveEditorGroup",
"when": "terminalFocus"
},
{
"key": "ctrl+`",
"command": "workbench.action.terminal.focus",
@rosswintle
rosswintle / functions.php
Created July 2, 2018 17:16
WordPress filters to make HTML password reset emails work
<?php
// adding support for html emails
// this converts ALL wp_mail emails to HTML, which messes up the password reset email
add_filter( 'wp_mail_content_type','prefix_set_content_type' );
function prefix_set_content_type() {
return "text/html";
}
// add this filter too
// this will make the password reset email compatible with the HTML format
@rosswintle
rosswintle / pair.php
Created January 10, 2019 22:55
Secret Santa Recursive Pairings
function make_valid_pairing( $people_to_pair, $people_yet_to_have_gifts ) {
// We made it! No more people left to pair! Return an empty array of pairings.
if (empty($people_to_pair)) {
return [];
}
// Get the first person
$person_to_pair = $people_to_pair[0];
// Get all the other people
@rosswintle
rosswintle / wordpress-cleanup.php
Created February 1, 2019 17:04
WordPress Cleanup hooks
<?php
/**
* Plugin Name: Wordpress Cleanup
*/
namespace WordPress_Cleanup;
/**
* Change filters here to control what this does
*/
@rosswintle
rosswintle / AssetCache.php
Last active February 22, 2020 21:16
Statamic tag for my LaravelAssetCache package
<?php
/*
* Tag for my LaravelAssetCache package: https://github.com/rosswintle/laravel-asset-cache/
*
* This grabs the asset file from the specified npm package from jsdelivr.net, and caches and serves it locally
*
* Before use you'll need to:
* composer require rosswintle/laravel-asset-cache
* php artisan storage:link (in all environments)
*
@rosswintle
rosswintle / weird-wide-webring.php
Created May 19, 2020 09:32
Simple WordPress Widget for Jack McDade's Weird Wide Webring
<?php
/**
* Plugin Name: Weird Wide Webring
* Plugin URI: https://weirdwidewebring.net
* Description: A widget for displaying the Weird Wide Webring links
* Author: Ross Wintle
* Author URI: https://rosswintle.uk/
* Text Domain: weird-wide-webring
* Domain Path: /languages
* Version: 1.0.0
@rosswintle
rosswintle / .bashrc-searches
Last active October 16, 2020 14:13
Command-line (bash) code-searching functions.
# Add these to your .bashrc file for some quick and clever recursive web-dev code searching
# from the command line/terminal.
#
# Should be easy enough to add your own too.
#
# Usage is just:
#
# phprgrep <regular expression>
#
# Regular expresssions need to be escaped/quoted if you're being clever.