Skip to content

Instantly share code, notes, and snippets.

View roblafeve's full-sized avatar
🥽

Rob LaFeve roblafeve

🥽
View GitHub Profile
@roblafeve
roblafeve / maybe.ts
Last active January 29, 2019 15:38
Modeling the Maybe monad in TypeScript
/**
* Tag
* These are used to create the Tagged Union
**/
const enum Tag {
None = "None",
Some = "Some"
}
@roblafeve
roblafeve / reducer.ts
Last active January 4, 2019 20:31
Vanilla Redux w/ TypeScript
const enum ActionTypes {
A1 = "A1",
A2 = "A2",
}
type ReduxAction<Type extends ActionTypes, Payload> = {
type: Type,
payload: Payload
}
@roblafeve
roblafeve / fp.md
Last active February 7, 2018 15:36
FP Concepts

Morphism

Morphisms can have any of the following properties.

A morphism f :: a -> b is a:

  • monomorphism (or monic) if f ∘ g1 = f ∘ g2 implies g1 = g2 for all morphisms g1, g2 : x → a.
  • epimorphism (or epic) if g1 ∘ f = g2 ∘ f implies g1 = g2 for all morphisms g1, g2 : b → x.
  • bimorphism if f is both epic and monic.
  • isomorphism if there exists a morphism g : b → a such that f ∘ g = 1b and g ∘ f = 1a.[b]
@roblafeve
roblafeve / reduce.js
Last active May 27, 2017 20:13
Recursive Reduce
// Recursive Reduce
const reduce = (x, y, z) => {
const head = z[0]
return !head
? y
: reduce(x, x(y, head), z.slice(1))
}
// Direct usage of reduce
reduce((acc, x) => acc + x, 0, [1, 2, 3]) // 6

Keybase proof

I hereby claim:

  • I am roblafeve on github.
  • I am roblafeve (https://keybase.io/roblafeve) on keybase.
  • I have a public key ASDF7gNVhCwvUTZJfZJ9WNBYhGgazV2yS_7BE24lsuCiKQo

To claim this, I am signing this object:

Actions

Actions correspond to Redux Async Action Creators and are responsible for dispatching store actions (found:'../src/store') or other async actions.

Typical Structure

While the specific implementation may vary, async actions take this basic form. Partial application is used to provide easy dependency injection (useful for easy testing of success and failure cases).

index.js

@roblafeve
roblafeve / confident-and-comfortable-with-node.md
Last active August 29, 2015 14:27
Getting Confident and Comfortable with Node.js

Getting Confident and Comfortable with Node.js

What is Node?

Simply, a Javascript runtime.

The success of Node

  1. Asynchronous as First Class Citizen
  2. Non-blocking I/O
  3. Event-driven I/O
  4. Single Threaded

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@roblafeve
roblafeve / modal_sans-js.html
Created November 10, 2013 23:57
A vertically-aligned, overflow-scrollable CSS-only modal.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Modal Sans-JS</title>
<style>
* { box-sizing: border-box }
body {
@roblafeve
roblafeve / _heading-scale.scss
Created August 21, 2013 21:46
A mixin that allows rapid creation of dynamic heading sizes based on any defined ratio. (Credit to @albatrocity for helping me out on this one.)
@mixin header-scale($ratio: 5, $top-offset: 0, $bottom-offset-ratio: 0.875, $header-rank-shift: -1, $min-width: null, $max-width: null) {
$min-width-query: "(min-width: #{$min-width})";
@if $min-width == null {
$min-width-query: "";
}
$max-width-query: "(max-width: #{$max-width})";
@if $max-width == null {
$max-width-query: "";
}