This file contains hidden or 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 twoDigits(n) { | |
return n < 10 ? '0' + n : '' + n; | |
} |
This file contains hidden or 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 arrayContains(array, string) { | |
return array.indexOf(string) > -1; | |
} |
This file contains hidden or 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 waitDOM(element, callback, waitTime) { | |
var stop = 0; | |
var waitTime = waitTime || 100; | |
var wait = setInterval( function() { | |
var elementDOM = document.querySelector(element); | |
if (elementDOM) { | |
clearInterval(wait); | |
callback(); | |
} else { |
This file contains hidden or 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 convertTimestamp(timestamp) { | |
function twoDigits(n) { | |
return n < 10 ? '0' + n : '' + n; | |
} | |
var date = new Date(timestamp); | |
var day = twoDigits(date.getDate()); | |
var month = twoDigits(date.getMonth()); | |
var year = date.getFullYear(); |
This file contains hidden or 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
/*! normalize-all-you-really-need-tho.css v1.0.0 | MIT License */ | |
html { | |
font-family: sans-serif; /* 1 */ | |
-webkit-text-size-adjust: 100%; /* 2 */ | |
-ms-text-size-adjust: 100%; /* 2 */ | |
} | |
body { | |
margin: 0; |
This file contains hidden or 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 equal(a, b, description) { | |
if (a === b) { | |
console.log('%c✔︎ ok', 'color: green', description); | |
} | |
else { | |
console.log('%c✘ not ok', 'color: red', description); | |
console.assert(a === b, description); | |
} | |
} |
This file contains hidden or 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
// Performs a smooth page scroll to an anchor on the same page. | |
// reference: http://css-tricks.com/snippets/jquery/smooth-scrolling/ | |
$(function() { | |
$('a[href*=#]:not([href=#])').click(function() { | |
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { | |
var target = $(this.hash); | |
target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); | |
if (target.length) { |
This file contains hidden or 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 React = require('react'); | |
var Input = React.createClass({ | |
getInitialState: function() { | |
return { | |
value: this.props.value || '' | |
}; | |
}, |
This file contains hidden or 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
// https://speakerdeck.com/vjeux/react-css-in-js | |
function m() { | |
var res = {}; | |
for (var i = 0; i < arguments.length; ++i) { | |
if (arguments[i]) { | |
Object.assign(res, arguments[i]); | |
} | |
} | |
return res; |
This file contains hidden or 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
/** | |
* Merge objects (recursively merge deep objects) | |
* @param {object} objects as arguments to merge merge(object, object2,..) | |
*/ | |
var merge = function() { | |
var res = {}; | |
for (var i = 0; i < arguments.length; ++i) { | |
if (arguments[i]) { |
OlderNewer