Prepare for developing with zsh, git and vim.
- install zsh and set it as default shell
- create .zshrc
- setup git alias
#!/usr/bin/env ruby | |
# | |
# Simple vmstat command with vmstat gem | |
# ex) | |
# $ ./ruby-vmstat.rb 1 3 | |
# cpu0 cpu1 cpu2 cpu3 memory load average | |
# i i i i free 1m 5m 15m | |
# 88.4 96.8 89.0 96.9 1093 0.5 0.9 0.9 2013-01-24 09:09:09 -0800 | |
# 88.4 96.8 89.0 96.9 1093 0.5 0.9 0.9 2013-01-24 09:09:10 -0800 | |
# 88.4 96.8 89.0 96.9 1093 0.5 0.9 0.9 2013-01-24 09:09:11 -0800 |
#!/usr/bin/ruby | |
require 'aws-sdk' | |
EIP_ADDR="XX.XX.XX.XX" | |
INSTANCE_ID='i-XXXXXXXX' | |
ec2_info = { | |
:access_key_id => ENV['AWS_KEY_ID'], | |
:secret_access_key => ENV['AWS_SECRET_KEY'] | |
} |
select column_name from INFORMATION_SCHEMA.COLUMNS where table_name = 'table_name' order by ordinal_position; |
r53 = AWS::Route53.new( | |
:access_key_id => 'aws-key-id', | |
:secret_access_key => 'aws-secret-key') | |
response = r53.client.list_resource_record_sets( | |
:hosted_zone_id => "zone-id", | |
:start_record_name => 'xxx.example.com', | |
:start_record_type => 'CNAME' | |
) | |
puts response[:resource_record_sets].map{|r| r[:name]} |
include Rails.application.routes.url_helpers |
create database [db-name];
revoke all on schema public from public;
create schema [schema-name];
create table [schema-name].[table-name](
...
)
require 'aws-sdk' | |
ACCESS_KEY_ID=ENV['AWS_KEY_ID'] | |
SECRET_ACCESS_KEY=ENV['AWS_SEC_KEY'] | |
CLUSTER_IDENTIFIER='test-instance' | |
DB_NAME='testdb' | |
PORT_NUMBER=5439 | |
MASTER_USERNAME='test_admin' | |
MASTER_USER_PASSWORD=ENV['MASTER_USER_PASSWORD'] |
pad = (num, figs, char='0') => | |
prefix = new Array(figs + 1).join(char) | |
(prefix + num).slice(-figs) | |
alert pad(12, 2) # => 12 | |
alert pad(5, 2) # => 02 | |
alert pad(12, 4) # => 0012 | |
alert pad(3, 4, '#') # => ###3 |