Skip to content

Instantly share code, notes, and snippets.

View i97506051502's full-sized avatar

Go Sato i97506051502

View GitHub Profile
@i97506051502
i97506051502 / copyagent.sh
Created December 16, 2011 02:48
copy file (or directory) to server(s)
#!/bin/bash
########################################################################
#
# Name:
# copyagent.sh
#
# Description:
# copy file (or directory) to server(s)
#
# Last Modified:
@i97506051502
i97506051502 / backupTool.sh
Created August 24, 2012 03:09
backup specified file to under /USER_HOME/backup/ directory.
########################################################################
#
# Script Name:
# backupTool.sh
#
# Project:
# Miscellaneous
#
# Execute User: any user you want
#
@i97506051502
i97506051502 / traceUser.sh
Created November 5, 2012 06:27
ある IP アドレスのユーザーがどういう順序でアクセスをしているか解析
#!/bin/bash
targetIp="$1"
Date="$2"
# ある IP アドレスのユーザーがどういう順序でアクセスをしているか解析
grep ${targetIp} access_log-${Date} | less | cut -d ' ' -f 7
exit 0
@i97506051502
i97506051502 / countUniqueUser.rb
Created November 5, 2012 06:28
ユニークユーザー数をカウント
#!/usr/bin/ruby
open('./tmpUu.txt') { |file|
file.each { |line|
start_idx = line.index('ids') + 4
ids_len = 31
end_idx = start_idx + ids_len
@i97506051502
i97506051502 / analyzeLog.sh
Created November 5, 2012 06:32
combined 形式アクセスログファイルの解析
#!/bin/bash
Date="$1"
# アクセス元 IP アドレスの数
cut -d ' ' -f 1 access_log-${Date} | sort | uniq -c | sort -nr > RANK/ip-rank-${Date}.txt
sed 's/^ *//' RANK/ip-rank-${Date}.txt | sed 's/ /,/' > CSV/ip-rank-${Date}.csv
# IP アドレスの名前解決
sed 's/ */ /' RANK/ip-rank-${Date}.txt | cut -d ' ' -f 3 > TEMP/only-ip-address-${Date}.txt
@i97506051502
i97506051502 / backup_macosx_important_data
Created December 12, 2012 10:42
OS X Mountain Lion: 重要なアプリケーションファイルのバックアップ (http://support.apple.com/kb/PH10941?viewlocale=ja_JP) に列挙されているファイルのバックアップを取得します。 バックアップから 7 日間が経過したファイルは削除されます。 リストアしたいときは解凍してからファイルを戻してください。 UNIX の礼儀に沿わず、フルパスでバックアップしてしまっていますがその点はご容赦ください。
########################################################################
#
# Script Name:
# backup_macosx_important_data
#
# Project:
# Miscellaneous
#
# Execute User: any user you want
#
@i97506051502
i97506051502 / changeStorageEngine.sh
Created December 19, 2012 07:00
指定した MySQL データベース内に存在する全テーブルのストレージエンジンを変更します。
#!/path/to/your/shell
if [ $# = 4 ];
then
# 変数の設定
MyUSER=$1
MyPASSWORD=$2
ENGINE=$3
DATABASE=$4
@i97506051502
i97506051502 / chkey.sh
Last active December 10, 2015 00:28
複数の AWS Key Pair を持つ者たちに捧ぐ(X.509 関連の環境変数変更ツール)。 chkey.sh にパスを通して以下のように実行します。 $ source chkey.sh key1
#!/bin/bash
if [ $# = 1 ];
then
Key_Name="$1"
if [ ${Key_Name} == 'key1' ]; then
export EC2_CERT=/path/to/your/key1/cert/key1.pem
@i97506051502
i97506051502 / makeUsersOnMacOSX.sh
Last active December 11, 2015 11:18
Mac OS X (Server) 上でユーザーを作成するスクリプトです。 「Users.list」という決められたフォーマットのテキストファイルを準備し、そこにユーザー情報を書き込み、実行します。 dscl のヘルプを読んだりして attribute を増やせば機能拡張が可能なはずです。
#!/bin/bash
########################################################################
#
# Script Name:
# makeUsersOnMacOSX.sh
#
# Project:
# Miscellaneous
#
@i97506051502
i97506051502 / analyze_response_time.rb
Created July 13, 2013 02:56
ab コマンドの結果をログり, 平均レスポンスタイムなどを返却します。
#! ruby -Ku
# -*- mode:ruby; coding:utf-8 -*-
$KCODE='u'
require 'jcode'
# ToDo
# ----------------------------------------------------------------------
# ファイルを変数に。複数に。
# 入力値のバリデーション