Skip to content

Instantly share code, notes, and snippets.

View iSkore's full-sized avatar
Vue + Vuetify + AWS Amplify = Power Overwhelming

Nick Soggin iSkore

Vue + Vuetify + AWS Amplify = Power Overwhelming
View GitHub Profile
@iSkore
iSkore / socketTalk.js
Created April 19, 2016 19:23
Talk to sockets
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' +
@iSkore
iSkore / SlickPractice.js
Created April 21, 2016 18:37
Double, isEven, getFileExtension, longestString, arraySum fun functions
'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 );
@iSkore
iSkore / recursiveRemoveFiles.js
Last active May 5, 2016 15:27 — forked from liangzan/recursiveRemoveFiles.js
A Node.js script to remove all files in a directory recursively
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 ) );
@iSkore
iSkore / environment.md
Last active May 12, 2016 19:00
Mac environment needs

Environment needs

Constantly updated list of environment needs for OSX environment

  1. Magnet - go throught the set up and boot at login
  2. WebStorm - License it, theme = dracula, javascript = ES6, keybind Run = ⌘R
#!/bin/bash

while true; do
/*
* Below is an example of when to use `var` and `let`
*/
'use strict';
let a = 'a';
var b = 'b';
const c = 'c';
@iSkore
iSkore / webstorm.md
Last active September 1, 2016 18:46
WebStorm's a wild animal. Here's how to tame it.

Settings

  • Editor -> Colors & Fonts -> Copy Scheme and change font to Source Code Pro

  • Keymap -> Run -> ⌘-R

@iSkore
iSkore / timestamp.js
Last active September 12, 2016 16:14
Excellent time stamp function
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();
@iSkore
iSkore / getAllWithKey.js
Created September 15, 2016 19:09
Get all values for key
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 );
@iSkore
iSkore / tricks.md
Last active September 19, 2016 04:22
Some funny tricks

Forced un-encapsulation

const { resolve } = require( 'path' );

resolve( './path/' );

Object construction & check for lengthy OR statements

@iSkore
iSkore / RecursivePromise.js
Last active September 28, 2016 19:27
Recursive Promise Resolution
// 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 );