Skip to content

Instantly share code, notes, and snippets.

View leek's full-sized avatar

Chris Jones leek

View GitHub Profile
/**
* Disable and enable event on scroll begin and scroll end.
* @see http://www.thecssninja.com/javascript/pointer-events-60fps
*/
(function(r, t) {
window.addEventListener('scroll', function() {
// User scrolling so stop the timeout
clearTimeout(t);
// Pointer events has not already been disabled.
if (!r.style.pointerEvents) {
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class ConfigServiceProvider extends ServiceProvider
{
/**
* Overwrite any vendor / package configuration.
@leek
leek / gist:1233135
Created September 21, 2011 20:04
git flow Introduction

About Git Flow

Git Flow is an extension to Git that provides extra functionality and simple commands that force you into a structured and proper branching model. Git Flow is not required and in fact all commands ran by Git Flow can be done using standard Git commands. Git Flow just makes everything easier. Git Flow only needs to be installed on the developer's machine (or wherever development happens) and not on any production server.

Installing on Windows

Git Flow can be installed alongside TortoiseGit without issue, but there are some steps needed.

  1. Download/Install msysGit
  2. Download this file: bin.zip
@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 / gist:1942116
Created February 29, 2012 16:19
INSERT ... ON DUPLICATE KEY UPDATE with Zend Framework (Zend_Db_Table))
<?php

/**
 * @method DbTable_Row_Foo createRow()
 */
class DbTable_Foo extends Zend_Db_Table_Abstract
{
    protected $_primary  = 'foo_id';
    protected $_name     = 'foo';
@leek
leek / reset_permissions.sh
Created September 30, 2013 15:50
Magento - Simple reset file permissions script
#!/bin/bash
#
# Found on StackOverflow:
# http://stackoverflow.com/a/9304264/3765
#
if [ ! -f ./app/etc/local.xml.template ]; then
echo "-- ERROR"
echo "-- This doesn't look like a Magento install. Please make sure"
echo "-- that you are running this from the Magento main doc root dir"
@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 / 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 / rewrite_uploads_wordpress_apache.conf
Last active April 16, 2021 04:20
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>

Includes:

  • Configuration
  • BrowserSync
  • Environments (e.g.,: --environment=production)
  • Image optimization (gif, jpg, png, and svg)
  • Sass compilation with external libraries
  • Bower installed Sass libraries example(s)
  • CSS processing with Pleeease