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
# truly curried function ! | |
add = (x)->(y)-> x()+y() | |
add4 = add(()->4) | |
console.log(add(()->4)(()->6)) | |
console.log(add4(()->6)) |
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
/* description: Parses end executes mathematical expressions. */ | |
/* lexical grammar */ | |
%lex | |
%% | |
\s+ { return 'SP'; } | |
"->" { return 'AR'; } | |
"(" { return 'LP'; } | |
")" { return 'RP'; } |
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
應該是在 toggle 設定時,雖然做了 names_node 去存父子的 name ,偵測反應時卻依然只是用 dom_name 這個單層者,沒有使用 names_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
RSpec::Matchers.define(:be_same_file_as) do |exected_file_path| | |
match do |actual_file_path| | |
md5_hash(actual_file_path).should == md5_hash(exected_file_path) | |
end | |
def md5_hash(file_path) | |
Digest::MD5.hexdigest(File.read(file_path)) | |
end | |
end |
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 t = ["3+3;console.log('abc');"] | |
var tb = new Blob(t, {"type": "text\/javascript"}); | |
w = new Worker(window.webkitURL.createObjectURL(tb)) |
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
location /newapi/no-op { | |
add_header Content-Type "application/json; charset=utf-8"; | |
return 200; | |
} |
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
Compute | |
.init( {:Xa => xa, :domain => domain, :uid => uid} ) | |
.wait("resource.scalar_product.Ra_ra",:Ra, :ra) #1. | |
.compute(:Xa_, lambda{ |m| add(m[:Xa], m[:Ra], m[:domain]) } ) #2. | |
.send("resource.scalar_product.Xa_", :Xa_) #3. | |
.wait("resource.scalar_product.Xb_", :Xb_) #4. | |
.wait("resource.scalar_product.t", :t) #5. | |
.compute( :yA, lambda{ |m| t1 = trans(m[:Xb_], m[:domain]) | |
t2 = mul(m[:Ra],t1, m[:domain]) | |
t3 = sub(m[:t] ,t2, m[:domain]) }) #6. |
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
t = fluorine.Environment({a: 1}) | |
.local(function(e){ return {'b': this.a+1}; }) | |
.async() | |
.local(function(data){ console.log('data');console.log(this.data);return this}) | |
.done().run() | |
// 重點:async 實作中設定了接續 run 的部份 | |
/* | |
// THIS FUNCTION IS ONLY FOR TEST ASYNC CALLS. |
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
Env(a:3, b:4) | |
._(()->@a+=3) | |
._(()->@b+=4) | |
.done() | |
.run() |
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
// From http://stackoverflow.com/questions/14850511/js-matrix-multiplication-issue | |
function multiplyMatrix(m1, m2) { | |
var result = []; | |
for(var j = 0; j < m2.length; j++) { | |
result[j] = []; | |
for(var k = 0; k < m1[0].length; k++) { | |
var sum = 0; | |
for(var i = 0; i < m1.length; i++) { | |
sum += m1[i][k] * m2[j][i]; | |
} |
OlderNewer