This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const balance = (data: any[], columns: number = 4) => { | |
const offset = data.length % columns ? 1 : 0 | |
const height = (data.length - (data.length % columns)) / columns + offset | |
const unbalanced = [...data] | |
const balanced = [] | |
while (unbalanced.length) balanced.push(unbalanced.splice(0, height)) | |
return balanced | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function optional(obj: any, ...keys: string[]) { | |
let opt = obj; | |
while (keys.length && opt[keys[0]] !== undefined) { | |
const key = keys.shift(); | |
opt = opt[key]; | |
} | |
return keys.length ? false : opt; | |
} | |
const scrollHeight = optional(someDOMNode, "previousElementSibling", "scrollHeight"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Coming soon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1, .h1 { | |
color: royalblue; | |
} | |
a, a:link { | |
color: orangered; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Start by creating two files (replace NIBEXAMPLE with w/e you want but make sure the names match): | |
1, NIBEXAMPLE.xib | |
* File > New > File... > iOS > View | |
2, NIBEXAMPLE.swift | |
* File > New > File... > iOS > Cocoa Touch Class (Extends UIView) | |
After creating the two files above, replace the default contents of your .swift file | |
with the code below. Be sure to update `class NIBEXAMPLE` and `nibName = "NIBEXAMPLE"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Optional customization ========================== | |
generateID(); | |
generateID({ | |
base: 'video_', | |
length: 12, | |
charset: '1234asdf', | |
overkill: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$create-grid: true; | |
// Breakpoints | |
$break-mobile: 320px; | |
$break-mobile-max: 460px; | |
$break-tablet: 760px; | |
$break-tablet-max: 900px; | |
$break-desktop: 1104px; | |
$break-desktop-max: 1320px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// map a value from one range onto another, in this case scrolling | |
var st = _private.getScrollTop(), | |
m1 = _private.modulate( st, [0, 500], [0,1] ), | |
m2 = _private.modulate( st, [0, 400], [1,0] ), | |
m3 = _private.modulate( st, [0, 300], [0,3] ); | |
_private.modulate = function(val, range1, range2){ | |
var min1 = range1[0], max1 = range1[1], | |
min2 = range2[0], max2 = range2[1], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65"; | |
$(document).keydown(function(e) { | |
kkeys.push( e.keyCode ); | |
if ( kkeys.toString().indexOf( konami ) >= 0 ) { | |
$(document).unbind('keydown',arguments.callee); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validateEmail(email) { | |
var re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; | |
return re.test(email); | |
} |