Skip to content

Instantly share code, notes, and snippets.

@hamakn
hamakn / node.rb
Created November 28, 2011 18:51
services/mysql/lib/mysql_service/node.rb
def gen_credential(name, user, passwd)
response = {
"name" => name,
"hostname" => @mysql_config['hostname'],
"host" => @mysql_config['host'],
"port" => @mysql_config['port'],
"user" => user,
"username" => user,
"password" => passwd,
}
@hamakn
hamakn / observer.js.coffee
Created December 17, 2011 05:41
js2coffee sample http://js2coffee.org/ (javascript pattern observer sample)
makePublisher = (o) ->
i = undefined
for i of publisher
o[i] = publisher[i] if publisher.hasOwnProperty(i) and typeof publisher[i] is "function"
o.subscribers = any: []
publisher =
subscribers:
any: []
@hamakn
hamakn / index.rb
Created May 15, 2012 14:25
show service environment (id, pw, host, dbname)
require 'rubygems' # for ruby18
require 'sinatra'
require 'json'
require 'yaml'
get '/' do
"<h1>Hello Tamac.io!!</h1>"
end
get '/version' do
['+', '-', ''].repeated_permutation(8).each do |p|
arr = []
(1..9).each do |i|
arr << i
arr << p.shift
end
str = arr.join
ans = eval(str)
p str if ans == 100
end
@hamakn
hamakn / cloud.rb
Created July 26, 2012 09:15
workaround for micro bosh northeast region
# /var/vcap/packages/director/bosh/director/vendor/bundle/ruby/1.9.1/gems/bosh_aws_cpi-0.6.0/lib/cloud/aws/cloud.rb
#aki = find_aki(architecture, root_device_name)
aki = "aki-ee5df7ef"
# we could set :description here, but since we don't have a
# handle to the stemcell name and version, we can't set it
# to something useful :(
image_params = {
:name => "BOSH-#{generate_unique_name}",
@hamakn
hamakn / config
Created September 3, 2012 09:39
check vcap-staging BUNDLE_WITHOUT option
---
BUNDLE_DISABLE_SHARED_GEMS: "1"
BUNDLE_WITHOUT: test
BUNDLE_PATH: vendor/bundle
@hamakn
hamakn / .gemrc
Created November 18, 2012 04:37
gemrc
gem: --no-ri --no-rdoc
:sources:
#- http://rubygems.org/
- http://production.s3.rubygems.org/
@hamakn
hamakn / nokogiri.rb
Created November 22, 2012 06:05
suburi of nokogiri
# coding: utf-8
require "nokogiri"
# Nokogiriの素振り
# <hosts>
# <host address="localhost">
# </hosts>
# を
# <hosts>
# <host address="172.16.0.1">
@hamakn
hamakn / gist:4174848
Created November 30, 2012 09:49
Rails4勉強用