Skip to content

Instantly share code, notes, and snippets.

View philcms1's full-sized avatar

Phil philcms1

View GitHub Profile
const flattenArr = (arr = []) => {
// Executing recursively a reducer function seems the logical choice, since it will result...
// ...in a single output value
return arr.reduce((accumulator, currentValue) => {
return accumulator.concat(Array.isArray(currentValue) ? flattenArr(currentValue) : currentValue);
}, []);
};
// Using Jest for testing
test('[[1,2,[3]],4] -> [1,2,3,4]', () => {
@philcms1
philcms1 / .eslintrc
Last active January 3, 2018 16:34
ESLint configuration with Airbnb JavaScript Style Guide
{
"extends": "airbnb",
"parser": "babel-eslint",
"env": {
"node": true,
"es6": true,
"mocha": true
},
"rules": {
// indentation
@philcms1
philcms1 / server.js
Created February 27, 2017 18:00
Sample Express.js configuration with Webpack-dev-middleware, to allow with backend authentication.
/**
* Created by Phil on 02/23/17.
*/
// BASE SETUP
// ================================================================================================
// Imports
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const path = require('path');
@philcms1
philcms1 / .vimrc
Created June 3, 2016 19:04
VIM configuration
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required