Skip to content

Instantly share code, notes, and snippets.

View oelmekki's full-sized avatar

kik oelmekki

View GitHub Profile
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
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
if ($uri ~* "(ftp|https?):|/etc/"){
set $rule_0 1;
return 403;
break;
}
if ($args ~* "(ftp|https?):|/etc/"){
set $rule_0 1;
return 403;
break;
}
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] ||= []
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
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
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
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
#!/usr/bin/env ruby
class Pouet
def initialize
if false
a = "kikoo"
end
p a
end
end
#!/usr/bin/env ruby
class Pouet
def initialize
if false
a = "kikoo"
end
p 'hello' unless defined? a
p a
end