- Magnet - go throught the set up and boot at login
- WebStorm - License it, theme = dracula, javascript = ES6, keybind
Run
=⌘R
#!/bin/bash
while true; do
const http = require('http'); | |
// Create an HTTP server | |
var srv = http.createServer( (req, res) => { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('okay'); | |
}); | |
srv.on('upgrade', (req, socket, head) => { | |
socket.write('HTTP/1.1 101 Web Socket Protocol Handshake\r\n' + | |
'Upgrade: WebSocket\r\n' + |
'use strict'; | |
function doubleInteger( i ) { | |
// i will be an integer. Double it and return it. | |
return i * 2; | |
} | |
function isNumberEven( i ) { | |
// i will be an integer. Return true if it's even, and false if it isn't. | |
return ( i % 2 === 0 ); |
const fs = require( 'fs' ) | |
, path = require( 'path' ) | |
, _ = require( 'lodash' ); | |
let rootPath = "/path/to/remove"; | |
rmRF(rootPath); | |
function rmRF( dirPath ) { | |
fs.readdir( dirPath, ( err, files ) => { | |
if ( err ) console.log( JSON.stringify( err ) ); |
/* | |
* Below is an example of when to use `var` and `let` | |
*/ | |
'use strict'; | |
let a = 'a'; | |
var b = 'b'; | |
const c = 'c'; |
function getNow( off ) { | |
let date = new Date(); | |
date.setTime( date.getTime() + ( 3600000 * off || 0 ) ); | |
let y = date.getFullYear(), | |
mo = date.getMonth() + 1, | |
d = date.getDate(), | |
h = date.getHours(), | |
m = date.getMinutes(), | |
s = date.getSeconds(), | |
mm = date.getMilliseconds(); |
function getAllWithKey( o, k ) { | |
return new Promise( ( res, rej ) => { | |
let paths = [], | |
vals = [], | |
find = obj => { | |
return new Promise( r => { | |
let run = oa => _.forEach( oa, ( v, n ) => { | |
if( _.has( v, k ) ) { | |
vals.push( v[ k ] ); | |
_.unset( v, paths ); |
Forced un-encapsulation
const { resolve } = require( 'path' );
resolve( './path/' );
Object construction & check for lengthy OR statements
// With Lodash | |
let resolveAll = P => { | |
let map = ( pl, next ) => Promise.all( pl.map( p => Promise.resolve( p ).then( next ) ) ), | |
props = o => { | |
let pToR = []; | |
_.map( _.keys( o ), k => pToR.push( Promise.resolve( o[ k ] ).then( v => _.set( o, k, v ) ) ) ); | |
return Promise.all( pToR ).return( o ); | |
}, | |
rNP = o => Promise.resolve( o ).then( o => { | |
if( _.isArray( o ) ) return map( o, rNP ); |