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
class Animal | |
private_method= -> 1+1 | |
@::sum= -> private_method() | |
dog=new Animal() | |
alert dog.sum() | |
class Fish extends Animal | |
delfin=new Fish() |
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
promise= (fn) -> df= $.Deferred(fn).promise() | |
df=promise (df) -> setTimeout( (-> df.resolve(1000)), 1 ) | |
df.pipe (x) -> | |
promise (df) -> setTimeout( (-> df.resolve(x+1000)), 2 ) | |
.pipe (x) -> | |
promise (df) -> setTimeout( (-> df.resolve(x+1000)), 2 ) | |
.pipe (x) -> | |
promise (df) -> setTimeout( (-> df.resolve(x+1000)), 2 ) | |
.pipe (x) -> |
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
//support for annotations | |
// https://wiki.php.net/rfc/annotations | |
@class_annotation({a:1,b:2}) | |
class Main { | |
@range(1,100) |
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
//support for autoboxing | |
// https://wiki.php.net/rfc/autoboxing | |
class Main { | |
public static function main() { | |
var hash = new Hash<Dynamic>(); | |
hash.set("key1","value1"); |
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
class A | |
say_something: -> alert "hello" | |
class B extends A | |
#create new instance of B and call say_something | |
new B().say_something() | |
#wrapping method say_something of prototype A |
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
$.fn.declare.add | |
'set.color': (color) -> @css({'color':color}) | |
'set.bgcolor': (color) -> @css({'background-color':color}) | |
$("div").declare('set.color','green').declare('set.bgcolor','red') |
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
$.fn.declare.add({ | |
'row.alternate': function(opt) { | |
this.find("tr.odd") | |
.css("background-color",opt.odd_color) | |
.end() | |
.find("tr.even") | |
.css("background-color",opt.even_color); | |
} | |
}); |
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
-- Code thaked from http://en.literateprograms.org/Fibonacci_numbers_(Lua)? | |
-- for benchmarking lua and luajit | |
-- at bottom of files the result of benchmark | |
-- Copyright (c) 2011 the authors listed at the following URL, and/or | |
-- the authors of referenced articles or incorporated external code: | |
-- http://en.literateprograms.org/Fibonacci_numbers_(Lua)?action=history&offset=20081019232035 | |
-- | |
-- Permission is hereby granted, free of charge, to any person obtaining |
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
chained_method= (obj,method,fn) -> obj::[method]= ()-> fn.apply(@,arguments);@ | |
class Base | |
constructor: -> @n=0 | |
chained_method @,'sum', (x) -> @n=@n+x | |
chained_method @,'minus', (x) -> @n=@n-x | |
chained_method @,'pp', (x) -> console.log @n | |
(new Base).sum(3).minus(10).pp() |
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
class Main { | |
public static function getInjector() { | |
var inject=new Injector(); | |
inject.service("logger",function(context) { | |
trace(context); | |
return 9999; | |
}); |