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 Time::Out qw(timeout); | |
use DDP; | |
sub run_with_timeout(&$$) { | |
my $block = shift; | |
my $timeout = shift; | |
timeout $timeout, @_ => sub { | |
my $pool = shift; | |
while ( my $s = pop @$pool ) { | |
$block->($s); |
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
def method_missing(name, *args) | |
attributes = args.last.to_a.collect {|y| y = "#{y[0]}=\"#{y[1]}\"" } .join(" ") if args.size > 1 | |
puts "<#{name} #{attributes}>#{args.first}" | |
yield if block_given? | |
puts "</#{name}>" | |
end | |
html do | |
body do | |
h1 "My internal DSL" |