This file contains hidden or 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://fightingforalostcause.net/misc/2006/compare-email-regex.php | |
# email validation | |
/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD |
This file contains hidden or 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 | |
desc "Drop then recreate the dev database, migrate up, and load fixtures" | |
task :remigrate => :environment do | |
return unless %w[development test staging demo].include? Rails.env | |
ActiveRecord::Base.connection.tables.each { |t| ActiveRecord::Base.connection.drop_table t } | |
Rake::Task["db:migrate"].invoke | |
ENV['FIXTURES_PATH'] = "db/data/#{RAILS_ENV}" unless (ENV['FIXTURES_PATH'] || Rails.env.test?) | |
Rake::Task["db:fixtures:load"].invoke | |
end |
This file contains hidden or 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 :sass do | |
desc 'Updates stylesheets if necessary from their Sass templates.' | |
task :update => :environment do | |
Sass::Plugin.update_stylesheets | |
end | |
end |
This file contains hidden or 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
javascript:window.location=%22http://localhost/links/new?url=%22+encodeURIComponent(document.location)+%22&title=%22+encodeURIComponent(document.title) |
This file contains hidden or 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 << ActiveRecord::Base | |
def paged_find_tagged_with(tags, args = {}) | |
tags.nil? ? paginate(args) : paginate_tagged_with(tags, args) | |
end | |
def concerned_with(*concerns) | |
concerns.each do |concern| | |
require_dependency "#{name.underscore}/#{concern}" | |
end |
This file contains hidden or 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 ActionMailer::Base | |
helper ActionView::Helpers::UrlHelper | |
def generic_mailer(options) | |
@recipients = options[:recipients] || (Settings.mailer_to_address if Settings.table_exists?) | |
@from = options[:from] || (Settings.mailer_from_address if Settings.table_exists?) | |
@cc = options[:cc] || "" | |
@bcc = options[:bcc] || "" | |
@subject = options[:subject] || "" |
This file contains hidden or 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 assert_layout(expected=nil, message=nil) | |
clean_backtrace do | |
layout = @response.layout ? @response.layout.split('/').last : false | |
msg = build_message(message, "expecting <?> but rendering with <?>", expected, layout) | |
assert_block(msg) do | |
if expected.nil? | |
@response.layout | |
else | |
expected == layout | |
end |
This file contains hidden or 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 log_test | |
if Rails::logger | |
# When I run tests in rake or autotest I see the same log message multiple times per test for some reason. | |
# This guard prevents that. | |
unless @already_logged_this_test | |
Rails::logger.info "\n\nStarting #{@method_name}\n#{'-' * (9 + @method_name.length)}\n" | |
end | |
@already_logged_this_test = true | |
end | |
end |
This file contains hidden or 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
## | |
# Calendar helper with proper events | |
# http://www.cuppadev.co.uk/webdev/making-a-real-calendar-in-rails/ | |
# | |
# (C) 2009 James S Urquhart (jamesu at gmail dot com) | |
# Derived from calendar_helper | |
# (C) Jeremy Voorhis, Geoffrey Grosenbach, Jarkko Laine, Tom Armitage, Bryan Larsen | |
# Licensed under MIT. http://www.opensource.org/licenses/mit-license.php | |
## | |
This file contains hidden or 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
# syntax_helper.rb | |
module SyntaxHelper | |
WhiteListHelper.tags.merge(UV_SYNTAX_TAGS) | |
def colorize_code(body, options = {}) | |
options = {:line_numbers => false, :theme => DEFAULT_SYNTAX_STYLE}.merge(options) | |
r = RedCloth.new(body || '') | |
output = r.gsub(/<code[\.|\:]([\w\-]+)>(.*?)<\/code[\.|\:]?\1?>/m) do | |
lang, text = $1, $2 | |
html = "<notextile>" + code((text || ''), {:syntax => (lang if UV_SYNTAXES.include?(lang))}.merge(options)) + "</notextile>" |
OlderNewer