This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'active_support/all' | |
module OnlyOnce | |
extend ActiveSupport::Concern | |
included do | |
class << self | |
def inherited_with_onlyonce(sub) | |
inherited_without_onlyonce(sub) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'active_support/all' | |
module OnlyOnce | |
extend ActiveSupport::Concern | |
included do | |
def self.singleton_method_added(method_name) | |
if method_name == :startup || method_name == :shutdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'active_support/all' | |
module BeforeAfterAll | |
extend ActiveSupport::Concern | |
included do | |
class << self | |
def beforeall(&block) | |
@_beforeall = block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit/assertions' | |
module AssertChange | |
# fixme message? | |
def assert_change(value_proc, options = {}, &event_proc) | |
change = Change.new(value_proc) | |
change.perform(event_proc) | |
case |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# vim: ft=ruby | |
# | |
# Simple Dockerfile build tasks | |
# https://gist.github.com/holysugar/0a78f58d02e52f1af9f2 | |
# | |
# set environment variables before execute: | |
# | |
# - DOCKER_REGISTRY=192.168.xxx.xxx | |
# - DOCKER_PREFIX=yourprefix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while read tag; do | |
upper_tag=${tag^^} | |
upper_underscore_tag=${upper_tag//-/_} | |
export GCE_TAG_${upper_underscore_tag}=1 | |
done < <( curl \ | |
-H "X-Google-Metadata-Request: True" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ここでは environment と role というメタデータがあると仮定 | |
environment=$1 | |
role=$2 | |
if [ -z "$role" ]; then | |
echo "[usage] $0 environment role" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
class GCE | |
def initialize(project_id, env) | |
@project_id = project_id | |
@env = env | |
end | |
def instance_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcloud compute instances list | | |
grep '^projectname-web' | | |
awk '{print $5}' | | |
tr "\n" " " | | |
xargs gcloud sql instances patch dbinstancename --authorized-network | |
# 本来はタグとかメタデータとかから取る方針にしたいのでこれは手抜き。 | |
# CloudSQL 側でもっと (GAEではなく) GCEなどから受け取れる前提で設定を簡単にできるようにならないのかな… |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sudo xcodebuild -license | |
xcode-select --install | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
brew doctor | |
brew update |