added files for documentation on include_code

This commit is contained in:
Brandon Mathis 2011-08-21 16:21:59 -04:00
parent 2ff46f3711
commit 1e26b77a0d
3 changed files with 48 additions and 0 deletions

View File

@ -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

View File

@ -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)}"

View File

@ -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);
};