Skip to content

Instantly share code, notes, and snippets.

View vasco3's full-sized avatar

Gorka Cesium vasco3

View GitHub Profile
var Style = React.createClass({
render: function() {
var style = assign({}, this.props);
delete style.children;
return React.createElement(
'div',
{style: style, children: this.props.children}
);
}
@vasco3
vasco3 / monads.markdown
Last active August 29, 2015 14:25
Monads

Monads

Macroids

function MONAD () {
  return function unit(value) {
 var monad = Object.create(null);
@vasco3
vasco3 / algorithms-notes.markdown
Last active September 24, 2015 03:29
Algorithm notes

Algorithms notes

Use Asymptotic Analysis to compare the eficiency of algorithms

Famous algorithm experts

  • Thomas Cormen
  • Devin Balkom
@kevinold
kevinold / immutable-js-flux-store.js
Created January 31, 2015 23:55
Immutable Flux Store example from Lee Byron (@leeb) from his React.js Conf 2015 talk
var Immutable = require('immutable');
var todos = OrderedMap();
var TodoStore = createStore({
getAll() { return todos; }
});
Dispatcher.register(function(action) {
if (action.actionType === "create") {
var id = createGUID();
@dmnd
dmnd / requiresToImports.js
Last active March 4, 2017 20:50 — forked from ide/requiresToImports.js
Converts commonJS requires to es6 imports
// converts commonJS requires to es6 imports
// var foo = require('foo');
// ->
// import foo from 'foo';
//
// jscodeshift -t requiresToImports.js src/**/*.js*
'use strict';
module.exports = function(fileInfo, api) {
var j = api.jscodeshift;

This is a response to Bill Fisher regarding experience with Flux:

@abdullin Also, can you clarify what you mean by "solution structure"? I am thinking about revising the examples soon.

Currently all flux samples (that I've seen) group files into folders based on technical similarity. For example, stores go with stores, action creators reside in the same folder shared with the other action creators.

This pattern works quite well for smaller projects. It feels especially good for the sample projects of various MVC frameworks, when you have just a bunch of controllers, models and views.

However, as we discovered on some production projects, such approach doesn't scale well. At some point you end up with dozens of technically similar files per folder and logically messy solution.

@datagrok
datagrok / ergodox.md
Last active January 14, 2019 07:45
Reflections on my ErgoDox keyboard
@jimfb
jimfb / react-refs-must-have-owner.md
Last active July 13, 2019 06:35
addComponentAsRefTo Invariant Violation

You are probably here because you got the following error messages:

addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's render method, or you have multiple copies of React loaded.

This usually means one of two things:

  • You are trying to add a ref to an element that is being created outside of a component's render() function.
  • You have multiple (conflicting) copies of React loaded (eg. due to a miss-configured NPM dependency)

Invalid Refs

@planetoftheweb
planetoftheweb / wkgitignore.txt
Last active July 21, 2019 21:33
sample .gitignore file from my workflows course.
.DS_Store
node_modules
.tmp
.sass-cache
builds/**/images/*
@CrabDude
CrabDude / callback_contract.md
Last active December 20, 2019 18:50
Node.js Callback Contract

Node.js Callback* Contract

(aka "errback" or "error first callback")

  1. Function that takes 2 arguments
    • first argument is an error
    • second argument is the result
    • Never pass both
    • error should be instanceof Error
  2. Must never excecute on the same tick of the event loop
  3. Must be passed as last argument to function