Tuesday, December 19, 2006

Gumstix - Getting Started

Yesterday I received my Gumstix order in the mail. It took all of about 2-3 hours to get working. The pack I got was the Wifistix, Audiostix2 and the Connex400 (no bluetooth). After clicking the pieces together, I powered up the device and blammo. It works. The Wifistix registered the computer on the network and all is well so far.

For those who are trying this configuration in an environment such as mine where there are dozens of wireless networks available, my strategy was to boot the Gumstix in very close proximity to the wireless router... this way, when the Wifistix tries to register the network, it chooses yours. Otherwise of course, it will register itself with any old wifi network it comes across.

More later.

Wednesday, December 06, 2006

How To Setup Ruby, Rails, and Oracle 10g on Solaris 10

Introduction



Here is the list of what you will need to have installed to run a Ruby on Rails application on Solaris 10.

* Ruby 1.8.4\+
* Oracle 10g client full install
* RubyGems
* Rails
* Mongrel
* Ruby OCI8 libraries

There are a number of dependencies in order to get these items installed which are detailed in the following sections.

This tutorial is going to assume that any Solaris machine that you are attempting installation on will be totally devoid of any software tools that would make an installation painless.

My first suggestion for this installation process is: *DO NOT use Sun's Download center*.
There is nothing simple about Sun's installations. I only tried one (gcc) and it placed the binaries in a folder that was outside of the default search path. Brilliant, thanks Sun.

Instead visit http://sunfreeware.com and search for packages for the platform in question.
In the following, I have linked to the files where possible, but in the case that you are not installing this on Solaris 10 with a Sparc processor, use the above link to get the packages.
There may be better places, but this site had all the packages I needed and better than that, it worked. If at all possible, you should be using a package manager in general, and for this, I used Sun's package manager which is pretty basic. Also, you should get the packages, NOT the src files for teh packages. If you get the src files you will need to build the packages before you install them which could be a pain. But I digress... onward!

1. Install the Oracle Client



 You \*must\* have a full install of the Oracle client for the Ruby OCI8 driver to work. This is not an option. I have gotten the OCI8 driver to compile with the Oracle Express Edition client (XE), but if at all possible, install the full client.
Check to see that you have the "oci.h" file that the Ruby OCI8 driver will want to use (which is installed with the Oracle client).


$ locate oci.h
/opt/local/oracle/product/10.2.0/client_1/rdbms/public/oci.h


This file should be somewhere like the path above - in a "public" folder.
If you do not have this file or it is in a "demo" folder, you dont have a full install of the client - stop right here and go get one installed.

1. Prerequisites



You will need to install a handful of libraries and whatnot before Ruby will work correctly.
Download these to the temporary directory of your choice.

* libiconv-1.11 (gcc dependency)
* gcc-3.4.6 or higher (requires libiconv-1.11)
* wget-1.102 not required, but it will make your life easier (requires gcc)
* openssl-0.9.8d(I have no idea why, but gem installation would not work without this package)
* readline-5.2(fixes input problem with IRB)

Also be sure that you have "make" installed. At the very least this is usually on even the most crippled system, but just check (which make).

Once you have downloaded the packages, gunzip them and install,


# pkgadd -d gcc-3.4.6-sol10-sparc-local
# pkgadd -d openssl-0.9.8d-sol10-sparc-local
# pkgadd -d wget-1.10.2-sol10-sparc-local
# pkgadd -d readline-5.2-sol10-sparc-local


or something like that...
if you want to remove the packages after installation, use pkgrm

2. Install Ruby



Download ruby-1.8.4 and install.


# wget ftp://ftp.sunfreeware.com/pub/freeware/sparc/10/ruby-1.8.4-sol10-sparc-local.gz
# pkgadd -d ruby-1.8.4-sol10-sparc-local


Make sure everything is there ($ which ruby, $ which irb) - or better yet, fire up IRB and make sure Ruby works. Just type a few lines and exit.


$ irb
irb(main):001:0> quit


3. Install RubyGems



Congratulations, you have Ruby installed (right?). Now you will want to install RubyGems, the Ruby package manager which functions alot like Yum or MacPorts or any other intelligent package management system. On Solaris, you will need to build this from source.

Get the latest distribution of RubyGems from http://rubyforge.org/frs/?group_id=126
Or install using wget like so,


$ wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
$ tar -zxf rubygems-0.9.0.tgz
$ ruby setup.rb


Check the [reference manual|http://docs.rubygems.org/read/chapter/3] if necessary.

4. Install Ruby OCI8 driver



I cannot stress this enough: make sure you have an Oracle 10g Client installed.
If you are absolutely sure that you have it, download and gunzip/untar the source code:


$ wget http://rubyforge.org/frs/download.php/12559/ruby-oci8-0.1.16.tar.gz
$ gzip ruby-oci8-0.1.16.tar.gz | tar xvf -
$ cd ruby-oci8-0.1.16


You are now prepared to compile and install the Ruby OCI8 library.

1. Check the following:

* ruby and make (or nmake on MSVC) are in the environment variable PATH.
* sqlplus runs correctly

2. Check library search path.

If sqlplus runs correctly, the environments variables are okay in general.
But if Oracle is 64-bit and ruby is 32-bit, make sure $ORACLE_HOME/lib32
in 32-bit library search path. (LD_LIBRARY_PATH_32 on Solaris, SHLIB_PATH
on HP-UX PA-RISC.)

3. make and install


$ make
$ make install


Common sources of errors:

* Oracle client is incomplete/ cannot find oci.h
* Oracle environment variables are not set correctly
* gcc is not installed correctly or cannot be found

May the force be with you.

5. Install Rails and Mongrel



Welcome to the easy life.


$ gem install rails --include-dependencies
$ gem install mongrel --include-dependencies


Actually there is a bug in the configuration of Mongrel on Solaris that you will need to fix here.

For any Rails application, you can include the Rails libraries in the application itself so an external library in the Ruby search path is not necessary. If there is a copy of the Rails libraries, a "rails" folder, in the "vendor" folder of the Rails application you want to run, the application will use that copy of Rails instead of the gem installation. As a best practice, a copy of Rails should be included in any deployed application. The reason for this is simple: Rails changes. It is quite possible that an updated Rails gem will break your application in some unexpected way. As long as your Rails application has a checkout of Rails in its vendor folder, everything should run as expected. For more on the topic of "GemRails" and "EdgeRails", see the [Rails wiki|http://wiki.rubyonrails.com/rails/pages/EdgeRails].

Monday, December 04, 2006

Beginning ChucK

What a lovely language, this ChucK.

While it might seem like a detriment that the language is still incomplete and under heavy development, the situation is actually quite dreamy. The language is still in a state of simplicity. You can learn the majority of ChucK and its functions in a single day. It is decently well documented. But beyond all that, it works... well, most of the time. Let me contrast this for a moment with ChucK's conceptual older sibling, SuperCollider.

I have been trying to wrap my head around SuperCollider for the past few years and just now feel like I understand the syntax. I have spent days on SuperCollier trying to get a single sample to play over and over on a trigger without much success. Search the SC mailing list archives turns up very little, and I personally find the wikis and documention on the language and its usage scattered, incomplete, and downright confusing... not that the community has not tried to get it together. For my own purposes, the final blow was the lack of a SC command line interface. As far as I can tell, you must use the SuperCollider language environment to execute scripts and send them to servers.

I will write more about ChucK as I get further into it, but on first blush I'm smitten. For all its incompleteness it is a simple and expressive language (although required semicolons are lame).