Skip to content

Instantly share code, notes, and snippets.

View riywo's full-sized avatar
🏈
Go 49ers!

Ryosuke Iwanaga riywo

🏈
Go 49ers!
View GitHub Profile
@riywo
riywo / gist:725640
Created December 2, 2010 16:45
easy QueryComment(where the query executed)
my $dbh = DBI->connect('dbi:mysql:test','test','test', {
RaiseError => 1,
Callbacks => {
ChildCallbacks => {
execute => sub {
my ($obj, @binds) = @_;
my ($package, $file, $line) = caller;
$obj->{Database}->{Statement} .= "/* $package:$file:$line */";
return;
},
#!/usr/bin/perl
use strict;
use warnings;
exit if(@ARGV != 2);
my $file1 = $ARGV[0];
my $file2 = $ARGV[1];
my %data1;
source('Rworker.r')
file <- rworker_download(args$data)
rworker_log(paste("Download finished:", file))
d <- read.csv(file, header = T)
rworker_log("read.csv finished:")
png(args$img)
plot(d)
speed dist
4 2
4 10
7 4
7 22
8 16
9 10
10 18
10 26
10 34
# ifstat -b -t -i bond0,eth0,eth1 1 5
Time bond0 eth0 eth1
HH:MM:SS Kbps in Kbps out Kbps in Kbps out Kbps in Kbps out
18:46:33 11248.00 19186.19 11166.92 19186.19 81.08 0.00
18:46:34 10672.05 17935.01 10589.01 17935.01 83.04 0.00
18:46:35 10908.38 21413.09 10837.35 21413.09 71.03 0.00
18:46:36 10786.80 18413.89 10739.27 18413.89 47.53 0.00
18:46:37 11408.11 18082.65 11339.09 18082.65 69.02 0.00
@riywo
riywo / gist:836630
Created February 21, 2011 03:41
指定秒間だけtcpdumpしてmk-query-digestするshell
#!/bin/sh
SEC=$1
tcpdump -s 65535 -nn -q -tttt -x port 3306 -l > /tmp/tcpdump.3306 2> /dev/null &
PID_3306=$!
tcpdump -s 65535 -nn -q -tttt -x port 11211 -l > /tmp/tcpdump.11211 2> /dev/null &
PID_11211=$!
@riywo
riywo / gist:836641
Created February 21, 2011 04:00
mk-slave-delay使って開発環境のslaveDBを3秒意図的に遅延させるdaemontools shell
#!/bin/sh
exec mk-slave-delay --delay 3s --interval 1s h=localhost,u=root,p=password &>/dev/null
@riywo
riywo / gist:838334
Created February 22, 2011 07:28
アクセスログをtailしてstatus codeが500だったら赤色にするawk
tail -f access_log | awk '$9 == 500{print "\033[31m"}{print $0,"\033[0m"}'
@riywo
riywo / gist:838408
Created February 22, 2011 09:18
httpのtcpdumpをmk-query-digestに食わせる時に、GET example.comのものだけ抜き出す場合
tcpdump -s 65535 -xx -n -q -tttt port 80 > tcpdump.log
mk-query-digest --type http --filter '($event->{fingerprint} || "") =~ m/^get example\.com/' --limit 100% tcpdump.log
@riywo
riywo / gist:838522
Created February 22, 2011 11:09
複数サーバに同じコマンド発行する基本
for i in host1 host2 host3; do echo $i; ssh $i "rm -fr /"; done