Skip to content

Instantly share code, notes, and snippets.

View s-tajima's full-sized avatar

Satoshi Tajima s-tajima

View GitHub Profile
@s-tajima
s-tajima / monitor_rds.rb
Created July 3, 2012 05:31
Monitoring RDS by right_aws
require 'rubygems'
require 'right_aws'
access_key_id = "your-access-key-id"
secret_access_key = "your-secret-access-key"
ENV["ACW_URL"] = "https://monitoring.ap-northeast-1.amazonaws.com:443/"
ENV["RDS_URL"] = "https://rds.ap-northeast-1.amazonaws.com:443/"
@s-tajima
s-tajima / watch_web.sh
Created June 13, 2012 00:40
Script for watch a web site changes.
#! /bin/bash
TMP_SAVE_DIR="/home/ --"
TARGET_URL="http://"
TARGET_FILE="target"
TARGET_FILE_TMP="target.tmp"
if [ ! -d ${TMP_SAVE_DIR} ]; then
mkdir -p ${TMP_SAVE_DIR}
if [ $? != 0 ]; then
@s-tajima
s-tajima / bash_snipets.sh
Created June 12, 2012 13:18
Bash snipets
# 連番でディレクトリを作成
seq 1 10 | xargs -t -i mkdir test_{}
mkdir test_{1..10}
@s-tajima
s-tajima / php_snipets.php
Created June 12, 2012 13:17
PHP snipets
<?php
//ユーザ情報配列からidだけ抜き出す
$users = array(
array('id' => 1, 'name' => 'name1'),
array('id' => 2, 'name' => 'name2'),
array('id' => 3, 'name' => 'name3'),
array('id' => 4, 'name' => 'name4')
);
@s-tajima
s-tajima / mysql_snipets.txt
Created June 12, 2012 13:15
MySQL snipets
#テーブルの初期化
TRUNCATE TABLE tablename;
#複数のカラムでユニークキーを張る
ALTER TABLE tablename ADD CONSTRAINT UNIQUE (column1, column2);
#テーブルにカラムを追加する
ALTER TABLE tablename ADD COLUMN columnname rule AFTER columnname;
ex.)ALTER TABLE users ADD COLUMN rest_partner_num int NOT NULL DEFAULT 20 AFTER tutorial;
<?php
echo "Hello";