Skip to content

Instantly share code, notes, and snippets.

@reesscot
reesscot / MutationObserver
Created September 1, 2016 23:51
How to monitor a DOM element for changes to the style attribute.
/**
* Example of using a Mutation Object
* https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
*/
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutationRecord) {
doSomething(mutationRecord);
});
});
@reesscot
reesscot / Full_Width_Row.js
Created August 29, 2016 16:39
Add full width row to an element inside a fixed grid container. This is useful when you can't change the parent page's html structure to add a full width container, such as when the entire page is already inside of a B.S. Container div. Ideally you would solve this without JS, but sometimes that isn't possible or practical.
/**
* Add full width row to an element inside a fixed grid container
* Note: This is useful when you can't change the parent page's html structure to add a full width container,
* such as when the entire page is already inside of a B.S. Container div. Ideally you would solve this without JS,
* but sometimes that isn't possible.
*/
function renderFullWidthRow(size) {
let parentElement = document.querySelector('.parent-element');
let childElement = document.querySelector('.child-element');
let elStyles = window.getComputedStyle(parentElement);
@reesscot
reesscot / AddEventHandlerThisExample.js
Last active May 4, 2017 20:25
Bind 'this' parameter to a Javascript Event Handler
/**
* @file: AddEventHandlerThisExample.js
* This example demonstrates how to pass 'this' correctly into an event handler
* which can be tricky due to events being the execution context inside of event handlers.
*
* The trick is to use an IIFE that returns an function with its encapsulated variable scope
* in order to preserve the value of 'this' inside another variable name (such as 'that')
**/
@reesscot
reesscot / Gruntfile.js
Last active June 1, 2016 17:54
Grunt - Sass default workflow setup
module.exports = function(grunt) {
require('jit-grunt')(grunt);
// Project configuration.
grunt.initConfig({
/**
* Sass
*/
@reesscot
reesscot / wp-permissions-script
Created May 23, 2016 23:19 — forked from macbleser/wp-permissions-script
WordPress Permissions Configuration Script
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro
#
WP_OWNER=changeme # <-- wordpress owner
WP_GROUP=changeme # <-- wordpress group
WP_ROOT=/home/changeme # <-- wordpress root directory
@reesscot
reesscot / Gruntfile.js
Created March 23, 2016 18:07
Grunt Task to Minify SVGs
module.exports = function (grunt) {
grunt.initConfig({
svgmin: {
options: {
plugins: [
{
removeViewBox: false
}, {
removeUselessStrokeAndFill: false
}