Tuesday, August 31, 2010

Easy access to documentation of all gems installed

I had a difficulty finding a documentation for pg (ruby gem to access PostgreSQL).
Then I fond an easy way to access a documentation of any gem that I installed.

1. Just launch a web server:
gem server
And go to http://localhost:8808.
You have it all there.

More info here: http://docs.rubygems.org/read/chapter/18


2. Run it at startup.

a. Goto Preferences > Startup Applications.
b. Add new application:
- Name: gem server
- Command: gem server
c. Restart Ubuntu.

For other way of starting it up, see also:
http://lindsaar.net/2008/4/12/tip-2-daemonize-your-gems
http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/

Testing sqlite3-ruby

# sqlite01.rb

require 'rubygems'
require 'sqlite3'

class SQLiteTest

 def initialize
  @db = SQLite3::Database.new("test.db")
  @db.execute("create table test (id INTEGER PRIMARY KEY, title TEXT)")\
    unless(table_exists("test"))
  @db.execute("insert into test (title) values('test1')")\
    unless(record_exists("test", "test1"))
  @db.execute("insert into test (title) values('test2')")\
    unless(record_exists("test", "test2"))
 end
 
 def table_exists(name)
  rows = @db.execute("select name from sqlite_master where name='"+name+"'")
  return (rows.count>0)
 end
 
 def record_exists(table_name, title)
  rows = @db.execute("select id from "+table_name+" where title='"+title+"'")
  return (rows.count>0)
 end
 
 def show_all
  rows = @db.execute('select * from test')
  p rows
 end
 
end

db = SQLiteTest.new
db.show_all

The result:
$ ruby sqlite01.rb 
[["1", "test1"], ["2", "test2"]]

Monday, August 30, 2010

Installed Ruby gems for database

Here are the list of ruby gems for database access installed on my Ubuntu PC.
$ irb 
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'pg'
=> true
irb(main):003:0> require 'sqlite3'
=> true
irb(main):004:0> require 'sequel'
=> true
irb(main):005:0> quit
$ irb1.9.1 
irb(main):001:0> require 'pg'
=> true
irb(main):002:0> require 'sqlite3'
=> true
irb(main):003:0> require 'sequel'
=> true
irb(main):004:0> quit

Sunday, August 29, 2010

Ruby - require 'gtk2' error, fixed

I was getting error on my laptop (not desktop pc):
Gtk-MESSAGE **:Failed to load module "pk-gtk-module": libpk-gtk-module.so
every time when I try to require 'gtk2' in ruby.

I found a workaround suggested by LeeDaugherty at
http://ubuntuforums.org/showthread.php?t=1534719

It works.
1. open gconf-editor.
2. remove check mark from /apps/gnome_settings_daemon/gtk-modules/pk-gtk-module.

Uninstalling Netbeans 9,0beta

I uninstalled Netbeans 9.0beta from my laptop.

~$ cd netbeans-6.9beta/
$ sh uninstall.sh
Configuring the installer...
Searching for JVM on the system...
Extracting installation data...
Running the installer wizard...

Saturday, August 28, 2010

Installing sqlite3-ruby

[2011-08-21 OBSOLETE]

The ruby gem sqlite3-ruby has been renamed sqlite3.
The sqlite3-ruby is now just a dummy gem that depends on sqlite3.
(See here.)

See also my latest installation: "Installing SQLie3 for Ruby on Unbuntu 11.04"


1 Install libsqlite3 libraries.

a. Synaptic
b. Search and install
- libsqlite3-dev
- libsqllite3-ruby # ruby1.8
- libsqlite3-ruby1.9.1

2. Install ruby gem.
$ sudo gem install sqlite3-ruby
Building native extensions.  This could take a while...
Successfully installed sqlite3-ruby-1.3.1
1 gem installed
Installing ri documentation for sqlite3-ruby-1.3.1...
Enclosing class/module 'mSqlite3' for class Statement not known
No definition for libversion
Installing RDoc documentation for sqlite3-ruby-1.3.1...
Enclosing class/module 'mSqlite3' for class Statement not known
No definition for libversion
$ sudo gem1.9.1 install sqlite3-ruby
Building native extensions.  This could take a while...
Successfully installed sqlite3-ruby-1.3.1
1 gem installed
Installing ri documentation for sqlite3-ruby-1.3.1...
Updating class cache with 1723 classes...
Installing RDoc documentation for sqlite3-ruby-1.3.1...

3. Check the installation.
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):003:0> require 'sqlite3'
=> true
irb(main):004:0> quit
$ irb1.9.1 
irb(main):001:0> require 'sqlite3'
=> true
irb(main):002:0> quit

Installing sequel - a Ruby gem for database access

1. Install sequel
$ sudo gem1.9.1 install sequel 
Successfully installed sequel-3.14.0
1 gem installed
Installing ri documentation for sequel-3.14.0...
Updating class cache with 1382 classes...
Installing RDoc documentation for sequel-3.14.0...
$ sudo gem install sequel  # gem1.8
Successfully installed sequel-3.14.0
1 gem installed
Installing ri documentation for sequel-3.14.0...
Installing RDoc documentation for sequel-3.14.0...

2. Install PostgreSQL lib for Ruby
a. Synaptic
b. Search and install
- libpg-ruby
- libpg-ruby1.8
- libpg-ruby1.9.1
- libpg-ruby-doc

3. Install PostgreSQL dev version.
I am failing to install postgres/pg gem.
$ sudo gem install postgres
Building native extensions.  This could take a while...
ERROR:  Error installing postgres:
 ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
extconf.rb:46: command not found: pg_config --includedir
extconf.rb:53: command not found: pg_config --libdir
checking for main() in -lpq... 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.
...
$ sudo gem install pg
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
 ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
checking for pg_config... no
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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.
...

But I do not want to build PG from sources. So I install a dev version.
a. Synapitic
b. Find and Install postgresql-server-dev-8.4.

4. Now ready to install posgres/pg gem.
Actually I am confused of these two gems: postgres and pg.
I found posrgres gem fails to install for gem1.9.1, but pg installs on both versions, 1.8 and 1.9.1.

$ sudo gem install postgres
Building native extensions.  This could take a while...
Successfully installed postgres-0.7.9.2008.01.28
1 gem installed
Installing ri documentation for postgres-0.7.9.2008.01.28...
Installing RDoc documentation for postgres-0.7.9.2008.01.28...
$ sudo gem1.9.1 install postgres
Building native extensions.  This could take a while...
 ERROR:  Error installing postgres:
 ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
extconf.rb:4:in : uninitialized constant PLATFORM (NameError)
$ sudo gem1.9.1 install pg
Building native extensions.  This could take a while...
Successfully installed pg-0.9.0
1 gem installed
Installing ri documentation for pg-0.9.0...
Updating class cache with 1720 classes...
Installing RDoc documentation for pg-0.9.0...
$ sudo gem install pg
Building native extensions.  This could take a while...
Successfully installed pg-0.9.0
1 gem installed
Installing ri documentation for pg-0.9.0...
Installing RDoc documentation for pg-0.9.0...

Friday, August 27, 2010

PostgreSQL Server Configuration

PostgreSQL Server configuration files are in /etc/postgresql/8.4/main/ directory.

$ locate postgresql
...
/etc/postgresql/8.4/main
/etc/postgresql/8.4/main/environment
/etc/postgresql/8.4/main/pg_ctl.conf
/etc/postgresql/8.4/main/pg_hba.conf
/etc/postgresql/8.4/main/pg_ident.conf
/etc/postgresql/8.4/main/postgresql.conf
/etc/postgresql/8.4/main/start.conf
...

The log file is at:
...
/var/log/postgresql
/var/log/postgresql/postgresql-8.4-main.log
...

I will make a change in conf file for log output.

1. Change to the configuration file directory:
$ cd /etc/postgresql/8.4/main/
$ ls -la
drwxr-xr-x 2 postgres postgres  4096 2010-08-24 07:59 .
drwxr-xr-x 3 postgres postgres  4096 2010-08-24 07:59 ..
-rw-r--r-- 1 postgres postgres   316 2010-08-24 07:59 environment
-rw-r--r-- 1 postgres postgres   143 2010-08-24 07:59 pg_ctl.conf
-rw-r----- 1 postgres postgres  3822 2010-08-24 07:59 pg_hba.conf
-rw-r----- 1 postgres postgres  1631 2010-08-24 07:59 pg_ident.conf
-rw-r--r-- 1 postgres postgres 16974 2010-08-24 07:59 postgresql.conf
-rw-r--r-- 1 postgres postgres   378 2010-08-24 07:59 start.conf

2. Make a backup copy of the original conf file.
Since postgresql.conf file is owned by postgres, I will make a copy with the same owner.
$ sudo -u postgres cp postgresql.conf postgresql.conf.bak.original
$ ls -la
drwxr-xr-x 2 postgres postgres  4096 2010-08-27 22:24 .
drwxr-xr-x 3 postgres postgres  4096 2010-08-24 07:59 ..
-rw-r--r-- 1 postgres postgres   316 2010-08-24 07:59 environment
-rw-r--r-- 1 postgres postgres   143 2010-08-24 07:59 pg_ctl.conf
-rw-r----- 1 postgres postgres  3822 2010-08-24 07:59 pg_hba.conf
-rw-r----- 1 postgres postgres  1631 2010-08-24 07:59 pg_ident.conf
-rw-r--r-- 1 postgres postgres 16974 2010-08-24 07:59 postgresql.conf
-rw-r--r-- 1 postgres postgres 16974 2010-08-27 22:24 postgresql.conf.bak.original
-rw-r--r-- 1 postgres postgres   378 2010-08-24 07:59 start.conf

3. Make a change.
The following changes are made base on suggestion by Suzuki Koichi at
http://lets.postgresql.jp/documents/tutorial/ubuntu/3

#-------------------------------------------------
# ERROR REPORTING AND LOGGING
#-------------------------------------------------
log_destination = 'stderr'       # 2010.08.27 - enabled
logging_collector = on           # 2010.08.27 - enabled and turned on
log_directory = 'pg_log'         # 2010.08.27 - enabled (I will create)
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # 2010.08.27 - enabled
log_truncate_on_rotation = off   # 2010.08.27 - enabled, keep it off
log_rotation_age = 1d            # 2010.08.27 - enabled
log_rotation_size = 10MB         # 2010.08.27 - enabled

4. Now create a new directory (pg_log) for log outputs.
$ su postgres 
$ cd ~/8.4/main/
$ mkdir pg_log
$ ls -F
PG_VERSION  global/  pg_log/  ....

5. Finally, restart the server.
$ sudo /etc/init.d/postgresql-8.4 restart
 * Restarting PostgreSQL 8.4 database server  

6. Confrim the log output.
$ sudo ls /var/lib/postgresql/8.4/main/pg_log
postgresql-2010-08-27_230554.log

Installing Shutter, a screenshot program

I have installed Shutter, a screenshot program.
The one installed by default in Ubuntu does not always work. It fails to capture certain windows (such as one displayed by a program from Geany.)

1. Software Center
2. Search and Install Shutter.

GTK Programming in Ruby (1) - Simple Window

Here is my first GTK program with Ruby.

# window01.rb

require 'gtk2'

class AppWindow < Gtk::Window

  def initialize
    super
    window_settings('Simple Window', 400, 300)
    event_settings
    show
  end
    
  def window_settings(title, width, height)
    set_title title
    set_default_size width, height
    set_window_position Gtk::Window::POS_CENTER
  end

  def event_settings
    signal_connect "destroy" do 
      Gtk.main_quit 
    end    
  end
  
end

Gtk.init
AppWindow.new
Gtk.main

This is how it looks.

Installing Ruby GTK Lib

I installed Ruby Gtk2 lib.

1. Synaptic
2. Search and install libgtk2-ruby
3. Test with irb.

Note: this library is only for Ruby 1.8.

irb(main):002:0> require 'gtk2'
=> true

Thursday, August 26, 2010

PostgreSQL Server Information

1. Check Server Status
a. Where is the Server?
$ locate postgresql-8.4 
/etc/init.d/postgresql-8.4
/etc/rc0.d/K21postgresql-8.4
/etc/rc1.d/K21postgresql-8.4
/etc/rc2.d/S19postgresql-8.4
/etc/rc3.d/S19postgresql-8.4
/etc/rc4.d/S19postgresql-8.4
/etc/rc5.d/S19postgresql-8.4
/etc/rc6.d/K21postgresql-8.4
/usr/share/doc/postgresql-8.4
/usr/share/doc/postgresql-8.4/README
/usr/share/doc/postgresql-8.4/README.Debian.gz
/usr/share/doc/postgresql-8.4/changelog.Debian.gz
/usr/share/doc/postgresql-8.4/copyright
/var/cache/apt/archives/postgresql-8.4_8.4.4-0ubuntu10.04_i386.deb
/var/lib/dpkg/info/postgresql-8.4.conffiles
/var/lib/dpkg/info/postgresql-8.4.list
/var/lib/dpkg/info/postgresql-8.4.md5sums
/var/lib/dpkg/info/postgresql-8.4.postinst
/var/lib/dpkg/info/postgresql-8.4.postrm
/var/lib/dpkg/info/postgresql-8.4.prerm
/var/lib/update-rc.d/postgresql-8.4
/var/log/postgresql/postgresql-8.4-main.log
b. Check its status
$ /etc/init.d/postgresql-8.4 --help
Usage: /etc/init.d/postgresql-8.4 {start|stop|restart|reload|force-reload
|status|autovac-start|autovac-stop|autovac-restart}
$ /etc/init.d/postgresql-8.4 status
Running clusters: 8.4/main 
OK, so we have our database cluster at: "8.4/main".
Since postgres home directory is "/var/lib/postgresql", our database cluster resides in
/var/lib/postgresql/8.4/main
2. Stop, Start, Restart Server
$ /etc/init.d/postgresql-8.4 stop
 * Stopping PostgreSQL 8.4 database server
 * Error: You must run this program as 
the cluster owner (postgres)                  [fail]
$ su postgres
$ /etc/init.d/postgresql-8.4 stop
 * Stopping PostgreSQL 8.4 database server    [ OK ] 
$ /etc/init.d/postgresql-8.4 status
Running clusters: 
$ /etc/init.d/postgresql-8.4 start
 * Starting PostgreSQL 8.4 database server    [ OK ] 
$ /etc/init.d/postgresql-8.4 status
Running clusters: 8.4/main 
$ /etc/init.d/postgresql-8.4 restart
 * Restarting PostgreSQL 8.4 database server  [ OK ] 
$ /etc/init.d/postgresql-8.4 status
Running clusters: 8.4/main 
$ exit
exit

Tuesday, August 24, 2010

Setting up PostgreSQL (again)

I am setting up a working environment for PostgreSQL again, and this time I expect it to be easier since the version of PostgreSQL is installed with Ubuntu package, instead of a third party installer (EnterpriseDB).

1. Give a password to the user postgres (the only user at first) so that we can access the database.
$ finger postgres  # check if user postgres is created
Login: postgres          Name: PostgreSQL administrator
Directory: /var/lib/postgresql       Shell: /bin/bash
Never logged in.
No mail.
No Plan.
$ sudo passwd postgres # set a password for user postgres
[sudo] password for socrateos: 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

2. Add myself as a database user who can create new databases.

$ su postgres  # switch to postgres user
$ createdb testdb  # create a new database
$ psql testdb # login to the database
psql (8.4.4)
testdb=# create role socrateos with login createdb;  # add a new user
CREATE ROLE
testdb=# \q
$ exit # exit from user postgres and back to myself (socrateos)
exit
$ psql testdb # test if I (socrateos) can access the database
psql (8.4.4)
testdb=> \q  # it works!
$ createdb mydb # and I can create a database
$ psql mydb
psql (8.4.4)
mydb=> \q
$ psql -l   # display database list
          Database List
   Name    |  Owner    | Encoding       
-----------+-----------+-----------------
 mydb      | socrateos | UTF8            
 postgres  | postgres  | UTF8           
 template0 | postgres  | UTF8        
 template1 | postgres  | UTF8         
 testdb    | postgres  | UTF8 
(5 Lines)
$ 
The blue part was done as user postgres.

Now, PostgreSQL is ready to be used, both by
(1) Database Administrator (postgres)
(2) Myself (socrateos)


3. Install pgAdmin|||, a GUI administration tool.
Finally, I install a popular and easy to use database administration tool.

a. Open Software Center
b. Search and Install pgAdmin |||
c. Launch pgAdmin ||| (Application menu > Programming)
d. Register a new server. (failed!)

I could not login to the server with account postgres.


I forgot to set a (OS) password for account
postgres
(as PostgreSQL user).
$ su postgres
$ psql
psql (8.4.4)
postgres=# alter user postgres with password 'secret';
ALTER ROLE
postgres=# \q
$ exit
exit
$

I had also problem accessing with my own account (socrateos) for the same reason.
So I set a (PostgreSQL) password for myself and the problem solved.
$ su postgres
$ psql
postgres=# alter user socrateos with password 'secret';
ALTER ROLE
postgres=# \q
$ exit
exit
$ psql -U socrateos -d mydb -h localhost -p 5432
mydb=> \q
$ 


Finally I can access the server with pgAdmin |||.

Reinstalling PostgreSQL (all over again) now using Ubuntu package

Since I did not like what I saw in EnterpreseDB version of PostgreSQL, I decided to reinstall PostgreSQL using Ubuntu package this time. It is an older version, but I will live with it.

Note that Software Center is confusing when you want to install PostgreSQL; it is hard to tell which one to select. So use Synaptic.

1. Open Synaptic.
2. Search and Install postgresql.

And that's it.

$ finger postgres
Login: postgres          Name: PostgreSQL administrator
Directory: /var/lib/postgresql       Shell: /bin/bash
Never logged in.
No mail.
No Plan.
I've just noticed that this one uses bash as its shell; the EnterpriseDB used sh.
That might have been a problem not not being able to use psql from bash terminal when switched user to postgres.

And I can access psql immediately, without changing the path environmental variable.
$ psql -V
psql (PostgreSQL) 8.4.4 

Uninstall EnterpriseDB version of PostgreSQL 9.0 beta

Having problems with EnterpriseDB version of PostgreSQL, I decided to uninstall it.

I could not find a documentation about uninstalling the software.
But I did find an executable file "uninstall-postgresql" in the following directory.
So I ran it.

$ ls /opt/PostgreSQL/9.0/
bin   doc      installer  pgAdmin3   scripts  stackbuilder
data  include  lib        pg_env.sh  share    uninstall-postgresql
$ sudo /opt/PostgreSQL/9.0/uninstall-postgresql

That started a GUI uninstaller. It gave me an warning at the end of the process, saying that /data directory and user postgres are not removed. That's fine. I will remove them manually.

$ ls /opt/PostgreSQL/9.0/
data
$ ls /opt/PostgreSQL/9.0/data
ls: Permission denied
$ sudo ls /opt/PostgreSQL/9.0/data
PG_VERSION  pg_hba.conf    pg_notify pg_twophase
base     pg_ident.conf  pg_stat_tmp pg_xlog
global     pg_log    pg_subtrans postgresql.conf
pg_clog     pg_multixact   pg_tblspc postmaster.opts
$ sudo rm -rf /opt/PostgreSQL/9.0/data
$ sudo ls /opt/PostgreSQL/9.0/data
ls: /opt/PostgreSQL/9.0/data: No such file or directory
$ sudo rm -rf /opt/PostgreSQL/
$ ls /opt/
$ 

Now remove the user:
$ finger postgres
Login: postgres          Name: PostgreSQL
Directory: /opt/PostgreSQL/9.0       Shell: /bin/sh
Never logged in.
No mail.
No Plan.
$ sudo userdel -r postgres
userdel: postgres home directory (/opt/PostgreSQL/9.0) not found
$ finger postgres
finger: postgres: no such user.

Done.

Monday, August 23, 2010

Setting up PostgreSQL - failed

I am now setting up PostgreSQL just installed.

1. Give a password for the (Ubuntu)user "postgres" (created by PostgreSQL).
$ sudo passwd postgres
[sudo] password for socrateos: 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

2. Create a new database and add myself as a new database user.
$ su postgres 
$ psql createdb testdb
sh: psql: not found
Oops! Changing of ~/.profile did not work.
So I modified /etc/environment to make a system-wide change.
PATH="/opt/PostgreSQL/9.0/bin;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
Well, I am still having a problem accessing psql as user postgres.
$ psql -V
psql (PostgreSQL) 9.0beta4
contains support for command-line editing
$ su postgres
passwd:
$ psql -V
sh: psql: not found
$ echo $PATH
/opt/PostgreSQL/9.0/bin;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
$ /opt/PostgreSQL/9.0/bin/psql -V
psql (PostgreSQL) 9.0beta4
contains support for command-line editing
I am too newbie to know what's going on here. Perhaps something to do with rights.
I am giving up EnterpriseDB version of PostgreSQL.

Reinstalling PostgreSQL 9.0 beta

I am reinstalling PostgreSQL 9.0, using EnterpriseDB installer.

1. Download the installer
http://www.enterprisedb.com/
2. Launch installer:
$ cd download/
$ chmod +x postgresql-9.0.0-beta4-linux.bin 
$ sudo ./postgresql-9.0.0-beta4-linux.bin
This opens a GUI installer. Just follow the instruction.

3. Do not install Stack Builder.
Unlike, earlier version of installer, Apache and PHP are optional.
Thank you! I really do not want PHP and have already apache running.

4. Check the installation.
$ finger postgresql
Login: postgres          Name: PostgreSQL
Directory: /opt/PostgreSQL/9.0       Shell: /bin/sh
Never logged in.
No mail.
No Plan.

There it is!

5. Make psql available from the Ubuntu terminal.
EnterprieseDB installer of PostgreSQL 9.0 beta installs a script that launches a psql shell of its own.
But I'd rather be able to launch it from the Ubuntu main terminal.
So I added a directory to the path.

a. open (or create) ~/.profile
b. add the following:
if [ -d "/opt/PostgreSQL/9.0/bin" ] ; then
  PATH="/opt/PostgreSQL/9.0/bin:$PATH"
fi
c. restart.

After restart, check it.
$ psql --version
psql (PostgreSQL) 9.0beta4
contains support for command-line editing

Reinstalling Apache

I am reinstalling apache as my Ubuntu crashed last week.
I added passenger (mod-rails, mod-rack) as well.

1. Synaptic
2. Search and install apache2.
3. Added mod-passenger, ruby interface.

Check the installation.
$ locate passenger
/etc/apache2/mods-available/passenger.conf
/etc/apache2/mods-available/passenger.load
/etc/apache2/mods-enabled/passenger.conf
/etc/apache2/mods-enabled/passenger.load
/usr/lib/phusion_passenger
/usr/lib/apache2/modules/mod_passenger.so
...
$ cd /etc/apache2/mods-enabled
$ cat passenger.conf
<ifmodule mod_passenger.c="">
  PassengerRoot /usr
  PassengerRuby /usr/bin/ruby
</ifmodule>
$ cat passenger.load
LoadModule passenger_module /usr/lib/apache2/modules/mod_passenger.so

Setting up Geany for GTK

To setup Geany for GTK, you have to change Build settings.

1. Go to Build menu and select "Set Include and Arguments" option.
2. Append `pkg-config --cflags gtk+-2.0` to Compile box. (Be sure to use back quote ` not single quote `)
gcc -Wall -c "%f" `pkg-config --cflags gtk+-2.0`
3. Append `pkg-config --libs gtk+-2.0` to Build box. (Be sure to use back quote ` not single quote `)
gcc -Wall -o "%e" "%f" `pkg-config --libs gtk+-2.0`


Reference: "Geany GTK2 setup Ubuntu 10.04"

Installing GTK+ Lib

Installed libgtk2.0.

1. Open Synaptic
2. Search and Insall libgtk2.0-dev.

Check the installation.

$ pkg-config --cflags gtk+-2.0
-pthread -D_REENTRANT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 

Sunday, August 22, 2010

Another simple Shoes app

Here is yet another simple Shoes app.
# now.rb
#
Shoes.app :width=>160, :height=>24 do
  para "Today is #{Time.now.strftime("%m/%d/%Y")}"
end

Run it:
$shoes now.rb

Saturday, August 21, 2010

Another Shoes app - Exit

Here is another simple Shoes app.

It opens a window with a single button "Exit".
When it is clicked, application quits.

# exit.rb
#
Shoes.app do 
  button 'Exit' do
    exit
  end
end

Now run it.
$ shoes exit.rb

My First Ruby GUI application, using Shoes

Here is my first Ruby GUI app, using Shoes.

# hello.rb
#
Shoes.app do
  para 'Hello World'
end

Execute it (from shell).
$ shoes hello.rb

This opens a window, displaying the text.


Another way to run it is to drag and drop the ruby file over an icon (link) of Shoes on the Ubuntu desktop.

Executing a command line program from within Ruby

This is a ruby program to execute a command-line program.
This is based on suggestion by geraldm in http://ubuntuforums.org/archive/index.php/t-544457.html.

# execprog.rb

class StdClass
  def initialize  
  end 

  def test
    bb = IO.popen("ls -la")
    b = bb.readlines
    puts b.join
    bb.close
  end 
end

x = StdClass.new
x.test

And here is the result:

$ ruby execprog.rb
total 16
drwx------ 2 4096 2010-08-21 13:54 .
drwxr-xr-x 5 4096 2010-08-21 08:55 ..
-rw-r--r-- 1 1034 2010-08-21 13:54 execprog.rb
-rw-r--r-- 1 1010 2010-08-21 08:43 helloworld.rb
$

Installing Transmageddon Video Trnascoder

I installed Transmageddon but may not use it after all.
I was able to use ffmpeg to convert Falsh files to MP3 after installing Ubuntu restriced extras.

Installing Ubuntu Restricted Extras to convert Flash to MP3

I installed Ubuntu Restricted Extras because ffmpeg failed to convert Flash files to MP3 files.

$ ffmpeg -i 'My Youtube File' -ar 44100 -ab 160k -ac 2 'My New File.mp3'
....
Unsupported codec for output stream #0.0

1. Open Software Center.
2. Find and Install "Ubuntu restricted extras"

Now ffmpeg works!

$ ffmpeg -i 'My Youtube File' -ar 44100 -ab 160k -ac 2 'My New File.mp3'
....
size= 6872kB time=351.84 bitrate= 160.0kbits/s
video:0kB audio:6872kB global headers:0kB muxing overhead 0.000455%


Apparently I needed libmp3lame, which was included in the extras.
(See:http://lame.sourceforge.net/)

Installing ffmpeg

I installed ffmpeg to convert media files.

1. Open Synaptic
2. Find and Install ffmpeg.
3. Cofirm:

$ ffmpeg -v
FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1

Friday, August 20, 2010

Using Geany (1) - Project

To create a new project
1. Select New from Project menu.
2. Save a project file with extension ".geany"

Installing Shoes - Simple Gui toolkit for Ruby

I have just installed Shoes.

1. Open Software Ceter.
2. Find and install Shoes.

Thursday, August 19, 2010

How I download YouTube video

This is a way I download (currently viewing) Yutube video.

Just run this command in shell while viewing a favorite video:
mv /tmp/Flash* "/home/user/video/youtube/A New Name of Video File"

The above is possible because:
1. Youtube downloads its file in /tmp folder.
2. Usually there is only one Flash... file (currently viewing video file).
3. You can move this file where you want with a new name, even during downloading.

Wednesday, August 18, 2010

Installing Geany

Geany is a minimalist IDE.

I have just installed it through Software Center.

1. It supports not only C/C++ but also various scripts including Ruby.
2. It can execute ruby script. (Goodbye Netbeans!)
3. It has project management.

This may be the tool I have been looking for.

Installation of Debian failed

I installed Debian, but it failed to recognize/setup monitors.
I went back to Ubuntu, despite the problem of mouse control problem.

Tuesday, August 17, 2010

Creating Ruby Project in Netbeans

I have created a Ruby Project in Netbeans.

1. The way to enable Ruby platform in Netbeans seems just create a new project with Ruby as a plat form. It then automatically enable Ruby environment upon first ruby project creation.

2. It complained when I created my first Ruby project; it said "Rake" gem was not installed.

3. However, when I executed it (Hello world), it just ran without any error.

But I installed Rake anyway.

Accessing Database - websites

GTK:
- GNOME-DB: http://www.gnome-db.org/

wxWidgets
- wxCodes: http://wxcode.sourceforge.net/complist.php?compperpage=1000&viewmode=full&browseby=category§ion=database&page=1
- Database Control Layer: http://www.twinforms.com/products/wxwidgets/dblayercontrols.php

Monday, August 16, 2010

Installing Netbeans 6.9.1

Installed Netbeans 6.9.1 from http://netbeans.org/community/releases/69/install.html

~$ cd download/
~/download$ ls
netbeans-6.9.1-ml-linux.sh
~/download$ chmod +x netbeans-6.9.1-ml-linux.sh 
~/download$ sh netbeans-6.9.1-ml-linux.sh 
Configuring the installer...
Searching for JVM on the system...
Extracting installation data...
Running the installer wizard...
~/download$ 

I had to install missing fonts to fix garbled characters.
This seems to be a java problem.

Installing JRE

I installed JRE, which is required by Netbeans.

1. Open Synaptic
2. Search for "jre"
3. Select:
- sun-java6-jre
- sun-java6-fonts
- sun-java6-jdk
- libpg-java (JDBC for PostgreSQL)
4. Apply.

Mouse Control Problme with Ubuntu

There is one recurring problem with Ubuntu (10.04).
My mouse suddenly stops working; its cursor just disappears from the screen.

It happens sometimes about only a few minutes after the start up, but it happens sometimes after one hour or much later.

It usually happens during keyboard entry, often after hitting a return key such as when doing a search on web, or doing a command line work.

Only way to restore the mouse control is to restart the OS.
Interestingly, if I have two or three mouses attached, only one of them stops at a time. In other words, if one mouse stops working, I can still use second mouse, and when the second mouse stops working, I can use the third one. But all of them stops working soon or later.

All my mouses are USB based, one of which is wireless. Not for sure, but it seems that the wireless one seems to stop sooner.

It cannot be hardware problem since my system is dual boot with Windows Vista and I have never had this kind of problem when running Windows (Vista).

This problem is one of few reasons why Ubuntu cannot completely replace Windows or Mac for me.

Sunday, August 15, 2010

Learning wxWidgets programming (1): String Literal

I've just started to learn wxWidgets programming.

All string literal must be changed to _T(string).
For example, in stead of
wxFrame *frame = new wxFrame((wxFrame *)NULL, -1, "Hello World",
                               wxPoint(50, 50), wxSize(450, 340));
Use:
wxFrame *frame = new wxFrame((wxFrame *)NULL, -1, _T("Hello World"),
                               wxPoint(50, 50), wxSize(450, 340));


(See also: Converting everything to and from wxString.)

Installing Glade

I've installed Glade.

1. Open Synaptic.
2. Select:
- glade
(other glade related libs are already installed)
3. Apply.

Installing wxWidgets

I got errors when I tried to compile wxWidget based project using CodeBlocks and Anjuta.

So I've installed wxWidgets.

1. Open Synaptic.
2. Search for "wx"
3. Select:
- wxFormBuilder
- libwxbase2.8...
- wx2.8...
- libwxgtk2.8...
- libwxsmith...
- codeblock-contrib
- wx-common
4. Apply.

Anjuta vs CodeBlocks

I am learning both Anjuta and Code::Blocks IDE systems.

Here are a few things that I've found so far.

1. Multi-Language Support: Anjujta wins
Since I use more languages than just English, multi-language support is very important aspect of any editor for me. This is one reason why I do not use popular editor TextMate (OSX), which has very poor in multi-language support. Luckily, both Anjuta and CB support multi-language. However, CB's multi-language support is minimum and does not support in-line input capability. Anjuta support of multi-language support is excellent, including in-line input support by default.

2. Multi-Platform Support: CodeBlocks wins
Anjusta supports only Linux platforms while CodeBlocks supports Linux, Windows as well as OSX.

3. GUI Objects: Tie
a. Widget
It requires installation of wxWidget librairies.
(1) Anjuta
The default wxWidget project requires to modify string "Hello World" to _T("Hello World").
(2) CodeBlocks
The default wxWidget project works as is.

3. Project Management: CodeBlocks wins.
Anjuta opens a different main window for every project - not very easy way to manage related multiple projects. CodeBlocks does place multiple project files within one main window as expected. But CodeBlocks also has a concept of "Workspace", which groups related projects. This is very nice in case your system consists of independent but related applications.

Thursday, August 12, 2010

Reinstalling Anjuta

I am having a problem with Anjuta.
It is not displaying terminal panel.

I tried to install a latest version (2.31.1) from the website.
But I was getting errors:

...
configure: error: 
...
No package 'glib-2.0' found
No package 'gobject-2.0' found
No package 'gmodule-2.0' found
No package 'gthread-2.0' found
No package 'gio-2.0' found
No package 'unique-1.0' found
...

OK, so I let Ubuntu do the installation :-).
1. Open Synaptic
2. Search for "anjuta"
3. Select all items shown
4. Apply

And, Anjuta is now happily showing the terminal panel.

Firefox crashes with Flashplayer

Firefox started to crash whenever visited a site that had a flash player movie.
Chrome also had a problem with flash moves but did not crash itself like Firefox.

The problem: I installed flash player plug-in using Ubuntu Synaptic.
The solution: Install the plug-in from Adobe download site:
http://get.adobe.com/flashplayer/?promoid=BUIGP

That fixed the problem, not only for Firefox but also Chrome all at once.

Wednesday, August 11, 2010

Ruby Basic (1) : Hello World with Ruby

Hello World with Ruby, using irb - interactive ruby.

$ irb                                         # startup irb 
irb(main):001:0> print "Hello World\n"        # using double quotes
Hello World                                   # yes
=> nil                                        # print command returns nil
irb(main):002:0> print 'Hello World\n'        # using single quotes
Hello World\n=> nil                           # oh, no!
irb(main):003:0> myvar = "World"              # let's test a varaible
=> "World"
irb(main):004:0> print "Hello #{myvar}\n"     # if you use double quotes
Hello World                                   # you get this
=> nil
irb(main):005:0> print 'Hello #{myvar}\n'     # otherwise
Hello #{myvar}\n=> nil                        # you get this
irb(main):006:0> puts 'Hello World'           # "puts" instead of "print ...\n"
Hello World
=> nil
irb(main):007:0> puts 'こんにちは'            # in another language
こんにちは
=> nil
irb(main):008:0> "Hello World"                # just a string expression without command
=> "Hello World"                              # returns itself
irb(main):009:0> quit                         # exit from irb
$ 


Lessons
1. Ruby interprets single quotes and double quotes differently.
2. Double quoted strings are parsed, and escapes and #{} expressions are replaced.
3. Single quoted strings are not parsed, and escapes and #{} expressions are displayed as they are.
4. puts automatically appends "\n" at the end; print does not.
5. You can "execute" string (or any) expression without command; it returns itself.

Adding Arcadia to Application Menu

I have added Arcadia to the Application Menu.

1. Open Preference.
2. Select Main Menu.
3. Select Programming menu.
4. Click Add New Item button.
5. Enter name: Arcadia.
6. Set path to the file and call ruby to execute it.
ruby /home/.../archadia

Installing PostgreSQL 9.0 using One-click installer from EnterpriseDB

I've just installed PostgreSQL 9.0 Beta4, using one-click installer by EnterpreiseDB.

(1) Downloaded linux (32bit) version of installer from:
http://www.enterprisedb.com/learning/pginst_guide.do
(2) Ran the installer,
$ sudo ./postgresql-9.0.0-beta4-linux.bin

At the end of installation, it prompts for additional installations.I checked:
Drupal and MediaWiki (which required Apache/PHP installations)

I did not know it also installed its own version of Apache (at port 8080).
Not knowing that, I installed Apache in normal way, using Synaptic.
(1) Open Synaptic
(2) Search for "apache2"
(3) Select apache2
(4) Apply

So two apache servers (at 80 and 8080) are running now, which may not be a bad idea. I can use one for Production and the other for Testing.

Tuesday, August 10, 2010

Installing htop - interactive process viewer

I have installed htop.

I was playing with Arcadia and ran a script that launched Webrick.
The problem was: HOW DO YOU STOP THE PROCESS?
You cannot CTL-C to abort the process within Arcadia.

You can use unix command, but this is Ubuntu. I want to do it in more Ubuntu-way.

1. Open Synaptic
2. Search fro "htop"
3. Select htop
4. Apply

Well, htop does not seem to be responding my keyboard.
I had to go back to the old unix trick.

ps aux | grep ruby
kill -INIT 7417
...

Installing Arcadia - Ruby IDE written in Ruby

Finally I was able to launch Arcadia without errors.

Here is the list of items that should have been installed before installing/using Arcadia.

(1) ruby-dev
(2) library: libopenssl-ruby
(3) library: ruby-debug
(4) gem: coderay
(5) gem: os whichr


According to the document, there are two ways to install Arcadia:

1. exec as root on command line "gem install arcadia"
or as user "sudo gem install arcadia"
2. using archive distribution
a. untar (on unix) (tar -xzf) arcadia-.tar.gz
b. unzip (on windows) arcadia-.zip

I used the second option because the first option caused an error about RDoc-data and did not update automatically. I am too newbie to know about effect of manually updating RDoc-data, especially in an environment where I keep two ruby versions separately. So I avoided the first option.

The second option (2.a) was simple:
Download it to local folder and untar the archive.
And placed the resulting folder in my home directory.

The documentation has just one line of instruction on how to run:
exec on command line "ruby arcadia"
I was little perplexed by this because I thought ruby file was supposed to have .rb extension. But it worked.

Installing whichr - what's that?

I am installing gem: whichr because Arcadia (upon launching) is still complaining that this gem is required by ruby-debug.

Note that you have to "gem install os whichr" - don't forget "os".


$ sudo gem1.8 install whichr
[sudo] password for socrateos:
ERROR: Error installing whichr:
sane requires os (>= 0, runtime)

$ sudo gem1.8 install os whichr
Successfully installed os-0.7.2
Successfully installed sane-0.23.1
Successfully installed whichr-0.3.5
3 gems installed
Installing ri documentation for os-0.7.2...
Installing ri documentation for sane-0.23.1...
Installing ri documentation for whichr-0.3.5...
Installing RDoc documentation for os-0.7.2...
Installing RDoc documentation for sane-0.23.1...
Installing RDoc documentation for whichr-0.3.5...


Now for ruby1.9.1.
It failed first time because RDoc-data need to be updated.
Fortunately, it automatically updated.
Gem install worked in the second time around.

$ sudo gem1.9.1 install os whichr
Successfully installed os-0.7.2
RDoc 2.5 did not save method parameters, so you should upgrade your rdoc-data
gem to a version >= 2.5.3.

To have ri data for core and stdlib you'll need to:

gem install rdoc-data

then run:

rdoc-data --install

To have ri data for you gems you'll also need to run:

gem rdoc --all --overwrite

If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc.
Successfully installed rdoc-2.5.9
Successfully installed andand-1.3.1
Successfully installed sane-0.23.1
Successfully installed whichr-0.3.5
5 gems installed
Installing ri documentation for os-0.7.2...
Installing ri documentation for rdoc-2.5.9...
Installing ri documentation for andand-1.3.1...
Installing ri documentation for sane-0.23.1...
Installing ri documentation for whichr-0.3.5...
Installing RDoc documentation for os-0.7.2...
Installing RDoc documentation for rdoc-2.5.9...
Installing RDoc documentation for andand-1.3.1...
Installing RDoc documentation for sane-0.23.1...
Installing RDoc documentation for whichr-0.3.5...

$ sudo gem1.9.1 install os whichr
Successfully installed os-0.7.2
Successfully installed whichr-0.3.5
2 gems installed
Installing ri documentation for os-0.7.2...
Installing ri documentation for whichr-0.3.5...
Installing RDoc documentation for os-0.7.2...
Installing RDoc documentation for whichr-0.3.5...

Installing ruby-debug (3) and success!

After installing libopenssl-ruby1.9.1, I was finally able to install ruby-debug19.
It took long, long, long time to build the extensions; be patient.


$ sudo gem1.9.1 install ruby-debug19
Building native extensions. This could take a while...
Building native extensions. This could take a while...
Successfully installed linecache19-0.5.11
Successfully installed ruby-debug-base19-0.11.23
Successfully installed ruby-debug19-0.11.6
3 gems installed
Installing ri documentation for linecache19-0.5.11...
Installing ri documentation for ruby-debug-base19-0.11.23...
Installing ri documentation for ruby-debug19-0.11.6...
Updating class cache with 516 classes...
Installing RDoc documentation for linecache19-0.5.11...
Installing RDoc documentation for ruby-debug-base19-0.11.23...
Installing RDoc documentation for ruby-debug19-0.11.6...

Installing ruby openssl lib

I am installing openssl lib for ruby1.9.1.
This is because I get error when I try to install ruby-debug1.9.1.
(See "Installing ruby-debug (2) post".)
The error was: no such file to load -- net/https (LoadError).
According to several blogs, it was because openssl lib is missing.

Let's install openssl lib for ruby1.9.1.

1. Open Synaptic.
2. Search for "ruby openssl"
4. Select:
libopenssl-ruby1.8 (not installed?)
libopenssl-ruby1.9.1
5. Apply.

I expected libopenssl-ruby1.8 was already installed but was not.
Though ruby-debu (1.8) was installed successfully, I decided to install it anyway.
I want my installation of ruby1.8 and 1.9.1 to be close as much as possible.

Installing ruby-debug (2) and missing net/https

I am making a second attempt to install ruby-debug, after installing ruby-dev.
Interestingly, it installed successfully for ruby1.8 but failed for ruby1.9.1

This one is a success:

$ sudo gem1.8 install ruby-debug
Building native extensions. This could take a while...
Building native extensions. This could take a while...
Successfully installed linecache-0.43
Successfully installed ruby-debug-base-0.10.3
Successfully installed ruby-debug-0.10.3
3 gems installed
Installing ri documentation for linecache-0.43...
Installing ri documentation for ruby-debug-base-0.10.3...
Installing ri documentation for ruby-debug-0.10.3...
Installing RDoc documentation for linecache-0.43...
Installing RDoc documentation for ruby-debug-base-0.10.3...
Installing RDoc documentation for ruby-debug-0.10.3...


But this one failed.

$ sudo gem1.9.1 install ruby-debug19
Building native extensions. This could take a while...
ERROR: Error installing ruby-debug19:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
*** 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/bin/ruby1.9.1
/var/lib/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:11:in `require': no such file to load -- net/https (LoadError)
from /var/lib/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:11:in `'
from /var/lib/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/ruby_core_source.rb:6:in `require'
from /var/lib/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/ruby_core_source.rb:6:in `'
from extconf.rb:2:in `require'
from extconf.rb:2:in `
'

Installing ruby-dev

I've installed ruby-dev.
I am having a problem installing ruby-debug (see my post "Installing ruby-debug and mkmf").
I read somewhere ruby-dev need to be installed for missing mkmf.

1. Open Synaptic
2. Search for "ruby-dev"
3. Select:
ruby1.8-dev
ruby1.9.1-dev
4. Apply.

Installing ruby-debug and missing mkmf

I am trying to install ruby-debug, required by Arcadia.
But it is failing:


$ sudo gem1.8 install ruby-debug
Building native extensions. This could take a while...
ERROR: Error installing ruby-debug:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1

$ sudo gem1.9.1 install ruby-debug19
Building native extensions. This could take a while...
ERROR: Error installing ruby-debug19:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1:in `
'

Installing Coderay

I've installed Coderay gem, which is required by Arcadia IDE.
(See: http://coderay.rubychan.de/)

$ sudo gem1.8 install coderay
Successfully installed coderay-0.9.3
1 gem installed
Installing ri documentation for coderay-0.9.3...
Installing RDoc documentation for coderay-0.9.3...

$ sudo gem1.9.1 install coderay
Successfully installed coderay-0.9.3
1 gem installed
Installing ri documentation for coderay-0.9.3...
Updating class cache with 443 classes...
Installing RDoc documentation for coderay-0.9.3...

Installing ruby-tk

I've installed ruby-tk;

1. Open Synaptic
2. Search "ruby-tk"
3. Select:
libtcltk-ruby1.8
libtcltk-ruby1.9.1
4. Apply

Installing Anjuta

I have installed Anjuta using Synaptic.
Just select Anjuta and apply.
That's it.

Monday, August 9, 2010

Installing CodeBlocks

Installed CodeBlocks, using Synaptic.

- CodeBlocks
- CodeBlocks-dbg
- CodeBlocks-dev (in case I want to build plugins)

Installing first gem - Sinatra and Sequel

I installed my first gem: Sinatra and Sequel


$ sudo gem install sinatra
Successfully installed rack-1.2.1
Successfully installed sinatra-1.0
2 gems installed
Installing ri documentation for rack-1.2.1...
Installing ri documentation for sinatra-1.0...
Installing RDoc documentation for rack-1.2.1...
Installing RDoc documentation for sinatra-1.0...
$ sudo gem1.9.1 install sinatra
Successfully installed rack-1.2.1
Successfully installed sinatra-1.0
2 gems installed
Installing ri documentation for rack-1.2.1...
Installing ri documentation for sinatra-1.0...
Updating class cache with 0 classes...
Installing RDoc documentation for rack-1.2.1...
Installing RDoc documentation for sinatra-1.0...

$ sudo gem install sequel
Successfully installed sequel-3.14.0
1 gem installed
Installing ri documentation for sequel-3.14.0...
Installing RDoc documentation for sequel-3.14.0...
$ sudo gem1.9.1 install sequel
Successfully installed sequel-3.14.0
1 gem installed
Installing ri documentation for sequel-3.14.0...
Updating class cache with 105 classes...
Installing RDoc documentation for sequel-3.14.0...

Sunday, August 8, 2010

Installing Ruby on Ubuntu 10.04

I installed Ruby (default to 1.8) and Ruby 1.9.1 using Synaptic Package Manager.
I needed just two steps:
(a) Turn on 2 check boxes (Ruby and Ruby1.9.1) and
(b) click the Apply button.
That's all I needed to do to install Ruby with two versions.

And, here is the result:

$ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
$ ruby1.9.1 -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i486-linux]
$ ruby -e 'puts $:'
/usr/local/lib/site_ruby/1.8
/usr/local/lib/site_ruby/1.8/i486-linux
/usr/local/lib/site_ruby/1.8/i386-linux
/usr/local/lib/site_ruby
/usr/lib/ruby/vendor_ruby/1.8
/usr/lib/ruby/vendor_ruby/1.8/i486-linux
/usr/lib/ruby/vendor_ruby
/usr/lib/ruby/1.8
/usr/lib/ruby/1.8/i486-linux
/usr/lib/ruby/1.8/i386-linux



Similarly, I installed rubygems (1.8 and 1.9.1).
Go to the Synaptic Package Manaager and
(a) check mark rubygems1.8 and rubygems1.9.1 and
(b) apply the change.

And here is the result:

$ gem -v
1.3.5
$ gem1.9.1 -v
1.3.5

$ gem list --local

*** LOCAL GEMS ***

$ gem1.9.1 list --local

*** LOCAL GEMS ***

No gems installed at this point.

Interestingly, irb was not installed, but irb1.91. was.
I had to install irb as follows:

$ sudo apt-get install irb

A few Things to Do After Installing Ubuntu

After installing Ubuntu (10.04), there are few things to do.

(1) Sound is initially set to be mute; so go to Preference > Sound and remove check mark from Mute check box.
(2) Firefox is without Adobe Flash; so install it Software Center > and install "Adobe Flash plugin (for Mozilla)"
(3) Extend the buffer size (scroll back size) of the Termail to "unlimited".
(4) Change the monitor settings (Preferences > Monitor) to use dual monitors.
(5) Change the font of gedit to courier10pitch 10pt to display backslash as backslash.

Ubunutu latest updates break my installation

I have recently installed Ubuntu 10.04 on my Vista machine with a dual boot.
My Ubuntu installation resides in the second drive to which I gave its entire space to this new OS.

It worked fine until I decided to install all latest updates, assuming it would work like Windows or OSX. The updater reported all updates were successful. But when I rebooted the machine, Ubuntu could not start up, failing to find hard drives.

Since this was a new install without any user data, I reinstalled the software from a live CD. And it is working again.

I will not be doing update anytime soon.