In your command-line run the following commands:
brew doctor
brew update
const memoizeUtil = func => { | |
// results store | |
const cache = {}; | |
return (input) => { | |
// return the value if it exists in the cache object | |
// otherwise, compute the input with the passed in function and | |
// update the collection object with the input as the key and | |
// computed result as the value to that key | |
// End result will be key-value pairs stored inside cache | |
return cache[input] || (cache[input] = func(input)); |
https://github.com/amix/vimrc | |
let g:javascript_plugin_jsdoc = 1 | |
let g:javascript_conceal_arrow_function = "⇒" |
var http = require('http'); | |
var fs = require('fs'); | |
var path = require('path'); | |
http.createServer(function (request, response) { | |
console.log('request ', request.url); | |
var filePath = '.' + request.url; | |
if (filePath == './') { | |
filePath = './index.html'; |
" Basic settings | |
set nocompatible " behave like vim, not old vi | |
set modelines=0 " don't use modelines | |
set viminfo='20,\"50 " use a viminfo file,... | |
set history=50 " and limit history | |
set ruler " show the cursor position | |
set title " show title on the window | |
set autoread " reload file if changed outside vim | |
set autowrite " save file on some commands | |
set scrolloff=1 " minimal no. of lines around cursor |
// Object.assign has an issue with nested Objects. This prevents that leakage | |
const cloneObj = (existingObj) => { | |
return JSON.parse(JSON.stringify(existingObj)) | |
} |
// Async compose | |
const compose = (…functions) => input => functions.reduceRight((chain, func) => chain.then(func), Promise.resolve(input)); | |
// Functions fn1, fn2, fn3 can be standard synchronous functions or return a Promise | |
compose(fn3, fn2, fn1)(input).then(result => console.log(`Do with the ${result} as you please`)) |
const fs = require('fs') | |
const rootDir = require('../utils/rootDir') | |
const env = { | |
// accepts a filename and if no filename, it defaults to .env | |
config: filename => { | |
filename === undefined ? (filename = '.env') : filename | |
fs.readFileSync(`${rootDir}/${filename}`, 'utf-8') |
const trace = label => value => { | |
console.log(`{$label} : {$value}`); | |
return value; | |
} |
In your command-line run the following commands:
brew doctor
brew update
function bytesToSize (bytes) { | |
if (bytes === 0) return '0 B'; | |
var k = 1024; | |
var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] | |
var i = Math.floor(Math.log(bytes) / Math.log(k)) | |
return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i] | |
} |