Skip to content

Instantly share code, notes, and snippets.

use strict;
use warnings;
use Coro;
use Coro::AnyEvent;
use Coro::Timer;
use AnyEvent;
warn $Coro::current->desc;
warn "start";
@hidekiy
hidekiy / coro_async_pool_join.pl
Created December 11, 2009 14:33
Coroをjoin無しでjoinするサンプルコード
#!/usr/bin/perl
use strict;
use warnings;
use AnyEvent;
use Coro;
use Coro::AnyEvent;
use Coro::Channel;
use Coro::Semaphore;
use Coro::Timer;
@hidekiy
hidekiy / gist:261809
Created December 22, 2009 15:52
Danga::Socket::Callback
use strict;
use warnings;
use Danga::Socket::Callback;
use IO::Socket::INET;
my $LISTENING_PORT = shift || 17000;
my $sock_server = IO::Socket::INET->new(
Proto => 'tcp',
LocalPort => $LISTENING_PORT,
@hidekiy
hidekiy / gist:261812
Created December 22, 2009 15:59
File::Tee
use File::Tee qw(tee);
open(my $log_fh, '>>', 'output.log');
tee(STDOUT, $log_fh);
tee(STDERR, $log_fh);
print STDERR "stderr\n";
print "stdout\n";
warn "warning";
system("echo system stdout");
// ==UserScript==
// @name TwitterAutoReloader
// @namespace http://hazisarashi.com/
// @description Twetterの差分更新を自動的に実行
// @include http://twitter.com/
// @include http://twitter.com/#/list/*
// @include http://twitter.com/#list/*
// @include http://twitter.com/#replies
// ==/UserScript==
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket::INET;
main(@ARGV);
sub main {
my $port = shift || 5000;
package Plack::Middleware::UpperCase;
use strict;
use warnings;
use parent qw(Plack::Middleware);
sub call {
my ($self, $env) = @_;
my $res = $self->app->($env);
# env PLACK_STACKTRACE_LEXICALS=1 plackup -MPlack::App::WrapCGI -e 'Plack::App::WrapCGI->new(script => "crash.cgi")'
use UNIVERSAL::require;
sub main {
my $mod = 'Encode';
$mod->require;
print "Content-Type: text/plain\n\nok";
}
use strict;
use Mojolicious::Lite;
get '/test1' => 'test1';
get '/test2' => 'test2';
app->start;
__DATA__
use strict;
use warnings;
use AnyEvent;
use AnyEvent::IRC::Client;
use AnyEvent::HTTP;
use AnyEvent::Util qw(run_cmd);
use Data::Dumper;
use Encode;
use Encode::Guess qw(euc-jp shiftjis 7bit-jis);
use HTML::ContentExtractor;