Skip to content

Instantly share code, notes, and snippets.

View bhuizi's full-sized avatar

Bryan Huizi bhuizi

View GitHub Profile
@bhuizi
bhuizi / promise_example.js
Last active January 7, 2018 04:55
promise example
const other = new Promise((resolve, reject) => {
let values = [1,2, 3,4, 5];
let sum = values.reduce((acc, next) => {
return acc + next;
}, 0)
resolve(sum);
reject('something went wrong');
});
let fullName = (first, last) => {
@bhuizi
bhuizi / example.js
Last active June 5, 2018 03:55
functional-lite
// compose
sum = (x, y) => x + y;
mult = (x, y) => x * y;
const result = sum(mult(3, 4), 5);
console.log(result);
compose2 = (fn1, fn2) => {
@bhuizi
bhuizi / git
Created December 13, 2018 16:05
git
git stash show -p stash@{1} : show contents
@bhuizi
bhuizi / launch.json
Created December 20, 2018 21:06
launch json w/ ts
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
@bhuizi
bhuizi / script.js
Last active January 19, 2019 18:10
dr_boolean
// 02
// const Box = x => ({
// map: f => Box(f(x)),
// fold: f => f(x),
// inspect: () => `Box(${x})`
// })
// const moneyToFloat = str =>
// Box(str)
// .map(s => s.replace(/\$/g, ''))
@bhuizi
bhuizi / script.js
Created May 3, 2019 14:10
algorithms in javascript
2. Divide and Conquer
function diffSum (arr){
if(arr.length === 0) return 0;
return arr[0] + sum(arr.slice(1))
}
sum([1, 2, 3])
3. Select Sort