Skip to content

Instantly share code, notes, and snippets.

View sonots's full-sized avatar
🤗

Naotoshi Seo sonots

🤗
View GitHub Profile
sudo yum install daemontools daemontools-toaster
# SV:12345:respawn:/usr/local/bin/svscanboot を /etc/inittab についか
kill -HUP 1
invalid_utf8 = "\xff"
invalid_utf8.force_encoding('UTF-8')
begin
invalid_utf8 =~ /hoge/
rescue => e
p e # <ArgumentError: invalid byte sequence in UTF-8>
end
invalid_utf8 = invalid_utf8.encode("UTF-8", "UTF-8")
# An example to create complex graphs
# require anyway
require 'growthforecast-client'
# Create a GrowthForecast Client, given he base URI of GrowthForecast
client = GrowthForecast::Client.new('http://localhost:5125')
service_name = 'a_service_name'
section_name = 'a_section_name'
graph_names = %w(<1sec_count <2sec_count <3sec_count <4sec_count >=4sec_count)
# An example to edit properties of graphs such as color, unit.
# require anyway
require'growthforecast-client'
# Create a GrowthForecast Client, given he base URI of GrowthForecast
client = GrowthForecast::Client.new('http://localhost:5125')
# Graph properties to overwrite
params = {
#!/bin/sh
stdin=$(cat /dev/stdin)
[ -n "$stdin" ] && /usr/bin/logger -t $1 -p user.info $stdin
# Usage
# {something} | silent_logger.sh something
# Preparation: assume rbenv and ruby-build is already installed.
curl https://raw.github.com/hsbt/ruby-build/3c94f7f696d51d96223ce64d3760d25d3b6a0b68/share/ruby-build/2.0.0-p0 -o ~/.rbenv/plugins/ruby-build/share/ruby-build/2.0.0-p0
rbenv install 2.0.0-p0
rbenv local 2.0.0-p0
rbenv rehash
# bundler must be 1.3.x for 2.0.0
gem install bundler --version 1.3.0.pre.8
# http://railsapps.github.com/openssl-certificate-verify-failed.html
wget http://curl.haxx.se/ca/cacert.pem -O /usr/local/etc/openssl/certs/cert.pem
export SSL_CERT_FILE=/usr/local/etc/openssl/certs/cert.pem
@sonots
sonots / method_chain
Created February 25, 2013 06:33
how to write this with Module#prepend? I mean, how to call #moge2_without_hoge from #moge1_without_hoge with Module#prepend?
class Hoge < Moge
def moge1_with_hoge
moge1_without_hoge
moge2_without_hoge
end
alias_method_chain :moge1, :hoge
def moge2_with_hoge
moge2_without_hoge
end
bundle install --gemfile Gemfile --path vendor/bundle --deployment --without development test
# Gemfile
# gem 'passenger', 'git: https://github.com/FooBarWidget/passenger'
bundle install
sudo yum install pcre-devel curl-devel
sudo bundle exec passenger start
Installing Phusion Passenger Standalone...
[*********************************************] Copying files...
All done!
@sonots
sonots / gist:5139546
Created March 12, 2013 01:34
fluent-agent-lite と fluentd の負荷。yes でログを垂れ流すとこんなかんじ。
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6157 root 15 0 241m 113m 1604 S 99.9 11.4 1:19.93 fluentd
3715 root 16 0 545m 438m 2276 S 7.0 43.8 0:10.78 perl