Monday, March 28, 2011

Installing wxRuby on Windows (wxruby-ruby19)

C:\>pik gem install wxruby-ruby19
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

Successfully installed wxruby-ruby19-2.0.1-x86-mingw32
1 gem installed
Installing ri documentation for wxruby-ruby19-2.0.1-x86-mingw32...
Installing RDoc documentation for wxruby-ruby19-2.0.1-x86-mingw32...

ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

Successfully installed wxruby-ruby19-2.0.1-x86-mingw32
1 gem installed
Installing ri documentation for wxruby-ruby19-2.0.1-x86-mingw32...
Installing RDoc documentation for wxruby-ruby19-2.0.1-x86-mingw32...

ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

Successfully installed wxruby-ruby19-2.0.1-x86-mingw32
1 gem installed
Installing ri documentation for wxruby-ruby19-2.0.1-x86-mingw32...
ERROR: Interrupted
Terminate batch job (Y/N)? n

ruby 1.9.2p136 (2010-12-25) [i386-mingw32]

Successfully installed wxruby-ruby19-2.0.1-x86-mingw32
1 gem installed
Installing ri documentation for wxruby-ruby19-2.0.1-x86-mingw32...
Installing RDoc documentation for wxruby-ruby19-2.0.1-x86-mingw32...

Terminate batch job (Y/N)? n

C:\>

Installing wxRuby on Windows

C:\>pik gem install wxruby
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

Successfully installed wxruby-2.0.1-x86-mingw32
1 gem installed
Installing ri documentation for wxruby-2.0.1-x86-mingw32...
Installing RDoc documentation for wxruby-2.0.1-x86-mingw32...

ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

Successfully installed wxruby-2.0.1-x86-mingw32
1 gem installed
Installing ri documentation for wxruby-2.0.1-x86-mingw32...
Installing RDoc documentation for wxruby-2.0.1-x86-mingw32...

ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

Successfully installed wxruby-2.0.1-x86-mingw32
1 gem installed
Installing ri documentation for wxruby-2.0.1-x86-mingw32...
Updating class cache with 670 classes...
Installing RDoc documentation for wxruby-2.0.1-x86-mingw32...
ERROR: Interrupted
Terminate batch job (Y/N)? n

ruby 1.9.2p136 (2010-12-25) [i386-mingw32]

Successfully installed wxruby-2.0.1-x86-mingw32
1 gem installed
Installing ri documentation for wxruby-2.0.1-x86-mingw32...
Installing RDoc documentation for wxruby-2.0.1-x86-mingw32...

Terminate batch job (Y/N)? n

C:\>

Wednesday, March 23, 2011

Installing rush on Ubuntu

Installed rush, a ruby-based unix shell.

1. Install.
$ sudo gem install rush
[sudo] password for socrateos: 
Successfully installed fattr-2.2.0
Successfully installed session-3.1.0
Successfully installed rush-0.6.7
3 gems installed
Installing ri documentation for fattr-2.2.0...
Installing ri documentation for session-3.1.0...
Installing ri documentation for rush-0.6.7...
Installing RDoc documentation for fattr-2.2.0...
Installing RDoc documentation for session-3.1.0...
Installing RDoc documentation for rush-0.6.7...

$ sudo gem1.9.1 install rush
Successfully installed fattr-2.2.0
Successfully installed session-3.1.0
Successfully installed rush-0.6.7
3 gems installed
Installing ri documentation for fattr-2.2.0...
Installing ri documentation for session-3.1.0...
Installing ri documentation for rush-0.6.7...
Installing RDoc documentation for fattr-2.2.0...
Installing RDoc documentation for session-3.1.0...
Installing RDoc documentation for rush-0.6.7...

2. Reference.
http://rush.heroku.com/

Installin git on Ubuntu 10.10

Installed git on my Ubuntu (10.10).

1. Open Synaptic.
2. Search and install git.
3. Confirm the installation.
$ git --version
git version 1.7.1

Creating Ramaze app

#       hello01.rb

require 'rubygems'
require 'ramaze'

class MainController < Ramaze::Controller
 def index
  'Hello, world!'
 end
end

Ramaze.start

$rub y hello01.rb

Installing Ramaze

Installed Ramaze.

1. Insallation
$ sudo gem install ramaze
============================================================

Thank you for installing Ramaze!
To create a new project:
$ ramaze create yourproject

============================================================
Successfully installed innate-2011.01
Successfully installed ramaze-2011.01.30
2 gems installed
Installing ri documentation for innate-2011.01...
Installing ri documentation for ramaze-2011.01.30...
Installing RDoc documentation for innate-2011.01...
Installing RDoc documentation for ramaze-2011.01.30...

$ sudo gem1.9.1 install ramaze
============================================================

Thank you for installing Ramaze!
To create a new project:
$ ramaze create yourproject

============================================================
Successfully installed innate-2011.01
Successfully installed ramaze-2011.01.30
2 gems installed
Installing ri documentation for innate-2011.01...
Installing ri documentation for ramaze-2011.01.30...
Installing RDoc documentation for innate-2011.01...
Installing RDoc documentation for ramaze-2011.01.30...


2. Check Installation
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'ramaze'
=> true
irb(main):003:0> exit

$ irb1.9.1 
irb(main):001:0> require 'ramaze'
=> true
irb(main):002:0> 

$ ramaze --version
ramaze: command not found



3. Modify PATH environment so that ramaze command is available.

Add the folloing line at the end of .bashrc or .bash_aliases.
export PATH=/var/lib/gems/1.9.1/bin:$PATH
Then, test it again:
$ ramaze --version
2011.01.30

4. Create and run a simple Ramaze app.
$ cd work/ruby/ramaze/
$ ramaze --create blog
Found proto at: "/var/lib/gems/1.9.1/gems/ramaze-2011.01.30/lib/proto", proceeding...

       mkdir    
       mkdir    model
       mkdir    layout
       mkdir    view
       mkdir    public
       mkdir    public/css
       mkdir    public/js
       mkdir    spec
       mkdir    controller
      create    config.ru
      create    model/init.rb
      create    layout/default.xhtml
      create    view/index.xhtml
      create    public/favicon.ico
      create    public/css/screen.css
      create    public/ramaze.png
      create    public/.htaccess
      create    public/dispatch.fcgi
      create    public/js/jquery.js
      create    spec/main.rb
      create    start.rb
      create    app.rb
      create    controller/main.rb
      create    controller/init.rb

$ cd blog/
$ ruby start.rb
D [2011-03-24 07:00:23 $2352] DEBUG | : Using webrick
I [2011-03-24 07:00:23 $2352]  INFO | : WEBrick 1.3.1
I [2011-03-24 07:00:23 $2352]  INFO | : ruby 1.8.7 (2010-06-23) [i686-linux]
D [2011-03-24 07:00:23 $2352] DEBUG | : TCPServer.new(0.0.0.0, 7000)
D [2011-03-24 07:00:23 $2352] DEBUG | : Rack::Handler::WEBrick is mounted on /.
I [2011-03-24 07:00:23 $2352]  INFO | : WEBrick::HTTPServer#start: pid=2352 port=7000


At http://localhost:7000, you see the result.




5. Resources
Ramaze Home Page

Tuesday, March 22, 2011

Setting up PostgreSQL for Windows - (3) Changing port

Just realized that the PostgreSQL installer used port 5433.
I changed it to 5432.

(1) Edit postgresql.conf
...
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '*'  # what IP address(es) to listen on;
                        # comma-separated list of addresses;
                        # defaults to 'localhost', '*' = all
                        # (change requires restart)
port = 5432             # (change requires restart)
max_connections = 100   # (change requires restart)
                        # Note:  Increasing max_connections costs ~400 bytes of shared memory per 
                        # connection slot, plus lock space (see max_locks_per_transaction).
...

(2) Restart the server
Stop and Start PostgreSQL service.

(3) Update connection entry for pgAdmin III.
Delete the old one (with 5433) and add new one (with 5432).

Sunday, March 20, 2011

Installing DBI for Ruby on Windows

Installed DBI gem.
C:\works\ruby>pik gem install dbi
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

Successfully installed dbi-0.4.5
1 gem installed
Installing ri documentation for dbi-0.4.5...
Installing RDoc documentation for dbi-0.4.5...

ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

Successfully installed dbi-0.4.5
1 gem installed
Installing ri documentation for dbi-0.4.5...
Installing RDoc documentation for dbi-0.4.5...

ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

Successfully installed dbi-0.4.5
1 gem installed
Installing ri documentation for dbi-0.4.5...
Updating class cache with 46 classes...
Installing RDoc documentation for dbi-0.4.5...

ruby 1.9.2p180 (2011-02-18) [i386-mingw32]

Successfully installed dbi-0.4.5
1 gem installed
Installing ri documentation for dbi-0.4.5...
Installing RDoc documentation for dbi-0.4.5...

Wednesday, March 16, 2011

Installing pg for Windows (failed again) after DevKit installation

I installed DevKit after the first failure of pg installation.
Then I tried to install pg second time.
C:\>pik gem install pg
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

ERROR:  Error installing pg:
        pg requires Ruby version >= 1.8.7.

ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

ERROR:  Error installing pg:
        The 'pg' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

C:/Ruby191/bin/ruby.exe extconf.rb
checking for pg_config... yes
Using config values from C:\Program Files\PostgreSQL\9.0\bin/pg_config.exe
checking for libpq-fe.h... *** 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=C:/Ruby191/bin/ruby
        --with-pg
        --without-pg
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/lib
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-pg_config
C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:364:in `try_do': The complier failed to genera
te an executable file. (RuntimeError)
You have to install development tools first.
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:433:in `try_cpp'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:830:in `block in find_header'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:670:in `block in checking_for'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:276:in `block (2 levels) in postp
one'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:250:in `open'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:276:in `block in postpone'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:250:in `open'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:272:in `postpone'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:669:in `checking_for'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:829:in `find_header'
        from extconf.rb:20:in `
' Gem files will remain installed in C:/Ruby191/lib/ruby/gems/1.9.1/gems/pg-0.10.1 for inspection. Results logged to C:/Ruby191/lib/ruby/gems/1.9.1/gems/pg-0.10.1/ext/gem_make.out ruby 1.9.2p136 (2010-12-25) [i386-mingw32] ERROR: Error installing pg: The 'pg' native gem requires installed build tools. Please update your PATH to include build tools or download the DevKit from 'http://rubyinstaller.org/downloads' and follow the instructions at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

Monday, March 14, 2011

Installing Ruby DevKit for Windows

Installed Ruby DevKit for Windows.

1. Download.
http://rubyinstaller.org/downloads/
The file downloaed is: DevKit-tdm-32-4.5.1-20101214-1400-sfx.exe

2. Right-click it and select "Smart extract here" option to unzip into a newly created folder.
The newly created folder: DevKit-tdm-32-4.5.1-20101214-1400-sfx

3. Rename the folder to "DevKit"

4. Place it under C:\

C:\DevKit>dir
 Volume in drive C is HD01-1TB
 Volume Serial Number is 5ED7-0C7F

 Directory of C:\DevKit

03/16/2011  05:27 AM    <DIR>          .
03/16/2011  05:27 AM    <DIR>          ..
03/16/2011  05:27 AM    <DIR>          bin
03/16/2011  05:27 AM               297 devkitvars.bat
03/16/2011  05:27 AM               361 devkitvars.ps1
03/16/2011  05:27 AM            10,380 dk.rb
03/16/2011  05:27 AM    <DIR>          etc
03/16/2011  05:27 AM    <DIR>          include
03/16/2011  05:27 AM    <DIR>          lib
03/16/2011  05:27 AM             2,238 m.ico
03/16/2011  05:27 AM    <DIR>          mingw
03/16/2011  05:27 AM             7,167 msys.bat
03/16/2011  05:27 AM            37,758 msys.ico
03/16/2011  05:27 AM             2,740 perllocal.pod
03/16/2011  05:27 AM    <DIR>          postinstall
03/16/2011  05:27 AM    <DIR>          sbin
03/16/2011  05:27 AM    <DIR>          share
               7 File(s)         60,941 bytes
              10 Dir(s)  607,934,238,720 bytes free

5. Add "C:\DevKit\bin" to shell's PATH environment.

6. Restart the Command line and check the PATH.
C:\DevKit>bash
bash-3.1$ ls
bin             dk.rb    lib    msys.bat       postinstall
devkitvars.bat  etc      m.ico  msys.ico       sbin
devkitvars.ps1  include  mingw  perllocal.pod  share
bash-3.1$ exit

7.[NEW] Run the following DevKit ruby command.
See "Setting up Rails 3 with PostgreSQL on Windows" By netpie

C:\>cd DevKit

C:\DevKit>ruby dk.rb init
[INFO] found RubyInstaller v1.8.6 at C:/Ruby186
[INFO] found RubyInstaller v1.8.7 at C:/Ruby187
[INFO] found RubyInstaller v1.9.1 at C:/Ruby191
[INFO] found RubyInstaller v1.9.2 at C:/Ruby192

Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.

C:\DevKit>ruby dk.rb install
[INFO] Installing 'C:/Ruby186/lib/ruby/site_ruby/1.8/rubygems/defaults/operating_system.rb'
[INFO] Installing 'C:/Ruby186/lib/ruby/site_ruby/devkit.rb'
[INFO] Updating convenience notice gem override for 'C:/Ruby187'
[INFO] Installing 'C:/Ruby187/lib/ruby/site_ruby/devkit.rb'
[INFO] Installing 'C:/Ruby191/lib/ruby/site_ruby/1.9.1/rubygems/defaults/operating_system.rb'
[INFO] Installing 'C:/Ruby191/lib/ruby/site_ruby/devkit.rb'
[INFO] Updating convenience notice gem override for 'C:/Ruby192'
[INFO] Installing 'C:/Ruby192/lib/ruby/site_ruby/devkit.rb'

Installing pg for Windows (failed)

1. Tried to install pg but failed.
C:>pik gem install pg
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

ERROR:  Error installing pg:
pg requires Ruby version >= 1.8.7.

ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

ERROR:  Error installing pg:
The 'pg' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

C:/Ruby191/bin/ruby.exe extconf.rb
checking for pg_config... yes
Using config values from C:\Program Files\PostgreSQL\9.0\bin/pg_config.exe
checking for libpq-fe.h... *** 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}/libp
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby191/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:364:in `try_do': The complier failed to genera
te an executable file. (RuntimeError)
You have to install development tools first.
from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:433:in `try_cpp'
from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:830:in `block in find_header'
from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:670:in `block in checking_for'
from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:276:in `block (2 levels) in postp
one'
from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:250:in `open'
from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:276:in `block in postpone'
from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:250:in `open'
from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:272:in `postpone'
from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:669:in `checking_for'
from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:829:in `find_header'
from extconf.rb:20:in 


Gem files will remain installed in C:/Ruby191/lib/ruby/gems/1.9.1/gems/pg-0.10.1
for inspection.
Results logged to C:/Ruby191/lib/ruby/gems/1.9.1/gems/pg-0.10.1/ext/gem_make.out


ruby 1.9.2p136 (2010-12-25) [i386-mingw32]

ERROR:  Error installing pg:
The 'pg' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

2. Tried again after installing DevKit but failed again.
C:\>pik gem install pg
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

ERROR:  Error installing pg:
        pg requires Ruby version >= 1.8.7.

ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

ERROR:  Error installing pg:
        The 'pg' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

C:/Ruby191/bin/ruby.exe extconf.rb
checking for pg_config... yes
Using config values from C:\Program Files\PostgreSQL\9.0\bin/pg_config.exe
checking for libpq-fe.h... *** 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=C:/Ruby191/bin/ruby
        --with-pg
        --without-pg
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/lib
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-pg_config
C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:364:in `try_do': The complier failed to genera
te an executable file. (RuntimeError)
You have to install development tools first.
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:433:in `try_cpp'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:830:in `block in find_header'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:670:in `block in checking_for'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:276:in `block (2 levels) in postp
one'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:250:in `open'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:276:in `block in postpone'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:250:in `open'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:272:in `postpone'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:669:in `checking_for'
        from C:/Ruby191/lib/ruby/1.9.1/mkmf.rb:829:in `find_header'
        from extconf.rb:20:in


Gem files will remain installed in C:/Ruby191/lib/ruby/gems/1.9.1/gems/pg-0.10.1
 for inspection.
Results logged to C:/Ruby191/lib/ruby/gems/1.9.1/gems/pg-0.10.1/ext/gem_make.out


ruby 1.9.2p136 (2010-12-25) [i386-mingw32]

ERROR:  Error installing pg:
        The 'pg' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

Installing Sequel on Windows

Installed sequel gem on Windows.
C:\>pik gem install sequel
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

Successfully installed sequel-3.21.0
1 gem installed
Installing ri documentation for sequel-3.21.0...
Installing RDoc documentation for sequel-3.21.0...

ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

Successfully installed sequel-3.21.0
1 gem installed
Installing ri documentation for sequel-3.21.0...
Installing RDoc documentation for sequel-3.21.0...

ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

Successfully installed sequel-3.21.0
1 gem installed
Installing ri documentation for sequel-3.21.0...
Updating class cache with 318 classes...
Installing RDoc documentation for sequel-3.21.0...

ruby 1.9.2p136 (2010-12-25) [i386-mingw32]

Successfully installed sequel-3.21.0
1 gem installed
Installing ri documentation for sequel-3.21.0...
Installing RDoc documentation for sequel-3.21.0...

C:\>sequel -v
sequel 3.21.0

Sunday, March 13, 2011

Setting up PostgreSQL for Windows - (2) New User

1. Create a Test Database
Using SQL Shell ("psql"), login as user "postgres", the only user available initially.
Then create a test database.

Server [localhost]:
Database [postgres]:
Port [5433]:
Username [postgres]:
Password for user postgres:
psql (9.0.3)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.

postgres=# CREATE DATABASE testdb;
CREATE DATABASE
postgres=#


2. Add a New User
postgres=# CREATE ROLE socrateos WITH LOGIN CREATEDB;
CREATE ROLE
postgres=# ALTER USER socrateos WITH PASSWORD 'secret';
ALTER ROLE
postgres=#

3. Test Login as New User
Server [localhost]:
Database [postgres]: testdb
Port [5433]:
Username [postgres]: socrateos
Password for user socrateos:
psql (9.0.3)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.

testdb=>CREATE DATABASE mydb;
CREATE DATABASE
testdb=>

Setting up PostgreSQL for Windows - (1) Log config

1. Location of PostgreSQL files.

C:\Program Files\PostgreSQL\9.0>dir
 Volume in drive C is HD01-1TB
 Volume Serial Number is 5ED7-0C7F

 Directory of C:\Program Files\PostgreSQL\9.0

03/13/2011  12:32 AM    <DIR>          .
03/13/2011  12:32 AM    <DIR>          ..
03/13/2011  12:31 AM    <DIR>          bin
03/13/2011  11:39 AM    <DIR>          data
03/13/2011  12:31 AM    <DIR>          doc
03/13/2011  12:31 AM    <DIR>          include
03/13/2011  12:31 AM    <DIR>          installer
03/13/2011  12:31 AM    <DIR>          lib
03/13/2011  12:31 AM    <DIR>          pgAdmin III
03/13/2011  12:32 AM               342 pg_env.bat
03/13/2011  12:31 AM    <DIR>          scripts
03/13/2011  12:31 AM    <DIR>          share
03/13/2011  12:31 AM    <DIR>          StackBuilder
03/13/2011  12:32 AM    <DIR>          symbols
03/13/2011  12:32 AM         5,768,777 uninstall-postgresql.exe
               2 File(s)      5,769,119 bytes
              13 Dir(s)  611,877,490,688 bytes free

2. Location of conf files.
C:\Program Files\PostgreSQL\9.0\data>dir *.conf
 Volume in drive C is HD01-1TB
 Volume Serial Number is 5ED7-0C7F

 Directory of C:\Program Files\PostgreSQL\9.0\data

02/27/2011  01:30 AM             3,648 pg_hba.conf
02/27/2011  01:30 AM             1,678 pg_ident.conf
02/27/2011  01:30 AM            18,554 postgresql.conf
               3 File(s)         23,880 bytes
               0 Dir(s)  611,877,838,848 bytes free

3. Changing log configuration.

(1) Location of log files:
By default, it creates log files in the directory:
C:\Program Files\PostgreSQL\9.0\data\pg_log

(2) First, make a backup copy of postgresql.conf file.
C:\Program Files\PostgreSQL\9.0\data>copy postgresql.conf postgresql.conf.bak.original
        1 file(s) copied.

C:\Program Files\PostgreSQL\9.0\data>dir *.conf*
 Volume in drive C is HD01-1TB
 Volume Serial Number is 5ED7-0C7F

 Directory of C:\Program Files\PostgreSQL\9.0\data

02/27/2011  01:30 AM             3,648 pg_hba.conf
02/27/2011  01:30 AM             1,678 pg_ident.conf
02/27/2011  01:30 AM            18,554 postgresql.conf
02/27/2011  01:30 AM            18,554 postgresql.conf.bak.original
               4 File(s)         42,434 bytes
               0 Dir(s)  611,877,171,200 bytes free

(3) Configuration can be changed in the postgresql.conf file.
I made the following changes:

#------------------------------------------------------------------------------
# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------

# - Where to Log -

log_destination = 'stderr'  # Valid values are combinations of
     # stderr, csvlog, syslog, and eventlog,
     # depending on platform.  csvlog
     # requires logging_collector to be on.

# This is used when logging to stderr:
logging_collector = on  # Enable capturing of stderr and csvlog
     # into log files. Required to be on for
     # csvlogs.
     # (change requires restart)

# These are only used if logging_collector is on:
log_directory = 'pg_log'  # 2011-03-13 enabled; directory where log files are written,
     # can be absolute or relative to PGDATA
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # 2011-03-13 enabled; log file name pattern,
     # can include strftime() escapes
log_truncate_on_rotation = off  # 2011-03-13 enabled, keep it off; If on, an existing log file of the
     # same name as the new log file will be
     # truncated rather than appended to.
     # But such truncation only occurs on
     # time-driven rotation, not on restarts
     # or size-driven rotation.  Default is
     # off, meaning append to existing files
     # in all cases.
log_rotation_age = 1d   # 2011-03-13 enaaled; Automatic rotation of logfiles will
     # happen after that time.  0 disables.
log_rotation_size = 10MB  # 2011-03-13 enabled; Automatic rotation of logfiles will 
     # happen after that much log output.
     # 0 disables.

4. Alternatively, you can view/edit configurations including postgresql.conf from pgAdmin
(1) Open pgAdmin and goto File menu
(2) Select "Open postgresql conf..."
That will open a config editor:
(3) [Update] The conf file can be opened directly from its Tools menu's Server Configuration option.


5. Confirm if logging is working.

(1) Stop and restart the server.
(2) Check the log contents.
postgresql-2011-03-13_140919.log
2011-03-13 14:09:19 EDT LOG:  database system was shut down at 2011-03-13 14:08:50 EDT
2011-03-13 14:09:19 EDT LOG:  database system is ready to accept connections
2011-03-13 14:09:19 EDT LOG:  autovacuum launcher started
2011-03-13 14:14:11 EDT LOG:  received fast shutdown request
2011-03-13 14:14:11 EDT LOG:  aborting any active transactions
2011-03-13 14:14:11 EDT LOG:  autovacuum launcher shutting down
2011-03-13 14:14:11 EDT LOG:  shutting down
2011-03-13 14:14:11 EDT LOG:  database system is shut down
postgresql-2011-03-13_141433.log
2011-03-13 14:14:33 EDT LOG:  database system was shut down at 2011-03-13 14:14:11 EDT
2011-03-13 14:14:33 EDT LOG:  database system is ready to accept connections
2011-03-13 14:14:33 EDT LOG:  autovacuum launcher started

Installing PostgreSQL 9.0 on Windows (Vista)

Installed PostgreSQL Version 9.0.3-1 on Windows. There seems to be only one way to install PostgreSQL 9.0 on Windows; that is using one-click installer provided by EnterpriseDB

1. Download installer.
I downloaded from http://www.enterprisedb.com/products-services-training/pgdownload#windows.

2. Execute installer.
Double click: postgresql-9.0.3-1-windows_x64.exe

3. Options.
I did not select any extra items.

4. Only information needed for installation was to provide a password for root user: postgres.

5. Installed PostgreSQL directory
It was installed in C:\Program Files\PostgeSQL\9.0\

6. Startup Menu
The startup menu includs:pgAdmin III, and a batch file (runpsql.bat, "SQL Shell") to launch psql.
The content of this batch file is as follows.
@echo off

REM PostgreSQL server psql runner script for Windows
REM Dave Page, EnterpriseDB

SET server=localhost
SET /P server="Server [%server%]: "

SET database=postgres
SET /P database="Database [%database%]: "

SET port=5433
SET /P port="Port [%port%]: "

SET username=postgres
SET /P username="Username [%username%]: "

for /f "delims=" %%a in ('chcp ^|find /c "932"') do @ SET CLIENTENCODING_JP=%%a
if "%CLIENTENCODING_JP%"=="1" SET PGCLIENTENCODING=SJIS
if "%CLIENTENCODING_JP%"=="1" SET /P PGCLIENTENCODING="Client Encoding [%PGCLIENTENCODING%]: "

REM Run psql
"C:\Program Files\PostgreSQL\9.0\bin\psql.exe" -h %server% -U %username% -d %database% -p %port%

pause

7. Viewing installed PostgreSQL 9.0 from pgAdmin III.


8. You can stop/start the server from Services control panel

Saturday, March 12, 2011

Installing Sinatra (on Windows, using pik)

1. Install Sinatra

Using pik, I can install a gem such as Sinatra for all Ruby versions installed in a single command. I have 4 versions of Ruby installed in my Vista.

C:\>pik gem install sinatra
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

Successfully installed tilt-1.2.2
Successfully installed sinatra-1.2.0
2 gems installed
Installing ri documentation for tilt-1.2.2...
Installing ri documentation for sinatra-1.2.0...
Installing RDoc documentation for tilt-1.2.2...
Installing RDoc documentation for sinatra-1.2.0...

ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

Successfully installed tilt-1.2.2
Successfully installed sinatra-1.2.0
2 gems installed
Installing ri documentation for tilt-1.2.2...
Installing ri documentation for sinatra-1.2.0...
Installing RDoc documentation for tilt-1.2.2...
Installing RDoc documentation for sinatra-1.2.0...

ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

Successfully installed tilt-1.2.2
Successfully installed sinatra-1.2.0
2 gems installed
Installing ri documentation for tilt-1.2.2...
Installing ri documentation for sinatra-1.2.0...
Updating class cache with 285 classes...
Installing RDoc documentation for tilt-1.2.2...
Installing RDoc documentation for sinatra-1.2.0...

ruby 1.9.2p136 (2010-12-25) [i386-mingw32]

Successfully installed tilt-1.2.2
Successfully installed sinatra-1.2.0
2 gems installed
Installing ri documentation for tilt-1.2.2...
Installing ri documentation for sinatra-1.2.0...
Installing RDoc documentation for tilt-1.2.2...
Installing RDoc documentation for sinatra-1.2.0...

2. Create a Sinatra app
# myapp01.rb
require 'sinatra'

get '/' do
  'Hello world!'
end

3. Run it.
C:\works\ruby\sinatra>ruby myapp01.rb
== Sinatra/1.2.0 has taken the stage on 4567 for development with backup from WEBrick
[2011-03-12 22:33:15] INFO  WEBrick 1.3.1
[2011-03-12 22:33:15] INFO  ruby 1.9.2 (2010-12-25) [i386-mingw32]
[2011-03-12 22:33:15] INFO  WEBrick::HTTPServer#start: pid=5164 port=4567

4. Result.






5. Resouces
Sinatra: http://www.sinatrarb.com/intro
pik: https://github.com/vertiginous/pik

Tuesday, March 8, 2011

Installing Ramaze (on Windows)

1. Install Ramaze, using PIK.
C:\>pik gem install ramaze
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]
...
ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]
...
ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]
...
ruby 1.9.2p136 (2010-12-25) [i386-mingw32]

2. Create a project.
C:\works\ruby>ramaze create blog
Found proto at: "C:/Ruby192/lib/ruby/gems/1.9.1/gems/ramaze-2011.01.30/lib/proto", proceeding...

       mkdir
       mkdir    controller
       mkdir    layout
       mkdir    model
       mkdir    public
       mkdir    public/css
       mkdir    public/js
       mkdir    spec
       mkdir    view
      create    app.rb
      create    config.ru
      create    controller/init.rb
      create    controller/main.rb
      create    layout/default.xhtml
      create    model/init.rb
      create    public/.htaccess
      create    public/css/screen.css
      create    public/dispatch.fcgi
      create    public/favicon.ico
      create    public/js/jquery.js
      create    public/ramaze.png
      create    spec/main.rb
      create    start.rb
      create    view/index.xhtml

3. Start ramze.
C:\works\ruby>cd blog
C:\works\ruby\blog>ramaze start
[2011-03-08 05:43:31] INFO  WEBrick 1.3.1
[2011-03-08 05:43:31] INFO  ruby 1.9.2 (2010-12-25) [i386-mingw32]
[2011-03-08 05:43:31] INFO  WEBrick::HTTPServer#start: pid=7108 port=7000

4. View it in browser.



5. Resouce.
http://www.ramaze.net/

Using pik

I really like pik (a Ruby version management tool for Windows).

I have 4 versions of Ruby installed on my Vista machine.
C:\>dir ruby*
 Directory of C:\
02/13/2011  12:30 AM    <DIR>          Ruby186
02/13/2011  12:20 AM    <DIR>          Ruby187
02/15/2011  03:21 AM    <DIR>          Ruby191
02/13/2011  12:50 AM    <DIR>          Ruby192

(1) I can use pik to list all installed Ruby versions.
C:\>pik list
  186: ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]
  187: ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]
  191: ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]
  192: ruby 1.9.2p136 (2010-12-25) [i386-mingw32]


(2) I can switch from one version to another easily.
C:\>
C:\>pik use 192

C:\>ruby -v
ruby 1.9.2p136 (2010-12-25) [i386-mingw32]

C:\>pik use 186

C:\>ruby -v
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

C:\>pik list
* 186: ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]
  187: ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]
  191: ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]
  192: ruby 1.9.2p136 (2010-12-25) [i386-mingw32]
The * tells which one is in use currently.


(3) I can install a gem for all version in a single pik command.
C:\>pik gem install ramaze
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

============================================================

Thank you for installing Ramaze!
To create a new project:
$ ramaze create yourproject

============================================================
Successfully installed rack-1.2.1
Successfully installed innate-2011.01
Successfully installed ramaze-2011.01.30
3 gems installed
Installing ri documentation for rack-1.2.1...
Installing ri documentation for innate-2011.01...
Installing ri documentation for ramaze-2011.01.30...
Installing RDoc documentation for rack-1.2.1...
Installing RDoc documentation for innate-2011.01...
Installing RDoc documentation for ramaze-2011.01.30...

ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

============================================================

Thank you for installing Ramaze!
To create a new project:
$ ramaze create yourproject

============================================================
Successfully installed rack-1.2.1
Successfully installed innate-2011.01
Successfully installed ramaze-2011.01.30
3 gems installed
Installing ri documentation for rack-1.2.1...
Installing ri documentation for innate-2011.01...
Installing ri documentation for ramaze-2011.01.30...
Installing RDoc documentation for rack-1.2.1...
Installing RDoc documentation for innate-2011.01...
Installing RDoc documentation for ramaze-2011.01.30...

ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

============================================================

Thank you for installing Ramaze!
To create a new project:
$ ramaze create yourproject

============================================================
Successfully installed rack-1.2.1
Successfully installed innate-2011.01
Successfully installed ramaze-2011.01.30
3 gems installed
Installing ri documentation for rack-1.2.1...
Installing ri documentation for innate-2011.01...
Installing ri documentation for ramaze-2011.01.30...
Updating class cache with 0 classes...
Installing RDoc documentation for rack-1.2.1...
Installing RDoc documentation for innate-2011.01...
Installing RDoc documentation for ramaze-2011.01.30...

ruby 1.9.2p136 (2010-12-25) [i386-mingw32]

============================================================

Thank you for installing Ramaze!
To create a new project:
$ ramaze create yourproject

============================================================
Successfully installed rack-1.2.1
Successfully installed innate-2011.01
Successfully installed ramaze-2011.01.30
3 gems installed
Installing ri documentation for rack-1.2.1...
Installing ri documentation for innate-2011.01...
Installing ri documentation for ramaze-2011.01.30...
Installing RDoc documentation for rack-1.2.1...
Installing RDoc documentation for innate-2011.01...
Installing RDoc documentation for ramaze-2011.01.30...