Skip to content

Instantly share code, notes, and snippets.

@toritori0318
toritori0318 / answer_948810
Created April 29, 2011 20:05
自信ないけどこんな感じ?
# for perl
my @allowd_tags = qw/redpre pre code notextile/;
my $str = '<html><body> <p><pre>fufufu</pre></p> </body></html>';
$str =~
s{<(\/?([!\w]+)[^<>\n]*)(>?)}
{
if(grep /^$2$/ , @allowd_tags ){
"<$1$3";
}else{
@toritori0318
toritori0318 / ssh_ec2.pl
Created May 7, 2011 16:59
ec2にsshしやすくするスクリプト?
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long qw/GetOptions :config auto_help/;
use Config::Pit;
use Net::Amazon::EC2;
use Term::ReadLine;
# デフォルト値の設定
my $pitname = 'aws_info';
@toritori0318
toritori0318 / radiation.pl
Created May 21, 2011 16:22
東京の放射線量をIRCに流す
use strict;
use warnings;
use Encode qw /encode_utf8 decode_utf8 from_to/;
use AnyEvent::Cron;
use AnyEvent::IRC::Client;
use Data::Dumper;
use Web::Scraper;
use URI;
use 5.10.0;
@toritori0318
toritori0318 / check_workday.pl
Created June 4, 2011 16:13
現在日付の実働日をチェック
#!/usr/bin/env perl
use strict;
use lib;
use Time::Piece;
use Calendar::Japanese::Business;
my $c = Calendar::Japanese::Business->new;
use Getopt::Long qw/GetOptions :config auto_help/;
my $work_day;
@toritori0318
toritori0318 / plack_status
Created June 11, 2011 14:57
plackのステータスを表示するmuninプラグイン
#!/usr/bin/perl -w
# -*- cperl -*-
=head1 NAME
plack_status - Munin plugin to show the connection status for plack
=encoding utf8
=head1 APPLICABLE SYSTEMS
@toritori0318
toritori0318 / bench_log.pl
Created July 4, 2011 10:58
perlのログモジュールベンチマークスクリプト
use strict;
use warnings;
use Benchmark qw(timethese cmpthese);
my $count = shift || 1;
my $message = 'Blah, blah';
#perl -MV=Log::Dispatch,Log::Handler,Log::Log4perl,Log::Minimal
######## Log::Dispatch
@toritori0318
toritori0318 / xslate_my_test.pl
Created July 9, 2011 15:06
xslate : my の扱いについて
# perlversion = 5.14.1
# Text::Xslate = 1.3000
use strict;
use Text::Xslate;
my $tx = Text::Xslate->new();
my %vars = (
title => 'A list of books',
@toritori0318
toritori0318 / scrappy1.pl
Created July 9, 2011 15:19
はてなフォトライフから画像ぶっこぬき
use strict;
use Scrappy;
my $s = Scrappy->new;
# 1秒間隔でクロール
$s->pause(1);
# クロール実行
$s->crawl('http://f.hatena.ne.jp/hotfoto',
# 1. root
@toritori0318
toritori0318 / scrappy2.pl
Created July 9, 2011 15:35
はてぶのトップからperlタグをたどってエントリのリンク先からテキストのみ抽出
use strict;
use Scrappy;
my $s = Scrappy->new;
# 1秒間隔でクロール
$s->pause(1);
# ファイルにログを保存
$s->logger->file('scrappy.log');
# クロール実行
@toritori0318
toritori0318 / cow_check.pl
Created July 19, 2011 10:37
copy on write の チェックスクリプト(starlet)
#!/usr/bin/perl
use strict;
use warnings;
use Linux::Smaps;
my $proc_name = 'plackup';#shift or die "usage: $0 PROC_NAME";
my $proc_list = `ps ax|grep $proc_name` || '';
my @pid_list;