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
$.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 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 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 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 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 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 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 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
#this version don't work with prototype chain for generation variable prop_value with closure | |
Object::attr_accessor= (prop) -> | |
self=@ | |
do -> | |
prop_value=null | |
self[prop]=(value) -> | |
prop_value=value if value? | |
prop_value |
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
Object::attr_accessor= (prop) -> | |
self=@ | |
self["_#{prop}"]=null | |
self[prop]=(value) -> | |
@["_#{prop}"]=value if value? | |
@["_#{prop}"] | |
Player={} |
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
describe "async", -> | |
it "async not null", -> | |
expect(async).not.toBeNull() | |
it "respond to map", -> | |
expect(async.map).not.toBeNull() | |
it "[1,2,3] map (x) -> x + 1 eq [2,3,4]", -> | |
callback = jasmine.createSpy() | |
summer= (el,callback) -> callback null, el + 1 | |
async.map([1,2,3],summer,callback) | |