See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
<scope>
is optional
<?php | |
/** | |
* Recursively get taxonomy hierarchy | |
* | |
* @source http://www.daggerhart.com/wordpress-get-taxonomy-hierarchy-including-children/ | |
* @param string $taxonomy | |
* @param int $parent - parent term id | |
* | |
* @return array |
// @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 (value === null || typeof value === 'number' || typeof value === 'undefined' || typeof value.call === 'undefined') { | |
return false; | |
} | |
return true; |
Total props to Brian Cray: http://briancray.com/posts/estimated-reading-time-web-design/ |