Latest Blog Activity From The Decider

The Decider said 6 months ago permalink Comment? (0)
Tagged: nginx

Fair Balancing for nginx

If you have a busy server running multiple mongrels you probably have noticed how nginx will sometimes queue requests onto already busy mongrels while some mongrels are completely idle.

There is now a fair balancer plugin for nginx that makes it fair rather than round robin. It’s easy to install. Grab the the plugin here and grab the latest stable release of nginx (I’m using 0.7.6) from here

Follow the directions on github:

Installation:

You’ll need to re-compile Nginx from source to include this module.
Modify your compile of Nginx by adding the following directive
(modified to suit your path of course):

./configure —with-http_ssl_module —add-module=/absolute/path/to/nginx-upstream-fair make make install

Usage:

Change your Nginx config file’s upstream block to include the ‘fair’ directive:

upstream mongrel { fair; server 127.0.0.1:5000; server 127.0.0.1:5001; server 127.0.0.1:5002; }

Caution

One issue I ran into was having to change my nginx config files that contained false to off. For example:

proxy_redirect false;

now reads

proxy_redirect off;

The Decider said 6 months ago permalink Comment? (0)
Tagged: ruby logic

De Morgan, Ruby

#De Morgan the Ruby way

[true,false].each do |p|
  [true,false].each do |q|
    puts "p=#{p} q=#{q}"
    if !(p or q) == (!p and !q)
      puts "De Morgan Rules! !(p or q) == (!p and !q)"
    else
      puts "De Morgan is a Liar!"
    end

    # if find yourself writing
    if !p and !q
      print "-"
      # you could be writing 
      unless p or q
        puts "if !p and !q equivalent to unless p or q"
      end
    end


    if !(p and q) == (!p or !q)
      puts "De Morgan Rules! !(p and q) == (!p or !q)"
    else
      puts "De Morgan is a Liar!"
    end

    # if find yourself writing
    if !p or !q
      print "-"
      # you could be writing 
      unless p and q
        puts "if !p or !q equivalent to unless p and q"
      end
    end

  end
end

The Decider said 9 months ago permalink Comment? (0)
Tagged: testing shoulda

Run individual shoulda tests

When you run tests of just one model or controller you usually do something like:

ruby test/unit/evaluation_test.rb

If you want to target just one test you can use the -n option

ruby test/unit/evaluation_test.rb -n test_return_pending_evaluatees_from_composite_group

For shoulda users if you want to target just one test the -n option can also take regular expressions.

ruby test/unit/evaluation_test.rb -v -n "/have many/"

The -v lists the test name before every test, aka verbose mode.

The Decider said 10 months ago permalink Comment? (0)
Tagged: spam site

Please Spam This Post

Just updated the code to detect the spamming bastards. Let’s see if it works.

The Decider said about 1 year ago permalink Comment? (0)
Tagged: ruby rails bdoc hanna

Pretty Local Rdoc

From the RubyInside site a couple of gems to make your local rdocs look and behave nicer.

activerecord-2.3.2 - Bdoc_1239019365281

To reap the benefits:

sudo gem install mislav-hanna sudo gem install manalang-bdoc sudo hanna —gems bdoc