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
# spec/spec_helper.rb | |
module FakeFS | |
module DefaultSettingHelper | |
def self.extended(example_group) | |
example_group.default_settings(example_group) | |
end | |
def self.included(example_group) | |
example_group.extend self |
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
FactoryGirl.define do | |
factory :access_token, :class => Doorkeeper::AccessToken do | |
resource_owner_id 1 | |
application_id 1 | |
revoked_at nil | |
expires_in 900 | |
trait :limitless do | |
expires_in nil | |
end |
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
# foo_spec.rb | |
class Foo | |
def self.bar | |
raise | |
end | |
end | |
describe Foo do | |
subject { @foo } | |
describe :bad_failure_output do |
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
# | |
# Old version | |
# | |
class Foo | |
def initialize | |
@counter = 0 | |
end | |
def false_if_first_time | |
if @counter == 0 |
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
Earthquake.init do | |
command %r|^:qt\s+(\d+)\s+(.*)$|, :as => :qt do |m| | |
target = twitter.status(m[1]) | |
text = "#{m[2]} QT @#{target["user"]["screen_name"]}: #{target["text"]}" | |
if confirm("QT '#{text}'") | |
async_e { twitter.update(text) } | |
end | |
end | |
command %r|^:rt\s+(\d+)$|, :as => :rt do |m| |
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
class Integer | |
def sample(num = 1) | |
to_a.sample(num) | |
end | |
def to_a | |
@to_a ||= self.times.map{|i| i + 1} | |
end | |
end |
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
# -*- coding: utf-8 -*- | |
Earthquake.init do | |
output :tweet do |item| | |
next unless item["text"] | |
info = [] | |
if item["in_reply_to_status_id"] | |
info << "(reply to #{id2var(item["in_reply_to_status_id"])})" | |
elsif item["retweeted_status"] | |
info << "(retweet of #{id2var(item["retweeted_status"]["id"])})" |
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
module Earthquake | |
attr_accessor :ng_list | |
def self.ng_list | |
@ng_list ||= [] | |
end | |
def self.ng_list=(ng_list) | |
@ng_list = ng_list | |
end |
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
# -*- coding: utf-8 -*- | |
# | |
# Earthquakeを実況モードにするプラグインです | |
# 普通に起動した後 | |
# :tsunami #K-ON #tbs | |
# のようにして実況モードに入ります | |
# | |
# すると #K-ON (空白区切りで最初のキーワードのみ) で検索した結果が | |
# リアルタイムに更新されます | |
# |
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 | |
# -*- coding: utf-8 -*- | |
miko = Fiber.new do | |
cnt = 0 | |
puts "みなさーん 元気ですかー!" | |
Fiber.yield | |
puts "それでは早速、いってみよー!" | |
Fiber.yield |