This file contains hidden or 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
// work in progress | |
// problem: you push a change to the database now your whole app needs to also update to that change | |
// one solution is to fetch the data back from the server just after it has changed | |
// this assumes acid updates, elastic search is not acid, nor are many nosql databases | |
// this is an impossible solution without acid | |
// the alternative is to retain an in memory copy of the data and update it optimistically | |
// if there is an error from the server roll back the in memory change | |
// if there is no error the update is already in memory, barring any server side transformations not accounted for | |
// to make this work you need to keep each object in memory over time, |
This file contains hidden or 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
/** | |
* @license | |
* Lodash (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE | |
* Build: `lodash include="isObject,isEqual"` | |
*/ | |
;(function(){function t(t,e){for(var r=-1,n=null==t?0:t.length,o=0,a=[];++r<n;){var i=t[r];e(i,r,t)&&(a[o++]=i)}return a}function e(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return true;return false}function r(t){return function(e){return t(e)}}function n(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function o(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}function a(){}function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){ | |
var n=t[e];this.set(n[0],n[1])}}function c(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function s(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function u(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new s;++e<r;)this.add(t[e])}function f(t){this.size=(th |
This file contains hidden or 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 mapper(data, setType) { | |
let keys = Object.keys(data), | |
ret = data.concat ? [] : {}; | |
console.log("keys", keys); | |
while (keys.length) { | |
let key = keys.shift(), | |
obj = data[key]; |
This file contains hidden or 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 React, { Component } from 'react'; | |
import DevTools from 'mobx-react-devtools'; | |
import Konva from 'konva'; | |
import {Stage, Layer, Rect, Line, Image} from 'react-konva'; | |
import Img from './Img/Img.js'; | |
import './App.css'; | |
import pg from '../assets/scribo-doc-dia-00008061.json' | |
console.log(pg); |
This file contains hidden or 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
// a normalize function constructor for mapping from one range of numbers to another | |
// actually it is 4 ranges, one from mid to max another from min to mid for each domain | |
// so given 3 input (domainA) numbers for min, mid, max | |
// and given 3 output (domainB) numbers or arrays of any length of numbers also for min, mid, max | |
// the constructor function will return a normalize function that wil convert any number in domainA to domainB | |
// | |
// example: | |
// converting a value from -1 to 1 to a color ramp red to green | |
// with a white neutral in the middle and alpha evenly interpolated | |
// |
This file contains hidden or 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 Map(keys, values) {return new _Map(keys, values)} | |
function _Map(keys, values) {this.clear(keys, values);} | |
_Map.prototype = { | |
set: function(key, value) { | |
var i = this.indexOf(key); | |
this._keys[i] = key; | |
this._values[i] = value; | |
return i !== this._keys.length; | |
}, |
This file contains hidden or 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
/** | |
* forceUpdateOnState | |
* | |
* @param state immstruct structure | |
* @returns component mixins {componentWillMount, componentWillUpdate, componentWillUnmount} | |
* | |
* the parent component should provide to the target component | |
* a map of prop names as keys for cursors and period delimited path strings | |
* on as 'cursors' property, e.g. <div cursors={{foo: 'bar.foo'}}></div> | |
* in the above example: props.foo = state.reference(['bar', 'foo']).cursor() |
This file contains hidden or 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
var webpack = require('webpack'), | |
path = require('path'), | |
ExtractTextPlugin = require("extract-text-webpack-plugin"), | |
isDev = process.env.NODE_ENV; | |
var config = { | |
cache: true, | |
resolve: { | |
extensions: ["", ".js", ".css", ".styl"] |
This file contains hidden or 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
var es = require('event-stream'), | |
gulp = require('gulp'), | |
riot = require('gulp-riot'), | |
rimraf = require('gulp-rimraf'), | |
jshint = require('gulp-jshint'), | |
stylus = require('gulp-stylus'), | |
concat = require('gulp-concat'), | |
uglify = require('gulp-uglify'), | |
notify = require("gulp-notify"), | |
plumber = require('gulp-plumber'), |
This file contains hidden or 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 jaccardIndex(s1, s2) { | |
// Jaccard index: http://en.wikipedia.org/wiki/Jaccard_index | |
// size of the intersection divided by the size of the union of the sample sets | |
s1 = _.isArray(s1) ? s1 : _.keys(s1); | |
s2 = _.isArray(s2) ? s2 : _.keys(s2); | |
return _.intersection(s1, s2).length / _.union(s1, s2).length | |
} |