Skip to content

Instantly share code, notes, and snippets.

@ainoya
ainoya / pry
Created December 7, 2012 06:08
pryで返り値のダンプを抑制する ref: http://qiita.com/items/0aea440faa5d78630c9a
[73] pry(main)> (1..100).step(1).to_a.each{|n| warn n if n==100}
100
=> [1,
2,
3,
4,
5,
: #ダンプ出力があふれてpagerが立ち上がる
---------------------
[74] pry(main)> (1..100).step(1).to_a.each{|n| warn n if n==100};
@ainoya
ainoya / gist:4662125
Last active December 11, 2015 21:28
Avoiding pry installation failure by installing rdoc gem before install it.
➜ ~ rbenv global 1.9.3-p286
➜ ~ rbenv rehash
➜ ~ gem install pry
Fetching: coderay-1.0.8.gem (100%)
Fetching: slop-3.4.3.gem (100%)
Fetching: method_source-0.8.1.gem (100%)
Fetching: pry-0.9.11.4.gem (100%)
Successfully installed coderay-1.0.8
Successfully installed slop-3.4.3
Successfully installed method_source-0.8.1
@ainoya
ainoya / gist:4662509
Created January 29, 2013 07:38
Convert csv data to array of hash/yaml/json.etc.. in ruby
#!/usr/bin/env ruby
require 'csv'
require 'yaml'
require 'json'
csv =<<EOF
id,name,price
A1,apple,100
A2,grape,300
@ainoya
ainoya / remote_sudo.rb
Created June 13, 2013 00:40
Execute remote sudo command with net-ssh
#!/usr/bin/env ruby
require 'net/ssh'
require 'highline/import'
def get_password
ask( "Enter Password: " ) {|q| q.echo = '*'}
end
def remote_sudo host, ssh_user, command, opts={}
@ainoya
ainoya / ws.rb
Created August 30, 2014 05:21
websocket logger
class WSLogger
def initialize(ws)
@ws = ws
end
def write(*args)
@ws.send(*args)
end
def close
@ainoya
ainoya / update_git.sh
Created October 4, 2014 23:49
update git
#!/bin/sh
rpm -i 'http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm'
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
yum -y --enablerepo=rpmforge-extras update git
@ainoya
ainoya / install_maven.sh
Created October 5, 2014 07:32
install maven
cd /tmp
wget http://ftp.tsukuba.wide.ad.jp/software/apache/maven/maven-3/3.2.3/binaries/apache-maven-3.2.3-bin.tar.gz
tar -xzf apache-maven-3.2.3-bin.tar.gz -C /opt/
cat << EOF > /etc/profile.d/maven.sh
export M3_HOME=/opt/apache-maven-3.2.3
export M3=\$M3_HOME/bin
export PATH=\$M3:$PATH
EOF
@ainoya
ainoya / install_java.sh
Created October 5, 2014 07:38
install oracle java
#!/bin/sh
cd /tmp
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.rpm"
rpm -Uvh jdk-7u67-linux-x64.rpm
@ainoya
ainoya / install_golang.sh
Created October 5, 2014 07:57
install golang
cd /tmp
wget https://storage.googleapis.com/golang/go1.3.3.linux-amd64.tar.gz
tar -xzf go1.3.3.linux-amd64.tar.gz -C /usr/local
cat << EOF > /etc/profile.d/golang.sh
export PATH=\$PATH:/usr/local/go/bin
EOF
@ainoya
ainoya / pipeline_sample.yml
Last active August 29, 2015 14:08
sample
pipeline:
- stage_name: command_stage_1
command: echo "hello, world"
run_after:
- stage_name: command_stage_2_group_1
command: echo "hello, world, command_stage_2_group_1" && sleep 1
- stage_name: command_stage_3_group_1
command: echo "hello, world, command_stage_3_group_1"&& sleep 0.2
run_after:
- stage_name: command_stage_3_group_2