Skip to content

Instantly share code, notes, and snippets.

View mhairston's full-sized avatar

Michael Hairston mhairston

View GitHub Profile
@mhairston
mhairston / emoti.txt
Created July 28, 2015 18:51
extended emoticons
¯\_(ツ)_/¯
@mhairston
mhairston / convert-to-array.js
Created July 29, 2015 17:20
Convert JS Array-like to Array
// Convert Array-like object to Array:
var unboundSlice = Array.prototype.slice;
var slice = Function.prototype.call.bind(unboundSlice);
function list() {
return slice(arguments);
}
var list1 = list(1, 2, 3); // [1, 2, 3]
@mhairston
mhairston / hexagon.css
Created August 14, 2015 13:30
CSS Hexagon
/* From http://csshexagon.com, natch! */
.hexagon {
position: relative;
width: 300px;
height: 173.21px;
background-color: #64C7CC;
margin: 86.60px 0;
}
.hexagon:before,
@mhairston
mhairston / inline-break.css
Last active September 28, 2015 11:13
Insert line break after inline element
/*
Insert a line break after inline element
(not the same as display:block)
from CSS Secrets by Lea Verou
*/
.u-line-break::after {
content: '\A';
white-space: pre;
}
@mhairston
mhairston / center-vertical.css
Last active November 5, 2015 18:37
Vertically Center in 3 lines of CSS
/*
Vertically center
From http://csstricks.com
No styles needed on parent.
*/
.u-vertical-center {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
@mhairston
mhairston / center-vertical-flex.css
Last active November 18, 2015 21:32
Better Center Vertical
.u-center-vertical-flex {
display: flex;
align-items: center;
}
/* to include IE10: */
.u-center-vertical-flex {
display: -ms-flex;
display: flex;
@mhairston
mhairston / date-format.sh
Created December 21, 2015 19:58
Preferred date format
#!/bin/sh
DATE="`date +%Y%m%d"-"%H%M`"
@mhairston
mhairston / copy-and-zip.sh
Created December 21, 2015 20:26
Copy & Zip files
#!/bin/sh
ditto -c -k --rsrc --keepParent ~/Documents/ Docs.zip
@mhairston
mhairston / jquery-object-merge.js
Created January 28, 2016 21:57
Merging Objects with jQuery
// Merging objects via jQuery
var defaults = { validate: false, limit: 5, name: "foo" };
var options = { validate: true, name: "bar" };
// merged objects not modified -- creates new object `settings`
var settings = $.extend( {}, defaults, options );
@mhairston
mhairston / react-markup.js
Created February 14, 2016 00:19
Sample Markup in React
Markup in React
Javascript:
return React.createElement("p", {className: "foo"}, "Hello, world!");
JSX:
return (<p className="foo">Hello, world!</p>);