diff --git a/source/downloads/code/ruby/test.rb b/source/downloads/code/ruby/test.rb new file mode 100644 index 0000000..186ea2b --- /dev/null +++ b/source/downloads/code/ruby/test.rb @@ -0,0 +1,20 @@ +class Float + def number_decimal_places + self.to_s.length-2 + end + def to_fraction + higher = 10**self.number_decimal_places + lower = self*higher + gcden = greatest_common_divisor(higher, lower) + + return (lower/gcden).round, (higher/gcden).round + end + +private + def greatest_common_divisor(a, b) + while a%b != 0 + a,b = b.round,(a%b).round + end + return b + end +end diff --git a/source/downloads/code/test.coffee b/source/downloads/code/test.coffee new file mode 100644 index 0000000..9917177 --- /dev/null +++ b/source/downloads/code/test.coffee @@ -0,0 +1,8 @@ +fibonacci = (n) -> + if n <= 2 + n + else + arguments.callee(n - 2) + arguments.callee(n - 1) + +for x in [1..10] + console.log "#{x} : #{fibonacci(x)}" diff --git a/source/downloads/code/test.js b/source/downloads/code/test.js new file mode 100644 index 0000000..ce01bf7 --- /dev/null +++ b/source/downloads/code/test.js @@ -0,0 +1,20 @@ +/** +sample javascript from xui +*/ + +var undefined, + xui, + window = this, + string = new String('string'), + document = window.document, + simpleExpr = /^#?([\w-]+)$/, + idExpr = /^#/, + tagExpr = /<([\w:]+)/, + slice = function (e) { return [].slice.call(e, 0); }; + try { var a = slice(document.documentElement.childNodes)[0].nodeType; } + catch(e){ slice = function (e) { var ret=[]; for (var i=0; e[i]; i++) + ret.push(e[i]); return ret; }; } + +window.x$ = window.xui = xui = function(q, context) { + return new xui.fn.find(q, context); +};