Skip to content

Instantly share code, notes, and snippets.

View statham_sanitizer.rb
module HTML
class StathamSanitizer < WhiteListSanitizer
protected
def tokenize(text, options)
super.map do |token|
if token.is_a?(HTML::Tag) && options[:parent].include?(token.name)
token.to_s.gsub(/</, "&lt;")
else
@vigetlabs
vigetlabs / http_redirect_test.rb
Created Feb 24, 2009
Test Drive mod_rewrite With Test::Unit
View http_redirect_test.rb
require 'resource_path'
require 'redirect_check'
require 'test/unit'
class HTTPRedirectTest < Test::Unit::TestCase
def default_test; end # placeholder to stop Test::Unit from complaining
def self.domain=(domain)
RedirectCheck.domain = domain
View truthy.rb
class Object
def truthy?
!(self.nil? ||
self == false ||
self == 0 ||
self == '0' ||
self == '' ||
self == [] ||
self == { } )
end