View my_first_gist.rb
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
puts "hello world" |
View access_controll_tester.rb
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
puts "Hello World" | |
class AccessControllTester | |
def private_method | |
puts 'private_method' | |
end | |
def protected_method | |
puts 'protected_method' |
View gist:734876
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 MyClass | |
private | |
def say_hello(name) | |
puts "Hello, #{name}." | |
end | |
end | |
my_object = MyClass.new | |
my_object.send :say_hello, "world" |
View gist:893259
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 Foo | |
def initialize(*args) | |
puts "Initializing Foo" | |
end | |
end | |
=> nil | |
def Foo(*args, &block) | |
puts args.inspect | |
block.call if block |
View gist:893262
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 Foo(*args, &block) | |
puts args.inspect | |
block.call if block | |
Class.new(Foo) | |
end | |
=> nil | |
class Bar < Foo("Hi There!") { | |
puts "Surprise!" | |
} |
View stupid_fast_erb.rb
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
string.gsub(/(<%[^(<%|%>)]+%>)/) { |s| eval(s[2..-3]) } |
View blow_mind.rb
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 A | |
def hello | |
self.world | |
end | |
private | |
def world | |
puts "world" | |
end |
View initializer.rb
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 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 |
View SomeGemfile.rb
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
# 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' |
View difference_between_override_and_new.cs
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
// Define the base class | |
class Car | |
{ | |
public virtual void DescribeCar() | |
{ | |
System.Console.WriteLine("Four wheels and an engine."); | |
} | |
} | |
// Define the derived classes |
OlderNewer