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
open System | |
open Soma.Core | |
let config = | |
{ new MsSqlConfig() with | |
member this.ConnectionString = "Data Source=.\SQLEXPRESS;Initial Catalog=Soma.Tutorial;Integrated Security=True" } | |
let person = dynamic config.Dialect | |
person?name <- "hoge"; | |
person?age <- 20; |
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
var assert = require('assert'); | |
// Object -> Function.prototype -> Object.prototype -> null | |
assert.strictEqual(Object.__proto__, Function.prototype); | |
assert.strictEqual(Function.prototype.__proto__, Object.prototype); | |
assert.strictEqual(Object.prototype.__proto__, null); | |
// Function -> Function.prototype -> Object.prototype -> null | |
assert.strictEqual(Function.__proto__, Function.prototype); | |
assert.strictEqual(Function.prototype.__proto__, Object.prototype); |
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
var nue = require('nue'); | |
var serial = nue.serial; | |
var serialEach = nue.serialEach; | |
var parallel = nue.parallel; | |
var parallelEach = nue.parallelEach; | |
var start = nue.start; | |
start(serial( | |
function () { console.log('a'); this.next(); }, | |
function () { console.log('b'); this.next(); }, |
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
nue = require('nue') | |
flow = nue.flow | |
parallel = nue.parallel | |
fs = require('fs') | |
flow( | |
parallel( | |
-> fs.readFile('path1', 'utf-8', @async()) | |
-> fs.readFile('path2', 'utf-8', @async())) | |
(results) -> fs.writeFile('path3', results[0] + results[1], @async()); |
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 f(a, b, c) { | |
console.log(this); | |
console.log(a); | |
console.log(b); | |
console.log(c); | |
} | |
var context = { | |
name: 'context' | |
}; |
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
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind | |
var toArray = Function.prototype.call.bind(Array.prototype.slice); | |
function f() { | |
var array = toArray(arguments); | |
console.log(Array.isArray(array)); // true | |
} | |
f(1,2,3); |
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
var flow = require('../index').flow; | |
var fs = require('fs'); | |
var hogeFlow = flow( | |
function (a, b) { | |
var self = this; | |
throw new Error('ERROR'); | |
setTimeout(function () { | |
self.next('HELLO' + a + b); | |
}, 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 a(x) { | |
console.log('a is called: ' + x); | |
if (this.next) { | |
this.next.call(null, 'aaa'); | |
} | |
} | |
function b(x) { | |
console.log('b is called: ' + x); | |
if (this.next) { |
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
var EventEmitter = require('events').EventEmitter; | |
var util = require('util'); | |
var F = function () {}; | |
util.inherits(F, EventEmitter); | |
Object.getOwnPropertyNames(Function.prototype).forEach(function(e) { | |
F.prototype[e] = Function.prototype[e]; | |
}); |
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
// see http://d.hatena.ne.jp/ashigeru/20090113/1231857274 | |
function edit(start, end, chars, buf) { | |
var undo = buf.val.slice(start, end); | |
buf.val = buf.val.slice(0, start) + chars + buf.val.slice(end); | |
return edit.bind(null, start, start + chars.length, undo); | |
} | |
function sequence(commands, buf) { | |
var undos = []; |
OlderNewer