This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Grid from './grid.js'; | |
var grid = new Grid(); | |
m.module(document.getElementById("grid-container"), { | |
controller: function () { | |
grid.init(); | |
// Generate a random number of panels (with random | |
// number of child tiles to create variations in height) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Collection { | |
constructor (opts = {}) { | |
this.list = []; | |
this.length = 0; | |
var isFn = $.is.function; | |
if (opts.key) { | |
var keyType = $.object.type(opts.key); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sum (arr) { | |
return arr.reduce((x, i) => x + i, 0); | |
} | |
function mean (arr) { | |
return sum(arr) / arr.length; | |
} | |
function variance (arr) { | |
let m = mean(arr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////// | |
// Factory // | |
///////////// | |
Kefir.model = function (store, tx) { | |
if (typeof tx !== 'function') tx = x => x; | |
const getset = function kefir$model (update) { | |
if (arguments.length > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkValue (msg, value, type) { | |
const check = t.validate(value, type); | |
if (!check.isValid()) { | |
console.error(msg + ' ' + check.firstError().message); | |
} | |
return value; | |
} | |
// This method accepts an object and returns a function that |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Action definition signature | |
const Definition = t.struct({ | |
fn: t.Func, | |
displayName: t.maybe(t.Str), | |
inputs: t.maybe(t.Obj), | |
exits: t.maybe(t.Obj), | |
sync: t.maybe(t.Bool) | |
}); | |
cerebral.action = function cerebral$action (action) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m.createComponent = function createClass (displayName, opts) { | |
const hooks = _.defaults(opts, hookDefaults); // Apply some defaults (excluded) | |
const methods = _.methods(_.omit(opts, hookNames)); // Get instance methods | |
const propTypes = createValidator(hooks.propTypes, displayName); // Create a prop type validator (excluded) | |
const Component = { | |
controller () { | |
const initialState = hooks.getInitialState() || {}; | |
const ctrl = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const t = require('tcomb'); | |
const Person = t.struct({ name: t.Str, money: t.Num }, 'Person'); | |
Person.prototype.pay = function (amount) { | |
return Person.update(this, { | |
money: { $set: this.money + t.Num(amount) } | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
localhost:80 | |
gzip | |
ext .html | |
root /home/deploy/current/build/www | |
proxy /graphql localhost:3000 | |
rewrite /login { | |
to {path} /login | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Internal helpers | |
*/ | |
// Predicates can return true/false or they can return an error message. | |
// true, null, undefined and empty string are considered a valid result | |
function isValid (result) { | |
return result === true || result === null || result === void 0 || result === ''; | |
} |
OlderNewer