Skip to content

Instantly share code, notes, and snippets.

View nz's full-sized avatar

Nick Zadrozny nz

View GitHub Profile
@nz
nz / user.rb
Created May 14, 2011 02:39 — forked from new2/user.rb
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
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)
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 }
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:
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
]
@nz
nz / focus.rb
Created March 3, 2009 18:46 — forked from robrasmussen/focus.rb
#!/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
#