Skip to content

Instantly share code, notes, and snippets.

View pertrai1's full-sized avatar
🏠
Working from home

Rob Simpson pertrai1

🏠
Working from home
  • Waynesville, NC
View GitHub Profile
@pertrai1
pertrai1 / intersection.js
Last active March 12, 2019 05:49
Set, Map, WeakSet, WeakMap
let union = ( set1, set2 ) => {
return new Set([...set1, ...set2]);
}
let first = [1, 3, 1, 5, 7, 3, 9, 12, 15];
let second = [1, 20, 18, 5, 10, 3, 16];
union(first, second); /*? */
let intersection = (set1, set2) => {
@pertrai1
pertrai1 / map1.js
Created March 11, 2019 04:30
Map Reduce Example
const map = (fn, arr) => arr.reduce((acc, item) => {
return acc.concat(fn(item));
}, []);
const myArray = [2, 4, 6, 8];
const reduceFn = item => item * 2;
const myReducer = map(reduceFn, myArray);
@pertrai1
pertrai1 / csx-fn-challenge-4.js
Created June 22, 2018 11:14
CSX Function Challenge 4
let calls = "";
function jerry(str) {
kramer('Jerry');
}
function george(str) {
calls = str + 'George';
elaine(calls);
}
function add(a, b) {
return a + b;
}
function sub(a, b) {
return a - b;
}
function mul(a, b) {
return a * b;
@pertrai1
pertrai1 / example01.js
Created April 25, 2018 09:02 — forked from mpj/example01.js
Code for the async/await episode of Fun Fun Function.
const response = await fetch(`https://catappapi.herokuapp.com/users/${userId}`)
const data = await response.json()
return data.imageUrl
}
@pertrai1
pertrai1 / tsconfig.json
Created March 17, 2018 11:50
TS Config BP
{
"compilerOptions": {
"target": "es2017",
"outDir": "build/main",
"rootDir": "src",
"moduleResolution": "node",
"module": "commonjs",
"declaration": true,
"inlineSourceMap": true,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
@pertrai1
pertrai1 / floats.css
Created October 3, 2017 15:34
FE Masters Float Example
/* Border box declaration
https://www.paulirish.com/2012/box-sizing-border-box-ftw/ */
html {
box-sizing: border-box;
}
/* inherit border-box on all elements in the universe and before and after
*/
*,
*:before,
*:after {
@pertrai1
pertrai1 / .vimrc
Created May 29, 2017 13:47
Latest Vimrc
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-git'
@pertrai1
pertrai1 / man-output
Created January 21, 2017 03:31
Send man pages to Preview
man -t grep | open -f -a Preview
@pertrai1
pertrai1 / derived.js
Last active January 15, 2017 21:31
JavaScript class from C++
/**
This is the C++ example
#include <iostream>
using namespace std;
class Base
{
public:
int m_id;