Skip to content

Instantly share code, notes, and snippets.

View takuma-saito's full-sized avatar

takuma.saito takuma-saito

  • 22:44 (UTC +09:00)
View GitHub Profile
@takuma-saito
takuma-saito / gem-installer.sh
Created November 13, 2015 03:04
gem-installer
# client
gem lists > gem-lists.txt
# server
gem install -v $(cat gem-lists.txt | cut -d' ' -f1 | tr '\n' ' ')
@takuma-saito
takuma-saito / create-instance-by-eip.sh
Last active November 16, 2015 02:48
create-instance-by-eip
#!/bin/zsh
AMI="ami-xxxxxxx" # Official CentOS 7.0 AMI in ap-northeast-1 region
ALOCID="eipalloc-xxxxxxx" # Allocating ip address
SIZE="m3.large"
KEYNAME="jobfind"
SEC_GROUP="default"
InstanceId=$(aws ec2 run-instances \
--count 1 \
@takuma-saito
takuma-saito / change-ip-by-eip.sh
Last active November 16, 2015 02:48
change-ip-by-eip.sh
#!/bin/zsh
InstanceId="$1"
# allocation id of current ip
OldAllocationId=$(aws ec2 describe-addresses |
jq -r '.Addresses[] | select(.InstanceId == "'$InstanceId'") | .AllocationId')
# create address
NewAllocationId=$(aws ec2 allocate-address | jq -r '.AllocationId')
@takuma-saito
takuma-saito / parallel-domain-checker.sh
Last active November 19, 2015 02:57
parallel domain checker
#!/bin/bash
SERVER='8.8.8.8'
cat $1 | sed -E 's;^https?://(.*)/;\1;g' | xargs -I{} dig +short +time=5 @$SERVER {}
dnsperf -d domain-1000000.txt -s 127.0.0.1 -p 53 -c 128 -t 10 -q 5000 -Q 150000 -S 1 2>&1 | grep -v -E 'Timeout|Warning'
@takuma-saito
takuma-saito / setup.sh
Created November 25, 2015 14:43
mac setup
#!/bin/bash
brew update
brew tap sanemat/font
brew tap caskroom/cask
brew cask install coteditor
brew cask install evernote
brew cask install google-chrome
brew cask install iterm2
brew cask install menumeters
@takuma-saito
takuma-saito / tmux.conf
Created December 1, 2015 15:37
tmux.conf
# prefixキーをctrl+tへ変更
set-option -g prefix C-t
bind-key C-t send-prefix
# ターミナルを256色にする
set -g default-terminal "xterm-256color"
# Shift + 上下左右でペインを移動できるようにする。
bind -n C-left select-pane -L
@takuma-saito
takuma-saito / ascii2decimal.sh
Created December 1, 2015 18:23
ascii2decimal
#!/bin/zsh
echo -en "$1" | hexdump -v -e '/1 "%02x "' | tr ' ' '\n' | xargs -I{} zsh -lc 'printf "\\\0%03d\n" $(echo $[[#8] 16#{}] | cut -b3-)' | tr -d '\n'
@takuma-saito
takuma-saito / con-db.sh
Created December 4, 2015 03:51
ruby connect to mysql database
#!/bin/bash
ruby -e "require 'mysql'; p Mysql.new('hostname', 'username', 'password', 'dbname')"