Skip to content

Instantly share code, notes, and snippets.

View mmasashi's full-sized avatar

Masashi mmasashi

View GitHub Profile
@mmasashi
mmasashi / dotfiles_for_dev_env.md
Created November 12, 2012 17:26
Dotfiles for a development environment

Purpose

Prepare for developing with zsh, git and vim.

Basic

  • install zsh and set it as default shell
    • create .zshrc
    • setup git alias
@mmasashi
mmasashi / ruby-vmstat.rb
Last active December 11, 2015 16:08
Simple vmstat command with vmstat gem (gem install vmstat)
#!/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
@mmasashi
mmasashi / setup_eip.rb
Created February 3, 2013 00:28
change eip
#!/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']
}
@mmasashi
mmasashi / pg_get_table_columns.sql
Created February 6, 2013 18:12
Get table columns with a sql on postgresql. It's same as `\d table_name`.
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]}
@mmasashi
mmasashi / include_url_helpers.rb
Created February 27, 2013 01:41
the command to check the url or path methods on rails console
include Rails.application.routes.url_helpers
  • Setup Database
create database [db-name];
revoke all on schema public from public;
create schema [schema-name];
create table [schema-name].[table-name](
  ...
) 
@mmasashi
mmasashi / launch_redshift.rb
Created March 13, 2013 00:10
Launch an Amazon Redshift Cluster with aws-sdk for ruby. Ref -> http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/Redshift/Client.html
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']
@mmasashi
mmasashi / pad.coffee
Created March 14, 2013 20:14
pad '0' for Coffee script
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
@mmasashi
mmasashi / setup_macosx_mountain_lion.md
Last active December 15, 2015 00:09
Setup my development environment for Moutain Lion

Mountain Lion setup

Preparation

  • account settings
  • software update

System Preferences

  • TrackPad
    • enable Tap to Click