Skip to content

Instantly share code, notes, and snippets.

View bhuizi's full-sized avatar

Bryan Huizi bhuizi

View GitHub Profile
@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
@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 / 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 / git
Created December 13, 2018 16:05
git
git stash show -p stash@{1} : show contents
@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 / 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 / spread reduce arrays
Last active July 18, 2017 13:51
spread reduce arrays
const offenseAnswer = [
{
name: 'offense1',
value: 'offense1 value'
},
{
name: 'offense2',
value: 'offense2 value'
},
{
@bhuizi
bhuizi / reducer.js
Created July 8, 2017 08:06
array reducer
const answers = [
{
name: 'offense1',
value: 'offense1 value'
},
{
name: 'offense2',
value: 'offense2 value'
},
{
@bhuizi
bhuizi / request_post.js
Created June 27, 2017 00:01
post request: using request
// superagent example https://github.com/request/request#streaming
const request = require('request');
const obj = {
username: 'string',
password: 'string',
redirectUrl: 'string',
sso: 'string'
};
@bhuizi
bhuizi / superagent_post.js
Created June 26, 2017 22:14
super agent example to return cookies
const request = require('superagent');
const agent = request.agent();
agent
.post(url)
.type('form')
.send(
{
username:"",
password:"^,W^.6ck",
redirectUrl: "''",