Clearing Memcached at Capistrano Deployment

Capistrano, Ruby on Rails No Comments »

It’s a two step process:

1. Create a rake task (in lib/tasks/clear_memcached.rake for example):

namespace :cache do
  desc ‘Clear memcache’
  task :clear => :environment do
    ActionController::Base.cache_store.clear
  end
end

2. In deploy.rb add the following:

namespace :cache do
  desc “Clear memcach after deployment”
  task :clear, :roles => :app do
    run “cd #{current_release} && rake cache:clear RAILS_ENV=production”
  end
end

and (depending on your task chain):

after “deploy:update_code”, “cache:clear”

Hope it helps.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

CSS Specificity Algorithm Table from Evan Sharp’s Mix 2010 talk

CSS No Comments »

Having watched Evan Sharp’s “Comp to Code” talk at Mix 2010 video (check out the other Mix videos also, most are excellent), searching the web for the CSS specificity algorithm table turned up nothing as simple as his pseudo-decimal algorithm. So I reproduced the table from the talk verbatim here for reference. As you can see, id selector elements will dramatically increase the specificity of the selector, while class selector elements are an order of magitude less specific:

CSS specificity algorithm table

selector

id

class

element

sum

#logo

1 0 0 100

.header .nav li

0 2 1 21

.header h1#logo

1 1 1 111

div div * a:hover

0 0 4 4

#nav img#logo

2 0 1 201

Exercise for the reader: Say “specificity” three times fast. Extra points: Say “specificity algorithm” three times fast.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in