Skip to content

Instantly share code, notes, and snippets.

View tonyclemmey's full-sized avatar

Tony Clemmey tonyclemmey

  • London
View GitHub Profile
@tonyclemmey
tonyclemmey / whatissoslow.php
Created December 20, 2020 02:34 — forked from Viper007Bond/whatissoslow.php
WordPress: Times how long it takes each filter and action to run and displays results at the end of the page. Quick and dirty.
<?php
/**
* This little class records how long it takes each WordPress action or filter
* to execute which gives a good indicator of what hooks are being slow.
* You can then debug those hooks to see what hooked functions are causing problems.
*
* This class does NOT time the core WordPress code that is being run between hooks.
* You could use similar code to this that doesn't have an end processor to do that.
*

Gray & White - Skewed Slider with Scrolling

This Skewed Slider with Scrolling based on Pure JS and CSS (without libraries).

A Pen by Victor Belozyorov on CodePen.

License.

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

@tonyclemmey
tonyclemmey / wp-admin-select2.php
Created November 26, 2020 15:25 — forked from yanknudtskov/wp-admin-select2.php
Add select2 to all select fields in WordPress Admin
<?php
function enqueue_select2_jquery() {
wp_register_style( 'select2css', '//cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.css', false, '1.0', 'all' );
wp_register_script( 'select2', '//cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.js', array( 'jquery' ), '1.0', true );
wp_enqueue_style( 'select2css' );
wp_enqueue_script( 'select2' );
}
add_action( 'admin_enqueue_scripts', 'enqueue_select2_jquery' );
@tonyclemmey
tonyclemmey / app.php
Created November 21, 2020 00:44 — forked from juban/app.php
Redis configuration for Craft CMS
<?php
/**
* Yii Application Config
*
* Edit this file at your own risk!
*
* The array returned by this file will get merged with
* vendor/craftcms/cms/src/config/app/main.php and [web|console].php, when
* Craft's bootstrap script is defining the configuration for the entire
* application.
@tonyclemmey
tonyclemmey / app.php
Created November 20, 2020 21:22 — forked from ryanirelan/app.php
app.php configuration for using Redis and Craft CMS 3
<?php
/**
* Yii Application Config
*
* Edit this file at your own risk!
*
* The array returned by this file will get merged with
* vendor/craftcms/cms/src/config/app.php and app.[web|console].php, when
* Craft's bootstrap script is defining the configuration for the entire
* application.
@tonyclemmey
tonyclemmey / db-env-var.php
Created July 29, 2020 10:33 — forked from coreymcmahon/db-env-var.php
Initialising a DB connection from environment variables. From the article: The 12 Factor PHP App - Part 1, http://www.modernphpbook.com/articles/the-12-factor-php-app-part-1 - Fig 1
<?php
// Initialising a DB connection from environment vars...
$dbHost = getenv('DB_HOST');
$dbName = getenv('DB_NAME');
$dbUser = getenv('DB_USER');
$dbPass = getenv('DB_PASS');
$pdo = new \PDO("mysql:host={$dbHost};dbname={$dbName}", $dbUser, $dbPass);
@tonyclemmey
tonyclemmey / mysql2-catalina.md
Created June 11, 2020 17:49 — forked from fernandoaleman/mysql2-catalina.md
Install mysql2 on MacOS Catalina

Problem

Installing mysql2 gem errors on MacOS Catalina.

Solution

Make sure openssl is installed on Mac via Homebrew.

brew install openssl
@tonyclemmey
tonyclemmey / .htaccess
Created May 14, 2020 16:33 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@tonyclemmey
tonyclemmey / Dockerfile
Created April 4, 2020 18:42 — forked from remarkablemark/Dockerfile
Install node and npm with nvm using Docker.
# set the base image to Debian
# https://hub.docker.com/_/debian/
FROM debian:latest
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \