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/1231855642 | |
var calc = { | |
add: function (node) { | |
return visit(this, node.l) + visit(this, node.r); | |
}, | |
sub: function (node) { | |
return visit(this, node.l) - visit(this, node.r); | |
}, | |
val: function (node) { |
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
using System; | |
using System.Data.Common; | |
using System.Threading; | |
using Soma.Core; | |
namespace DbTransactionExample | |
{ | |
public static class LocalDbExtensions | |
{ |
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 chain(functions) { | |
return functions.reduceRight(function (next, curr) { | |
return function () { | |
var result = curr.apply(null, arguments); | |
return next.call(null, result); | |
}; | |
}); | |
} | |
function pipeline(val) { |
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 create(behaviors, context) { | |
return Object.getOwnPropertyNames(behaviors).reduce(function(obj, name) { | |
obj[name] = behaviors[name].bind(context); | |
return obj; | |
}, {}); | |
} | |
var Gadget = { | |
getName: function () { | |
return this.name; |
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 fun(f) { | |
return function curry() { | |
if (arguments.length < f.length) { | |
var args = Array.prototype.slice.call(arguments); | |
return function () { | |
return curry.apply(this, args.concat(Array.prototype.slice.call(arguments))); | |
} | |
} else { | |
return f.apply(this, arguments); | |
} |
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
fun = (f) -> | |
curry = () -> | |
if (arguments.length < f.length) | |
args = Array.prototype.slice.call(arguments); | |
() -> | |
curry.apply(this, args.concat(Array.prototype.slice.call(arguments))); | |
else | |
f.apply(this, arguments) | |
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 class MyCommandObserver : ICommandObserver | |
{ | |
public void NotifyExecuting(DbCommand command, PreparedStatement statement, out object userState) | |
{ | |
OracleCommand oracleCommand = command as OracleCommand; | |
if (oracleCommand != null && oracleCommand.CommandType == CommandType.StoredProcedure) | |
{ | |
oracleCommand.BindByName = true; | |
} | |
userState = null; |
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 fs = require('fs'); | |
var domain = require('domain'); | |
function countChars(filename, callback) { | |
var d = domain.create().on('error', function (err) { | |
callback(err); | |
}); | |
fs.readFile(filename, 'utf-8', d.intercept(function (_, data) { | |
callback(null, data.length); | |
})); |
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
package example; | |
import java.math.BigDecimal; | |
import java.math.BigInteger; | |
import java.sql.Array; | |
import java.sql.Blob; | |
import java.sql.Clob; | |
import java.sql.Date; | |
import java.sql.NClob; | |
import java.sql.Time; |
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 req = msIndexedDB.deleteDatabase("MyDB"); | |
req.onsuccess = function () { | |
var req = msIndexedDB.open("MyDB"); | |
req.onupgradeneeded = function (event) { | |
var db = event.target.result; | |
var store = db.createObjectStore("MyStore", {autoIncrement: true }); | |
store.createIndex("name", "name", { unique: true }); | |
}; | |
req.onsuccess = function (event) { | |
var db = event.target.result; |