Saturday, March 27, 2010

rails ferret in production

I've had a few problems as i've moved from dev to production. My task has been complicated by not always maintaining my migrations. However the problem I've had recently has been with ferret not working.

When I've started './console/script procution' and try and rebuild indexes manually I get:

Mymodel1.rebuild_index()
=> false


It turns out that the problem was that ferret has an expectation that in production, there will be a ferret server running. This is asserted in the file:

./config/ferret_server.yml

I commented out the production server and it works.

Friday, March 26, 2010

gnuplot point types

I was using gnuplot today and wanted a list of the different point types which are available so I could choose a suitable one.

After visiting the internet, I couldn't find a list so I made my own:

echo plot `perl -e 'for ($i = 0; $i < 30; $i++) {print " \"<echo $i 1\" u 1:2 pt $i ps 2 notitle, ";}'` | sed 's/,$//' | gnuplot -persist
echo set term postscript enhanced\; set output \'./points.eps\'\; plot `perl -e 'for ($i = 0; $i < 90; $i++) {print " \"<echo $i 1\" u 1:2 pt $i ps 1 notitle, ";}'` | sed 's/,$//' | gnuplot

Thursday, March 25, 2010

rails won't run in production

I've been working on a Rails app (2.3.5).

I'm hosting on modest hardware and chose Nginx and Thin to hopefully get the most performance out of my app.

My problem was that my app wouldn't run in production. It worked fine in development, but not in production.

There were a couple of problems:
  1. I was using a legacy database, and like non-pluralised table names, development picked up 'ActiveRecord::Base.pluralize_table_names = false' in my config/environment.rb, but I didn't seem to propagate to production. I added in 'ActiveRecord::Base.pluralize_table_names = false' into ./config/environments/production.rb
  2. Thin wouldn't start. Starting thin with -D allowed me to start it not daemonized, and then I could see the problem: 'Missing the Rails  gem. Please `gem install -v= rails`, update your RAILS_GEM_VERSION'.
    This is Thin reacting against rack version 1.1.0 apparently.
    gem uninstall --version '> 1.0.1' rack fixed that.
One less thing on my todo list.

Monday, February 8, 2010

Building TOra with Oracle support on Ubuntu

I'm doing some Oracle development, so I wanted to use the TOra db browser for convenience.

TOra is Free Software. There is a license conflict between TOra and the license that Oracle use on their client libraries. As a result TOra is not distributed with Oracle support: if you want to use TOra with Oracle, you must download the separate components, TOra source and Oracle client, and build TOra yourself.

This process is documented on the web, notably at pythian blog. However the instructions are for Ubuntu 9.04, and I'm using 9.10, so I thought there is an opportunity to document my experience as well.

So, on Ubuntu 9.10, I have installed Oracle XE (a resource-limited 10G installation), into it's default directory: /usr/lib/oracle/xe/

I'm also assuming that you, like me, have the three Oracle packages oracle-instantclient-basic-10.2.0.4-1.i386.rpm oracle-instantclient-devel-10.2.0.4-1.i386.rpm oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm installed in their default location: /usr/lib/oracle/10.2.0.4/client/

NOTE: I chose the '10.x' client packages - I'm not sure if this makes a difference.

It seems that the Ubuntu source for TOra have migrated to git, so when I tried to pull down the source using apt-get source I didn't have any joy. So I cloned the TOra git repository and attempted to modify the debian/rules file to include the relevant Oracle libraries. This wasn't possible - there were no configure rules in there...

So instead I configure using 'cmake'.
First I need to configure: ORACLE_HOME and LD_LIBRARY_PATH:

export LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.4/client/lib
export ORACLE_HOME=/usr/lib/oracle/10.2.0.4/client/

I also need to install the old libstdc++5 which is available from the Debian repository: http://packages.debian.org/lenny/i386/libstdc++5/download

Then a command line to configure build:

 fakeroot cmake -DORACLE_PATH_LIB=/usr/lib/oracle/10.2.0.4/client/lib -DORACLE_LIBRARY_CLNTSH=/usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so.10.1 -DORACLE_LIBRARY_OCCI=/usr/lib/oracle/10.2.0.4/client/lib/libocci.so.10.1 -DORACLE_INCLUDES=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/rdbms/public

NOTE: I'm calling in the INCLUDES from the XE install.
...and another to build:

make

And you should know what to do from here...

Saturday, January 23, 2010

FormFu, DBIC, model_config and resultset.

I have found myself back in Catalyst development work. This wouldn't be such a bad think if I hadn't just spent a whole day trying to fix up a form to edit a 'many_to_many' relationship which is stored in my Schema.

I've been following this post which says it should be about as simple as it sounds. i.e. not as simple as Rails, but definitely doable with finite effort. So, FormFu syntax not withstanding, I following these instructions but ended up with some peculiar error talking about 'result_source'. I tried playing with 'nested_name', 'model_config' etc... I began to think about building my Select in the controller.

Finally, I discovered my error: I had not configured Controller::HTML::FormFu which is shown nicely in this post:

http://lists.scsys.co.uk/pipermail/html-formfu/2009-March/001932.html

That is a day of my life gone, but at least I will be able to rise from sleep tomorrow knowing that I can move onto doing some new development.

UPDATE: One additional comment to the post above from 2009-March. I found that I needed to use the many_to_many relationship as the nested_name, not the has_many as stated.

Friday, January 8, 2010

Skype on a Ubuntu HP Mini 1000

I have been playing with Ubuntu 9.10 on a HP Mini for a while - on and off.

I have a request to get Skype working. I struggled with this for a bit, but I couldn't get it to work with the duplex sound card: when I pluged a microphone in, the speakers stopped working for example.

Something changed - it could have been an kernel update - anyway, I can now use Skype with minimal effort - including the web-cam.

The vital thing I had to do was disable the checkbox (options->audio settings or something):

'Allow Skype to automatically adjust my mixer levels'

Then, I could twiddle the 'pulse audio' options (right click on the volume icon) to increase the microphone input level. It seemed that one problem was Skype wouldn't let me increase the microphone input level while I was letting it 'automatically adjust my mixer levels'.

Wednesday, December 16, 2009

Fedora, sqlplus: error while loading shared libraries

My sqlplus stopped working one day with the error:

sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory

this is a classic shared object where the shared object cannot be found.

I don't know how it happened, but my sqlplus install had become detached. The solution is simple as root: search for the .so file in your file system. You can do this using your expert knowledge, or find:

find /usr -name 'libsqlplus.so'

Once you have this location, stick the folder which contains this library (i.e. /usr/lib/oracle/11.2/client/lib/) in a file for linker to find:

/etc/ld.so.conf.d/oracle.conf

The linker is call 'ld' and on Fedora 11 uses /etc/ld... for it's configuration files. The final step is to re-configure the dynamic linker run time bindings which is done with:

ldconfig