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 User < ActiveRecord::Base | |
attr_accessible :email, :name | |
validates :email, :presence => true | |
validates :name, :presence => true | |
validates_uniqueness_of :email, :scope => :user | |
has_many :song_entries | |
has_many :songs, :through => :song_entries |
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 User < ActiveRecord::Base | |
has_many :product_interests | |
has_many :products, :through => :product_interests | |
has_many :brand_interests | |
has_many :brands, :through => :brand_interests | |
def deals | |
product_interests.collect(&:deals) + brand_interests.collect(&:deals) |
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 sequence4(n, m, c, b) | |
# p("Inside sequence4") | |
i = 0 | |
while(i < n) | |
b.call i*m + c | |
i += 1 | |
end | |
end | |
proc1 = Proc.new { |x| puts x } |
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
require 'benchmark' | |
require 'yaml' | |
require 'set' | |
# This overrides 'require' to records the time it takes to require a file, and | |
# then generate a report. It's intelligent enough to figure out where files were | |
# required from and construct a hierarchy of the required files. | |
# | |
# To use, copy this file to lib/require_benchmarking.rb, then add this to the | |
# top of the Rails::Initializer block in environment.rb: |
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
require 'rubygems' | |
require 'grit' | |
ddp = Grit::Repo.new("/Users/nick/Sites/ddp") | |
ddp.commits('qualcomm', 100).select{ |commit| commit.author.name =~ /Zadrozny/ }.each do |commit| | |
puts "%s - %s - %s" % [ | |
commit.date.strftime('%a, %d %b, %H:%m'), | |
commit.id_abbrev, | |
commit.short_message | |
] |
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/env ruby | |
# The script that give you focus! | |
# Create a text file that contains sites want to give yourself | |
# access to only during certain times of day. | |
# | |
# The file will look like this: | |
# 12 news.ycombinator.com | |
# 11-13,19-21 twitter.com | |
# |