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
#example_code | |
def search(query, page_number) | |
third_party_search_library.search("*{query}*").from(page_number * page_size).size(page_size).matched_results | |
end | |
#example_unit_test | |
it "should search for partial match and return paged result" do | |
third_party_search_library.should_receive(:search).with('*new york*').and_return(cities) | |
cities.should_receive(:from).with(40).and_return(cities) | |
cities.should_receive(:size).with(20).and_return(cities) |
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 MyModule | |
def self.included base | |
included_classes << base unless included_classes.include?(base) | |
end | |
def self.included_classes | |
@@included ||= [] | |
end | |
end |
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 a_good_method | |
Logger.log(self, "This is a call to a static log method") | |
# do some other thing here | |
end |
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
#!/usr/bin/ruby | |
module BaseModule | |
def cry | |
p "wa wa wa waaa" | |
end | |
end | |
module ExtendedModule | |
include BaseModule |
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
$.ajax({ | |
url: '/blog/posts/' + tag_name. | |
type: 'DELETE', | |
... | |
}); |
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
#example code to cancel subscription | |
Customer.find('John Fake').tv_channel_subscriptions.find(:nat_geo).cancel!(1.month.from_now) | |
class Customer | |
attr_accessor :name, :start_date, :end_date | |
has_many :tv_channel_subscriptions | |
end | |
class TvChannelSubscription |
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
public void processMessage(Object message){ | |
if(message instanceof CleanFloor){ | |
((CleanFloor) message).cleanKitchen(); | |
} | |
elsif(message instanceof LaunchRocket){ | |
((LaunchRocket) message).shootToMoon(); | |
} | |
} |
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
public void processMessage(CleanFloor cleanFloor){ | |
cleanFloor.cleanKitchen(); | |
} | |
public void processMessage(LaunchRocket launchRocket){ | |
launchRocket.shootToMoon(); | |
} |
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
<html> | |
<head> | |
<style> | |
.container{ | |
width: 10%; | |
height: 10%; | |
float: left; | |
background-color: green; | |
border: 1px solid #00FF 00; |
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
<% products.each do |product| %> | |
<div class="product" id="product_<%= product.id %>"> | |
<%= link_to_image product.thumbnail, product %> | |
<%= product.name %> | |
... | |
</div> | |
<% end %> |