Skip to content

Instantly share code, notes, and snippets.

View leek's full-sized avatar

Chris Jones leek

View GitHub Profile
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
@leek
leek / .php-cs-fixer.dist.php
Created July 11, 2022 04:50
Personal ideal PHP CS Fixer configuration
<?php
/**
* PHP Coding Standards fixer configuration
*/
$finder = PhpCsFixer\Finder::create()
->ignoreDotFiles(true)
->ignoreVCSIgnored(true)
->exclude('node_modules')
@leek
leek / tools.md
Last active April 14, 2022 03:16
Helpful list of tools and things that I want to remember.
@leek
leek / rewrite_uploads_wordpress_apache.conf
Last active May 4, 2024 07:47
Rewrite WordPress Uploads on Local Environment using Nginx or Apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/[^\/]*/.*$
RewriteRule ^(.*)$ https://<DOMAIN>/$1 [QSA,L]
</IfModule>
@leek
leek / add_slug_to_body_class.php
Created April 2, 2021 05:51
Add current page slug to <body> class in WordPress.
<?php
// Alternative:
// Install https://github.com/roots/soil
// Add slug to <body> class
add_filter('body_class', function ($classes) {
// Add post/page slug if not present
if (is_single() || is_page() && !is_front_page()) {
if (!in_array($slug = basename(get_permalink()), $classes)) {
@leek
leek / add_sri_attribute.php
Created April 2, 2021 05:44
Add SRI attribute to WordPress scripts and stylesheets.
<?php
/**
* Add SRI attributes to external JS resources
*/
function add_sri_attribute($tag, $handle, $src = null)
{
$known_hashes = array(
'https://code.jquery.com/jquery-1.12.4.min.js' => 'sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=',
);
@leek
leek / magento_2_dump_and_die.php
Last active July 21, 2022 11:08
Laravel dd() for Magento 2
<?php
function d($arg) {
if (is_object($arg)) {
echo PHP_EOL . 'CLASS: ' . get_class($arg) . PHP_EOL;
if ($arg instanceof \Magento\Framework\DB\Select) {
var_dump($arg->__toString());
}
if (method_exists($arg, 'getSelect')) {
var_dump($arg->getSelect()->__toString());
@leek
leek / optimize_media.sh
Created March 12, 2020 17:38
Magento 2 - Optimize Media
#!/bin/bash
if [ ! -f ./app/etc/config.php ]; then
echo "-- ERROR"
echo "-- This doesn't look like a Magento 2 install. Please make sure"
echo "-- that you are running this from the Magento main doc root dir"
exit
fi
echo -ne '\n'
@leek
leek / deploy.sh
Last active May 31, 2022 23:53
Magento 2 Deployment Script
#!/bin/bash
LOCKFILE=deploy.lock
if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then
echo "-- ERROR"
echo "-- Deployment is already running"
exit
fi
@leek
leek / _Magento2_DeleteTestData.md
Last active January 10, 2024 05:39
Magento 2 - Delete All Test Data

These set of scripts are for Magento 2. For Magento 1, see this Gist.