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
function draw(fractal, state, R, maxDepth, context) { | |
context.moveTo(state.x, state.y); | |
step(0, R); | |
function step(depth, R) { | |
if (depth == maxDepth) { | |
var x1 = state.x + R * Math.cos(state.alpha) | |
, y1 = state.y + R * Math.sin(state.alpha); | |
context.lineTo(x1, y1); | |
state.x = x1; |
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
# waterfall is the most obvious one | |
sub waterfall { | |
my $promise = make_promise; | |
for (@_) { | |
$promise = $promise->then($_); | |
} | |
return $promise; | |
} | |
# series is a bit harder |
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
<div class="item"> | |
<div class="toSave"></div> | |
<div class="focusable"></div> | |
</div> |
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use AnyEvent; | |
use AnyEvent::Promises qw( make_promise ); | |
sub waterfall { | |
my $promise = make_promise; | |
for (@_) { | |
$promise = $promise->then($_); |
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use AnyEvent; | |
use AnyEvent::Promises qw( make_promise ); | |
my $exit = AnyEvent->condvar; | |
my $p = make_promise; | |
$p->then(sub { 1 })->then(sub { print "1\n" }); |
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
{ | |
my $_postpone; | |
if ( exists &AE::postpone ) { | |
$_postpone = \&AE::postpone; | |
} | |
else { | |
my $POSTPONE_W; | |
my @POSTPONE; |
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
sub lexer { | |
my $target = shift; | |
sub { | |
TOKEN: { | |
return ['VAR', $1] if $target =~ /\G \$ ([A-Za-z_]\w*) /gcx; | |
return ['BINOP', $1] if $target =~ /\G (and|or) /gcx; | |
return ['UNOP', $1] if $target =~ /\G (not) /gcx; | |
return ['CMP', $1] if $target =~ /\G (eq|ne|=~|!~) /gcx; | |
return ['LP', undef] if $target =~ /\G \( /gcx; | |
return ['RP', undef] if $target =~ /\G \) /gcx; |
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
%{ | |
use English qw( -no_match_vars ); | |
use Data::Dumper; | |
sub a_rule { | |
shift; | |
return join "\n", "sub {", @_, "}"; | |
} | |
sub a_default { |
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
if: ($method eq PUT and not $from) or $method eq POST | |
metric: multi_counter uploads (os) | |
metric: multi_sum uploads_traffic (os rcv) | |
metric: multi_timing upload_time (os time) | |
if: $method eq PUT and $from | |
metric: multi_counter continued_uploads (os) | |
metric: multi_sum continued_uploads_traffic (os rcv) | |
metric: multi_timing continued_upload_time (os time) |
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
function Eagle(...) { | |
Bird.call(this, ...); | |
} | |
Eagle.prototype = { | |
__proto__: Bird.prototype, | |
... | |
}; |
OlderNewer