Skip to content

Instantly share code, notes, and snippets.

View self-loop link in directed layout
View joint.layout.kieler.js
function layout(graph) {
var graphJSON = { id: 'root', children: [], edges: [] };
_.each(graph.getElements(), function(el) {
graphJSON.children.push({
id: el.id,
width: el.get('size').width,
height: el.get('size').height
});
});
View Statechart require.js
var m = require('statechart-sync');
m.count = 3;
m.done = function() { /* ... */ };
var dispatch = function(err, doc) { m.dispatch(err ? 'error' : 'data', err || doc);
m.run();
db.get('myID1', dispatch);
db.get('myID2', dispatch);
View Statechart.js
var machine = _.extend({
// slots
count: 1,
done: function() {},
// logic
initialState: 'Init',
states: {
View Promises.js
var deferredValue = promiseMe();
deferredValue.then(function done(data) { /*...*/ });
View Continuation-passing style.js
function getData(callback) {
callAsync(function(data) {
callback(data);
})
}
getData(function done() { /* ... */ });
@DavidDurman
DavidDurman / gist:1423315
Created Dec 2, 2011
JointJS connections demo.
View gist:1423315
var paper = Raphel('paper', 400, 300),
rect = paper.rect(50, 50, 100, 30),
circle = paper.circle(200, 100, 20);
rect.joint(circle);