View StateTree.hs
module StateTree ( buildTree ) where
import Prelude hiding (lookup)
import Control.Monad.State
import Data.Map (Map, insert, insertWith, empty, lookup)
data Item = Item {
sId :: String,
pId :: String,
value :: [Char],
View gist:f7b2010dc3752fa5db60f5719ae3b878
So if we have configs like:
- All button from Red Button to Blue Button (style change)
- The form should have 1 sidebar, 1 main aread with 4 fields, instead of only 1 main area with 2 fields (layout change)
- W/o loging, the Submit button pressed, it should show error message in DOM instead of redirect to login page (behaviour change)
The config will have a variance-id, like case01, case02...
--
View regulator.js
'use strict';
/**
* A regulator connects Source and Reducer/Effect with regards of responsiveness.
*/
class Regulator {
constructor(configs) {
this._source = null;
View oauthmultipartform.js
var fs = require('fs');
var request = require('request');
/*
var plurkTokens =
{ "consumer_key": "<key>"
, "consumer_secret": "<secret>"
, "token": "<token>"
, "token_secret": "<secret>"
};
View ncu-exam.js
// This would provide `createFile`, `createReadStream`, `writeContent` and `createWriteStream`.
var FileSystem = require('FileSystem');
var Reader = function() {
this.counter = 0;
};
Reader.prototype = FileSystem.prototype;
Reader.prototype.paths = ['/tmp/urandom-1.txt', '/tmp/urandom-2.txt'];
Reader.prototype.start = function() {
this.mainPromise = Promise.resolve()
.then(function() {
View ncu-q4.js
var Cube = function(width) {
this.width = width;
};
Cube.prototype.volume = function() {
return Math.pow(this.width, 3);
};
var cube = new Cube(4)
cube.volume = cube.volume.bind({ width: 3});
View ncu-q3.js
var Cuboid = function() {
this.volume = function() {
return this.cuboidSize[0] *
this.cuboidSize[1] *
this.cuboidSize[2] ;
};
};
Cuboid.prototype.cuboidSize = [12, 8, 10];
View ncu-q2.js
var Foo = function() {};
Foo.prototype.bark = function() {
console.log('Foo barks');
};
var Bar = function() {};
Bar.prototype = Foo.prototype;
Bar.prototype.bark = function() {
console.log('Bar barks');
};
View simpleClosureTrick.js
(function() {
let action = 'barks';
let foo = function() {
console.log('foo', action);
};
})();
console.log(typeof foo);
View simpleThisTrick.js
let Foo = function() {
this._name = 'Foo';
};
Foo.prototype.bark = function() {
console.log(this._name, ' barks');
};
let foo = new Foo();
let fooBark = foo.bark;