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: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: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:838522
Created February 22, 2011 11:09
複数サーバに同じコマンド発行する基本
for i in host1 host2 host3; do echo $i; ssh $i "rm -fr /"; done
@riywo
riywo / gist:838525
Created February 22, 2011 11:14
無限ループ使ってお手軽ロギング
while : ; do echo -n "`date` "; mysql -e 'show global status like "Queries";' | grep Queries; sleep 1; done | tee queries.log
@riywo
riywo / gist:838531
Created February 22, 2011 11:18
リモートサーバとdiffを取る簡単な方法
ssh host1 cat /path/to/file | diff -u /path/to/file -
@riywo
riywo / gist:840229
Created February 23, 2011 09:48
システム講座をやるならどんな感じ?

前提

参加者(僕も含む)数人で講座は10回未満くらいのイメージ。 時間外で作ってくるのがメイン。

前半〜ローカルで簡単なアプリ作る〜

とりあえずPerlの場合

  • Windowsの人はとりあえずMacを買いに行く
  • cpanmの使い方
  • スクリプト単体で or まずlocal::lib入れてから
@riywo
riywo / gist:842342
Created February 24, 2011 16:02
とりあえずEC2にログインするまで
[~]$ mkdir .ssh
[~]$ chmod 600 .ssh
[~]$ mv ~/Downloads/riywo-test.pem ~/.ssh
[~]$ chmod 600 ~/.ssh/riywo-test.pem
[~]$ vim ~/.ssh/config
Host test-cf
HostName ec2-XX-XX-XX-XX.compute-1.amazonaws.com
User ec2-user
Port 22
IdentityFile ~/.ssh/riywo-test.pem
@riywo
riywo / gist:842372
Created February 24, 2011 16:22
sshの設定をする
[ec2-user@domU-11-11-11-11-11-11 ~]$ sudo su -
[root@domU-11-11-11-11-11-11 ~]# vim /etc/ssh/sshd_config
Port 2222
PermitRootLogin no
[root@domU-11-11-11-11-11-11 ~]# service sshd restart
[root@domU-11-11-11-11-11-11 ~]# netstat -taopn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name Timer
tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN 1076/sshd off (0.00/0/0)
@riywo
riywo / gist:848984
Created March 1, 2011 11:12
ApacheでBasic認証かけつつ特定IPは認証はずす
<Directory />
AuthUserFile /path/to/.htpasswd
AuthName "f0ck you"
AuthType Basic
Require valid-user
Satisfy Any
# Require valid-user 別のディレクティブで指定する場合
Order deny,allow
Deny from all
@riywo
riywo / gist:854138
Created March 4, 2011 03:45
bashでプログラムの実行結果のdiffを取りたい時
diff -u <(echo hoge) <(echo fuga)
--- /dev/fd/63 2011-03-04 12:44:34.176435837 +0900
+++ /dev/fd/62 2011-03-04 12:44:34.176435837 +0900
@@ -1 +1 @@
-hoge
+fuga