Skip to content

Instantly share code, notes, and snippets.

View theleoborges's full-sized avatar

Leonardo Borges theleoborges

View GitHub Profile
@theleoborges
theleoborges / test.rb
Created January 22, 2011 10:27
hacking-rubys-syntax#3
class Test
def_p say_hello
puts "I'm a private method"
end
end
@theleoborges
theleoborges / test.rb
Created January 22, 2011 10:26
hacking-rubys-syntax#2
class Test
def method_a
method_b
end
#just another public method. We might have several
def method_c
method_b
end
@theleoborges
theleoborges / test.rb
Created January 22, 2011 10:24
hacking-rubys-syntax#1
class Test
def method_a
method_b
end
def method_b
puts "I'm a private method"
end
private :method_b
end
@theleoborges
theleoborges / test.rb
Created January 22, 2011 10:23
hacking-rubys-syntax#0
# this is the first way to do it
class Test
def say_hello
puts "I'm a private method"
end
private :say_hello
end
# and this is the second way
class Test
@theleoborges
theleoborges / gist:790886
Created January 22, 2011 05:22
learning-objective-c-a-ruby-analogy#4
[myArray each: ^(id *item){
NSLog(@"Current item: %@", item);
}];
@theleoborges
theleoborges / gist:790884
Created January 22, 2011 05:20
learning-objective-c-a-ruby-analogy#3
//in the interface file
@interface NSArray (each)
-(void) each: (void (^)(id *))block;
@end
//in the implementation file
@implementation NSArray (each)
-(void) each: (void (^)(id *))block {
for (id *object in self) {
@theleoborges
theleoborges / gist:790883
Created January 22, 2011 05:19
learning-objective-c-a-ruby-analogy#2
my_array.each do |item|
puts(item)
end
@theleoborges
theleoborges / gist:790882
Created January 22, 2011 05:18
learning-objective-c-a-ruby-analogy#1
// in the interface file
@interface Person : NSObject
{
NSString *name;
}
@property(retain) NSString *name;
@end
@theleoborges
theleoborges / gist:790881
Created January 22, 2011 05:16
learning-objective-c-a-ruby-analogy#0
class Person
attr_accessor :name
end
@theleoborges
theleoborges / gist:790879
Created January 22, 2011 05:13
upgrading-appconstants-to-rails-3#1
class AppConstantsGenerator < Rails::Generators::Base
def self.source_root
@source_root ||= File.expand_path('../templates', __FILE__)
end
def copy_config_files
copy_file('constants.yml', 'config/constants.yml')
copy_file('load_app_constants.rb', 'config/initializers/load_app_constants.rb')
end
end