Skip to content

Instantly share code, notes, and snippets.

@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
}
@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
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 / 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 / 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 / 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 / package.json
Last active January 12, 2017 21:53
Simple npm scripts setup for compiling less, autoprefixing, and minifying CSS.
{
"name": "my-npm-project",
"version": "0.0.1",
"description": "My project description",
"watch": {
"dist-css": {
"patterns": [
"./"
],
"extensions": "less",
@reesscot
reesscot / package.json
Created February 21, 2017 20:33
Simple NPM script to compile and host JS project using Babel ES2015
{
"name": "Simple_ES6_Babel_Project",
"version": "1.0.0",
"description": "Build template to watch, compile, and serve a ES2015 JS project.",
"main": "index.html",
"scripts": {
"dev": "http-server | npm run compile-js",
"compile-js": "babel ./public/js/app.js --watch --out-file ./public/js/app_compiled.js --presets=es2015"
},
"author": "Scott Rees",
@reesscot
reesscot / basic-webpack-config.js
Last active June 7, 2017 17:25
A basic ES2015 Webpack Configuration with Uglification
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
entry: './src/main.js',
output: {
path: './dist/',
filename: 'bundle.js'
},
module: {
@reesscot
reesscot / aligning-images.md
Created November 22, 2017 19:57 — forked from DavidWells/aligning-images.md
Guide to aligning images in github readme.md files

Aligning images

left alignment

This is the code you need to align images to the left: