Skip to content

Instantly share code, notes, and snippets.

View kole's full-sized avatar

Nick Johnson kole

  • San Francisco, CA
  • 06:57 (UTC -07:00)
View GitHub Profile
@kole
kole / gist:246c88f98d93baf6bece43404b9d9cac
Created January 28, 2019 17:13
Quick Start React App
# Create react app
- `npx create-react-app <app-location>`
- cd to new react app directory
# Add eslint (StandardJS)
- `npm install standard --save-dev`
- `touch eslintrc.yml && echo "extends: standard" >> eslintrc.yml`
@kole
kole / uniq_arrays.js
Last active September 11, 2017 19:24
Unique Arrays in ES2015
// adapted from https://gist.github.com/aherve/741753e1f25e4c87450e6aebe590134b
// more info on Set: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
// Get a unique array of numbers
const numbersArr = [4, 1, 2, 1, 1, 2, 1, 3, 4, 1 ]
const uniqNumArr = [...new Set(numbersArr)] // => [ 4, 1, 2, 3 ]
const uniqNumArrSorted = [...new Set(numbersArr)].sort(); // => [ 1, 2, 3, 4 ]
// Get a unique array of strings (unsorted)
const strArr = ['c', 'a', 'b', 'c', 'c', 'c', 'd', 'a'];
@kole
kole / fibonacci.js
Created January 17, 2017 17:54
Return number in Fibonacci sequence at given index
// Fibonacci sequence for increased delay algorithm
// return number in sequence at given index
const fib = (a) => {
const arr = [0, 1];
let i = a;
if (i > 30) { i = 30; } // safeguard against recursion
for (let n = 0; n < i; n++) {
const last = arr[arr.length - 1];
const nextToLast = arr[arr.length - 2];
const sum = nextToLast + last;