Skip to content

Instantly share code, notes, and snippets.

@mfrancois3k
mfrancois3k / BinarySearchTree.js
Created February 24, 2022 00:08 — forked from zerobias/BinarySearchTree.js
Binary Search Tree
/**
* 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() {
/**

The Basics

Okay, we're going to warm up by implementing a reducer in order to get everything up and running again.

We're going to implement the basic functionality.

const reducer = (state = [], action) => {
  return state;
};
@mfrancois3k
mfrancois3k / redux demo js
Created February 27, 2022 01:16 — forked from justin3737/redux demo js
redux practice
//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);
@mfrancois3k
mfrancois3k / javascript.partial.markdown
Created March 4, 2022 06:19 — forked from polarity/javascript.partial.markdown
# Functional Programming Javascript: using Partials

Functional Programming Javascript: using Partials

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 
@mfrancois3k
mfrancois3k / array.js
Created March 4, 2022 08:03 — forked from brainrake/array.js
javascript functional array processing
// 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)
//
@mfrancois3k
mfrancois3k / code.js
Created March 4, 2022 08:07 — forked from bgoonz/code.js
object-methods.js
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']];
@mfrancois3k
mfrancois3k / gulpfile.js
Created March 5, 2022 02:28 — forked from ar-to/gulpfile.js
My Gulp file example
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
@mfrancois3k
mfrancois3k / gulpfile.js
Created March 5, 2022 02:29 — forked from dbasilioesp/gulpfile.js
Flow using Gulp
'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');
@mfrancois3k
mfrancois3k / README.md
Created March 5, 2022 02:32 — forked from theRemix/README.md
The Holy Grail - Gulp + Sass + LiveReload + Foundation

Gulp + Sass + LiveReload + Foundation

Goals

To have a gulp workflow that with a single process,

  1. watches for any sass changes, then compiles sass source into css
  2. watches for any changes in the public directory, triggers live-reload
  3. serves your static content in public/