Skip to content

Instantly share code, notes, and snippets.

View allomov's full-sized avatar

Aliaksandr Lomau allomov

View GitHub Profile
puts "hello world"
@allomov
allomov / access_controll_tester.rb
Created October 26, 2010 10:33
access controll differences from other OO languages
puts "Hello World"
class AccessControllTester
def private_method
puts 'private_method'
end
def protected_method
puts 'protected_method'
class MyClass
private
def say_hello(name)
puts "Hello, #{name}."
end
end
my_object = MyClass.new
my_object.send :say_hello, "world"
class Foo
def initialize(*args)
puts "Initializing Foo"
end
end
=> nil
def Foo(*args, &block)
puts args.inspect
block.call if block
def Foo(*args, &block)
puts args.inspect
block.call if block
Class.new(Foo)
end
=> nil
class Bar < Foo("Hi There!") {
puts "Surprise!"
}
string.gsub(/(<%[^(<%|%>)]+%>)/) { |s| eval(s[2..-3]) }
@allomov
allomov / blow_mind.rb
Created August 11, 2011 07:34
fast way to blow your mind
class A
def hello
self.world
end
private
def world
puts "world"
end
@allomov
allomov / initializer.rb
Created August 12, 2011 10:28
overview of rails 2.3.12 initialization
module Rails
class Initializer
# Sequentially step through all of the available initialization routines,
# in order (view execution order in source).
def process
Rails.configuration = configuration
check_ruby_version
install_gem_spec_stubs
@allomov
allomov / SomeGemfile.rb
Created October 11, 2011 14:05
link refinery cms 2.0
# first way: straightforward, also need to add generators engine
gem 'refinerycms', '~> 2.0.0', :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-generators', :git => 'git://github.com/resolve/refinerycms-generators.git'
# second way: optional
gem 'devise' #temporarily commented out,'~> 1.4.0'
gem 'refinerycms-base', :git => 'git://github.com/resolve/refinerycms.git'
@allomov
allomov / difference_between_override_and_new.cs
Created November 16, 2011 08:15
C# is funny (difference between override and new)
// Define the base class
class Car
{
public virtual void DescribeCar()
{
System.Console.WriteLine("Four wheels and an engine.");
}
}
// Define the derived classes