Skip to content

Instantly share code, notes, and snippets.

View mmower's full-sized avatar
💭
Writing code

Matt Mower mmower

💭
Writing code
View GitHub Profile
@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
@mmower
mmower / tryErb.erb
Created May 12, 2011 15:14 — forked from mattstifanelli/tryErb.erb
ERB File with Ruby code embedded into HTML
<!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>
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
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
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 )
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
x = "test"
y = " string"
z = x + y
puts"#{x} + #{y} = #{z}"
require 'test/unit'
class Person
attr_accessor :name, :age, :gender
end
person_instance = Person.new
person_instance.name = 'robert'
person_instance.age = 52
person_instance.gender = 'male'
#import <Cocoa/Cocoa.h>
@interface AppController : NSObject {
IBOutlet NSTextField *clockInTextField;
IBOutlet NSTextField *clockOutTextField;
IBOutlet NSTextField *resultsField;
IBOutlet NSTextField *payRateField;
# 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