Skip to content

Instantly share code, notes, and snippets.

View mikesprague's full-sized avatar

Michael Sprague mikesprague

View GitHub Profile
@mikesprague
mikesprague / endsWith.js
Created September 13, 2014 20:05
Adds a String function named endWith() to check and return the last character (if the function hasn't already been overridden)
if ( typeof String.prototype.endsWith !== 'function' ) {
String.prototype.endsWith = function( str ) {
return this.indexOf( str.toString(), this.length - str.length ) !== -1;
};
}
#! /usr/bin/env bash
# Variables
APPENV=local
DBHOST=localhost
DBNAME=dbname
DBUSER=dbuser
DBPASSWD=test123
echo -e "\n--- Mkay, installing now... ---\n"
@mikesprague
mikesprague / hex-clock.html
Created March 29, 2015 01:12
Source from http://www.jacopocolo.com/hexclock/ (not my original work)
<!DOCTYPE html>
<html lang="en">
<!--
My coding philosophy
__ ___ _ _______ ________ ________ _____ __ ______ _____ _ __ _____
\ \ / / | | | /\|__ __| ____\ \ / / ____| __ \ \ \ / / __ \| __ \| |/ // ____|
\ \ /\ / /| |__| | / \ | | | |__ \ \ / /| |__ | |__) | \ \ /\ / / | | | |__) | ' /| (___
\ \/ \/ / | __ | / /\ \ | | | __| \ \/ / | __| | _ / \ \/ \/ /| | | | _ /| < \___ \
\ /\ / | | | |/ ____ \| | | |____ \ / | |____| | \ \ \ /\ / | |__| | | \ \| . \ ____) |
\/ \/ |_| |_/_/ \_\_| |______| \/ |______|_| \_\ \/ \/ \____/|_| \_\_|\_\_____/
@mikesprague
mikesprague / git-commit-message-guide-quick-reference.txt
Last active August 29, 2015 14:27
Text version of the quick reference image (png) included with https://github.com/bluejava/git-commit-guide
TYPE(Scope): Change Summary ( < 50-70 chars )
Optional Message Body ( < 100 char lines )
Multiple paragraphs are okay.
Bulleted lists:
* are
* also
* okay
@mikesprague
mikesprague / gist:5721210
Created June 6, 2013 12:41
JavaScript: Math.round (modified to round number with decimal places)
Math.round = (function() {
var originalRound = Math.round;
return function(number, precision) {
precision = Math.abs(parseInt(precision)) || 0;
var multiplier = Math.pow(10, precision);
return (originalRound(number * multiplier) / multiplier);
};
})();
/*
example usage:
@mikesprague
mikesprague / gist:6000485
Created July 15, 2013 14:41
JavaScript: getObjectType() - Return object type
function getObjectType(obj) {
if(obj===null)return "[object Null]"; // special case
return Object.prototype.toString.call(obj);
}
img.grayscale {
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */
}
img.grayscale.disabled {
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 1 0\'/></filter></svg>#grayscale");
-webkit-filter: grayscale(0%);
}
@mikesprague
mikesprague / gist:5706268
Last active December 25, 2015 11:47
JavaScript: getRootWebSitePath
function getRootWebSitePath() {
var _location = document.location.toString();
var applicationNameIndex = _location.indexOf('/', _location.indexOf('://') + 3);
var applicationName = _location.substring(0, applicationNameIndex) + '/';
var webFolderIndex = _location.indexOf('/', _
location.indexOf(applicationName) + applicationName.length);
var webFolderFullPath = _location.substring(0, webFolderIndex);
return webFolderFullPath;
}
@mikesprague
mikesprague / set-cookie.cfm
Last active December 25, 2015 11:49
set cookie without cfcookie example (cfscript)
@mikesprague
mikesprague / convert-query-to-struct-array.cfm
Last active December 25, 2015 11:49
CFML: convertQueryToStructArray
<cfscript>
function convertQueryToStructArray( q ) {
var result = [];
for ( var row in arguments.q ) {
result.append( row );
}
return result;
}