Skip to content

Instantly share code, notes, and snippets.

View abiodun0's full-sized avatar

Abiodun abiodun0

View GitHub Profile
@abiodun0
abiodun0 / introrx.md
Created March 13, 2016 12:03 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@abiodun0
abiodun0 / slim-redux.js
Created June 12, 2016 23:21 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@abiodun0
abiodun0 / gulpfile.js
Last active June 26, 2016 20:58
Seeting up react gist
"use strict";
var gulp = require('gulp');
var connect = require('gulp-connect'); // Runs a local dev server
var open = require('gulp-open');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var concat = require('gulp-concat');
var eslint = require('gulp-eslint');
var babelify = require('babelify');
getDate: function(driverDobParam) {
const givenDate = driverDobParam || this.state.formDob || this.props.dob;
const timestamp = Date.parse(givenDate);
let dateGiven;
if (!isNaN(timestamp)) {
dateGiven = new Date(timestamp);
}
return dateGiven;
},
validatedDate: function(givenDate) {
@abiodun0
abiodun0 / ngrxintro.md
Created August 10, 2016 17:19 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

#Comprehensive Introduction to @ngrx/store By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

Type Safe JSON Decoding in Elm

The power of a Static Typed language can seem magical at first. But the goal here is to take a tiny peak behind that curtain.

Elm's implementation of JSON parsing is type safe and how it achieves that can seem like a mystery. Even though I got the code to work, it took me a while to fully understand how it works.

I'm writing it down here for 2 reasons. To help others gain a greater understanding of Types and so I don't forget what I learned.

Word of Caution

@abiodun0
abiodun0 / finabocci.hs
Last active July 17, 2020 14:19
Estimates the time difference in performance for recursive and iterative function in javascript. Using finabocci as a case study
recurse :: (Integral a) -> a -> a
recurse 1 = 1
recurse 0 = 1
recurse n = recurse (n-2) + recurse (n-1)
-- refactoring
recurse :: (Integral a) -> a -> a
recurse n
| n < 2 = 1
| otherwise = recurse (n-2) + recurse (n-1)
function Index() {
this.importedJson = {}
}
Index.prototype.createIndex = function () {
fetch('the url to the jsoin').then((res)=> {
return res.json()
}).then((res)=> {
this.importedJson = res
})
function pay() {
for(var i = 0; i< employees.length; i++ ){
if(employees[i].isPayDay()){
let pay = employees[i].calculate(pay);
employees[i].deliverPay(pay);
}
}
}
// This particular piece of code does three things.. Refactoring
function promiseFn(id) {
// replace this with your axios function, this is an asyn simulator
return new Promise(function(resolve, reject){
setTimeout(()=> resolve(id), 2000);
});
}
let makePromises = (result) => result.map(promiseFn);
Promise.all(makePromises([1,2,3,4,5])).then(function(r){
console.log(r)