Skip to content

Instantly share code, notes, and snippets.

View peczenyj's full-sized avatar
💻
coding

Tiago Peczenyj peczenyj

💻
coding
View GitHub Profile
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);
@peczenyj
peczenyj / dsl_for_html_generation.rb
Created March 2, 2009 18:09 — forked from fabiokung/dsl_for_html_generation.rb
HTML DSL, adicionando atributos
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"