Skip to content

Instantly share code, notes, and snippets.

@ptzn
ptzn / bm.rb
Last active December 13, 2015 18:08
search_for = '46846'
value = '00000'
stats = []
search_for.size.times do |index|
stats[index] ||= []
10.times do |digit|
# This Rack middleware helps solving the issue with some Rails versions which do not accept
# a '*/*;q=0.6' and their variants 'Accept' request header. This header is particularly used
# by Google Bot, and if Rails doesn't like it, it will return a 500 or 406 error to Google Bot,
# which is not the best way to get your pages indexed.
#
# References:
# - http://stackoverflow.com/questions/8881756/googlebot-receiving-missing-template-error-for-an-existing-template
# - https://github.com/rails/rails/issues/4127
#
class GoogleBotAware
@ptzn
ptzn / formatted_date_attribute.rb
Created June 3, 2011 18:11 — forked from skojin/formatted_date_attribute.rb
virtual formatted date attribute
module FormattedDateAttributes
# Define virtual formatted date attribute
#
# formatted_date_attribute(:start_at, :end_at, :format => :default)
# formatted_date_attribute(:start_at, :end_at, :format => '%d/%m/%y')
#
# format parameter can be a symbol from config/initializers/date_time_formats.rb or any
# string format that will work with Date#strftime and DateTime.strptime methods
def formatted_date_attributes(*args)
options = { :format => :default }.merge(args.extract_options!)