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
boolean_converter = ->(s){ s == "true" ? true : false} | |
type_converters = {Fixnum => ->(s){s.to_i}, Float => ->(s){s.to_f}, Date => ->(s){s.to_date}, | |
TrueClass => boolean_converter, FalseClass => boolean_converter, String => ->(s){s}} | |
puts type_converters[Fixnum]["100"] | |
puts type_converters[Float]["100"] | |
puts type_converters[Date]["100"] | |
puts type_converters[TrueClass]["true"] | |
puts type_converters[FalseClass]["true"] |
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 Content | |
module Base | |
end | |
end | |
class Content | |
include Content::Base |
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 Spec, cities_controller_spec.rb | |
require 'spec_helper' | |
describe CitiesController do | |
include Apify | |
describe 'cities api' do | |
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
Vehicle = Backbone.Model.extend({defaults: { make: '', model: ''}}) | |
VehicleView = Backbone.View.extend({ | |
initialize: () -> | |
this.model.bind 'change', this.render, this | |
render: () -> | |
this.$el.html(this.template(this.model.toJSON())) | |
this | |
}) |
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 | |
<% products.each do |product| %> | |
<div class="product" data-id="<%= product.id %>"> | |
<%= link_to_image product.thumbnail, product %> | |
<%= product.name %> | |
... | |
</div> | |
<% 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
$('.div.product').click(showScreenshots) | |
showScreenshots = function(){ | |
selectedProductId = $(this).id.split('_')[1] | |
//load the screenshots for the product with id = selectedProductId | |
} |
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 %> |
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
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
public void processMessage(Object message){ | |
if(message instanceof CleanFloor){ | |
((CleanFloor) message).cleanKitchen(); | |
} | |
elsif(message instanceof LaunchRocket){ | |
((LaunchRocket) message).shootToMoon(); | |
} | |
} |