JavaScript optimization Part 3: Attaching events

May 10
2007 01:41 (Development, JavaScript) · Русский (16,798 views)

This is a third part of the JavaScript optimization tutorial, and today I’m going to talk about events. Sorry for a long delay between posts, I hope remaining parts would not be delayed so much.

Scenario: you have some elements and you need to add some actions to them (for example, when user moves mouse cursor over element, or clicks on elements).

Read the rest of entry »

Useful helpers for RSpec mocks

May 05
2007 02:38 (Development, RSpec, Ruby on Rails) · Русский (10,376 views)

RSpec has great feature — mock objects (mocks). In a few words: mock object imitates behavior of the object, which used by the tested methods. And simple example immediately:

describe UserHelper
  it 'should generate correct link to user profile in user_link' do
    @user = mock('User')
    @user.stub!(:id, 10)
    @user.stub!(:new_record?, false)
    @user.stub!(:preferred_name, 'Dmytro S.')
    @user.stub!(:full_name, 'Dmytro Shteflyuk')
    user_link(@user).should == link_to('Dmytro S.', user_url(:id => 10), :title => 'Dmytro Shteflyuk')
  end
end

Read the rest of entry »

Rails is just…

Apr 27
2007 19:26 (Development, Ruby on Rails) · Русский (4,526 views)

Rails is just an interface to the memcached?

Cache the Hell out Everything
90% API Requests — cache them

Read the Scaling Twitter.

Testing mailers with RSpec

Apr 19
2007 07:42 (Development, RSpec, Ruby on Rails) · Русский (8,347 views)

Unfortunately, RSpec does not provide helpers for testing mailers like TestUnit. But it is easy to add them to your application, and here you could find code snippet for testing mailers.

Read the rest of entry »

Using sub-queries to avoid multiple DB requests in Rails

Apr 12
2007 08:12 (Development, MySQL, Ruby on Rails) · Русский (7,295 views)

When I worked on Best Tech Videos with Alexey Kovyrin, we faced a problem of filtering videos by category with selecting posts categories in the same query. It was easy to solve the problem, but there is one query optimization trick exists.

Read the rest of entry »

 
Copyright © 2005 - 2008, Dmytro Shteflyuk