Skip to content

Instantly share code, notes, and snippets.

class Assignment < ActiveRecord::Base
belongs_to :user
belongs_to :role
end
@suggested_companies = []
while @suggested_companies.count != 6
@random_industry = Industry.first(:offset => rand(Industry.count)) # Industry.all.choice
@suggested_companies = AssociatedIndustry.where("source_type = 'Company' and industry_id = #{@random_industry.id}").limit(6).first.source # .collect(&:source)
end
def index
@industries=Industry.find(:all, :order=>"name asc")
render :layout=>'home_page'
end
Started GET "/" for 127.0.0.1 at 2013-11-19 12:21:30 +0000
Processing by UserController#index as HTML
ActiveRecord::SessionStore::Session Load (0.3ms) SELECT `sessions`.* FROM `sessions` WHERE `sessions`.`session_id` = '4ed044611a37b2915a3259d0a6df3c85' AND `sessions`.`is_destroy` = 1 LIMIT 1
@MikeHibbert
MikeHibbert / gist:3181935
Created July 26, 2012 13:05
... And in the darkness bind them !
#!/usr/bin/env ruby
def is_valid_isbn13?(isbn13)
sum = 0
13.times { |i| sum += i.modulo(2)==0 ? isbn13[i].to_i : isbn13[i].to_i*3 }
0 == sum.modulo(10)
end
def isbn13_checksum(isbn12)
sum = 0