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
-- suppose you have a Vec2 and Vec3 type, and a T type which will use them accordingly | |
-- The Class information should be available out side of this file scope, e.g | |
-- require 'Vec2' | |
-- require 'Vec3' | |
-- require 'Class_with_dimension' | |
-- I wrote it down here just for simplification | |
local Vec2 = {} | |
function Vec2:new(x, y) return setmetatable({x, y}, {__index = self}) 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
// env, kit 為 server 暴露給開發者用的功能物件 | |
var sys = kit.sys; // 服務管理工具 | |
var game = kit.game; // 遊戲邏輯工具 | |
var db = kit.db; // 資料永續儲存介面 | |
var mem = kit.sharedmem; // shared variable, 跨多個 logic files | |
var data_ = {}; // user defined local variable | |
/* | |
* 1. 覆寫遊戲服務的管理事件, 如 start, stop 等, 沒寫的話 server 會用內建版本 | |
*/ |
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
/* list color 字記得改成 416A7A */ | |
pre { margin: 0; } | |
ol { list-style-type: decimal; } | |
ol ol, ol ol ol ol, ol ol ol ol ol ol { | |
list-style-type: none; | |
counter-reset: item; | |
margin: 0 0 0 2em; |
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
LOL | |
@ @@ | |
@@ @ @@ | |
@@ @@ @@@@ @@@ | |
@@@@@@@@@@@ | |
@@@ @@@@ | |
@@@@@@@ @@@ @@@@@ | |
@@@@@@@ @ @@ @@@ | |
@@@@@@@ @@ @@@@ @@ @ |
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
<NotepadPlus> | |
<UserLang name="Scala" ext="scala"> | |
<Settings> | |
<Global caseIgnored="no" /> | |
<TreatAsSymbol comment="no" commentLine="yes" /> | |
<Prefix words1="no" words2="no" words3="no" words4="no" /> | |
</Settings> | |
<KeywordLists> | |
<Keywords name="Delimiters">\'0"'0</Keywords> | |
<Keywords name="Folder+">{</Keywords> |
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 memoizer = function (memo, fundamental) { | |
var make_query = function(args) { | |
var i = 0, query = ''; | |
for( ; i < args.length - 1 ; i += 1 ) { | |
query += args[i] + ','; | |
} | |
query += args[i]; // i == args.length - 1 | |
return query; | |
}; |
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 memoizer = function (memo, fundamental) { | |
var shell = function (n) { | |
var result = memo[n]; | |
if (typeof result !== 'number') { | |
result = fundamental(shell, n); | |
memo[n] = result; | |
} | |
return result; | |
}; | |
return shell; |
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 fibonacci = function() { | |
var memo = [0, 1]; | |
var fib = function (n) { | |
var result = memo[n]; | |
if (typeof result !== 'number') { | |
result = fib(n - 1) + fib(n - 2); | |
memo[n] = result; | |
} | |
return result; | |
}; |
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.method('curry', function(){ | |
var slice = Array.prototype.slice, | |
args = slice.apply(arguments), | |
that = this; | |
return function(){ | |
var complete_pack = args.concat(slice.apply(arguments)); | |
if( complete_pack.length < that.arity ) { | |
return that.curry.apply(that, complete_pack); | |
} | |
else return that.apply(null, complete_pack); |
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
r = Regexp.new( | |
'( (http|https|ftp)://)*'+ #protocol:// 可有可無 | |
'( (\d{1,3}\.){3,3}\d{1,3}|'+ #第二段,這邊可能是 IPv4 | |
'((-|\w)+\.)+(tw|com|aero|us|gr)|'+ #或正常suffix的DN | |
'((-|\w)+\.)*localhost )'+ #或localhost | |
'(:\d{1,5})?'+ #:port number | |
'(/\S+)*', Regexp::EXTENDED) #第一個 / 後面就不管他了 |