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 with_conditions(method_name, computed_value) | |
if method_name.to_s == 'address' && !computed_value.nil? | |
address.renderable? | |
else | |
super | |
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
mod = Module.new | |
mod.module_eval %{ | |
def fill_out_#{name}(value) | |
checkbox = find(:#{name}) | |
if (#{name}_checked_values.include?(value) && !checkbox.selected?) || | |
(#{name}_unchecked_values.include?(value) && checkbox.selected?) | |
checkbox.click | |
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
require 'resolv' | |
class EmailValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
if Resolv::DNS.new.getresources(value.split("@").last, Resolv::DNS::Resource::IN::MX).empty? | |
record.errors[attribute] << (options[:message] || "does not have a valid domain") | |
end | |
rescue Resolv::ResolvError, Resolv::ResolvTimeout | |
record.errors[attribute] << (options[:message] || "does not have a valid domain") | |
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
<div rel="warning-record"> | |
<p>Warning text... <span rel="which-field">1</span> of 3</p> | |
</div> |
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 Something | |
def self.protector(name, &block) | |
begin | |
call_mod = self.const_get(:ExternalSystemCalls, false) | |
rescue NameError | |
call_mod = Module.new | |
const_set(:ExternalSystemCalls, call_mod) | |
include call_mod | |
end | |
begin |
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
# This is designed to be used in cell classes but will work with any class | |
# which has a 'model' method. | |
# | |
# Example: | |
# | |
# class UserCell < Cell::ViewModel | |
# extend ModelFeature | |
# | |
# model_feature :name | |
# 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
task :census => ['census:snippets', 'census:layouts'] | |
namespace :census do | |
desc "Show usage stats for Snippets" | |
task :snippets => :environment do | |
snippets, missing_snippets = snippet_usage | |
longest_name = snippets.keys.inject(0) do |max, name| | |
max = name.to_s.size > max ? name.to_s.size : max |
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
// Fisher-Yates shuffle | |
function fyshuffle(a){ var t,i,l = a.length; if(l) while(--l){ i = Math.floor(Math.random() * (l + 1)); t = a[i]; a[i] = a[l]; a[l] = t; }; return a;}; |
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
.grid_list li | |
display: -moz-inline-box | |
-moz-box-orient: vertical | |
display: inline | |
display: inline-block | |
vertical-align: top | |
word-wrap: break-word | |
list-style: none | |
* html .grid_list li |
OlderNewer