Skip to content

Instantly share code, notes, and snippets.

View bayashi's full-sized avatar
💎
OK

bayashi bayashi

💎
OK
View GitHub Profile
@bayashi
bayashi / NicoVideo.pm
Created October 9, 2010 17:40
MojoMojo::Formatter::NicoVideo
package MojoMojo::Formatter::NicoVideo;
use strict;
use warnings;
use parent qw/MojoMojo::Formatter/;
=head1 NAME
MojoMojo::Formatter::NicoVideo - Embed Nico Nico Doga player
=cut
@bayashi
bayashi / check_starman_cow.pl
Created February 12, 2011 03:39
check_starman_cow
#!/usr/bin/perl
use strict;
use warnings;
use Linux::Smaps;
my $proc_name = 'starman';#shift or die "usage: $0 PROC_NAME";
my $proc_list = `ps a|grep $proc_name` || '';
my @pid_list;
@bayashi
bayashi / gist:888120
Created March 26, 2011 08:02
TokyoDenryoku.pl
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use URI::Fetch;
use Cache::FileCache;
use Data::Dumper;
my $TSV_URL = 'http://www.tepco.co.jp/forecast/html/images/juyo-j.csv2';
@bayashi
bayashi / StackTrace.pm
Created June 3, 2012 10:21
Plack::Middleware::Debug::StackTrace
package Plack::Middleware::Debug::StackTrace;
use strict;
use parent qw/Plack::Middleware::Debug::Base/;
use Devel::StackTrace;
our $VERSION = '0.01';
our $StackTraceClass = "Devel::StackTrace";
# Optional since it needs PadWalker
eval {
require Devel::StackTrace::WithLexicals;
@bayashi
bayashi / find_3words.pl
Created August 4, 2012 12:29
この中から最初に見つけた言葉3つがあなたが人生でほしいもの。なんだって。
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Encode qw/encode_utf8/;
my @list = split //, 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをんがぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽ';
my $words = [qw/
おかね げんきん たいきん
ゆめ きぼう じゆう せいこう
@bayashi
bayashi / found_3idols.pl
Created August 10, 2012 17:15
found 3 idols
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Encode qw/encode_utf8/;
my @list = split //, '岩多大片倉小篠高高仲中仲前前松秋板内梅大菊田中仁野藤松松峯宮横石河柏北小小佐佐佐鈴鈴近増宮渡渡阿市入岩大加川島島高竹田仲中永山伊小小名藤森伊小小名藤森大サ佐平武江相岩梅大岡北篠高光村茂内岡小西橋前宇上折高今星渡増井大駒戸中成野松川早大早成佐大野浦小佐小奥森平米指磯大坂藤堀飯金小吉渡出山西中片石有鈴冨畑瓜上小林西浅石石郭小坂杉冨三村伊今石絹藤高植岩佐豊岡川金牛山鈴雨北長森渡百玉佐有高';
my $words = [qw/
岩佐美咲
多田愛佳
@bayashi
bayashi / gist:4292477
Created December 15, 2012 10:12
とあるページの画像だけ抜き出す Web App

とあるページの画像だけ抜き出す Web App

plack ワンライナー

plackup -MLWP::Simple=get -e 'sub { my $env = shift; my ($url) = ($env->{REQUEST_URI} =~ m!^/(.*)!); my @html; push(@html, qq|<img src="$_">|) for get($url) =~ m!<img[^>]*src="(https?://[^"]+)"[^>]*>!g; return [200, ["Content-Type" => "text/html"], [join("", @html) || "OK"]] }'

http://127.0.0.1:5000/http://matome.naver.jp/odai/2135350364969742801

package Test::AllModules;
use strict;
use warnings;
use Module::Pluggable::Object;
use List::MoreUtils qw(any);
use Test::More ();
our $VERSION = '0.01';
use Exporter;
@bayashi
bayashi / gist:4751969
Created February 11, 2013 02:03
Test: : Do NOT load modules
use strict;
use Test::AllModules;
use Test::More;
BEGIN {
note('compile all modules.');
all_ok(
search_path => 'MyApp',
check => sub {
my $class = shift;
@bayashi
bayashi / Benchmark.pm
Created March 10, 2013 09:20
patched Benchmark.pm: croak if return values are wrong.
package Benchmark;
use strict;
=head1 NAME
Benchmark - benchmark running times of Perl code
=head1 SYNOPSIS