Skip to content

Instantly share code, notes, and snippets.

View theleoborges's full-sized avatar

Leonardo Borges theleoborges

View GitHub Profile
pairprog@pairprog06:~/jruby$ ant
Buildfile: build.xml
init:
jar:
init:
extract-rdocs:
@theleoborges
theleoborges / gist:790871
Created January 22, 2011 04:59
are_you_testing_your_javascript_yet#0
function Greeter() {
this.greet = function() {
return "Hi";
}
this.render_hi = function(container) {
$(container).text('Hi there!');
}
}
@theleoborges
theleoborges / gist:790873
Created January 22, 2011 05:01
are_you_testing_your_javascript_yet#1
Screw.Unit(function() {
describe("Greeter", function() {
it("should say Hi", function() {
greeter = new Greeter();
expect(greeter.greet()).to(equal, "Hi");
});
it("should render the message 'Hi there' inside the container div", function() {
dom_test = $('#dom_test');
dom_test.html("");
@theleoborges
theleoborges / gist:790877
Created January 22, 2011 05:07
small-update-to-appconstants#0
development: &default
max_upload_in_bytes: <%= 1.megabyte %>
@theleoborges
theleoborges / gist:790878
Created January 22, 2011 05:11
upgrading-appconstants-to-rails-3#0
class AppConstantsGenerator < Rails::Generator::Base
def manifest
record do |m|
m.directory('config')
m.file('constants.yml', 'config/constants.yml')
m.directory('config/initializers')
m.file('load_app_constants.rb', 'config/initializers/load_app_constants.rb')
end
end
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
@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: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: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: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) {