Skip to content

Instantly share code, notes, and snippets.

View mikesprague's full-sized avatar

Michael Sprague mikesprague

View GitHub Profile
@mikesprague
mikesprague / gist:7225173
Last active December 26, 2015 22:39
Tuckey URL Rewrite: Strip .html
Tuckey URL Rewrite - Remove .html Extensions
<rule>
<note>Example: http://hostname/sample/loginhelp?cid=2 is masked from http://hostname/sample/loginhelp.html?cid=2</note>
<from>^(.*)?(.*)$</from>
<to>$1.html?$2</to>
</rule>
<outbound-rule>
<note>Example: http://hostname/sample/loginhelp.html?cid=2 is redirected to http://hostname/sample/loginhelp?cid=2</note>
<from>^(.*)(.html)(.*)$</from>
<to type="redirect">$1$2</to>
@mikesprague
mikesprague / create-data-uri.php
Last active December 27, 2015 02:19
PHP: Create Data URI
<?php
function data_uri($file, $mime) {
$contents=file_get_contents($file);
$base64=base64_encode($contents);
echo "data:$mime;base64,$base64";
}
?>
@mikesprague
mikesprague / create-data-uri.cfm
Created October 31, 2013 15:42
CFML: Create Data URI
<cfscript>
function data_uri(fullFilePath, mimeType='image/*') {
var contents = fileReadBinary(fullFilePath);
var base64contents = toBase64(contents);
var returnString = "data:" & mimeType & ";base64," & base64contents;
return returnString;
}
</cfscript>
@mikesprague
mikesprague / geolocation-example.js
Created November 18, 2013 03:17
JavaScript: GeoLocation Example
// Check to see if this browser supports geolocation.
if (navigator.geolocation)
{
// Get the location of the user's browser using the
// native geolocation service. When we invoke this method
// only the first callback is requied. The second
// callback - the error handler - and the third
// argument - our configuration options - are optional.
navigator.geolocation.getCurrentPosition
(
select.form-control + .chosen-container.chosen-container-single .chosen-single {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
@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 / set-cookie.cfm
Last active December 25, 2015 11:49
set cookie without cfcookie example (cfscript)