Skip to content

Instantly share code, notes, and snippets.

//
// Author: Jonathan Blow
// Version: 1
// Date: 31 August, 2018
//
// This code is released under the MIT license, which you can find at
//
// https://opensource.org/licenses/MIT
//
//

Motivation

  • expression-oriented programming one of the great advances of FP
  • expressions plug together like legos, making more malleable programming experience in-the-small

Examples

Write in an expression-oriented style, scoping variables as locally as possible:

@geoffreydhuyvetters
geoffreydhuyvetters / react_fiber.md
Last active January 13, 2023 06:49
What is React Fiber? And how can I try it out today?
@thebigredgeek
thebigredgeek / input.js
Created December 1, 2016 20:42
Pure input component with external value and sticky cursor
import React, { PropTypes } from 'react';
import classNames from 'classnames';
import { autobind } from 'core-decorators'
import PureComponent from './pure';
@withStyles(style)
export default class Input extends PureComponent {
static propTypes = {
onChange: PropTypes.func.isRequired,
@gunar
gunar / curryNamed.js
Last active November 11, 2019 22:20
Currying Functions with Named Parameters in JavaScript
/**
* Currying Functions with Named Parameters.
* @gunar, @drboolean, @dtipson 2016
*
* Why does it return a thunk, though?
* Because in JS named arguments are opaque. There is no way of getting a function's named arguments list.
* e.g.
* const foo = function ({ a, b }) { }
* console.log(foo.arguments) // Throws. Ideally would return ['a', 'b'].
*
class TodoStore extends BaseStore {
// Constructor is executed in the config phase.
constructor(stores, initialState) {
super(stores, initialState) // ensures initial state loads for SSR
// Other store initialization...
}
// This is executed in the run phase, after all stores have initialized.
storeDidInitialize(stores) {
@gaearon
gaearon / combining.js
Created June 3, 2015 18:03
Combining Stateless Stores
// ------------
// counterStore.js
// ------------
import {
INCREMENT_COUNTER,
DECREMENT_COUNTER
} from '../constants/ActionTypes';
const initialState = { counter: 0 };
@chenglou
chenglou / gist:34b155691a6f58091953
Last active April 5, 2021 19:15
Better feature for React key

key is pretty much crucial for state perservation in React. As of React 0.13 it can't do the following things:

  • Clone state
<Comp key={1} /><Comp key={1} />
  • Preserve component state across different parents:
@iamatypeofwalrus
iamatypeofwalrus / stacktrace.md
Last active July 28, 2023 13:07
Print stacktrace without raising and Exception in Ruby and/or Rails

Print a stacktrace in Ruby or Rails without raising an exception

Why

You know what method is being and you want to figure out how it got there. Raising an exception is a bit harsh since all you want is a stack trace

How

puts caller

Seriously. It's that easy. If you're getting too much information you could

@hugomd
hugomd / google-comments.html
Created September 25, 2013 07:01
Use Google+ comments.
<script src="https://apis.google.com/js/plusone.js">
</script>
<div class="g-comments"
data-href="[URL]"
data-width="642"
data-first_party_property="BLOGGER"
data-view_type="FILTERED_POSTMOD">
</div>