Skip to content

Instantly share code, notes, and snippets.

View joshburgess's full-sized avatar
💭
🤔

Josh Burgess joshburgess

💭
🤔
View GitHub Profile
@joshburgess
joshburgess / introrx.md
Created October 28, 2015 04:03 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@joshburgess
joshburgess / frp.md
Created November 4, 2015 16:12 — forked from ohanhi/frp.md
Learning FP the hard way: Experiences on the Elm language

Learning FP the hard way: Experiences on the Elm language

by Ossi Hanhinen, @ohanhi

with the support of Futurice 💚.

Licensed under CC BY 4.0.

Foreword

After listening to the latest Magic Read-along episode "You should watch this" (which you should go listen to now) I got caught up thinking about Brian's idea of an Endomorphism version of Kleisli composition for use with Redux, it's actually a very similar model to what I'm using in my event framework for event listeners so I figured I'd try to formalize the pattern and recognize some of the concepts involved. IIRC Brian described the idea of a Redux-reducer, which is usually of type s -> Action -> s, it takes a state and an action and returns a new state. He then re-arranged the arguments to Action -> s -> s. He then recognized this as Action -> Endo s (an Endo-morphism is just any function from one type to itself: a -> a). He would take his list of reducers and partially apply them with the Action, yielding a list of type Endo s where s

@joshburgess
joshburgess / egghead-screencast-guideline.md
Created June 9, 2017 23:41 — forked from joelhooks/egghead-screencast-guideline.md
It seems trivial to record a 1-8 minute screencast, but there are actually quite a few moving parts when it comes to recording a **high quality** screencast. Here's some of our thoughts on the subject.

Recording a Great Coding Screencast

The Screen

First and foremost a coding screencast is about the code, and we need to make sure it looks great. There are a few aspects to this that help ensure that is the case.

Resolution

720p is the target resolution. In pixel terms this is 1280x720. We've gotten the best results when we record at 2560x1440 in a HiDPI (pixel double) mode, giving an effective visible resolution of 1280x720, but extremely crisp. This resolution is achievable on 27" monitors and retina MBPs.

@joshburgess
joshburgess / flatten.js
Last active February 10, 2018 17:58
Solutions showing how to flatten arbitrarily nested arrays of ints in JavaScript
// shorthand function for the Number.isInteger method
const isInt = Number.isInteger
// shorthand function for the Array.isArray method
const isArray = Array.isArray
// functional wrapper for the Array.reduce method
const reduce = f => initVal => arr => arr.reduce(f, initVal)
// functional wrapper for the Array.concat method
import compose from 'ramda/src/compose'
import equals from 'ramda/src/equals'
import filter from 'ramda/src/filter'
import head from 'ramda/src/head'
import length from 'ramda/src/length'
import map from 'ramda/src/map'
import min from 'ramda/src/min'
import not from 'ramda/src/not'
import sort from 'ramda/src/sort'
import split from 'ramda/src/split'
import all from 'ramda/src/all'
import chain from 'ramda/src/chain'
import compose from 'ramda/src/compose'
import contains from 'ramda/src/contains'
import curry from 'ramda/src/curry'
import equals from 'ramda/src/equals'
import filter from 'ramda/src/filter'
import flip from 'ramda/src/flip'
import join from 'ramda/src/join'
import map from 'ramda/src/map'
@joshburgess
joshburgess / articles.md
Created February 15, 2018 07:45 — forked from miwillhite/articles.md
Functional JavaScript (and other)
@joshburgess
joshburgess / recursive-tree-traversal-and-aggregation.js
Last active February 22, 2018 10:53
Demonstrates how to traverse a tree of unknown subtrees for 'content' items of a specific type
// write a function to find all content items of a specific type
// under a specific topic, where a "topic" could be a top-level
// subject, a subcategory of that subject, or a particular concept
// falling under that subcategory
// possible example data structure
const EDUCATION_DATA = {
math: {
arithmetic: {
subtraction: {

The future is here: Classless object-oriented programming in JavaScript.

Douglas Crockford, author of JavaScript: The Good parts, recently gave a talk called The Better Parts, where he demonstrates how he creates objects in JavaScript nowadays. He doesn't call his approach anything, but I will refer to it as Crockford Classless.

Crockford Classless is completely free of class, new, this, prototype and even Crockfords own invention Object.create.

I think it's really, really sleek, and this is what it looks like:

function dog(spec) {