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
@deals = Deal | |
if params[:updated_at] != '' | |
@deals = @deals.where("UNIX_TIMESTAMP(created) >= ?", params[:updated_at]) | |
end | |
@deals = @deals.page(params[:page].to_i).per(params[:per_page].to_i).all |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>try erb</title> | |
</head> | |
<body> | |
<p> | |
<% 99.downto(96) do |number| %> | |
<%= number %> bottles of beer…<br> |
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
describe "Hospital Patient Chart" do | |
it "should have heart rate information" do | |
# heart rate information is numeric | |
# so it should be represented as a number | |
# it's implied that it's beats per minute | |
# (unless you're going to be storing it in | |
# some other format elsewhere) | |
HospitalPatientChart.new( 75 ).heart_rate.should == 75 | |
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
describe "Hospital Patient Chart" do | |
it "should have heart rate information" do | |
# heart rate information is numeric | |
# so it should be represented as a number | |
# it's implied that it's beats per minute | |
# (unless you're going to be storing it in | |
# some other format elsewhere) | |
HospitalPatientChart.new( 75 ).heart_rate.should == 75 | |
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
class Album | |
def info(val1, val2, val3) | |
val1 + ", " + val2 + ", " + "#{val3}" | |
end | |
end | |
# It's not at all clear what is going on here. First, I can make the assumption | |
# that val1 is an album name & val2 is the band. But val3? No clue. How about | |
def info( album, band, whatever_this_is ) |
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 Calculator | |
def equation(val1, val2) | |
result = val1 + val2 | |
return result | |
end | |
end | |
# Okay so the only real point here is one of style. In Ruby it's not necessary | |
# to use 'return'. By default a method returns the value of the last expression | |
# evaluated. So your method can be rewritten |
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
x = "test" | |
y = " string" | |
z = x + y | |
puts"#{x} + #{y} = #{z}" | |
require 'test/unit' |
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 Person | |
attr_accessor :name, :age, :gender | |
end | |
person_instance = Person.new | |
person_instance.name = 'robert' | |
person_instance.age = 52 | |
person_instance.gender = 'male' | |
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
#import <Cocoa/Cocoa.h> | |
@interface AppController : NSObject { | |
IBOutlet NSTextField *clockInTextField; | |
IBOutlet NSTextField *clockOutTextField; | |
IBOutlet NSTextField *resultsField; | |
IBOutlet NSTextField *payRateField; |
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
# ruby beginner elevator program | |
# We might break this stuff up into more classes as the need to separate state and | |
# behaviour of different entities emerges, for now we keep it simple and imagine | |
# the state to be that of the building as a whole. | |
# | |
# new code added by calvin... work in progress, still figuring how to make it all work | |
class Building |
NewerOlder