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 Replaceable | |
BASE_REGEXP = '(^|\W){1}%s(\b|\.|,|:|;|\?|!|\(|\)|$){1}' | |
attr_accessor :body | |
alias to_s body | |
def initialize(body) | |
self.body = body | |
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
after = ARGV.join | |
def say(message) | |
system "say -v Zarvox #{message}" | |
end | |
begin | |
time = after.to_i | |
puts "You will be notified after #{time} hours" | |
sleep time * 60 * 60 |
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 | |
require 'rubygems' | |
require 'resque' | |
require 'resque-cleaner' | |
HOST = ENV['host'] ||= 'db1.kupikupon.ru' | |
PORT = ENV['port'] ||= '6379' | |
Resque.redis = [HOST, PORT].join(':') |
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
source 'http://rubygems.org' | |
gem 'activemodel', '>= 3.0.0', :require => 'active_model' | |
gem 'state_machine', '>= 1.0.0' | |
gem 'rspec', '~> 2.8.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
# http://stackoverflow.com/questions/6312448/how-to-disable-logging-of-asset-pipeline-sprockets-messages-in-rails-3-1 | |
Rails.application.assets.logger = Logger.new('/dev/null') | |
Rails::Rack::Logger.class_eval do | |
def call_with_quiet_assets(env) | |
previous_level = Rails.logger.level | |
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0 | |
call_without_quiet_assets(env).tap do | |
Rails.logger.level = previous_level | |
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
<table> | |
<% @hash.keys.each do |key| %> | |
<th>key</th> | |
<% end %> | |
<% @hash.values.max_by(&:size).size.times do |i| %> | |
<tr> | |
<% @group.values.map { |a| a[i] }.each do |value| %> | |
<td><%= value %></td> | |
<% end %> | |
</tr> |
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
<table> | |
<tr> | |
<th>foo</th> | |
<th>bar</th> | |
<th>baz</th> | |
</tr> | |
<tr> | |
<td>1</td> | |
<td>3</td> | |
<td>5</td> |
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
@hash = { | |
:foo => [1, 2], | |
:bar => [3, 4], | |
:baz => [5, 6] | |
} |
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
>> a | |
=> "Something like this\n\n<div class=\"gistable\" data-gist-at=\"1988392\"></div>\n\n#ruby #fiber" | |
>> a.split(' ') | |
=> ["Something", "like", "this", "<div", "class=\"gistable\"", "data-gist-at=\"1988392\"></div>", "#ruby", "#fiber"] | |
>> a.split(/ /) | |
=> ["Something", "like", "this\n\n<div", "class=\"gistable\"", "data-gist-at=\"1988392\"></div>\n\n#ruby", "#fiber"] |
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
process = Fiber.new do | |
i = 0 | |
loop do | |
puts "process_#{i = i.next}" | |
sleep 0.1 | |
Fiber.yield | |
end | |
end | |
loop do |