Semantic Commit Messages
See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
<scope>
is optional
// @function explode() -- split a string into a list of strings | |
// {string} $string: the string to be split | |
// {string} $delimiter: the boundary string | |
// @return {list} the result list | |
@function explode($string, $delimiter) { | |
$result: (); | |
@if $delimiter == "" { | |
@for $i from 1 through str-length($string) { | |
$result: append($result, str-slice($string, $i, $i)); | |
} |
<!DOCTYPE html> | |
<head> | |
<script type='text/javascript'> | |
window.onload = function () { | |
var video = document.getElementById('videoId'); | |
var canvas = document.getElementById('canvasId'); | |
var img = document.getElementById('imgId'); | |
video.addEventListener('play', function () { | |
canvas.style.display = 'none'; |
/** | |
* Freeze given value recursively if needed. | |
* @param obj | |
* @return {*} | |
*/ | |
export default function freezeRecursive(obj) { | |
Object.freeze(obj); | |
if (obj === undefined) { | |
return obj; |
/** | |
* Returns the distance bewteen 2 coordinates. | |
* @param {Object} from - Object with lat and lng | |
* @param {Object} to - Object with lat and lng | |
* @return {float} | |
*/ | |
function distance(from, to) { | |
const {atan2, cos, sqrt, sin} = Math; | |
// @note - radius of the planet earth in meters | |
const R = 6378137; |
/** | |
* Define unwritable property to the given object. | |
* @example | |
* var test = {}; | |
* test = definePropertyFreeze(test, 'foo', 'bar'); | |
* test = definePropertyFreeze(test, 'baz', {bat: 'bral'}); | |
* test = definePropertyFreeze(test, 'bot', [1, 2]); | |
* // then | |
* test.bat = 'ok'; // works | |
* test.foo = 'nok'; // not working, test.foo return 'bar' |
/** | |
* Memoization helper. | |
* @param fn | |
* @param context | |
* @return Function | |
*/ | |
export default function memoize(fn, context = null) { | |
const cache = {}; | |
return (...args) => { |
/** | |
* Return true if the given value is a callable object or function. | |
* @param value | |
*/ | |
export default function isCallable(value) { | |
if (fn === null || typeof fn === 'number' || typeof fn === 'undefined' || typeof fn.call === 'undefined') { | |
return false; | |
} | |
return true; |
See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
<scope>
is optional
Total props to Brian Cray: http://briancray.com/posts/estimated-reading-time-web-design/ |
/* | |
* Easing Functions - inspired from http://gizma.com/easing/ | |
* only considering the t value for the range [0, 1] => [0, 1] | |
*/ | |
EasingFunctions = { | |
// no easing, no acceleration | |
linear: function (t) { return t }, | |
// accelerating from zero velocity | |
easeInQuad: function (t) { return t*t }, | |
// decelerating to zero velocity |