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
root = true | |
[*] | |
end_of_line = lf | |
insert_final_newline = true | |
trim_trailing_whitespace = true | |
indent_style = space |
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
copyClass = (klass) -> | |
newKlass = (new Function(""" | |
return function (call) { | |
return function #{klass.name}() { | |
return call(this, arguments) | |
}; | |
}; | |
""")())(Function.apply.bind(klass)) | |
for own key, value of klass |
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
shinout ~ shinout$ npm install strongloop | |
> [email protected] install /Users/shinout/node_modules/strongloop/node_modules/strong-supervisor/node_modules/heapdump | |
> node-gyp rebuild | |
CXX(target) Release/obj.target/heapdump/src/heapdump.o | |
CXX(target) Release/obj.target/heapdump/src/platform-posix.o | |
SOLINK_MODULE(target) Release/heapdump.node | |
SOLINK_MODULE(target) Release/heapdump.node: Finished | |
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
N = 100000 | |
READ_SIZE = 100 | |
fs = require "fs" | |
fd = fs.openSync __filename, "r" | |
i = 0 | |
console.time "sync" | |
while i < N |
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
rt = require "random-tools" # https://github.com/shinout/random-tools | |
N = 1000000 | |
d = [] | |
i = 0 | |
# data preparation | |
while i < N | |
n = rt.randomInt(256 * 256 * 256 - 1) | |
b = new Buffer(3) |
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
fs = require("fs") | |
rstream = fs.createReadStream process.argv[2] | |
wstream = fs.createWriteStream(process.argv[3]) | |
rstream.setEncoding "utf-8" | |
ended = false | |
piping = -> | |
return if ended | |
d = rstream.read() | |
return rstream.once "readable", read_write if d is null |
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
GAP = -1 | |
MISMATCH = -1 | |
MATCH = 1 | |
class Cell | |
constructor: (i,j)-> | |
@p1 = i | |
@p2 = j | |
@pointers = [] | |
@score = 0 |
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
const UP = 1; | |
const LEFT = 2; | |
const UL = 4; | |
function nw(s1, s2, op) { | |
op = op || {}; | |
const G = op.G || 2; | |
const P = op.P || 1; | |
const M = op.M || -1; | |
var mat = {}; |
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
least_square = (dataset)-> | |
n = dataset.length | |
sigma_xy = 0 | |
sigma_x = 0 | |
sigma_y = 0 | |
sigma_xsq = 0 | |
for data in dataset | |
x = data[0] | |
y = data[1] |
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
# 最急降下法 | |
steepest = (f, alpha, x0)-> | |
alpha = 1/2 * (Math.abs Math.random()) + 0.1 if typeof alpha isnt "number" | |
alpha = Math.abs alpha | |
x0 = Math.random() if typeof x0 isnt "number" | |
fx0 = f(x0) | |
x = x0 + 0.01 # for approximating gradient | |
loop |