Tuesday, July 22, 2008

Ultrasphinx Search Engine with Rails 2.0.2

ultrasphinx: Anonymous modules have no name to be referenced by

This error is caused due to the autoloading failing to load the required Ultrasphinx files in Rails 2.0.2. The following is the fix:

1. require 'ultrasphinx/fields' in ultrasphinx/configure.rb

2.

production.conf

source episodes_main
{
html_strip = 1
}

index main
{
strip_html = 0
}

3.
In environment.rb

config.after_initialize do
Ultrasphinx::Configure.load_constants
end

Notes:
git clone git://github.com/DrMark/ultrasphinx.git vendor/plugins/ultrasphinx
rm -rf vendor/plugins/ultrasphinx/.git

Tuesday, July 08, 2008

How Google reinvented Ruby Hash or Protocol Buffers by Google

I was laughing out aloud when I saw the following example on Protocol Buffers:

person {
name = "John Doe"
email = "jdoe@example.com"
}

How close is it to Ruby?

person => {
name => "John Doe"
email => "jdoe@example.com"
}

Tuesday, June 17, 2008

no such file to load -- memcache

On Mac OS Leopard:

sudo gem install memcache-client

fixed the issue.

Install memcached and dependencies on Mac OS X

cd src
ls -l
curl -O http://www.monkey.org/~provos/libevent-1.4.4-stable.tar.gz
tar xvzf libevent-1.4.4-stable.tar.gz
cd libevent-1.4.4-stable
./configure --prefix=/usr/local
make
sudo make install
cd ..
ls -l
rm -rf libevent-1.4.4-stable.tar.gz
ls -l
curl -O http://danga.com/memcached/dist/memcached-1.3.0.tar.gz
tar xvzf memcached-1.3.0.tar.gz
cd memcached-1.3.0
./configure --prefix=/usr/local
make
sudo make install

I installed this on Leopard. Original script by Geoffrey Grosenbach http://nubyonrails.com

Thursday, June 12, 2008

How to import a new project into Google code SVN

1. Go to the root of the project
2. svn import -m "Initial checkin" . https://aoror.googlecode.com/svn/trunk/ --username bparanj
3. Accept the authentication by entering 'p'
4. Enter the Google password for your project

Monday, June 09, 2008

Rubyplus Featured on 15 Great Places to Find Screencasts

Josh Catone has compiled a list of 15 Great Places for Screencasts at ReadWriteWeb.

Ryan Bates is my inspiration behind the rubyplus.org site. Rubyplus site is a tool that I use to share my passion for programming with other developers. Its purpose is to ease the pain and introduce the joy of programming in Ruby to other developers. I have learned a lot from his screencasts and I am a big railscasts fan. I have met him personally at Railsconf 2008.

Open Closed Principle in Ruby

Most of the developers in Ruby community only know about DRY principle. There are very few who know about Open Closed Principle in Ruby.

In this episode I will explain this principle and show an example in Rails where this principle can be applied. You will learn when and how you can apply this principle in Ruby.

Podcasting & Screencasting in Rails RailsConf 2008 Presentation

This presentation will definitely make podcasting and screencasting scary for those who want to get started.

The first few videos of my screencasts available at rubyplus.org has poor audio quality. Don't let details take away your focus.

Here's the lesson from my experience: If you're about to start something new, don't spend weeks trying to make the first attempt perfect. Get started as quickly as possible and learn as you go. Tinker, experiment and look for the big things you can tackle as you go. Solve problems when they need to be solved and you won't feel as overwhelmed by all the things that could be fixed.

Last paragraph stolen from: Solve Problems When They Need To Be Solved

Wednesday, May 07, 2008

Ruby Gems ERROR: could not find rush locally or in a repository

I had to do :

gem sources -r http://gems.github.com/

gem env shows:

- :sources => ["http://gems.rubyforge.org"]

Wednesday, April 30, 2008

Why return lambda from a function?

There was an excellent question at the meetup after my presentation on why return lambda instead of the actual result from a function. I did some digging on comp.lang.ruby group. Here is highlights of the notes from that group:

> I have seen many tutorials on the Internet explaining where lambdas
> CAN be used, such as clever multiplication functions, but when are
> they actually NEEDED?

> Sure, I can take a lambda and "pass it around" so to speak, but I can
> call a function from anywhere too, right?

Sure, you can call methods from almost anywhere. But you can't pass them
around (unless you turn them into proc objects, in which case you are back to
using lambdas.) And passing them around is necessary if you didn't write (and
don't want to have to monkeypatch) all the library, etc., code from which you
may want to perform a particular task. If those libraries are written to let you
pass in proc objects, you are in good shape.

> Can somebody give me an extremely useful, NOT complicated, example of
> when lambdas are the absolute perfect solution to a problem?

Callbacks.

--------------


Every time you use a block in ruby you're using a lambda implicitly.

Implicitly, but not really. I wonder, was the original question more
like "what are blocks for?" or "yes, I know what blocks are for, but why
are there also these Proc objects, which are instantiated with the
lambda construct?"

If the latter, then one answer is: when you need the program state that
is encapsulated in a block to persist outside of the method in which it
is used. For example, this happens in event-based frameworks: a setup
method in a client class registers lambdas as event handlers; the
framework doesn't need to know the classes or methods of the client
class, hence loose coupling. As a bonus, these handlers can refer to
shared program state (local variables) in the setup method.


cache :index, :ttl => 42, :key => lambda{ request['important'] }

this is a class level method which says

"cache the index method, invalidating every 42 seconds, by using the
current request's 'important' value from the query"

note that in this cast the lambda will be instance_eval'd - so when we
say 'request' here it will ultimately mean the current request

another example:

def each &block

@list.each &block

end

here we need to have captured the calling block's scope in other to
relay it along to our internal @list object's each method. it's NOT
the case that we want the scope if the function for this lambda, what
we want is logic bound to the scope of the caller

lambda are perfect anytime you want a context sensitive result and
don't want to code everything in one massive global scope.

My problem with lambda's is that I have a hard time to find a
real use case for them. I am not sure of some use case with
lambda {} that brings a definite advantage over i.e. just
using some special object or simple method.

Technically, you can replace every lambda with
an class and an instance thereof. The difference is that
the lambda is syntactically and semantically more lightweight.

To add another example, Rake tasks store away lambdas.

my_lib_version = "1.0.2"

task :tgz do
sh "tar -czf my_lib-#{my_lib_version}.tgz lib"
end

Assuming a Ruby-like language without lambdas,
we'd get this "pure OO" Rakefile:

class TgzTask
def initialize(version)
@version = version
end
def execute
sh "tar -czf my_li...@version.tgz lib"
end
end

my_lib_version = "1.0.2"

task :tgz, TgzTask.new(my_lib_version)

All context we need in our method (local variables,
eventually the current "self") has to be explicetely
passed to the constructor, which has to initialize
our object etc. Rake would loose all its appeal.

a lambda is a special object - on that knows about every variable in
scope. have fun maintaining code that populates that object by hand ;-)

the entire point of lambdas is that the language already *has* a
scope. so, sure, you can cherry pick the required variables and
populate an object, but you can also make loops with GOTO - lambda is
merely an abstraction.

the 'definite' bit comes in because you don't HAVE to do ANYTHING.
you simply write this code

sum = 0

list.each do |i|

sum += i

end

and you don't have to write anything special, the environment is
captured, the code is evaulated in the captured context, but you don't
have to build a special summing function that take i and a sum var.

so it 'definitely' is an advantage - that is unless you don't happen
to think less code is advantageous over more...

Short answer: they are more more concise and convenient.

Ever use C++ STL? In this library a "functor" is a very important concept
(for various comparators, visiting objects, etc). You make a functor by
defining a class with a primary method for functor's functionality
("operator()"). It might also have some state (possibly maintained through
other methods) or references to things external to the functor.

In ruby, this type of thing is done with blocks and lambdas. But, it is a
lot more concise and convenient. Because blocks/lambdas have access to
variables in the scope where they are defined (which can also be used to
create state), there shouldn't be a need to create dedicated "functor"
classes.

One main use is precisely when you don't need to pass anything around - you
need a one-off function, and probably the function isn't particularly
complicated. Typical examples are when supplying a code block to a sort,
group, map or filter function.

Are they needed? No. But then again, neither are subroutines or modules or
for loops...

the lambda expression came from the lisp community, it's kind of
abstraction of procedures.
in oo languages it's usually difficult to extend methods than extend
data structures.
ruby or other modern programming languages did a great job to mix them together.
well , back to the topic, imo to fully understand the power of
lambda(or abstraction), one has to look into the lisp/scheme world :)

Lambda comes from lambda calculus. The fact that LISP uses them is just a
happy coincidence.

But let's compare LISP and Ruby for a moment.

In LISP, any time you want to pass an unnamed ad-hoc function to another
function, you define it like (lambda (var1 var2) (code)), so you wind up
using the lambda macro a lot. You might have
(mapcar #'(lambda (x) (* x x)) '(1 2 3 4))
which returns
(1 4 9 16)

In Ruby, you do this kind of thing a lot too. Only we have syntactic
sugar that makes things a little nicer in many cases. The equivalent code
to the LISP example is
[1 2 3 4].map{|x| x*x}
so you just used a lambda, but didn't have to type the keyword.

There's one thing to know though. Kernel#proc and Kernel#lambda have
slightly different semantics when it comes to the return, next, and break
keywords. Kernel#lambda does things one way, and Kernel#proc or a bare
block do things the other way. So really, Ruby uses lambdas a lot (maybe
even more than LISP) but we just don't use the term very much, mostly
because we've shortened the syntax.

I like to use them when I have to efficiently choose an algorithm based
on some value:

algos = {
"print" => lambda {|x| puts x},
"ignore" => lambda {|x| },
"log" => lambda {|x| File.open("log","w") {|io| io.puts x}},

}

Now you can efficiently call a function based on some input

...each do |x,y|
algos[x][y]
end

Yes, I know the example is artificial and yes, you can do it with an
object and #send as well. But if keys are not Strings or have different
types then this approach is simpler.

Here is the link to the actual thread : http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/643980216d5c3356/2d0af8f6eabf9fb3?lnk=gst&q=proc#2d0af8f6eabf9fb3

Saturday, April 12, 2008

Changing the transparency of terminal in Mac OS Leopard

Go to Terminal -> Preferences, Window tab, Background Color and change the opacity to whatever you like. The window will change as you change the percentage of opacity.

make: yacc: Command not found on CentOS

When I was installing monit on CentOS 5, I got that error message when make was executed. The solution is to install byacc:

yum install byacc

Thursday, April 10, 2008

How to install Mongrel on CentOS 5

If you dont' have ruby-devel installed you will get the following error:

can't find header files for ruby

yum install ruby-devel

gem install mongrel



[root@rubyplus rubygems-1.1.0]# yum install -y postfix
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for postfix to pack into transaction set.
postfix-2.3.3-2.i386.rpm 100% |=========================| 41 kB 00:00
---> Package postfix.i386 2:2.3.3-2 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
postfix i386 2:2.3.3-2 base 3.6 M

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 3.6 M
Downloading Packages:
(1/1): postfix-2.3.3-2.i3 100% |=========================| 3.6 MB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: postfix ######################### [1/1]

Installed: postfix.i386 2:2.3.3-2
Complete!
[root@rubyplus rubygems-1.1.0]# chkconfig postfix on
[root@rubyplus rubygems-1.1.0]# mysqladmin -u root password 'esterc500mg'
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
[root@rubyplus rubygems-1.1.0]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@rubyplus rubygems-1.1.0]# which mysql
/usr/bin/mysql
[root@rubyplus rubygems-1.1.0]# /usr/bin/mysqladmin -uroot
/usr/bin/mysqladmin Ver 8.41 Distrib 5.0.22, for redhat-linux-gnu on i686
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Administration program for the mysqld daemon.
Usage: /usr/bin/mysqladmin [OPTIONS] command command....
-c, --count=# Number of iterations to make. This works with -i
(--sleep) only.
-#, --debug[=name] Output debug log. Often this is 'd:t:o,filename'.
-f, --force Don't ask for confirmation on drop database; with
multiple commands, continue even if an error occurs.
-C, --compress Use compression in server/client protocol.
--character-sets-dir=name
Directory where character sets are.
--default-character-set=name
Set the default character set.
-?, --help Display this help and exit.
-h, --host=name Connect to host.
-p, --password[=name]
Password to use when connecting to server. If password is
not given it's asked from the tty.
-P, --port=# Port number to use for connection.
--protocol=name The protocol of connection (tcp,socket,pipe,memory).
-r, --relative Show difference between current and previous values when
used with -i. Currently works only with extended-status.
-O, --set-variable=name
Change the value of a variable. Please note that this
option is deprecated; you can set variables directly with
--variable-name=value.
-s, --silent Silently exit if one can't connect to server.
-S, --socket=name Socket file to use for connection.
-i, --sleep=# Execute commands again and again with a sleep between.
--ssl Enable SSL for connection (automatically enabled with
other flags). Disable with --skip-ssl.
--ssl-key=name X509 key in PEM format (implies --ssl).
--ssl-cert=name X509 cert in PEM format (implies --ssl).
--ssl-ca=name CA file in PEM format (check OpenSSL docs, implies
--ssl).
--ssl-capath=name CA directory (check OpenSSL docs, implies --ssl).
--ssl-cipher=name SSL cipher to use (implies --ssl).
-u, --user=name User for login if not current user.
-v, --verbose Write more information.
-V, --version Output version information and exit.
-E, --vertical Print output vertically. Is similar to --relative, but
prints output vertically.
-w, --wait[=#] Wait and retry if connection is down.
--connect_timeout=#
--shutdown_timeout=#

Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- -----------------------------
count 0
force FALSE
compress FALSE
character-sets-dir (No default value)
default-character-set (No default value)
host (No default value)
port 0
relative FALSE
socket (No default value)
sleep 0
ssl FALSE
ssl-key (No default value)
ssl-cert (No default value)
ssl-ca (No default value)
ssl-capath (No default value)
ssl-cipher (No default value)
user root
verbose FALSE
vertical FALSE
connect_timeout 43200
shutdown_timeout 3600

Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf /etc/my.cnf
The following groups are read: mysqladmin client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit
--no-defaults Don't read default options from any options file
--defaults-file=# Only read default options from the given file #
--defaults-extra-file=# Read this file after the global files are read

Where command is a one or more of: (Commands may be shortened)
create databasename Create a new database
debug Instruct server to write debug information to log
drop databasename Delete a database and all its tables
extended-status Gives an extended status message from the server
flush-hosts Flush all cached hosts
flush-logs Flush all logs
flush-status Clear status variables
flush-tables Flush all tables
flush-threads Flush the thread cache
flush-privileges Reload grant tables (same as reload)
kill id,id,... Kill mysql threads
password new-password Change old password to new-password, MySQL 4.1 hashing.
old-password new-password Change old password to new-password in old format.

ping Check if mysqld is alive
processlist Show list of active threads in server
reload Reload grant tables
refresh Flush all tables and close and open logfiles
shutdown Take server down
status Gives a short status message from the server
start-slave Start slave
stop-slave Stop slave
variables Prints variables available
version Get version info from server
[root@rubyplus rubygems-1.1.0]# /usr/bin/mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@rubyplus rubygems-1.1.0]# /usr/bin/mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@rubyplus rubygems-1.1.0]# sudo gem install rails -y
INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
Bulk updating Gem source index for: http://gems.rubyforge.org/
Successfully installed rake-0.8.1
Successfully installed activesupport-2.0.2
Successfully installed activerecord-2.0.2
Successfully installed actionpack-2.0.2
Successfully installed actionmailer-2.0.2
Successfully installed activeresource-2.0.2
Successfully installed rails-2.0.2
7 gems installed
Installing ri documentation for rake-0.8.1...
Installing ri documentation for activesupport-2.0.2...
Installing ri documentation for activerecord-2.0.2...
Installing ri documentation for actionpack-2.0.2...
Installing ri documentation for actionmailer-2.0.2...
Installing ri documentation for activeresource-2.0.2...
Installing RDoc documentation for rake-0.8.1...
Installing RDoc documentation for activesupport-2.0.2...
Installing RDoc documentation for activerecord-2.0.2...
Installing RDoc documentation for actionpack-2.0.2...
Installing RDoc documentation for actionmailer-2.0.2...
Installing RDoc documentation for activeresource-2.0.2...
[root@rubyplus rubygems-1.1.0]# sudo gem install mongrel
Building native extensions. This could take a while...
ERROR: Error installing mongrel:
ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb install mongrel
can't find header files for ruby.


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.1/ext/fastthread/gem_make.out
[root@rubyplus rubygems-1.1.0]#

Installation notes

[root@rubyplus rubygems-1.1.0]# yum install -y postfix
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for postfix to pack into transaction set.
postfix-2.3.3-2.i386.rpm 100% |=========================| 41 kB 00:00
---> Package postfix.i386 2:2.3.3-2 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
postfix i386 2:2.3.3-2 base 3.6 M

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 3.6 M
Downloading Packages:
(1/1): postfix-2.3.3-2.i3 100% |=========================| 3.6 MB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: postfix ######################### [1/1]

Installed: postfix.i386 2:2.3.3-2
Complete!
[root@rubyplus rubygems-1.1.0]# chkconfig postfix on
[root@rubyplus rubygems-1.1.0]# mysqladmin -u root password 'new_password_here'
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
[root@rubyplus rubygems-1.1.0]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@rubyplus rubygems-1.1.0]# which mysql
/usr/bin/mysql
[root@rubyplus rubygems-1.1.0]# /usr/bin/mysqladmin -uroot
/usr/bin/mysqladmin Ver 8.41 Distrib 5.0.22, for redhat-linux-gnu on i686
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Administration program for the mysqld daemon.
Usage: /usr/bin/mysqladmin [OPTIONS] command command....
-c, --count=# Number of iterations to make. This works with -i
(--sleep) only.
-#, --debug[=name] Output debug log. Often this is 'd:t:o,filename'.
-f, --force Don't ask for confirmation on drop database; with
multiple commands, continue even if an error occurs.
-C, --compress Use compression in server/client protocol.
--character-sets-dir=name
Directory where character sets are.
--default-character-set=name
Set the default character set.
-?, --help Display this help and exit.
-h, --host=name Connect to host.
-p, --password[=name]
Password to use when connecting to server. If password is
not given it's asked from the tty.
-P, --port=# Port number to use for connection.
--protocol=name The protocol of connection (tcp,socket,pipe,memory).
-r, --relative Show difference between current and previous values when
used with -i. Currently works only with extended-status.
-O, --set-variable=name
Change the value of a variable. Please note that this
option is deprecated; you can set variables directly with
--variable-name=value.
-s, --silent Silently exit if one can't connect to server.
-S, --socket=name Socket file to use for connection.
-i, --sleep=# Execute commands again and again with a sleep between.
--ssl Enable SSL for connection (automatically enabled with
other flags). Disable with --skip-ssl.
--ssl-key=name X509 key in PEM format (implies --ssl).
--ssl-cert=name X509 cert in PEM format (implies --ssl).
--ssl-ca=name CA file in PEM format (check OpenSSL docs, implies
--ssl).
--ssl-capath=name CA directory (check OpenSSL docs, implies --ssl).
--ssl-cipher=name SSL cipher to use (implies --ssl).
-u, --user=name User for login if not current user.
-v, --verbose Write more information.
-V, --version Output version information and exit.
-E, --vertical Print output vertically. Is similar to --relative, but
prints output vertically.
-w, --wait[=#] Wait and retry if connection is down.
--connect_timeout=#
--shutdown_timeout=#

Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- -----------------------------
count 0
force FALSE
compress FALSE
character-sets-dir (No default value)
default-character-set (No default value)
host (No default value)
port 0
relative FALSE
socket (No default value)
sleep 0
ssl FALSE
ssl-key (No default value)
ssl-cert (No default value)
ssl-ca (No default value)
ssl-capath (No default value)
ssl-cipher (No default value)
user root
verbose FALSE
vertical FALSE
connect_timeout 43200
shutdown_timeout 3600

Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf /etc/my.cnf
The following groups are read: mysqladmin client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit
--no-defaults Don't read default options from any options file
--defaults-file=# Only read default options from the given file #
--defaults-extra-file=# Read this file after the global files are read

Where command is a one or more of: (Commands may be shortened)
create databasename Create a new database
debug Instruct server to write debug information to log
drop databasename Delete a database and all its tables
extended-status Gives an extended status message from the server
flush-hosts Flush all cached hosts
flush-logs Flush all logs
flush-status Clear status variables
flush-tables Flush all tables
flush-threads Flush the thread cache
flush-privileges Reload grant tables (same as reload)
kill id,id,... Kill mysql threads
password new-password Change old password to new-password, MySQL 4.1 hashing.
old-password new-password Change old password to new-password in old format.

ping Check if mysqld is alive
processlist Show list of active threads in server
reload Reload grant tables
refresh Flush all tables and close and open logfiles
shutdown Take server down
status Gives a short status message from the server
start-slave Start slave
stop-slave Stop slave
variables Prints variables available
version Get version info from server
[root@rubyplus rubygems-1.1.0]# /usr/bin/mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@rubyplus rubygems-1.1.0]# /usr/bin/mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@rubyplus rubygems-1.1.0]# sudo gem install rails -y
INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
Bulk updating Gem source index for: http://gems.rubyforge.org/
Successfully installed rake-0.8.1
Successfully installed activesupport-2.0.2
Successfully installed activerecord-2.0.2
Successfully installed actionpack-2.0.2
Successfully installed actionmailer-2.0.2
Successfully installed activeresource-2.0.2
Successfully installed rails-2.0.2
7 gems installed
Installing ri documentation for rake-0.8.1...
Installing ri documentation for activesupport-2.0.2...
Installing ri documentation for activerecord-2.0.2...
Installing ri documentation for actionpack-2.0.2...
Installing ri documentation for actionmailer-2.0.2...
Installing ri documentation for activeresource-2.0.2...
Installing RDoc documentation for rake-0.8.1...
Installing RDoc documentation for activesupport-2.0.2...
Installing RDoc documentation for activerecord-2.0.2...
Installing RDoc documentation for actionpack-2.0.2...
Installing RDoc documentation for actionmailer-2.0.2...
Installing RDoc documentation for activeresource-2.0.2...
[root@rubyplus rubygems-1.1.0]# sudo gem install mongrel
Building native extensions. This could take a while...
ERROR: Error installing mongrel:
ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb install mongrel
can't find header files for ruby.


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.1/ext/fastthread/gem_make.out
[root@rubyplus rubygems-1.1.0]#

rubygems 1.1.0 on CentOS 5

ruby setup.rb
./lib/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- rdoc/rdoc (LoadError)
from ./lib/rubygems/custom_require.rb:27:in `require'
from setup.rb:48

Rubygems is retarded, it will puke until you install ruby-rdoc and rdoc to install the rubygems 1.1

yum install ruby-rdoc

Download rubygems
wget http://rubyforge.org/frs/download.php/34638/rubygems-1.1.0.tgz
cd rubygems-1.1.0.tgz
Extract
tar -xvzf rubygems-1.1.0.tgz
ruby setup.rb

Installing Nginx on CentOS 5

[root@rubyplus etc]# yum install pcre
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
base 100% |=========================| 1.1 kB 00:00
updates 951 B 00:00
addons 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for pcre to pack into transaction set.
pcre-6.6-2.el5_1.7.i386.r 100% |=========================| 7.4 kB 00:00
---> Package pcre.i386 0:6.6-2.el5_1.7 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Updating:
pcre i386 6.6-2.el5_1.7 updates 112 k

Transaction Summary
=============================================================================
Install 0 Package(s)
Update 1 Package(s)
Remove 0 Package(s)

Total download size: 112 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): pcre-6.6-2.el5_1.7.i386.rpm 112 kB 00:02
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : pcre ######################### [1/2]
Cleanup : pcre ######################### [2/2]

Updated: pcre.i386 0:6.6-2.el5_1.7
Complete!
[root@rubyplus etc]# yum install pcre-devel
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for pcre-devel to pack into transaction set.
pcre-devel-6.6-2.el5_1.7. 100% |=========================| 10 kB 00:00
---> Package pcre-devel.i386 0:6.6-2.el5_1.7 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
pcre-devel i386 6.6-2.el5_1.7 updates 176 k

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 176 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): pcre-devel-6.6-2.el5_1.7.i386.rpm 176 kB 00:02
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: pcre-devel ######################### [1/1]

Installed: pcre-devel.i386 0:6.6-2.el5_1.7
Complete!
[root@rubyplus etc]# yum install zlib
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Nothing to do
[root@rubyplus etc]# yum install zlib-devel
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Nothing to do
[root@rubyplus etc]# yum install openssl
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Nothing to do
[root@rubyplus etc]# yum install openssl-devel
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Nothing to do
[root@rubyplus etc]# ./configure --sbin-path=/usr/local/sbin --with-http_ssl_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with
-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-cc-opt="-I /usr/include/pcre" --pid-path=/var/run/ngin
x.pid --lock-path=/var/lock/subsys/nginx --conf-path=/etc/nginx/nginx.conf
-bash: ./configure: No such file or directory
[root@rubyplus etc]#
[root@rubyplus etc]# wget http://sysoev.ru/nginx/nginx-0.5.35.tar.gz
--12:44:58-- http://sysoev.ru/nginx/nginx-0.5.35.tar.gz
Resolving sysoev.ru... 81.19.69.70
Connecting to sysoev.ru|81.19.69.70|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 488926 (477K) [application/octet-stream]
Saving to: `nginx-0.5.35.tar.gz'

100%[===============================================================================================================================>] 488,926 48.7K/s in 9.3s

12:45:08 (51.3 KB/s) - `nginx-0.5.35.tar.gz' saved [488926/488926]

[root@rubyplus etc]# tar xzvf nginx-0.5.35.tar.gz
nginx-0.5.35/



nginx-0.5.35/contrib/unicode2nginx/koi-utf
[root@rubyplus etc]# cd nginx-0.5.35
[root@rubyplus nginx-0.5.35]# ./configure --sbin-path=/sbin/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module
--with-md5=auto/lib/md5 --with-sha1=auto/lib/sha1
checking for OS
+ Linux 2.6.18-53.1.6.el5.028stab053.6PAE i686
checking for C compiler ... not found

./configure: error: C compiler gcc is not found

[root@rubyplus nginx-0.5.35]# yum install gcc
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for gcc to pack into transaction set.
gcc-4.1.2-14.el5.i386.rpm 100% |=========================| 64 kB 00:00
---> Package gcc.i386 0:4.1.2-14.el5 set to be updated
--> Running transaction check
--> Processing Dependency: libgomp.so.1 for package: gcc
--> Processing Dependency: binutils >= 2.17.50.0.2-8 for package: gcc
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc
glibc-common-2.5-18.el5_1 100% |=========================| 723 kB 00:00
---> Package glibc-common.i386 0:2.5-18.el5_1.1 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
gcc i386 4.1.2-14.el5 base 5.2 M
Installing for dependencies:
binutils i386 2.17.50.0.6-5.el5 base 2.9 M
cpp i386 4.1.2-14.el5 base 2.6 M
glibc-devel i386 2.5-18.el5_1.1 updates 2.0 M
glibc-headers i386 2.5-18.el5_1.1 updates 609 k
libgomp i386 4.1.2-14.el5 base 76 k
Updating for dependencies:
glibc i686 2.5-18.el5_1.1 updates 5.1 M
glibc-common i386 2.5-18.el5_1.1 updates 16 M
libgcc i386 4.1.2-14.el5 base 87 k

Transaction Summary
=============================================================================
Install 6 Package(s)
Update 3 Package(s)
Remove 0 Package(s)

Total download size: 35 M
Is this ok [y/N]: y
Downloading Packages:
(1/9): binutils-2.17.50.0 100% |=========================| 2.9 MB 00:03
(2/9): gcc-4.1.2-14.el5.i 100% |=========================| 5.2 MB 00:07
(3/9): libgcc-4.1.2-14.el 100% |=========================| 87 kB 00:00
(4/9): libgomp-4.1.2-14.e 100% |=========================| 76 kB 00:00
(5/9): glibc-2.5-18.el5_1 100% |=========================| 5.1 MB 00:02
(6/9): cpp-4.1.2-14.el5.i 100% |=========================| 2.6 MB 00:02
(7/9): glibc-headers-2.5- 100% |=========================| 609 kB 00:00
(8/9): glibc-common-2.5-1 100% |=========================| 16 MB 00:07
(9/9): glibc-devel-2.5-18 100% |=========================| 2.0 MB 00:01
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : libgcc ####################### [ 1/12]
Updating : glibc-common ####################### [ 2/12]
Updating : glibc ####################### [ 3/12]
Installing: binutils ####################### [ 4/12]
Installing: libgomp ####################### [ 5/12]
Installing: cpp ####################### [ 6/12]
Installing: glibc-headers ####################### [ 7/12]
Installing: glibc-devel ####################### [ 8/12]
Installing: gcc ####################### [ 9/12]
Cleanup : libgcc ####################### [10/12]
Cleanup : glibc ####################### [11/12]
Cleanup : glibc-common ####################### [12/12]

Installed: gcc.i386 0:4.1.2-14.el5
Dependency Installed: binutils.i386 0:2.17.50.0.6-5.el5 cpp.i386 0:4.1.2-14.el5 glibc-devel.i386 0:2.5-18.el5_1.1 glibc-headers.i386 0:2.5-18.el5_1.1 libgomp.i386 0:4.1.2-14.el5
Dependency Updated: glibc.i686 0:2.5-18.el5_1.1 glibc-common.i386 0:2.5-18.el5_1.1 libgcc.i386 0:4.1.2-14.el5
Complete!
[root@rubyplus nginx-0.5.35]# ./configure --sbin-path=/sbin/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module
--with-md5=auto/lib/md5 --with-sha1=auto/lib/sha1
checking for OS
+ Linux 2.6.18-53.1.6.el5.028stab053.6PAE i686
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.1.2 20070626 (Red Hat 4.1.2-14)
checking for gcc -pipe switch ... found
checking for gcc variadic macros ... found
checking for C99 variadic macros ... found
checking for unistd.h ... found

checking for ioctl(FIONBIO) ... found
checking for struct tm.tm_gmtoff ... found

Configuration summary
+ threads are not used
+ using system PCRE library
+ using system OpenSSL library
+ using md5 library: auto/lib/md5
+ using sha1 library: auto/lib/sha1
+ using system zlib library

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/sbin/nginx"
nginx configuration file: "/usr/local/nginx/nginx.conf"
nginx pid file: "/usr/local/nginx/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "/usr/local/nginx/client_body_temp"
nginx http proxy temporary files: "/usr/local/nginx/proxy_temp"
nginx http fastcgi temporary files: "/usr/local/nginx/fastcgi_temp"

Run:
make
make install

Installing MySQL server on Centos 5

Followed the instructions on this blog post : Rails Stack on CentOS 5

The following instructions has the chkconfig which works. The given instruction on the blog for that does not work.

[root@rubyplus etc]# yum install which
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for which to pack into transaction set.
which-2.16-7.i386.rpm 100% |=========================| 6.5 kB 00:00
---> Package which.i386 0:2.16-7 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
which i386 2.16-7 base 23 k

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 23 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): which-2.16-7.i386. 100% |=========================| 23 kB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: which ######################### [1/1]

Installed: which.i386 0:2.16-7
Complete!
[root@rubyplus etc]# which mysql
which: no mysql in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
[root@rubyplus etc]# yum install mysql-server
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for mysql-server to pack into transaction set.
mysql-server-5.0.22-2.2.e 100% |=========================| 33 kB 00:00
---> Package mysql-server.i386 0:5.0.22-2.2.el5_1.1 set to be updated
--> Running transaction check
--> Processing Dependency: libmysqlclient_r.so.15 for package: mysql-server
--> Processing Dependency: libmysqlclient.so.15 for package: mysql-server
--> Processing Dependency: perl-DBI for package: mysql-server
--> Processing Dependency: mysql = 5.0.22-2.2.el5_1.1 for package: mysql-server
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server
--> Processing Dependency: libmysqlclient_r.so.15(libmysqlclient_15) for package: mysql-server
--> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15) for package: mysql-server
--> Processing Dependency: perl(DBI) for package: mysql-server
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for perl-DBD-MySQL to pack into transaction set.
perl-DBD-MySQL-3.0007-1.f 100% |=========================| 8.3 kB 00:00
---> Package perl-DBD-MySQL.i386 0:3.0007-1.fc6 set to be updated
---> Downloading header for mysql to pack into transaction set.
mysql-5.0.22-2.2.el5_1.1. 100% |=========================| 36 kB 00:00
---> Package mysql.i386 0:5.0.22-2.2.el5_1.1 set to be updated
---> Downloading header for perl-DBI to pack into transaction set.
perl-DBI-1.52-1.fc6.i386. 100% |=========================| 16 kB 00:00
---> Package perl-DBI.i386 0:1.52-1.fc6 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
mysql-server i386 5.0.22-2.2.el5_1.1 updates 10 M
Installing for dependencies:
mysql i386 5.0.22-2.2.el5_1.1 updates 3.0 M
perl-DBD-MySQL i386 3.0007-1.fc6 base 147 k
perl-DBI i386 1.52-1.fc6 base 605 k

Transaction Summary
=============================================================================
Install 4 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 14 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): perl-DBD-MySQL-3.0 100% |=========================| 147 kB 00:00
(2/4): mysql-5.0.22-2.2.e 100% |=========================| 3.0 MB 00:01
(3/4): mysql-server-5.0.2 100% |=========================| 10 MB 00:04
(4/4): perl-DBI-1.52-1.fc 100% |=========================| 605 kB 00:01
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: perl-DBI ######################### [1/4]
Installing: mysql ######################### [2/4]
Installing: perl-DBD-MySQL ######################### [3/4]
Installing: mysql-server ######################### [4/4]

Installed: mysql-server.i386 0:5.0.22-2.2.el5_1.1
Dependency Installed: mysql.i386 0:5.0.22-2.2.el5_1.1 perl-DBD-MySQL.i386 0:3.0007-1.fc6 perl-DBI.i386 0:1.52-1.fc6
Complete!
[root@rubyplus etc]# yum install mysql
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Nothing to do
[root@rubyplus etc]# yum install mysql-devel
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for mysql-devel to pack into transaction set.
mysql-devel-5.0.22-2.2.el 100% |=========================| 28 kB 00:00
---> Package mysql-devel.i386 0:5.0.22-2.2.el5_1.1 set to be updated
--> Running transaction check
--> Processing Dependency: openssl-devel for package: mysql-devel
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for openssl-devel to pack into transaction set.
openssl-devel-0.9.8b-8.3. 100% |=========================| 142 kB 00:00
---> Package openssl-devel.i386 0:0.9.8b-8.3.el5_0.2 set to be updated
--> Running transaction check
--> Processing Dependency: openssl = 0.9.8b-8.3.el5_0.2 for package: openssl-devel
--> Processing Dependency: zlib-devel for package: openssl-devel
--> Processing Dependency: krb5-devel for package: openssl-devel
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for openssl to pack into transaction set.
openssl-0.9.8b-8.3.el5_0. 100% |=========================| 35 kB 00:00
---> Package openssl.i686 0:0.9.8b-8.3.el5_0.2 set to be updated
---> Downloading header for zlib-devel to pack into transaction set.
zlib-devel-1.2.3-3.i386.r 100% |=========================| 7.0 kB 00:00
---> Package zlib-devel.i386 0:1.2.3-3 set to be updated
---> Downloading header for krb5-devel to pack into transaction set.
krb5-devel-1.6.1-17.el5_1 100% |=========================| 48 kB 00:00
---> Package krb5-devel.i386 0:1.6.1-17.el5_1.1 set to be updated
--> Running transaction check
--> Processing Dependency: krb5-libs = 1.6.1-17.el5_1.1 for package: krb5-devel
--> Processing Dependency: e2fsprogs-devel for package: krb5-devel
--> Processing Dependency: libkeyutils.so.1 for package: krb5-devel
--> Processing Dependency: libselinux-devel for package: krb5-devel
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for keyutils-libs to pack into transaction set.
keyutils-libs-1.2-1.el5.i 100% |=========================| 5.0 kB 00:00
---> Package keyutils-libs.i386 0:1.2-1.el5 set to be updated
---> Downloading header for libselinux-devel to pack into transaction set.
libselinux-devel-1.33.4-4 100% |=========================| 45 kB 00:00
---> Package libselinux-devel.i386 0:1.33.4-4.el5 set to be updated
---> Downloading header for krb5-libs to pack into transaction set.
krb5-libs-1.6.1-17.el5_1. 100% |=========================| 45 kB 00:00
---> Package krb5-libs.i386 0:1.6.1-17.el5_1.1 set to be updated
---> Downloading header for e2fsprogs-devel to pack into transaction set.
e2fsprogs-devel-1.39-10.e 100% |=========================| 24 kB 00:00
---> Package e2fsprogs-devel.i386 0:1.39-10.el5_1.1 set to be updated
---> Downloading header for keyutils-libs-devel to pack into transaction set.
keyutils-libs-devel-1.2-1 100% |=========================| 6.7 kB 00:00
---> Package keyutils-libs-devel.i386 0:1.2-1.el5 set to be updated
--> Running transaction check
--> Processing Dependency: e2fsprogs-libs = 1.39-10.el5_1.1 for package: e2fsprogs-devel
--> Processing Dependency: libselinux = 1.33.4-4.el5 for package: libselinux-devel
--> Processing Dependency: libsepol-devel >= 1.15.2-1 for package: libselinux-devel
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for libselinux to pack into transaction set.
libselinux-1.33.4-4.el5.i 100% |=========================| 38 kB 00:00
---> Package libselinux.i386 0:1.33.4-4.el5 set to be updated
---> Downloading header for e2fsprogs-libs to pack into transaction set.
e2fsprogs-libs-1.39-10.el 100% |=========================| 19 kB 00:00
---> Package e2fsprogs-libs.i386 0:1.39-10.el5_1.1 set to be updated
---> Downloading header for libsepol-devel to pack into transaction set.
libsepol-devel-1.15.2-1.e 100% |=========================| 29 kB 00:00
---> Package libsepol-devel.i386 0:1.15.2-1.el5 set to be updated
--> Running transaction check
--> Processing Dependency: libselinux = 1.33.4-2.el5 for package: libselinux-python
--> Processing Dependency: e2fsprogs-libs = 1.39-8.el5 for package: e2fsprogs
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for libselinux-python to pack into transaction set.
libselinux-python-1.33.4- 100% |=========================| 35 kB 00:00
---> Package libselinux-python.i386 0:1.33.4-4.el5 set to be updated
---> Downloading header for e2fsprogs to pack into transaction set.
e2fsprogs-1.39-10.el5_1.1 100% |=========================| 25 kB 00:00
---> Package e2fsprogs.i386 0:1.39-10.el5_1.1 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
mysql-devel i386 5.0.22-2.2.el5_1.1 updates 2.4 M
Installing for dependencies:
e2fsprogs-devel i386 1.39-10.el5_1.1 updates 563 k
keyutils-libs i386 1.2-1.el5 base 18 k
keyutils-libs-devel i386 1.2-1.el5 base 27 k
krb5-devel i386 1.6.1-17.el5_1.1 updates 1.9 M
libselinux-devel i386 1.33.4-4.el5 base 131 k
libsepol-devel i386 1.15.2-1.el5 base 189 k
openssl-devel i386 0.9.8b-8.3.el5_0.2 base 1.8 M
zlib-devel i386 1.2.3-3 base 101 k
Updating for dependencies:
e2fsprogs i386 1.39-10.el5_1.1 updates 960 k
e2fsprogs-libs i386 1.39-10.el5_1.1 updates 114 k
krb5-libs i386 1.6.1-17.el5_1.1 updates 652 k
libselinux i386 1.33.4-4.el5 base 94 k
libselinux-python i386 1.33.4-4.el5 base 55 k
openssl i686 0.9.8b-8.3.el5_0.2 base 1.4 M

Transaction Summary
=============================================================================
Install 9 Package(s)
Update 6 Package(s)
Remove 0 Package(s)

Total download size: 10 M
Is this ok [y/N]: y
Downloading Packages:
(1/15): openssl-0.9.8b-8. 100% |=========================| 1.4 MB 00:01
(2/15): libselinux-1.33.4 100% |=========================| 94 kB 00:00
(3/15): mysql-devel-5.0.2 100% |=========================| 2.4 MB 00:01
(4/15): keyutils-libs-1.2 100% |=========================| 18 kB 00:00
(5/15): e2fsprogs-libs-1. 100% |=========================| 114 kB 00:00
(6/15): libselinux-devel- 100% |=========================| 131 kB 00:00
(7/15): zlib-devel-1.2.3- 100% |=========================| 101 kB 00:00
(8/15): libselinux-python 100% |=========================| 55 kB 00:00
(9/15): openssl-devel-0.9 100% |=========================| 1.8 MB 00:02
(10/15): e2fsprogs-1.39-1 100% |=========================| 960 kB 00:00
(11/15): krb5-libs-1.6.1- 100% |=========================| 652 kB 00:00
(12/15): e2fsprogs-devel- 100% |=========================| 563 kB 00:00
(13/15): keyutils-libs-de 100% |=========================| 27 kB 00:00
(14/15): libsepol-devel-1 100% |=========================| 189 kB 00:00
(15/15): krb5-devel-1.6.1 100% |=========================| 1.9 MB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : e2fsprogs-libs ####################### [ 1/21]
Updating : libselinux ####################### [ 2/21]
Installing: keyutils-libs ####################### [ 3/21]
Updating : krb5-libs ####################### [ 4/21]
Updating : openssl ####################### [ 5/21]
Installing: keyutils-libs-devel ####################### [ 6/21]
Installing: e2fsprogs-devel ####################### [ 7/21]
Installing: libsepol-devel ####################### [ 8/21]
Installing: libselinux-devel ####################### [ 9/21]
Installing: krb5-devel ####################### [10/21]
Installing: zlib-devel ####################### [11/21]
Installing: openssl-devel ####################### [12/21]
Installing: mysql-devel ####################### [13/21]
Updating : libselinux-python ####################### [14/21]
Updating : e2fsprogs ####################### [15/21]
Cleanup : openssl ####################### [16/21]
Cleanup : libselinux ####################### [17/21]
Cleanup : e2fsprogs-libs ####################### [18/21]
Cleanup : libselinux-python ####################### [19/21]
Cleanup : e2fsprogs ####################### [20/21]
Cleanup : krb5-libs ####################### [21/21]

Installed: mysql-devel.i386 0:5.0.22-2.2.el5_1.1
Dependency Installed: e2fsprogs-devel.i386 0:1.39-10.el5_1.1 keyutils-libs.i386 0:1.2-1.el5 keyutils-libs-devel.i386 0:1.2-1.el5 krb5-devel.i386 0:1.6.1-17.el5_1.1 libselinux-devel.i386 0:1.33.4-4.el5 libsepol-devel.i386 0:1.15.2-1.el5 openssl-devel.i386 0:0.9.8b-8.3.el5_0.2 zlib-devel.i386 0:1.2.3-3
Dependency Updated: e2fsprogs.i386 0:1.39-10.el5_1.1 e2fsprogs-libs.i386 0:1.39-10.el5_1.1 krb5-libs.i386 0:1.6.1-17.el5_1.1 libselinux.i386 0:1.33.4-4.el5 libselinux-python.i386 0:1.33.4-4.el5 openssl.i686 0:0.9.8b-8.3.el5_0.2
Complete!
[root@rubyplus etc]# sudo checkconfig --level 345 mysqld on
sudo: checkconfig: command not found
[root@rubyplus etc]# yum install checkconfig
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Nothing to do
[root@rubyplus etc]# sudo checkconfig --level 345 mysqld on
sudo: checkconfig: command not found
[root@rubyplus etc]# chkconfig --level 345 mysqld on

Could not retrieve mirrorlist on CentOS 5.0

Problem:

# yum install ruby
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=i386&repo=os error was
[Errno 4] IOError:
Error: Cannot find a valid baseurl for repo: base

Resolution:

Add the nameserver entry to your /etc/resolv.conf file.

-----
nameserver 1.2.3.4

Replace 1.2.3.4 with the actual values for your server

Wednesday, April 09, 2008

How to find out the version of CentOS?

[root@rubyplus ~]# uname -a
Linux rubyplus.tempdomain.com 2.6.18-53.1.6.el5.028stab053.6PAE #1 SMP Mon Feb 11 20:53:20 MSK 2008 i686 i686 i386 GNU/Linux

Doesnt tell much

[root@rubyplus ~]# rpm -qa | grep centos
filesystem-2.4.0-1.el5.centos
basesystem-8.0-5.1.1.el5.centos
procmail-3.22-17.1.el5.centos
initscripts-8.45.14.EL-1.el5.centos.1
httpd-2.2.3-6.el5.centos.1
setuptool-1.19.2-1.el5.centos
centos-release-notes-5.0.0-2
gzip-1.3.5-9.el5.centos
centos-release-5-0.0.el5.centos.2
httpd-manual-2.2.3-6.el5.centos.1
yum-3.0.5-1.el5.centos.2

Says what's installed.

[root@rubyplus ~]# cat /etc/issue
CentOS release 5 (Final)
Kernel \r on an \m

This is clear.

Saturday, April 05, 2008

Authorize.net CIM and ARB

CIM cannot be used in combination with the ARB Service. These are two totally separate services.

Customer Information Manager (CIM) is a new paid service that allows merchants to store their
customers’ sensitive payment information on our secure servers for use in future transactions. CIM
helps eliminate steps in the checkout process for a merchant’s repeat customers, potentially
increasing loyalty and revenue. It can also help merchants comply with the Payment Card Industry (PCI)
Data Security Standard, since customer information is no longer stored on their local servers.

Automated Recurring Billing (ARB) is a powerful tool that enables you to provide a scheduled
recurring billing service to your customers. ARB is completely automated—there’s no manual entry of
transactions required at each billing. The process is simple. You will create an ARB
“subscription” (using a subscription form similar to the Virtual Terminal) that includes the customer’s
payment information, billing amount, and a specific billing interval and duration. The payment
gateway does the rest, generating the subsequent recurring transactions based on the set schedule.
Subscriptions may also be created from eligible previous transactions and via batch upload.

For more details refer the development documentation.

Thursday, April 03, 2008

monit install problem

I was getting error message while ./configure of monit:

checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking whether gcc needs -traditional... no
checking for a BSD-compatible install... /usr/bin/install -c
checking whether make sets $(MAKE)... yes
checking for flex... no
checking for lex... no
checking for yywrap in -lfl... no
checking for yywrap in -ll... no
configure: error: monit requires flex, not lex

Flex was not installed. I installed that via:

apt-get install flex

After doing that, ./configure works fine.

Sunday, March 30, 2008

Upgrading gems from 1.0.1 to 1.1.0

I followed Hivelogic tutorial to install the gems 1.0.1 on Leopard. So I had to use the following commands to upgrade:

sudo gem install rubygems-update
sudo update_rubygems

Note: sudo gem update --system did not work. It installed it in some other directory and gem env was showing version 1.0.1

Thursday, March 27, 2008

Error installing MySQL

sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
Password:
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install mysql -- --with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib


Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

Fix: You forgot to run make

no acceptable C compiler found in $PATH

If you get this error:

configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1
checking build system type... i686-apple-darwin9.0.0
checking host system type... i686-apple-darwin9.0.0
checking target system type... i686-apple-darwin9.0.0
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

Install XCode to resolve the above issue.

ls command not found in Leopard

Followed the Hivelogic tutorial to install the Rails stack on Leopard. This message was due to the messed up PATH variable in ./bash_login. I deleted the line that was mentioned in the MySQL installation and there is only one line:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

That fixed the problem. I had to install the Tinkertool to make the invisible files show up in the Finder so that it can be edited.

Monday, March 24, 2008

cvs login: warning: failed to open /User/user_name/.cvspass for reading: No such file or directory

This error message occured when using CVS to checkout lame.
cvs -d:pserver:anonymous@lame.cvs.sourceforge.net:/cvsroot/lame login

Just ignore it. Continue the checkout:

cvs -z3 -d:pserver:anonymous@lame.cvs.sourceforge.net:/cvsroot/lame co -P lame

Voila, it checks out the lame code with no problemo!

Monday, March 10, 2008

Installing Ruby 1.9 on Mac OS X with Ruby 1.8 Intact

Install ReadLine

cd /temp
curl -O http://ftp.gnu.org/gnu/readline/readline-5.2.tar.gz
tar xvzf readline-5.2.tar.gz
cd readline-5.2
./configure --prefix=/Users/balaparanj/
sudo make
sudo make install

Install Ruby 1.9

cd /temp
curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.0-0.tar.gz
tar xzvf ruby-1.9.0-0.tar.gz
cd ruby-1.9.0-0
autoconf
sudo ./configure --prefix=/Users/balaparanj/ruby19 --with-readline-dir=/Users/balaparanj/
sudo make
sudo make install

Monday, March 03, 2008

How to Speak - Lecture Tips from Patrick Winston

http://isites.harvard.edu/fs/html/icb.topic58703/winston1.html

Introduction

Success of your career depends on following factors:

1) Ability to speak
2) Ability to write
3) Quality of your ideas

My objective is to prove to you that with knowledge you can be a better speaker. Second objective ...

When I am thru, what I hope to accomplish is to ...

How to Start

1. Outline on the board (with checkboxes)
2. Start with a promise
Say something to the audience that indicates to them how they will be empowered by the talk, how they will be better people by the time you are finished.

The Big Four

1. Cycle (say the concept 3 times)
Repeating reduces the probability that the audience misses a certain point. It is a fact that people lose their attention and think about something else during the presentation.

2. Verbal Punctuation
Keep track of where you are by checking off the boxes on the outline.

3. Near miss
Two or more. Surround the concept with near misses that help to establish its boundaries and provides an effective way to zero-in on just what the concept is about.

4. Ask questions
Frequent easy questions. Wait for 5 seconds before demanding an answer.

5. Time and Place

10:30 or 11 in the morning. Hall must be well lit (with natural light if possible).
It must be full. There are three types of talk: seminar, lecture, theatre. Avoid theatre like ambiance.

6. Blackboard
Well suited because it matches the pace at which people can absorb material. Drawings, icons and lists can be made. Use it as a target to point your hand.

7. Projectors
Do not read slides
Do not stand far away from transparency
Do not use physical pointers
Do not hide slides, use color instead
Do not use paragraphs use bullet points

8. Props

9. Style
To develop your own style, look at other good speakers with a view towards finding points of style that you can adapt to your own skills and situation.
It's ok to be eccentric. It will be useful as a handle if it is entertaining. Use stories.

10. How to stop
Do not thank the audience. Tell a joke. Deliver on the promise. When you conclude, remind people of your promise and exhibit how the promise is fulfilled. Call for answers to questions. Salute the audience.

Ex: This concludes what I have to say, I wish to add only that being here the past few days has been wonderfully stimulating and provacative experience for me. And I look forward to the same kind of interactions frequently in the future.

You can also say: Your questions have been stimulating and provocative.

11. Questions
Are there any questions. You can ask questions to get started.


Thursday, February 07, 2008

Wednesday, February 06, 2008

Sunday, January 20, 2008

Startup Success 2006

Notes from Google video Startup Success 2006

Distribution, Distribution, Distribution. There is no value in consumer Internet company if there is no distribution model. If you are not embarrassed by first version of your product you are too late to market. Keep iterating. Value speed and intelligent feedback.

Persistence, never take no for an answer. Opportunities - one opportunity leads to another. Keep the site very simple. Focus is very important for a startup. One step process, one form. Just do one thing and do it very well. Google - search, Flickr - photo etc.

Two Types of Entrepreneur

Pick an established market and penetrate a niche within it. Ex: Vertical search engine.
Look for patterns in the market and provide a solution. Ex: Wiki product for the non-geeks.

Secrets of a Serial Entrepreneur

Notes from Google video presentation by Mike O'Donnel

Startup Phases & Objectives

Start - Need
Innovate - Product
Sell - Customers
Hire - People
Partner - Channels
Finance - Revenue

Marketing comes after above phases

Six Phases of start-up success:

1. Idea Valuation
2. Product Valuation
3. Market Valuation
4. Channel Valuation
5. People Valuation
6. Revenue Valuation

There is no such thing as serial entrepreneur. There are parallel entrepreneur who run multiple businesses at the same time.

Start: Idea Valuation

All startups are a leap of faith. Founders cannot foresee what will unfold. Based on passion.
The true value of an idea can only be found in its execution
Starting is more important than finishing. Use feedback and learn as you go.
Will is more important than money. Passion, determination and good will of others more important.
It's marathon, not a sprint. Take a long term view.

Innovate: Product Valuation

Key insight, unique and sustainable advantage. How you are going to serve the market.
Nothing succeeds like a working prototype
Rapid development and iteration
Galvanizing event

Sell: Market Valuation

Marquee account, referenceable user
New pain points. Your real business
Cost of customer acquisition and LTV
Does it scale

Hire: People Valuation

1:3 rule. Generalists more valuable than specialists.
Fire yourself. Contract everything and everyone.
Pay for work not for advice.
Leverage "client development" programs.
Advertise for all positions every 6 months.

Partner: Channel Valuation

Leverage the resources of partners. Distribution, customers, people, budget.
Customers make the best salespeople
It's the 'service provider' network, stupid.

Finance: Investor Valuation

The best investors are customers, followed by partners with a strategic stake.
All money has the same value, the costs to acquire it varies greatly.
Investors value the future higher than the present, but base that value on the past.
Tell them whatever they want to hear.
Your chances of being right are better with the money than without it.

Sunday, January 06, 2008

AWDR - Part 2 Screencast Clarifications

In this screencast, admin namespaced products controller is created. This gives products_controller in the admin directory.

The public products_controller has only index and show and the other actions are not needed so we delete them. The admin products controller is capable of all the CRUD operations. So we copy them over to the admin controller. The urls needs to be changed because when we access them as an admin the url on the browser will be:

http://localhost:3000/admin/products

Since we have admin in the url the url helper methods will be different than the public url methods. You can find out the name of the URL methods by doing rake routes in your rails project home directory. Here is the process:

1. Let's say you want to find out the name of the URL helper method to route to update action in admin's products controller.
2. Look at the output of rake routes and find the controller with value admin/products and action with value show. The first column will give you the name of the URL helper you should use in the admin/products_controller and the views under admin/views/ directory.
3. The :id in the /admin/products/:id is a variable that is available in the params hash. You can access it's value in your controller by doing params[:id]. Similarly if you find anything in the second column that is prefixed by : , it means that it is a variable and you can extract it's value in the controller from the params hash.

Sunday, December 30, 2007

Simply Rich Authenticator using Rails 2.0.2

This is a mini Rails App that uses RESTful authentication and Acts as State Machine to implement: 1. Signup 2. Activation 3. Forgot Password 4. Reset Password 5. Change Password Download it here. Code is available under Rails MIT license. You can check out the code from: svn checkout *http*://simply-rich-authenticator.googlecode.com/svn/trunk/simply-rich-authenticator-read-only Happy New Year! P.S: I have fixed the file size problem. So enjoy the screencast.

Saturday, December 29, 2007

Pimp My AWDwR Depot App - Revised Rails 2.0

Download the screencast on how to get the depot app in Agile Web Development with Rails to work with Rails 2.0

Friday, December 28, 2007

How to develop plugins in Rails - Part 4

In this episode we will revisit the include and extend and learn how it is used when
developing Rails plugins. Download it now : How to develop plugins in Rails - Part 4

Sunday, December 23, 2007

Alias in Ruby

Learn about alias method in Ruby

Upgrading RubyGems to 1.0.1

If the sudo gem update --system hangs then try:

sudo gem install rubygems-update
sudo update_rubygems

This successfully installed Rubygems 1.0.1 on my Powerbook G4. Old version was 0.9.1

Tuesday, December 18, 2007

Time Management for Software Engineers

Today I read the book 4 hour workweek by Timothy Ferriss. While I am not totally convinced by his business ideas, I definitely learned a lot about time management. Check it out in your local library or book store.

Monday, December 17, 2007

Upgrading to Rails 2.0.2

If you are getting the following error during upgrade of Rails:

ERROR: While executing gem ...(OpenURI::HTTPError)
404 Not Found

1. sudo gem update --system.
This will upgrade the Ruby gems to 0.9.5

2. sudo gem install rails --source http://gems.rubyonrails.org
Note that gem install -y is the default, so you don't have to provide it.

Class_Eval in Ruby

Here is the screencast download link for learning about class_eval in Ruby.

Sunday, December 16, 2007

How to install Rails 2.0.1 in Cent OS

gem install rails -y --source http://gems.rubyonrails.org --no-rdoc --no-ri

No documentation will be installed on the production, saves disk space. source option is used if you have difficulties installing.

Friday, December 14, 2007

Thursday, December 13, 2007

Data Migration using ActiveRecord

If you are using ActiveRecord to create new records while you are migrating from a old database, use new instead of create when you want to use the same primary key. Because create does not allow you change the primary key.

Friday, December 07, 2007

Migrations chapter in AWD


The book shows an example of how to use data only migrations. The problem with this approach is that you have to write code for every table you want to populate. A better way to do it is to use the Rick Olsen's rake task found in the Beast source code.

This allows you to add data to any number of tables using just one task. It basically loads the data using fixtures. The fixture files are created under bootstrap folder in fixtures directory.

I still don't get it when the book has an example of irreversible migration and just raises the exception. What if I just want to continue migrating downwards without stopping at the irreversible migration?

Sunday, November 11, 2007

Restful Rails Development Book

Excellent book on RESTful Rails Development.
It has very good explanation of the RESTful Rails concepts. It's free. Check it out.

Saturday, November 10, 2007

Ruby Blocks Screencast Part 1

This screencast covers the basics of blocks in Ruby. It gradually builds on simple example and introduces the complicated concepts in a simple way. Duration : 17 mins. Dowload it here .

Domain Driven Design Quickly - Book Review

"According to Eric Evans, a domain model is not a particular diagram; it is the idea that the diagram is intended to convey. It is not just the knowledge in a domain expert's head; it is a rigorously organized  and selective abstraction of that knowledge. A diagram can represent and communicate a model, as can carefully written code, as can an English sentence."

A good domain model focuses only on the relevant details and ignores  the rest. There are several ways to communicate the model. The book explains some of the techniques covered by the book Domain Driven Design by Eric Evans.

They are :
  1.  Ubiquitous Language

  2.  Layered Architecture

  3.  Value Objects

  4.  Entity Objects

  5.  Aggregates

  6.  Services

  7.  Factories

  8.  Repositories
I am not going to explain them all here. You can download a
free copy of the book from info site. I will briefly go over some of them in the context of Rails
projects.

Ubiquitous Language


 We need to find those key concepts which define the domain and the design, and find corresponding words for them, and start using them. Some of them are easily spotted, but some are harder.

Aggregates


In the Code Review session by Marcel Molina and Jamis Buck Aggregates, they show an example where Aggregates is put into practice. They call the Aggregate as the Super Model.

I worked on a Rails project where the User model become bloated with attributes that could be extracted into its own model. For instance, address, contact info, billing info etc. So the User model is
an Aggregate.

Repositories


A good example would be ActiveRecord's find method, given an id it finds the record and returns an object that represents a row in the database.


Development Process and Domain Driven Design


"The Agile methods have their own problems and limitations; they advocate simplicity, but everybody has their own view of what that means. Also, continuous refactoring done by developers without solid design principles will produce code that is hard to understand or change."

I have experienced this on a project where the team was doing TDD and due to simplistic design the code was brittle. The team did not spend much time on design. It seemed like we were going back to
square one once every couple of weeks. The overall productivity of the team went down.

It talks about implicit concept, constraint, process and specification. It provides practical tips on how to refine and improve the initial domain model. I really liked this section of the
book.

Creating the Model


UML can lead to diagrams that are cluttered and hard to maintain. Creating a UML diagram to represent the whole system can result in a huge domain model.

The alternatives are :

1. Create a set of small diagrams with text that explains some aspect of the system which cannot be represented by the diagram. The diagrams can be hand drawn. In the initial stages the domain model
changes a lot, so this is a practical approach.

2. Communicate using code. This is the XP approach. Use well written code as the communication tool. In this case you don't have the problem of documents getting out of sync with the requirement
changes.

The book talks about the Analysis Model and the Design Model and how there is gap between these two models. The developers have to deal with the implementation issues that cannot be foreseen by the analysts.

Bounded Context


I learned this from Rails core team member Marcel Molina during the Advanced Rails studio. At that time I did not know it was explained in the Domain Driven Design book. The idea here is to create a
very cohesive model that is as small as possible.

If required, you can split your application into several applications that have its own domain model. For instance if you have a web application that is about outdoor adventure club management, you can split the billing system into a separate application. This allows the billing system to be used with any system.

I agree with other bloggers regarding the way the Rails team integrates those apps using ActiveResource. It is not a good solution. The ideal way to integrate them would be to use some kind of asynchronous messaging system. This could be as simple as a cron job.

Preserving Model Integrity


This chapter talks about large projects that consist of multiple teams. It describes how to go about applying domain driven design practices.

Conclusion


Domain driven design is not something new, it has been around for couple of decades or so. Eric Evans has documented them very well in his book. It is a must read for any developer regardless of whether you are part of a small or a big team.

In the last chapter where Eric Evans is interviewed he mentions the pitfalls of domain modeling:
  1.  Stay hands-on. Modelers need to code.

  2.  Focus on concrete scenarios. Abstract thinking has to be anchored in concrete cases.

  3.  Don't try to apply DDD to everything.
I remember an interview couple of years ago where the company that interviewed me was very interested in hiring me as a modeler. I never felt comfortable in just being a modeler without getting my hands dirty by writing some code. I am glad that I did not accept the offer, since they never allow a modeler to code.

Wednesday, November 07, 2007

Living on the Edge

1. rake rails:freeze:edge
2. rake rails:update

script/about output should show value for Edge Rails Version.

xml-simple gem was giving errors when script/about was run. It is used by aws-s3 gem. Uninstalled it for now.

Tuesday, November 06, 2007

Domain Driven Design

I attended the one day QCon Tutorial on Domain Driven Design by Eric
Evans. It was jam packed with real-world tips on dealing with software
complexity.

Introduction



In 1990's we were aiming for reuse, productivity and flexibility by
using object oriented systems. Here we are in 2007 and we still find
it elusive to achieve these in projects.

Eric said that his book was the result of analyzing several successful
projects and identifying the common elements in them. Those elements
do not guarantee success. There will be failures. The critical
complexity of most software projects is in understanding the domain
itself.

Experimentation - Fail Cheaply



Learn to brainstorm. It is cheap to fail at this stage. Go beyond the
first idea. Suggest two mutually exclusive ideas. This is a technique
to break out of the box. It allows us to explore the system beyond its
boundary.

So, look broader. Once we get a big picture we can zoom into the
smaller system that we are considering and come up with a better
solutions. The first idea can be a simple one.

Another way to fail cheaply is to prototype. Remember that is a throw
away so that the developer is free to make mistakes and does not have
to worry about doing it "The Right Way".

Terminology



Domain



The subject area to which the user applies a program is the "domain"
of the software.

Model



A model is a system of abstractions that describes selected aspects of
a domain and can be used to solve problems related to that domain. It
serves a particular use. It is NOT as realistic as possible. He gave
an interesting example of this: NASA uses Newton's principles, not
Einstein's even though it is a known fact that Einstein model is more
accurate. So it is useful relative to specific domain scenarios.

Ubiquitous Language



A language structured around the domain model and used by all team
members to connect all the activities of the team with the software.

Context



The setting in which a word or statement appears that determines its
meaning.,

Dealing with Clients and Resolving Impediments to Software Delivery


Core Vs Generic



Have you ever had the experience where you sit with a client and you
come up with a huge list of features for the software you are going to
develop? The client knows how to prioritize but do they know what is
essential in the domain that will satisfy their mission statement or
unique selling proposition?

Ask them:

1. What distinguishes your business from others?
2. What is your mission statement?

Use the answer as the criteria to find the core domain of the system
from the laundry list of features.

Generic things would be something that we could re-use and purchase
from a third-party. It could be used by your competition too, but the
core domain separates you from the rest. It gives you some kind of
competitive edge over your competitors.

Conclusion:



This is a must attend tutorial. I felt 3 days would have been ideal.
There is still lot to learn about domain driven design from the book.

Using RJS with Rails 2.0 Preview Release

1. Change the extension from rjs to .js.rjs
2. You must use the respond_to block (format.js will call the corresponding .js.rjs file)
3. Use link_to_remote or other remote calls to make the AJAX call.