Skip to content

Instantly share code, notes, and snippets.

View moredip's full-sized avatar

Pete Hodgson moredip

View GitHub Profile
@moredip
moredip / run-command-on-git-revisions
Created May 8, 2011 06:58
A quieter version of Gary Bernhardt's script, with timestamps
#!/bin/bash
#
# This script runs a given command over a range of Git revisions. Note that it
# will check past revisions out! Exercise caution if there are important
# untracked files in your working tree.
#
# This came from Gary Bernhardt's dotfiles:
# https://github.com/garybernhardt/dotfiles
#
# Example usage:
@moredip
moredip / -README.md
Last active July 3, 2017 06:15
functionally-stateful

stateful()

A helper function that lets us write stateful React components in the same functional style as stateless components.

Why?

  • sidesteps the need to introduce class and this-binding confusion into your codebase.
  • slightly terser, slightly more declarative
  • opinionated - doesn't expose the more dangerous features of class-based Components (e.g. lifecycle callbacks)

When you have a team working on a larger React codebase it is hard for everyone to understand which patterns are preferable vs. those which are a necessary compromise.

@moredip
moredip / part-app.js
Last active July 13, 2017 15:42
Introduce Partial Application
const priceByCommodityAndCountry = {
'MANGO': [
{
origin: 'US',
price: 101
},
{
origin: 'BR',
price: 120
@moredip
moredip / registerCustomer.coffee
Created April 9, 2012 16:35
Alternative functional approach to dealing with the async pyramid. This is a response to http://wekeroad.com/2012/04/05/cleaning-up-deep-callback-nesting-with-nodes-eventemitter/
validate = (customer, next)->
console.log 'validating...'
#VALIDATE HERE
next()
insert = (customer, next)->
console.log 'inserting...'
# insert into DB (asynchronously of course), and then call...
next()
@moredip
moredip / test.json
Created November 28, 2012 22:49
A small sample JSON file
{
"test":"json"
}