Skip to content

Instantly share code, notes, and snippets.

View totty's full-sized avatar

Takahisa Tokunaga totty

  • Groovenauts, Inc.
  • fukuoka/japan
View GitHub Profile
[
{
"name": "gcs_url",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "timestamp",
"type": "TIMESTAMP",
"mode": "NULLABLE"
@totty
totty / spec.rake
Last active December 16, 2015 16:49
ネット上では、COVERAGEなどの環境変数を設定して rake spec を実行する方法で simplecov 走らせる手段が散見してるが、それはそれで面倒なので、simplecov 用の rake タスクを作成しました。 「RAILS_ROOT/lib/tasks/spec.rake」としてファイルを配置して「rake spec:scov」で実行可能。
namespace :spec do
desc "Run all specs with simplecov"
task :coverage do
require "simplecov"
SimpleCov.start "rails"
Rake::Task["spec"].execute
`open coverage/index.html`
end
end
@totty
totty / uninstall_system_gem.rb
Created January 11, 2012 06:01
systemのgemをほとんどuninstallするスクリプト
#!/usr/bin/env ruby
gems = `gem list --no-versions`.split(/\n/) - %w(bundler minitest rake rdoc)
system("gem uninstall -a -I -x #{gems.join(' ')}")
@totty
totty / pub_sub_recover.rb
Created October 4, 2011 07:11
pub sub recovery & retry
# -*- coding: utf-8 -*-
require "rubygems"
require "amqp" # requires version >= 0.8.0.RC14
puts
EM.run do
puts "#"*20
puts "AMQP.start block runs"
def connection(&block)
# -*- coding: utf-8 -*-
require "rubygems"
require "amqp" # requires version >= 0.8.0.RC14
puts "=> Example of automatic AMQP channel and queues recovery"
puts
AMQP.start(:host => "localhost") do |connection, open_ok|
puts "AMQP.start block runs"
# on_open, on_closedに渡されたブロックは、何度再接続をしても最初の一度だけしか呼び出されないが、