Skip to content

Instantly share code, notes, and snippets.

1_000.times do |i|
File.open('test.txt', 'a+') do |f|
f.write File.read('lipsum.txt')
end
puts "written #{i} time(s)"
sleep 0.5
end
class Person < ActiveRecord::Base
belongs_to :country
scope :minor, proc { where('birthday >= ?', 18.years.ago) }
scope :adult, proc { where('birthday <= ?', 18.years.ago) }
scope :male, where(gender: 'male')
scope :female, where(gender: 'female')
def self.living_in(country)
class TheUppermostClass
def initialize(one, two, three, four)
end
end
class TheInheritingClass < TheUppermostClass
def initialize(one, two, three)
super(one, two, three, 'four')
end
end
@dtrasbo
dtrasbo / terminal_shortcuts.md
Created December 1, 2010 16:25
Very useful Terminal.app shortcuts
  • Ctrl + Q Delete entire command
  • Ctrl + W Delete one word back
  • Ctrl + E Moves to the end of the command
  • Ctrl + R Search back in command history
  • Ctrl + A Moves to beginning of command
  • Ctrl + D Works like delete
# This:
require 'rails/generators'
Rails::Generators.fallbacks[:shoulda] = :test_unit
# and this:
config.generators do |g|
g.fallbacks[:shoulda] = :test_unit
end
class Car < ActiveRecord::Base
named_scope :color, lambda { |color| {:conditions => {:color => color }} }
named_scope :by_age, :order => 'created_at'
end
Car.color('red').by_age # returns all cars where color equals red ordered by age
Dan Pickett
David Trasbo
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require 'bundler/version'
Gem::Specification.new do |s|
s.name = "bundler"
s.version = Bundler::VERSION
s.platform = Gem::Platform::RUBY
class SinatraWebService
attr_reader :services
def initialize
@services = []
end
end