Skip to content

Instantly share code, notes, and snippets.

View sawanoboly's full-sized avatar
🤷‍♂️
🙃

Yukihiko SAWANOBORI sawanoboly

🤷‍♂️
🙃
View GitHub Profile
@sawanoboly
sawanoboly / .vimrc
Last active December 22, 2015 08:39
Vimで矢印キーの有効無効を切り替える ref: http://qiita.com/sawanoboly/items/3b599f6141cc637e1e74
function! HardMode ()
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
endfunction
function! EasyMode ()
noremap <Up> <Up>
noremap <Down> <Down>
@sawanoboly
sawanoboly / Gemfile
Last active December 22, 2015 03:59
Sphinxで作成したドキュメントをherokuでホスティング、Continuous Documentationなススメ(Basic認証付き) ref: http://qiita.com/sawanoboly/items/be1dbc9f19e93e4b62cf
source "https://rubygems.org"
gem "sinatra"
gem "rake"
gem "thin"
@sawanoboly
sawanoboly / env.rb
Last active December 22, 2015 00:08
cucumberのstepsでserverspecをつかう ref: http://qiita.com/sawanoboly/items/ced6f7f1bfe2a26943c2
require 'serverspec'
include RSpec::Matchers
include Serverspec::Helper::Exec # リモートが対象ならここはSsh
include Serverspec::Helper::DetectOS
@sawanoboly
sawanoboly / chef-apply
Last active December 21, 2015 12:19
Chefのレシピでmysql_secure_installation(bashリソース利用) ref: http://qiita.com/sawanoboly/items/90d2b038f0f15282b872
# cat <<'EOL' | chef-apply -s
> bash 'mysql_secure_install emulate' do
> code <<-"EOH"
> /usr/bin/mysqladmin drop test -f
> /usr/bin/mysql -e "delete from user where user = '';" -D mysql
> /usr/bin/mysql -e "delete from user where user = 'root' and host = \'#{node[:hostname]}\';" -D mysql
> /usr/bin/mysql -e "SET PASSWORD FOR 'root'@'::1' = PASSWORD('newpassword');" -D mysql
> /usr/bin/mysql -e "SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpassword');" -D mysql
> /usr/bin/mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');" -D mysql
> /usr/bin/mysqladmin flush-privileges -pnewpassword
@sawanoboly
sawanoboly / Chef
Last active December 21, 2015 07:19
Chefのレシピでsed的な事を実施 ref: http://qiita.com/sawanoboly/items/355288c4592bdf4a3550
pry(main)> Chef::Util::FileEdit.instance_methods(false)
=> [:search_file_replace_line,
:search_file_replace,
:search_file_delete_line,
:search_file_delete,
:insert_line_after_match,
:insert_line_if_no_match,
:write_file]
@sawanoboly
sawanoboly / Pry_build_encrypt_by_plane
Last active December 21, 2015 06:59
UnixCryptな設定ファイルをRubyのCSV.tableで扱う (/etc/shadow や ftpd.passwd など) ref: http://qiita.com/sawanoboly/items/e9de14ff3264b1c66658
pry(main)> build_encrypt_by_plane('password3')
=> "$6$f22eb55ffd0731f$FhoAmeAQmcqsGbEnRJWLuqv.AwlpYHiRz8xecGE.0teBnIY3pzko2y7lRl.rXcUraZVLJ4Kc.vF5EUU5HjTir0"
@sawanoboly
sawanoboly / config_example.rb
Last active December 21, 2015 00:28
Redis Sentinel 環境で redis-namespace, sidekiqを動かす ref: http://qiita.com/sawanoboly/items/9ead476b2b00147fe48d
## -- snip --
Sidekiq.configure_server do |config|
config.redis = {
:master_name => "example-test",
:sentinels => [
{:host => "localhost", :port => 26379},
{:host => "localhost", :port => 26380}
]
}
end
@sawanoboly
sawanoboly / zonefie_to_route53.rb
Last active December 20, 2015 12:39
Create Route53 records from bind zonefile.
require 'zonefile'
require 'route53'
my_access_key = 'REPLACE_TO_YOUR_KEY'
my_secret_key = 'REPLACE_TO_YOUR_SECRET'
domain = 'example.com.'
zone_id = '/hostedzone/ZONEID'
default_ttl = '600'
@sawanoboly
sawanoboly / Dockerfile
Created July 8, 2013 03:47
Omnibus Chef install for Docker ``` docker build -t omnibus-chef . docker run -i -t omnibus-chef /bin/bash ```
# Omnibus Chef Client
#
# VERSION 0.0.1
FROM ubuntu
MAINTAINER Yukihiko Sawanobori "[email protected]"
# install curl
RUN apt-get update
RUN apt-get install -y curl
@sawanoboly
sawanoboly / default.rb
Last active December 17, 2015 14:59
[chef]nodeのアトリビュートをファイルにダンプするレシピ、OpsWorksも対応 ref: http://qiita.com/sawanoboly/items/92696f19ad937fda9eb4
require 'json'
file "/tmp/dna.json" do
content JSON.pretty_generate(node)
end