Skip to content

Instantly share code, notes, and snippets.

View mhairston's full-sized avatar

Michael Hairston mhairston

View GitHub Profile
@mhairston
mhairston / mac-quicklook-select-copy.txt
Last active December 19, 2015 21:29
Enable select & copy in QuickLook previews
defaults write com.apple.finder QLEnableTextSelection -bool TRUE; killall Finder
http://www.macworld.com/article/1164668/select_and_copy_text_within_quick_look_previews.html
@mhairston
mhairston / no-visual.css
Created February 19, 2014 16:26
New Improved 2013 "no-visual" style
/*
Hide elements from visual browsers, keep content accessible.
Taken from http://html5boilerplate.com/
*/
.no-visual {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
@mhairston
mhairston / ToggleContentEditable.js
Last active August 29, 2015 14:01
Toggle contentEditable
javascript:!function(){"true"!==document.body.contentEditable?(document.body.contentEditable="true",document.documentElement.style.borderTop="15px solid red"):(document.body.contentEditable="false",document.documentElement.style.borderTopWidth="0px")}();
var initSessionPropertyOnce = function(prop,defaultVal) {
var savedValue = sessionStorage.getItem(prop);
if (!savedValue) {
sessionStorage.setItem(prop,defaultVal);
$scope.switchTabTo(defaultVal);
return defaultVal;
} else {
$scope.switchTabTo(savedValue);
return savedValue;
}
@mhairston
mhairston / closure-princess.js
Last active August 29, 2015 14:05
closures via fairy tales
// Great explanation of closures (plus I love this style of documentation):
// from http://stackoverflow.com/a/6472397 answer by Jacob Swartwood
// ------------------------------------------------------------------- //
// I'm a big fan of analogy and metaphor when explaining difficult concepts, so let me try my hand with a story.
// Once upon a time:
// There was a princess...
@mhairston
mhairston / niceNumbers.js
Created October 29, 2014 16:30
Number Formatting
// Nice number formatting
// by Chris Quick
// http://devspoint.wordpress.com/2011/01/07/two-quick-javascript-snippets-i-use-everyday/
function addCommas(nStr)
{
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
@mhairston
mhairston / number-ball.html
Last active November 15, 2015 22:56
Big Orange Number Ball
<div style="background-color: #e64f35; border-radius: 50%; width: 160px; height: 160px; padding: 3px; margin: 2rem; border: 1rem solid #e64f35;color:#fff; font-size:3rem; text-align:center;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;">
<div>
56<small>%</small>
</div>
</div>
@mhairston
mhairston / grid-debug.html
Created April 7, 2015 20:02
grid-debugger
<style> .ns-newcsslib .grid--debug {outline: 5px solid #f00;height: 100px;} .ns-newcsslib .grid--debug [class^="col-"] {height:100%; background-color:#fee; display:block;}</style>
<div class="grid grid--debug"> <div class="col-1">&nbsp;</div> <div class="col-1">&nbsp;</div> <div class="col-1">&nbsp;</div> <div class="col-1">&nbsp;</div> <div class="col-1">&nbsp;</div> <div class="col-1">&nbsp;</div> <div class="col-1">&nbsp;</div> <div class="col-1">&nbsp;</div> <div class="col-1">&nbsp;</div> <div class="col-1">&nbsp;</div> <div class="col-1">&nbsp;</div> <div class="col-1">&nbsp;</div> </div>
@mhairston
mhairston / module-pattern.js
Created May 11, 2015 20:23
Module Pattern with Private Stuff
// Module pattern
ABC = ABC || {};
ABC.ModuleName = (function() {
function render_donut(el) {
dostuff();
}
function init(){
@mhairston
mhairston / jekyll-cheatsheet.html
Last active August 29, 2015 14:25
Jekyll cheats
Include
{% include footer.html %}
Include with params
{% include footer.html param="value" variable-param=page.variable %}
{{ site.time | date_to_string }}
07 Nov 2008
Include a gist -- filename optional.