Skip to content

Instantly share code, notes, and snippets.

@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"
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
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>
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(-)
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
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)