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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
miko = Fiber.new do | |
cnt = 0 | |
puts "みなさーん 元気ですかー!" | |
Fiber.yield | |
puts "それでは早速、いってみよー!" | |
Fiber.yield |
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
require 'net/http' | |
require 'uri' | |
require 'kconv' | |
Net::HTTP.version_1_2 | |
puts 'require url' and exit if ARGV[0].nil? |
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
#include <stdio.h> | |
void main(int argc, char** argv){ | |
int i, a = atoi(argv[1]), b = atoi(argv[2]), sum = 0; | |
for(i = (a > 0 ? a : 0); i <= b && i <= 100; i ++){ | |
sum += (1 - i % 2) * i; | |
} | |
printf("sum = %d\n", sum); | |
} |