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
$ brew update | |
$ brew install nvm | |
$ mkdir ~/.nvm | |
# in your ~/.zshrc or in .bash_profile | |
$ export NVM_DIR=~/.nvm | |
$ source $(brew --prefix nvm)/nvm.sh |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet"> | |
<title>Donut</title> | |
<style> |
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
/** | |
* Freeze nested objects | |
* | |
* const dude = deepFreeze({ | |
* name: 'John', | |
* lastname: 'Doe', | |
* address: { | |
* street: 'Wall Street', | |
* number: '62' | |
* } |
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
#add 'node_modules' to .gitignore file | |
git rm -r --cached node_modules | |
git commit -m 'Remove the now ignored directory node_modules' | |
git push origin master |
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
/** | |
* Asynchronous Loop | |
* @param {Int} | |
* @param {Function} | |
* @param {Function} | |
* @return {Object} | |
* | |
* | |
* Usage: | |
* |
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 roman = (n) => { | |
n = String(Math.floor(Math.abs(n))) | |
let element, i, result = '' | |
const table = [ | |
['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'], | |
['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'], | |
['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM'] | |
] | |
for (i = 0; i < table.length; i += 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
export const repeat = (str, times) => (new Array(times + 1)).join(str); | |
export const padStart = (num, maxLength, char = ' ') => repeat(char, maxLength - num.toString().length) + num; | |
export const formatTime = (time) => { | |
const h = padStart(time.getHours(), 2, '0'); | |
const m = padStart(time.getMinutes(), 2, '0'); | |
const s = padStart(time.getSeconds(), 2, '0'); | |
const ms = padStart(time.getMilliseconds(), 3, '0'); | |
return `${h}:${m}:${s}.${ms}`; |
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
clamp (n, min, max) { | |
return Math.max(Math.min(n, max), min) | |
} |
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
range (num) { | |
return [...Array(num).keys()] | |
} |
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 assignPrototypeMethods = ( constructorMethod, context ) => { | |
// Loop over the BaseController's prototype methods and assign them to the current context | |
for ( var methodName in constructorMethod.prototype ) { | |
if (constructorMethod.prototype.hasOwnProperty( methodName ) && !context[ methodName ]) { | |
// Copy the method into the current controller context. | |
context[ methodName ] = constructorMethod.prototype[ methodName ]; | |
} | |
} | |
} |
NewerOlder