Skip to content

Instantly share code, notes, and snippets.

@toritori0318
toritori0318 / a.pl
Created July 19, 2011 11:38
遅延ロードを確認するのに lib/App/Web.pm へ記述する部分
# 初期ロードモジュール
my %init_module = ();
$init_module{$_}++ for keys %INC;
# getter
sub get_module {
return \%init_module;
}
# trigger
@toritori0318
toritori0318 / gist:1092137
Created July 19, 2011 12:28
Net::Amazon::EC2 パッチ (Branch: instance_attr_fix)
diff --git lib/Net/Amazon/EC2.pm lib/Net/Amazon/EC2.pm
index a2062a7..2f9a318 100644
--- lib/Net/Amazon/EC2.pm
+++ lib/Net/Amazon/EC2.pm
@@ -1782,9 +1782,11 @@ sub describe_instances {
my $tag_sets;
foreach my $tag_arr (@{$instance_elem->{tagSet}{item}}) {
+ my $key = $tag_arr->{key};
+ my $value = (ref $tag_arr->{value} eq '') ? $tag_arr->{value} : '';
@toritori0318
toritori0318 / ssh_vmec2.pl
Created July 29, 2011 14:56
EC2へのssh接続を楽にするスクリプト VM::EC2バージョン
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long qw/GetOptions :config auto_help/;
use Config::Pit;
use VM::EC2;
use Term::ReadLine;
my $pitname = 'aws_info';
my $region = '';
@toritori0318
toritori0318 / kuru_kuru_bot_retweet.pl
Created July 30, 2011 16:52
kuru_kuru_bot_retweet
#!/usr/bin/perl
use strict;
use warnings;
use AnyEvent::Twitter::Stream;
use AnyEvent;
use Encode qw/encode_utf8/;
use Net::Twitter::Lite;
use Log::Minimal;
use Data::Dumper;
use Clone qw/clone/;
@toritori0318
toritori0318 / list_grep.pl
Created August 17, 2011 08:44
perl : 配列から値検索ベンチマーク
use strict;
use warnings;
use Data::Dumper;
use List::Util qw/first shuffle/;
use Benchmark qw(timethese cmpthese);
use 5.10.0;
my $count = shift || 1;
my $dbg = ($count == 1) ? 1 : undef;
@toritori0318
toritori0318 / aws_status.pl
Created September 1, 2011 17:34
AWS全リージョンの情報取得(perl版)
use strict;
use VM::EC2;
my $owner_id = $ENV{EC2_OWNER_ID} or die 'EC2_OWNER_ID is required.';
#my $owner_id = shift or die 'aws_status.pl <owner_id>';
my $ec2 = VM::EC2->new;
my @regions = $ec2->describe_regions();
for my $region (@regions) {
# region
@toritori0318
toritori0318 / sortのテストだよ
Created September 22, 2011 08:29
何でこうなる? linux sort
$ cat sorttest.txt
a20jae
a2ueyO
AeRezo
aLrl58
aryHoV
As3jL3
aS40ft
Aswonj
awviEw
@toritori0318
toritori0318 / hoge.js
Created September 25, 2011 17:52
mongooseで入れたデータがmongodbのコマンドラインから見れない件
#### node.js
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/counterdb');
var Schema = mongoose.Schema;
var CounterSchema = new Schema({
count: Number
});
mongoose.model('Counter', CounterSchema);
var Counter = mongoose.model('Counter');
@toritori0318
toritori0318 / style.less.patch
Created October 11, 2011 15:24
yapcasia-timetable-2011 patch
% git diff style.less <master ✗>
diff --git a/style.less b/style.less
index 01448e8..c41709a 100644
--- a/style.less
+++ b/style.less
@@ -31,7 +31,7 @@ img {
}
}
-ul.day-list {
@toritori0318
toritori0318 / redmine_irc_notifications.patch
Created October 28, 2011 16:27
redmine_irc_notifications の パッチファイル
% diff -u lib/redmine_irc_notifications/irc.rb-org lib/redmine_irc_notifications/irc.rb <master ✗>
--- lib/redmine_irc_notifications/irc.rb-org 2011-10-29 01:24:12.000000000 +0900
+++ lib/redmine_irc_notifications/irc.rb 2011-10-29 01:17:07.000000000 +0900
@@ -47,8 +47,9 @@
end
sock = TCPSocket.open(@@server, @@port || 6667)
- sock.puts "USER #{@@user} 0 * #{@@user}"
sock.puts "NICK #{@@nick}"
+ sock.puts "USER #{@@user} 0 * #{@@user}"