Skip to content

Instantly share code, notes, and snippets.

View elierotenberg's full-sized avatar

Elie Rotenberg elierotenberg

View GitHub Profile
@elierotenberg
elierotenberg / Animate.js
Created July 25, 2014 09:37
Animating with React and d3
var _ = require("lodash");
var d3 = require("d3");
var raf = require("raf");
var getInterpolator = function getInterpolator(from, to) {
return d3.interpolate(from, to);
};
var startInterpolation = function startInterpolation(properties, easing, duration, onTick, onComplete) {
var aborted = false;
/** @jsx React.DOM */
var React = require("react");
var AnimateMixin = require("react-animate");
var SimpleAnimation = React.createClass({
mixins: [AnimateMixin],
getInitialState: function getInitialState() {
return {
showoff: false,
};
@elierotenberg
elierotenberg / SimpleCSS.jsx
Created August 2, 2014 17:01
SimpleCSS.jsx
/** @jsx React.DOM */
var React = require("react");
var fromCSS = require("react-css").fromCSS;
var myStyle = fromCSS("{" +
"transform: rotate(20deg);" +
"background-color: red;" +
"width: 100px;" +
"margin: 50px;" +
"}");
@elierotenberg
elierotenberg / SimpleAnimationWithCSS.jsx
Created August 2, 2014 17:03
SimpleAnimationWithCSS.jsx
/** @jsx React.DOM */
var React = require("react");
var AnimateMixin = require("react-animate");
var fromCSS = require("react-css").fromCSS;
var from = fromCSS("{" +
"transform: rotate(0deg);" +
"background-color: blue;" +
"margin: 50px;" +
"width: 200px;" +
@elierotenberg
elierotenberg / SpinWheel.jsx
Created August 2, 2014 17:03
SpinWheel.jsx
/** @jsx React.DOM */
var React = require("react");
var AnimateMixin = require("react-animate");
var fromCSS = require("react-css").fromCSS;
var from = fromCSS("{" +
"transform: rotate(0deg);" +
"background-color: blue;" +
"margin: 50px;" +
"width: 200px;" +
@elierotenberg
elierotenberg / AsyncDependenciesExample.js
Last active August 29, 2015 14:06
AsyncDependencies
var AsyncDependencies = require("react-asyncdependencies");
var request = require("request");
var TodoList = React.createClass({
mixins: [AsyncDependencies.Mixin],
getInitialState: function() {
return {
todosIds: null,
};
},
@elierotenberg
elierotenberg / .bashrc
Created December 15, 2014 16:01
Usefule .bashrc additions
alias git-patch="git add -A && git commit -m"
alias npm-patch="npm version patch && git push && git push --tags && npm publish"
alias npm-minor="npm version minor && git push && git push --tags && npm publish"
alias npm-major="npm version major && git push && git push --tags && npm publish"
alias npm-upgrade="npm cache clear && npm-check-updates -u && npm install"
function renderToObject(element) {
const inst = instantiateReactComponent(element);
inst.state = inst.getInitialState ? inst.getInitialState() : null;
return Promise.resolve(inst.componentWillMount ? inst.componentWillMount() : null)
.then(() => {
const r = inst.render();
inst.componentWillUnmount();
return r;
});
}
Full stack flux
^ Actions go up v Updates go down
PostgreSQL (shardable)
^ Stored procedures v NOTIFY
Node PostegreSQL/redis broker (clusterable)
^ PUBLISH v SUBSCRIBE
redis MQ (shardable)
^ PUBLISH v SUBSCRIBE
@elierotenberg
elierotenberg / server.js
Last active August 29, 2015 14:15
Flux over the Wire server.js
const server = new FluxServer(8080);
const messageList = server.Store('/messageList');
messageList.set('nextId', 0).commit();
const postMessage = server.Action('/postMessage')
.onDispatch(({ nickname, message }) => {
messageList.set(messageList.get('nextId') + 1, { nickname, message })
.set('nextId', messageList.get('nextId') + 1)
.commit()
});