-
Editor -> Colors & Fonts -> Copy Scheme and change font to
Source Code Pro -
Keymap -> Run ->
⌘-R
Forced un-encapsulation
const { resolve } = require( 'path' );
resolve( './path/' );Object construction & check for lengthy OR statements
This file contains hidden or 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
| 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 ); |
This file contains hidden or 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
| // 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 ); |
This file contains hidden or 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 rand = () => { | |
| const a = [ | |
| 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', | |
| 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', | |
| 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', | |
| 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', | |
| 'w', 'x', 'y', 'z', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 | |
| ]; | |
| let i = -1; | |
| while ( ++i < 62 ) { |
This file contains hidden or 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
| "use strict"; | |
| // Average completion time: 9.57 ms | |
| const [ a, o, ms, s, log ] = ( function * () { | |
| yield * [ | |
| ( process.hrtime )(), | |
| process.hrtime, | |
| ms => ( ( ms[ 0 ] * 1e9 + ms[ 1 ] ) / 1000000 ), | |
| s => s / 1000, | |
| () => { |
This file contains hidden or 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
| #include <stdio.h> | |
| int main(int argc, char *argv[]) { | |
| int w = 0; | |
| for( int x = 0; x < 100; x++ ) { | |
| for( int y = 0; y < 100; y++ ) { | |
| for( int z = 0; z < 100; z++ ) { | |
| w += z; | |
| } |
chmod 400 key.pemssh -i "nick-aws-key.pem" [email protected]sudo apt-get upgradesudo apt-get updatecurl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -sudo apt-get install -y nodejssudo apt-get install -y build-essentialsudo apt-get install awsclisudo vi /etc/ssh/sshd_configPasswordAuthentication no=>PasswordAuthentication yes
This file contains hidden or 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
| 'use strict'; | |
| let crypto = require( 'crypto' ), | |
| request = require( 'request' ), | |
| qstr = require( 'querystring' ), | |
| keys = Object.keys, | |
| signString = ( method, endpoint, uri, qs ) => `${method}\n${endpoint}\n${uri}\n${qs}`, | |
| makeString = ( ...args ) => args.join( '' ), | |
| generateHmac = ( signedData, awsSecretKey ) => crypto.createHmac( 'sha256', awsSecretKey ).update( signedData ).digest( 'base64' ), | |
| urlEncode = o => keys( o ).reduce( ( r, k ) => ( r[ encodeURIComponent( k ) ] = encodeURIComponent( o[ k ] ), r ), {} ), |
This file contains hidden or 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> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>AWS IoT Pub/Sub Demo</title> | |
| </head> | |
| <body> | |
| <h1>AWS IoT Pub/Sub Demo</h1> | |
| <form> | |
| <button type="button" id="connect">connect!</button> |