Skip to content

Instantly share code, notes, and snippets.

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

Yukihiko SAWANOBORI sawanoboly

🤷‍♂️
🙃
View GitHub Profile
@sawanoboly
sawanoboly / knife.rb
Created September 17, 2015 07:39
Role(Ruby DSL) with knife-zero.
Dir.glob("roles/*.rb").each do |rf|
role = Chef::Role.new
role.name(File.basename(rf, ".rb"))
role.from_file(rf)
File.open(rf.gsub(".rb", ".json"),"w") {|f| f.puts(role.to_json)}
end
local_mode true
chef_repo_path File.expand_path("../", __FILE__)
@sawanoboly
sawanoboly / knife.rb
Last active August 29, 2015 14:23
Chef bootstrap_install_command for smartos14.3
## For SmartOS14.3.0
knife[:bootstrap_install_command] =<<"EOL"
if ! exists /opt/local/bin/chef-client; then
pkgin -y install gcc47 git gmake ruby214-base ruby214-yajl ruby214-nokogiri ruby214-readline pkg-config
pkgin -y install libxslt
## install chef
gem update --system --no-ri --no-rdoc
gem uninstall nokogiri --version 1.6.1 # missing native extention
gem install --no-ri --no-rdoc nokogiri
@sawanoboly
sawanoboly / app.rb
Created April 19, 2015 05:10
普通なRubyプログラムでもi18nで多言語対応してみる ref: http://qiita.com/sawanoboly/items/b1c16814ec6f08503290
#!/usr/bin/env ruby
# coding: utf-8
require 'i18n'
require 'yaml'
I18n.enforce_available_locales = true ## 対応ずみ言語かを実行時にチェックして止める
I18n.backend = I18n::Backend::Simple.new
## Yamlのパスをアレイで渡すとロードする
I18n.backend.load_translations(Dir.glob('locales/*.yml'))
@sawanoboly
sawanoboly / .envrc
Created April 17, 2015 01:41
GolangでHTTPのヘルスチェックをベースにDNSのレコードを更新してみる ref: http://qiita.com/sawanoboly/items/7cf7bcc956b28a7de14e
.envrc
layout go
export DNSIMPLE_TOKEN='*********************'
export DNSIMPLE_USER='*********************@higanworks.com'
export DNS_TARGET_DOMAIN='example.net'
export DNS_TARGET_RR='wwwww'
export DNS_TARGET_HOSTS='210.152.xxx.xx1,210.152.xxx.xx2'
export DNS_BACKUP_HOSTS='210.152.xxx.xx3'
sudo yum install -y php-pecl-redis php-pecl-igbinary redis
sudo service redis start
sudo chkconfig redis on
cd /var/www/vhosts/`ec2-metadata -i | awk '{print $2}'`
sudo -u nginx /usr/local/bin/wp plugin install wp-redis
sudo cp -p wp-content/plugins/wp-redis/object-cache.php wp-content/
@sawanoboly
sawanoboly / docker_conf_trusterd.conf.rb
Last active August 29, 2015 14:17
docker run -d -p 443:8080 local/trusterd
SERVER_NAME = "Trusterd"
SERVER_VERSION = "0.0.1"
SERVER_DESCRIPTION = "#{SERVER_NAME}/#{SERVER_VERSION}"
root_dir = "/usr/local/trusterd"
s = HTTP2::Server.new({
#
# required config
@sawanoboly
sawanoboly / gist:336852e84ec44f42e607
Last active August 29, 2015 14:16
recipe_file.rb
file '/var/tmp/date.txt' do
content Time.now.to_s
end
@sawanoboly
sawanoboly / Rakefile
Last active August 29, 2015 14:14
Create CHANGELOG from Github milestones.
require 'bundler'
Bundler.setup
require 'octokit'
require 'sanitize'
@client = Octokit::Client.new(:access_token => ENV['GITHUB_API_TOKEN'])
@milestones = @client.milestones(ENV['GITHUB_REPO'], {state: 'all'})
task :default do
puts File.read('./_templates/header.txt')
@sawanoboly
sawanoboly / filesys_20min.md
Last active February 24, 2023 21:35
[IDCF Cloud] highio.5XL128 vdbench results.
# ./vdbench -f examples/filesys/random_rw                                                                                                                                                 


Vdbench distribution: vdbench50402
For documentation, see 'vdbench.pdf'.

17:05:39.642 input argument scanned: '-fexamples/filesys/random_rw'
17:05:39.694 anchor=/dir1: there will be 1 directories and a maximum of 1000 files under this anchor.
17:05:39.694 Estimated maximum size for this anchor: 125m
@sawanoboly
sawanoboly / client.rb
Created October 23, 2014 10:13
monkey patch using Policyfile.rb for chef-zero
use_policyfile true
require 'chef/policy_builder/policyfile'
class ::Chef
module PolicyBuilder
class Policyfile
class_eval do
def manifest_for(cookbook_name, lock_data)
xyz_version = lock_data["version"]
http_api.get("cookbooks/#{cookbook_name}/#{xyz_version}")