Skip to content

Instantly share code, notes, and snippets.

@kozy4324
kozy4324 / a.sh
Created November 28, 2013 03:48
Heap buffer overflow (CVE-2013-4164) occurs in in_http via the HTTP requests with malicious POST data.
# using ruby 2.0.0-p247
rbenv local 2.0.0-p247
# install fluentd
echo 'source "https://rubygems.org"
gem "fluentd"' > Gemfile
bundle install --path=bundle
# create fluent.conf
echo '<source>
@kozy4324
kozy4324 / a_helper.rb
Created August 9, 2013 06:13
Railsのrenderメソッドでレンダリングされる時だけulタグで括るラッパー
class AHelper
def render_ul arg
unless arg.nil? or arg.empty?
"<ul>#{render arg}</ul>".html_safe
else
""
end
end
end
@kozy4324
kozy4324 / shared_serverspec.md
Last active December 19, 2015 19:29
serverspecをshared_examplesを使ってRole毎のspecを分けてみる

serverspecをshared_examplesを使ってRole毎のspecを分けてみる

spec/_role以下にspecファイルを分離してみた.

$ tree spec/
spec/
├── _role
│   ├── cloudforecast_spec.rb
│   ├── growthforecast_spec.rb
@kozy4324
kozy4324 / ext_command.md
Created July 10, 2013 01:36
serverspecで特定ユーザーにおけるコマンド実行をテストしたい

Commandクラスにby_userメソッドを追加してみる.

module Serverspec
  module Type
    class Command
      def by_user(user)
        self.class.new("su -l '#{user}' -c '#{@name}'")
      end
 end
@kozy4324
kozy4324 / jenkins.md
Created June 28, 2013 05:10
Jenkinsのメモ
@kozy4324
kozy4324 / unicorn_rails.sh
Created June 17, 2013 10:24
bundle execで動かすunicorn_railsのinit.dスクリプト(とりあえず動くVer.)
#!/bin/sh
#
# mapi-on-rails - this script starts and stops the unicorn_rails daemon for mapi-on-rails
#
# chkconfig: - 90 10
# description: unicorn_rails for mapi-on-rails
# Source function library.
. /etc/rc.d/init.d/functions
@kozy4324
kozy4324 / rc_script.md
Created June 17, 2013 10:23
rcスクリプトの書き方について

CentOS6.3でrcスクリプトを書くよ

ランレベルとは?

/etc/inittabに書いてあるので確認.

# Default runlevel. The runlevels used are:
@kozy4324
kozy4324 / first-chef-solo.md
Created June 14, 2013 08:33
shef-colo本写経

gemインストール.

$ gem install chef
$ gem install knife-solo

vagrantの秘密鍵設定しておく. やっておかないとknife solo cookした時にrsyncで都度パスワード入力求められる.

@kozy4324
kozy4324 / replace-ruby-and-chef-solo.sh
Last active December 18, 2015 09:39
CentOS6.3でsystem Rubyを1.8.7→1.9.3、Chefを10系→最新に置き換えるVagrantのprovision shell
if [ -n "$(ruby --version|grep 'ruby 1.8')" ]; then
# yum settings
rpm --import http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# install dependencies to compile ruby
yum install -y zlib-devel openssl-devel readline-devel ncurses-devel gdbm-devel db4-devel libffi-devel tk-devel libyaml-devel
# uninstall system ruby 1.8.x
yum -y erase rubygems.noarch
@kozy4324
kozy4324 / vagrant.md
Last active September 15, 2016 06:08
Vagrantめも

Vagrant

box

OSのベースイメージ. 以下でローカルにprecise32という名前で特定URLからダウンロードして追加する.

$ vagrant box add precise32 http://files.vagrantup.com/precise32.box