Skip to content

Instantly share code, notes, and snippets.

View benoneal's full-sized avatar

Ben O'Neal benoneal

View GitHub Profile
@benoneal
benoneal / solution.js
Created January 15, 2018 03:09
Mars Rover Solution
const INITIAL_COMMAND = `5 5
1 2 N
LMLMLMLMM`
const cardinals = ['N', 'E', 'S', 'W']
const directions = {L: -1, R: 1}
const traverseRing = (ring, i) =>
ring[(i % ring.length + ring.length) % ring.length]
const marshal = input => {
@benoneal
benoneal / workshop_requirements.js
Created September 15, 2017 23:49
React Workshop Requirements
// Node
https://nodejs.org/en/download/current/
// Create React App
https://github.com/facebookincubator/create-react-app
@benoneal
benoneal / SSR considerations.md
Last active September 17, 2017 14:53
SSR considerations

SSR Considerations:

ES Modules Non-js files babel/webpack compile server code Gate browser-specific APIs

React componentDidMount Ensure responsiveness through CSS only

@benoneal
benoneal / classical.js
Last active October 3, 2017 03:18
Controlled/uncontrolled pattern with Recompose
class AsyncButton extends Component {
render() {
const {
loading,
action,
label,
children
} = this.props
return (
@benoneal
benoneal / bindEvents
Created March 6, 2016 23:42
Isomorphic and legacy browser compatible event binding
'use strict'
let exists = scope => typeof scope !== 'undefined' ? scope : null
let bind = (e, fn, scope) => {
scope.addEventListener && scope.addEventListener(e, fn)
scope.attachEvent && scope.attachEvent(`on${e}`, () => fn.call(scope))
}
let unbind = (e, fn, scope) => {
@benoneal
benoneal / gist:80f98bedba0eab17c8e8
Created July 23, 2015 12:01
Dawn Relationships
List of possible relationships
everyone
grandfather
grandmother
father
mother
child
sibling
cousin
let options = { something: value, somethingElse: anotherVal }
// interface 1: instantiate with an options object
let lib = require('lib')(options)
// interface 2: exposes an init method, into which you pass options
let lib = require('lib')
lib.init(options)
// interface 3: assign options directly on the library
[credential]
helper = osxkeychain
[alias]
co = checkout
st = status
di = diff
dc = diff --cached
pull = pull --ff-only
lg = log --pretty=format:'%C(bold)-%Creset %C(red bold)%h%d%Creset | %C(green)%an%Creset | %C(magenta)%cr%Creset | %C(cyan)%s%Creset'
[push]