Skip to content

Instantly share code, notes, and snippets.

onVideoStalled = () ->
this.pause()
this.play()
videos = document.querySelectorAll( "video")
for video in videos
video.addEventListener( "stalled", onVideoStalled, false )
onVideoCanplay = () ->
this.play()
onVideoLoaded = () ->
# I had 2 video layers: foreground video which is playing and background video which is loading data and waiting to be displayed
if isVideoOnTop( this )
this.play()
else
this.pause()
# some foreground and background videos change logick here
@osdrv
osdrv / gist:2039438
Created March 14, 2012 20:54
main() routine declaration
main() => print("hello");
void main() => print("hello");
int main() => print("hello");
ololo main() => print("hello");
@osdrv
osdrv / gist:2039616
Created March 14, 2012 21:22
primitives equality
int a = 1;
num b = 1;
Integer c = 1;
print( a === b ); // => true
print( a == b ); // => true
print ( a === c ) // => true
print ( b === c ) // => true
double a = 1;
@osdrv
osdrv / gist:2039661
Created March 14, 2012 21:30
semicolon sensetive
main() {
var a = 1
var b = null
}
@osdrv
osdrv / gist:2042245
Created March 15, 2012 05:51
undeclared function fatal error
main() {
void a() {
void b() {
print( "b" );
}
b();
}
a();
}
@osdrv
osdrv / gist:2042308
Created March 15, 2012 06:00
functions overloading
void a( Integer b ) => print( "hello integer $b" );
void a( String b ) => print( "hello string $b" ); // fatal error: `a` is already defined
@osdrv
osdrv / gist:2042403
Created March 15, 2012 06:14
No strong class check
Integer a = "asdf";
a += 1;
print( a ); // => asdf1
@osdrv
osdrv / gist:2042453
Created March 15, 2012 06:23
different types compatibility
print( null + 1 ); // raises NullPointerException
print( "asdasd" + 123 ); // => asdasd123
print( "asdasd" - 123 ); // raises NoSuchMethodException "-"
print( 0 / 0 ); // => NaN
print( "asd" * 3 ); // raises NoSuchMethodException "*"
print( "asd" / 3 ); // same
print( 3 * "asd" ); // raises NoSuchMethodException: method not found: 'mulFromInteger'
Static a () => 1;
print( a ); // => Closure
print( [ 123, 456 ] + [ 1 ] ); // raises NoSuchMethodException
@osdrv
osdrv / gist:2042748
Created March 15, 2012 07:35
Dart integers
Integer a = "asdf";
print( a is Integer );
a += 1;
print( a is Integer );
print( a / 10 ); // NoSuchMethodException