Skip to content

Instantly share code, notes, and snippets.

View hideo55's full-sized avatar

Hideaki Ohno hideo55

View GitHub Profile
package mro;
package MRO::Compat;
use strict;
use warnings;
require 5.006_000;
our $VERSION = '0.11';
BEGIN {
package Android::FixupUTF8;
sub fixup {
package Android;
no warnings 'redefine';
*do_rpc = sub {
my $self = shift;
if ( $self->trace ) {
show_trace(qq[do_rpc: $self: @_]);
}
@hideo55
hideo55 / dotcloud_mysql.pl
Created May 14, 2011 14:19
Login to MySQL shell on DotCloud
#!/usr/bin/env perl -w
use strict;
use IPC::Cmd qw/run/;
use IPC::System::Simple qw(systemx);
die "You must provide deploy name as argument" unless scalar(@ARGV) > 0;
my $deploy_name = $ARGV[0];
my ($ok, $err, undef, $stdout) = run(
/*
PC Emulator
Copyright (c) 2011 Fabrice Bellard
Redistribution or commercial use is prohibited without the author's
permission.
*/
"use strict";
var aa;
var ba = [1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1,
0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0,
@hideo55
hideo55 / tcpdump.pl
Created May 19, 2011 17:10
tcpdump like implementation of Perl
#!/usr/bin/env perl -w
use strict;
use Net::Frame::Dump::Online2;
use Net::Frame::Simple;
my $d = Net::Frame::Dump::Online2->new( dev => 'en1', );
$d->start;
while (1) {
@hideo55
hideo55 / io-scalar.pl
Created May 30, 2011 14:40
STDERR into scalar
use Test::More tests => 1;
use strict;
use warnings;
local *STDERR;
my $stderr;
open STDERR, '>', \$stderr or die $!;
warn 'error';
@hideo55
hideo55 / coerce_sample.pl
Created July 4, 2011 15:05
Moose coerce
package WWW::ImagePager;
use Any::Moose;
use Any::Moose '::Util::TypeConstraints';
use URI;
class_type 'URI';
coerce 'URI' => from 'Str' => via { URI->new(shift) };
has 'basepage' => ( is => 'rw', isa => 'URI', coerce => 1 );
@hideo55
hideo55 / dynamic_load.pl
Created July 12, 2011 13:59
モジュールの動的ロードとメソッドの呼び出し
use strict;
use warnings;
use Class::Load qw(load_class);
my $module_name = 'MY::MODULE::NAME';
#Moose::Util::load_class()とほぼ同等、ロードに失敗すると例外を投げる
load_class($module_name);
#can()はCodeRefを返す
@hideo55
hideo55 / metacpan-growler-gntp.pl
Created July 27, 2011 13:55
MetaCPAN Growler - Growl::GNTP version
#!perl
use strict;
use warnings;
use Growl::GNTP;
use AnyEvent;
use AnyEvent::HTTP;
use JSON;
use Data::MessagePack;
use Cache::LRU;
@hideo55
hideo55 / color.pl
Created July 29, 2011 15:42
keyword coloring on terminal.
#!/usr/bin/env perl -w
use strict;
my $kw_path = shift @ARGV;
if( !defined($kw_path) || !(-e $kw_path ) ){
die <<"__USAGE__";
Usage:
# tail -f | ./color.pl keywords.pl
keywords are defined by ArrayRef such as:
[qw(error fail)];