Skip to content

Instantly share code, notes, and snippets.

abstract (1.0.0)
actionmailer (2.1.0, 2.0.2, 1.3.6, 1.3.3)
actionpack (2.1.0, 2.0.2, 1.13.6, 1.13.3)
actionwebservice (1.2.6, 1.2.3)
activerecord (2.1.0, 2.0.2, 1.15.6, 1.15.3)
activeresource (2.1.0)
activesupport (2.1.0, 2.0.2, 1.4.4, 1.4.2)
acts_as_cached (0.1.2)
acts_as_ferret (0.4.3, 0.4.1)
AdoccaMemcache (0.1.12)
Caching with Rails: An overview
===============================
Everyone caches. This guide will teach you what you need to know about
avoiding that expensive round-trip to your database and returning what you
need to return to those hungry web clients in the shortest time possible.
Specifically, this guide is split into two parts:
- Basic Caching
From 0df85097c8733cd650992ef4960cd4e010469bea Mon Sep 17 00:00:00 2001
From: Aditya Chadha <aditya@outside.in>
Date: Wed, 8 Oct 2008 15:35:17 -0400
Subject: [PATCH] Cleaned up the radar controller and addressable module a bit
---
app/controllers/radar_controller.rb | 2 --
app/models/addressable.rb | 17 +++++++----------
2 files changed, 7 insertions(+), 12 deletions(-)
irb(main):004:0> class Foo
irb(main):005:1>
irb(main):006:1* protected
irb(main):007:1> def sanders_mom
irb(main):008:2> puts 'a'
irb(main):009:2> end
irb(main):010:1> end
=> nil
irb(main):011:0> Foo.new.sanders_mom
NoMethodError: protected method `sanders_mom' called for #<Foo:0x25b700>
def self.chunk(klass, chunk_size, proc, conditions=nil, maximum=nil)
maximum ||= klass.count(:conditions => conditions)
chunkify(maximum, chunk_size) do |limit, offset|
klass.find(:all,
:limit => limit,
:offset => offset,
:conditions => conditions).each {|obj| result = proc.call(obj); yield result if block_given?}
end
end
@aditya
aditya / gist:36742
Created December 16, 2008 19:31 — forked from mage2k/gist:36737
begin;
select count(*)
from actions
where item_type='Story'
and item_published_at is not null;
select count(distinct(item_id))
from actions
where item_type='Story'
outside_in_development=# update actions a
outside_in_development-# set a.item_published_at = s1.published_at
outside_in_development-# from stories s1
outside_in_development-# where a.item_id = s1.id and a.item_type='Story'
outside_in_development-# a.item_published_at is null
outside_in_development-# s1.id in (select s2.id
outside_in_development(# from stories s2
outside_in_development(# where s2.id=a.item_id
outside_in_development(# limit 100);
ERROR: syntax error at or near "a"
config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir|
File.directory?(lib = "#{dir}/lib") ? lib : dir
end
>> class Foo
>> def bar=(a = nil, b = nil)
>> @bar = "#{a}#{b}"
>> end
>> end
=> nil
>> f = Foo.new
=> #<Foo:0x5f3390>
>> f.bar = 5,10
=> [5, 10]
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 groupped groupped.localhost
127.0.0.1 localhost subdomain1.localhost subdomain2.localhost www.localhost