Skip to content

Instantly share code, notes, and snippets.

View xtetsuji's full-sized avatar

OGATA Tetsuji xtetsuji

View GitHub Profile
@xtetsuji
xtetsuji / ae-signal.pl
Created June 10, 2013 13:50
Compare AnyEvnet->signal with %SIG about calback argument.
#!/usr/bin/env perl
use strict;
use warnings;
use AnyEvent;
use Data::Dumper;
my $cv = AnyEvent->condvar;
my $ae_signal_term = AnyEvent->signal(
@xtetsuji
xtetsuji / get.pl
Created July 26, 2013 12:38
Cache::SharedMemoryCache concept code.
#!/usr/bin/env perl
use strict;
use Cache::SharedMemoryCache;
my $cache = Cache::SharedMemoryCache->new({namespace => 'foo', default_expire_in => "60s"});
while (1) {
sleep 1;
print $cache->get('bar')."\n";
@xtetsuji
xtetsuji / bitwise-15and8.t
Created July 30, 2013 09:23
"Bitwise And" of String and String on perl.
use strict;
use warnings;
use Test::More;
# Those are stringify after.
my ($x, $y) = (15, 8);
# Only STRING and STRING bitwise-and is compared by ASCII!!!
ok( !("$x" & "$y"), qq/is "$x" & "$y" = @{[ "$x" & "$y" ]} not true?/);
@xtetsuji
xtetsuji / concat-xwr.pl
Created August 21, 2013 12:36
From posterous (gone one of blog service) exported article XMLs to WordPress WXR format.
#!/usr/bin/env perl
# concat-wxr.pl *.txt > wxr.xml
use strict;
use warnings;
use utf8;
use Data::Dumper;
use Data::Section::Simple 'get_data_section';
use Date::Format 'time2str';
@xtetsuji
xtetsuji / wunderlist.pl
Created August 24, 2013 12:41
WWW::Wunderlist sample.
#!/usr/bin/env perl
use strict;
use warnings;
use lib 'lib', '../lib';
BEGIN { $ENV{DEBUG} = 1; }
use Config::PL 'config_do';
use Data::Dumper;
use Encode;
@xtetsuji
xtetsuji / ti-export.pl
Created November 10, 2013 14:20
The Interviews article exporter and downloader.
#!/usr/bin/env perl
# Initial release by @xtetsuji at 2013/11/10
# See following document for detail.
use strict;
use warnings;
use utf8;
use LWP::UserAgent;
use Web::Query;
@xtetsuji
xtetsuji / calc_string.pl
Last active January 1, 2016 02:59
calc_string.pl sample code of twice eval simple_replace option. see: https://github.com/perl-entrance-org/workshop-2013-05/blob/master/slide.md
#!/usr/bin/env perl
# https://github.com/perl-entrance-org/workshop-2013-05/blob/master/slide.md#%E7%B7%B4%E7%BF%92%E5%95%8F%E9%A1%8C-1
use strict;
use warnings;
while(my $str = <STDIN>) {
chomp $str;
my $res = calc_strings($str);
if ( defined $res ) {
@xtetsuji
xtetsuji / solve-onedrive.pl
Created February 19, 2014 16:10
Solve OneDrive puzzle.
#!/usr/bin/env perl
# https://twitter.com/onedrive/status/436167285259382784
use strict;
use warnings;
my %mapping = (qw/
A 3
B 0
C Q
@xtetsuji
xtetsuji / ClutchWorker.pm
Last active August 29, 2015 13:57
Clutch, a perl one of jobqueue system's sample.
package My::ClutchWorker;
use strict;
use warnings;
use Clutch::Worker;
register_function(
'echo' => sub {
my $args = shift;
$$ .':'. $args; # return worker process response.
@xtetsuji
xtetsuji / JonkWorker.pm
Last active August 29, 2015 13:57
Jonk, a perl one of jobqueue system's sample.
package My::JonkWorker;
use strict;
use warnings;
use Data::Dumper;
sub work {
my ($class, $job) = @_;
print "job is " . Dumper($job) . "\n";