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 Config | |
# Allows you to scope everything to specific field(s). Works just like validates_uniqueness_of. | |
# For example, let's say a user belongs to a company, and you want to scope everything to the | |
# company: | |
# | |
# acts_as_authentic do |c| | |
# c.validations_scope = :company_id | |
# end | |
# | |
# * <tt>Default:</tt> nil |
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 Hash | |
def contains?( hash ) | |
hash.each do |key,value| | |
return false unless ( self.has_key?( key ) and self[ key ] == value ) | |
end | |
true | |
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
if ($uri ~* "(ftp|https?):|/etc/"){ | |
set $rule_0 1; | |
return 403; | |
break; | |
} | |
if ($args ~* "(ftp|https?):|/etc/"){ | |
set $rule_0 1; | |
return 403; | |
break; | |
} |
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 :routes do | |
desc 'Print out all defined routes in match order, with names, per constraint class. Target specific constraint class with CONSTRAINT=x. Target specific controller with CONTROLLER=x.' | |
task :constrained => :environment do | |
Rails.application.reload_routes! | |
constraints_routes = Hash.new | |
Rails.application.routes.routes.each do |route| | |
group = (route.app.class == ActionDispatch::Routing::Mapper::Constraints ? route.app.constraints.to_s : 'No constraint class') | |
constraints_routes[group] ||= [] |
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
describe 'with valid attributes' do | |
describe 'when publishing' do | |
before :each do | |
post 'create', :blog_post => @valid_attributes, :commit => { :publish => 'publish' } | |
end | |
it 'should create a new blog post' do | |
BlogPost.count.should == 1 | |
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
class DebugLogger < Logger | |
def format_message( severity, timestamp, progname, msg ) | |
if msg.is_a? String | |
"#{msg}\n" | |
else | |
"#{msg.message}\n#{msg.backtrace.join "\n" }" | |
end | |
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
class DebugLogger < Logger | |
def format_message( severity, timestamp, progname, msg ) | |
if msg.kind_of? Exception | |
"#{msg.message}\n#{msg.backtrace.join "\n" }" | |
else | |
"#{msg}\n" | |
end | |
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
class DebugLogger < Logger | |
def format_message( severity, timestamp, progname, msg ) | |
case true | |
when ( msg.kind_of? Exception ) | |
"#{msg.message}\n#{msg.backtrace.join "\n" }" | |
when ( msg.is_a? String ) | |
"#{msg}\n" | |
else | |
msg.inspect |
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
#!/usr/bin/env ruby | |
class Pouet | |
def initialize | |
if false | |
a = "kikoo" | |
end | |
p a | |
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
#!/usr/bin/env ruby | |
class Pouet | |
def initialize | |
if false | |
a = "kikoo" | |
end | |
p 'hello' unless defined? a | |
p a | |
end |