Skip to content

Instantly share code, notes, and snippets.

@arukoh
arukoh / base.rb
Created March 31, 2014 03:09
Thorでコマンドラインツール
# lib/sample/command/base.rb
module Sample
module Command
class Base < Thor
def self.banner(task, namespace = false, subcommand = true)
super
end
@arukoh
arukoh / omniauth.rb
Created March 31, 2014 02:58
Omniauth Mockサンプル
# see also: https://github.com/intridea/omniauth/wiki/Integration-Testing
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({
provider: "facebook",
uid: "12345",
info: { name: "Mock User" },
credentials: { token: "1234567890", expires_at: Time.now + 60.days },
extra: { raw_info: { id: "12345", name: "Mock User", } }
})
@arukoh
arukoh / migrate.rb
Created March 31, 2014 02:53
MongoDBからAmazon SimpleDBへデータのお引越し
require "resolv"
require "./mongodb"
require "./simpledb"
RECORD_LIMIT = 2000
unless ARGV.size >= 3
puts <<USAGE
Usage: #{File.basename(__FILE__)} [FROM] [TO]
FROM : start date
@arukoh
arukoh / route53_add_record.sh
Created June 2, 2013 08:53
Route 53へレコードを追加するシェルスクリプト。
#!/bin/sh
if [ $# -lt 3 ]; then
CMDNAME=`basename $0`
cat <<__EOT__
Add a record to a zone.
New record value is set current public-ipv4 or public-hostname to get from ec2 meta-data.
Usage: $CMDNAME [hosted_zone_id] [name] [type] [ttl] [comment]
type is supported A and CNAME.
ttl and comment are optional.
@arukoh
arukoh / route53_change_record.sh
Created June 2, 2013 05:37
Route 53の指定レコードを変更するシェルスクリプト。
#!/bin/sh
if [ $# -lt 3 ]; then
CMDNAME=`basename $0`
cat <<__EOT__
Delete and then add a record to a zone.
New record value is set current public-ipv4 or public-hostname to get from ec2 meta-data.
Usage: $CMDNAME [hosted_zone_id] [name] [type] [ttl] [comment]
type is supported A and CNAME.
ttl and comment are optional.
@arukoh
arukoh / find_step_definition.rb
Created May 26, 2013 06:50
Cucumber Tips。 フィーチャのシナリオステップ名にマッピングされている「ステップ定義」を検索する。
# encoding: utf-8
#!/usr/bin/env ruby
require "./runtime"
if ARGV.empty?
STDERR.puts "Must be specified STEP_NAME"
exit 1
end
step_name = ARGV.shift
runtime = Runtime.new(ARGV.dup)
@arukoh
arukoh / dump_step_definitions.rb
Created May 26, 2013 06:44
Cucumber Tips。 ステップ定義をJSONファイルにダンプ。
# encoding: utf-8
#!/usr/bin/env ruby
require "./runtime"
unless ARGV.include?("--dotcucumber")
STDERR.puts "Must be specified option --dotcucumber OUTPUT_DIR"
exit 1
end
runtime = Runtime.new(ARGV.dup)
runtime.write_stepdefs_json