Skip to content

Instantly share code, notes, and snippets.

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

Yukihiko SAWANOBORI sawanoboly

🤷‍♂️
🙃
View GitHub Profile
@sawanoboly
sawanoboly / get_https_cert.rb
Created July 18, 2012 01:26
get cert not_after via net/https.
require 'net/https'
https = Net::HTTP.new('google.com',443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
https.start {
puts https.peer_cert.not_after.class
puts https.peer_cert.not_after
}
@sawanoboly
sawanoboly / config_container.rb
Created August 2, 2012 09:51
Checking config structure when deploy with capistrano.
# -*- coding: utf-8 -*-
# Capistranoのデプロイ時にコンフィグを作成する、作成元は "*.sample"ファイル
#
# 各環境用の設定を上書きした後、キー及びバリューのクラス、階層を元のsampleと比較し、
# 文字・数字の区別がついていることなどを確認する。
#
# TODO:Capistranoのモジュールにしたい
require 'yaml'
require 'json'
@sawanoboly
sawanoboly / fluentd_install.sh
Created August 9, 2012 04:19
install fluentd under rvm. and create global command for UPstart.
#!/usr/bin/env bash -l
# rvm get latest && rvm reload #<< current rvm older than 1.10
useradd -d /opt/fluentd --system -c fluentd -s /usr/sbin/nologin --user-group fluent
rvm get stable
mkdir -p /opt/fluentd
cd /opt/fluentd
rvm install ruby-1.9.3-p194
@sawanoboly
sawanoboly / Vagrantfile
Created October 3, 2012 12:10
Create GlusterFS clusteredVolume for Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
vmbox = "precise64"
vmboxurl = "http://files.vagrantup.com/precise64.box"
gluster_repo = "http://download.gluster.org/pub/gluster/glusterfs/LATEST/Ubuntu/12.04/glusterfs_3.3.0-1_amd64.deb"
gluster_file = "glusterfs_3.3.0-1_amd64.deb"
@sawanoboly
sawanoboly / .mongorc.js
Created October 15, 2012 05:08
mongorc.js: prompt with serverrole(mongos/config/replican-ode or single) and version.
prompt = function() {
// set version
version = db.version();
// case mongos
if (rs.status().info == 'mongos') {
return rs.status().info + ':[' + version + '] > ';
}
// config or replica
@sawanoboly
sawanoboly / ohai_to_attributes.rb
Created November 1, 2012 04:30
Convert ohai output(json) to cookbook attributes format.
def _out(k,hash)
hash.each_pair do |k2,v2|
str = [k,"['#{k2}']"].join
ha = {str => v2}
out ha
end
end
def out(hash)
hash.each_pair do |k,v|
@sawanoboly
sawanoboly / m_monit_reporter.rb
Created December 14, 2012 05:41
Create report from M/Monit
#!/usr/bin/env ruby
require 'json'
require 'faraday'
class MonitReports
def initialize(mmonit = "http://127.0.0.1:8080")
@connection = Faraday.new(:url => mmonit)
res = @connection.get "/index.csp"
@cookie = res.headers['set-cookie']
@sawanoboly
sawanoboly / sm-summary_json
Last active December 11, 2015 05:29
formatted sm-summary output as JSON.
#!/usr/bin/bash
#
# Provides SmartMachine summary of information.
# Joyent 2012.
# JSON OPTION Author: github_id:sawanoboly
PATH="/opt/local/bin:/opt/local/gnu/bin:/opt/local/sbin:/usr/bin:/usr/sbin";
JSON=0
OPT=
@sawanoboly
sawanoboly / auto_install_httpfs.sh
Last active December 11, 2015 14:58
Install script Cloudera HttpFS for joyentcloud dataset "hadoop-1.0.0"
#!/usr/bin/bash
## for dataset 'hadoop' 1.0.0
set -e
## httpfs build
pkgin -y install apache-mavenpkgin -y install scmgit
pkgin -y install sun-jdk6
ln -s /opt/local/java/sun6/lib /opt/local/java/
@sawanoboly
sawanoboly / user-script.sh
Last active December 15, 2015 15:29
Continuous convergence with the chef-solo on the joyent smartmachine.
#!/usr/bin/bash
# REPLACE APP_REPO and APP_NAME
set -e
set -x
export PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin
MDATA_WRAPPER=001