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
def log(msg) | |
puts "#{Fiber.current.name}: #{msg}" | |
end | |
def maybe_inf_op | |
Channel(Int32).new.tap do |fin_ch| | |
spawn do | |
loop do | |
s = "aaa" * rand(10) | |
end |
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
# To avoid IO::Handle and other IO::* "autoloading" when using $fh->autoflush(1) | |
sub __autoflush($) { | |
my $fl_have2select = defined(my $fh = $_[0]); | |
# previously selected file handler | |
my $prv_sel_fh; | |
if ( $fl_have2select and ! eval { | |
no warnings; | |
$prv_sel_fh = select $fh; | |
print '' or die "$!\n"; | |
}) { |
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
package Log::Log4perl::KISS; | |
use constant LOG_SEVERITIES => qw/trace debug info warn error fatal/; | |
use constant DONE => 1; | |
use constant NIL => '<Nil>'; | |
use constant TRUE => 1; | |
use constant FALSE => ! TRUE; | |
use 5.16.1; | |
use strict; | |
use warnings; |
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
Exception: Error writing to socket: Broken pipe (Errno) | |
from usr/share/crystal/src/socket.cr:0:13 in 'unbuffered_write' | |
from usr/share/crystal/src/io/buffered.cr:194:5 in 'write' | |
from usr/share/crystal/src/http/server/response.cr:217:11 in 'unbuffered_write' | |
from usr/share/crystal/src/io/buffered.cr:0:5 in 'write' | |
from home/a.konovalov/Apps/Crystal/druid-ng/src/druid_mp.cr:2:3 in '->' | |
from home/a.konovalov/Apps/Crystal/druid-ng/lib/kemal/src/kemal/route.cr:12:9 in '->' | |
from home/a.konovalov/Apps/Crystal/druid-ng/lib/kemal/src/kemal/route_handler.cr:255:3 in 'call' | |
from usr/share/crystal/src/http/server/handler.cr:26:7 in 'call' | |
from usr/share/crystal/src/http/server/handler.cr:26:7 in 'call_next' |
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
#!/bin/bash | |
[[ $1 == '-x' ]] && { export TRACE=1; shift; set -x; } | |
proc=${1:-chrome} | |
declare -a pids | |
declare -i c=-1 | |
while pids=($(pgrep $proc)); do | |
kill ${pids[@]} | |
(( c++ )) || { |
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
sub __set_timer { | |
my ($ptrEvID, %options) = @_; | |
my ($secAfter, $secInterval, $callback) = @options{qw/after interval cb/}; | |
return unless $secAfter or $secInterval; | |
$$ptrEvID | |
= $secAfter | |
? Mojo::IOLoop->timer( | |
$secAfter => $secInterval | |
? sub {$callback->(); $$ptrEvID = Mojo::IOLoop->recurring($secInterval => $callback)} | |
: $callback |