A Pen by Anuj Yadav on CodePen.
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
/** | |
* A binary search tree implementation in JavaScript. This implementation | |
* does not allow duplicate values to be inserted into the tree, ensuring | |
* that there is just one instance of each value. | |
* @class BinarySearchTree | |
* @constructor | |
*/ | |
class BinarySearchTree { | |
constructor() { | |
/** |
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
//https://egghead.io/lessons/javascript-redux-the-single-immutable-state-tree | |
//redux | |
const createStore = (reducer, initialState) => { | |
let state = initialState; | |
let listeners = []; | |
const getState = () => state; | |
const dispatch = (action) => { | |
state = reducer(state, action); |
Partials are basically functions that return functions with some already predefined arguments and need some arguments to be completed. Let's say you have a function with several arguments to be set, but you don't want to set the majority of arguments over and over again because you need it more than once.
# my useless function to write something to the dom
function writeSomethingToDom(element, content){
element.append(content);
}
# use the function repeatedly
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
// sml-list-style array functions | |
copy = (xs) => xs.slice(0, xs.length) | |
cons = (x, xs) => { ys = copy(xs); ys.unshift(x); return ys} | |
isEmpty = (xs) => xs.length == 0 | |
hd = (xs) => xs[0] | |
tl = (xs) => { ys = copy(xs); ys.unshift(); return ys } | |
repeat = (n, x) => new Array(n).fill(x) | |
// |
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 CSVToArray( data, delimiter = ',', omitFirstRow = false ) { | |
return data | |
.slice( omitFirstRow ? data.indexOf( '\n' ) + 1 : 0 ) | |
.split( '\n' ) | |
.map( v => v.split( delimiter ) ); | |
} | |
CSVToArray( 'a,b\nc,d' ); // [['a', 'b'], ['c', 'd']]; | |
CSVToArray( 'a;b\nc;d', ';' ); // [['a', 'b'], ['c', 'd']]; | |
CSVToArray( 'col1,col2\na,b\nc,d', ',', true ); // [['a', 'b'], ['c', 'd']]; |
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
var gulp = require('gulp');//main | |
var filter = require('gulp-filter');//filters files with globs | |
var pump = require('pump');//used only on uglify | |
var sass = require('gulp-sass');//using | |
var autoprefixer = require('gulp-autoprefixer');//using | |
var pug = require('gulp-pug');//using | |
var pugInheritance = require('gulp-pug-inheritance');//compile only changed files | |
var sourcemaps = require('gulp-sourcemaps');//using | |
var requirejsOptimize = require('gulp-requirejs-optimize');//using;optimizes modules individually & bundle (minify) | |
var path = require("path");//using for callback for pug task |
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'; | |
// Include Gulp & Tools We'll Use | |
var gulp = require('gulp'); | |
var concat = require('gulp-concat'); | |
var $ = require('gulp-load-plugins')(); | |
var del = require('del'); | |
var runSequence = require('run-sequence'); | |
var browserSync = require('browser-sync'); | |
var pagespeed = require('psi'); |