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
# attachment_fu spec helper. | |
# | |
# Usage: | |
# | |
# before(:all) do | |
# before_attachment_fu(Avatar) | |
# end | |
# | |
# it "should do weird stuff with avatar" do | |
# avatar = Avatar.new |
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
# Picks a pluralization rule specified in translation tables for a language or | |
# uses default pluralization rules. | |
# | |
# This is how pluralization rules are defined in translation tables, English | |
# language for example: | |
# | |
# store_translations :'en-US', { | |
# :pluralize => lambda { |n| n == 1 ? :one : :other } | |
# } | |
# |
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
LOCALIZE_ABBR_MONTH_NAMES_MATCH = /(%d|%e)?(\s*)(%b)/ | |
LOCALIZE_MONTH_NAMES_MATCH = /(%d|%e)?(\s*)(%B)/ | |
LOCALIZE_STANDALONE_ABBR_DAY_NAMES_MATCH = /^%a/ | |
LOCALIZE_STANDALONE_DAY_NAMES_MATCH = /^%A/ | |
# Acts the same as +strftime+, but returns a localized version of the | |
# formatted date string. Takes a key from the date/time formats | |
# translations as a format argument (<em>e.g.</em>, <tt>:short</tt> in <tt>:'date.formats'</tt>). | |
def localize(locale, object, format = :default) | |
raise ArgumentError, "Object must be a Date, DateTime or Time object. #{object.inspect} given." unless object.respond_to?(:strftime) |
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
makeSearchCommand({ | |
name: "Lingvo", | |
url: "http://lingvo.yandex.ru/en?text={QUERY}&st_translate=1", | |
icon: "http://slovari.yandex.ru/favicon.ico", | |
description: "Searches Yandex Linvo for a translation", | |
}); |
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
def update_thumbnails | |
temp_file = create_temp_file | |
attachment_options[:thumbnails].each { |suffix, size| create_or_update_thumbnail(temp_file, suffix, *size) } | |
save | |
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
namespace :db do | |
namespace :sessions do | |
desc "Clean up expired Active Record sessions (updated before ENV['EXPIRE_AT'], defaults to 1 month ago)." | |
task :expire => :environment do | |
Rails.logger.info "Cleaning up expired sessions..." | |
puts "Cleaning up expired sessions..." | |
time = ENV['EXPIRE_AT'] || 1.month.ago.to_s(:db) | |
rows = CGI::Session::ActiveRecordStore::Session.delete_all ["updated_at < ?", time] | |
Rails.logger.info "Expired sessions cleanup: #{rows} session row(s) deleted." | |
puts "Expired sessions cleanup: #{rows} session row(s) deleted." |
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 PluralizedConsts | |
P = self | |
def const_missing(sym) | |
return super(sym) if Thread.current[:pc_const_missed] | |
begin | |
super(sym) | |
rescue NameError => e | |
begin | |
Thread.current[:pc_const_missed] = true |
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
# by http://ptitov.ru/ | |
if ($http_user_agent ~ "libwww|BlogSearch|picsearch|WebAlta|Gigabot|ping\.blo\.gs|Aport|Feedster|Blo | |
gPeople|Accelatech|RSSCrawler|blogoonbot|ia_archiver|ichiro|RSS_READER|RSS Crawler|blogfan|lwp|Java\ | |
/|MaplogCrawler|sproose|Technoratibot|Moreoverbot|Jakarta|wadaino\.jp|MJ12bot|Sensis|msnbot|DepSpid| | |
Twiceler|Mail\.Ru|Slurp|Yandex/1\.01"){ | |
set $limit_rate 300; | |
} |
OlderNewer