msgbartop
A place to share my thoughts
msgbarbottom

20 Jul 10 Setup Netbeans on OSX and Oracle OCI8 for Ruby on Rails

I switched over to Netbeans on OSX from TextMate after using Netbeans a lot on my ubuntu setup. First thing I ran into was the following error when I started the application.

oci8lib.c:98:in oci8lib.bundle: OCI Library Initialization Error (OCIError)

The problem is that OSX is starting netbeans from a separate shell than from your usual terminal shell. Netbeans has a configuration file that you can add to put in your environment stuff.

Create a file called netbeans.conf in your ~/.netbeans/6.9/etc folder. You may have to create the folder first. The contents of the netbeans.conf should be the enviornment settings pulled from ~/.bash_profile. An example is below:

export ORACLE_BASE=/Users/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_SID=

Mark the file executable and start netbeans again.

My Configuration:
Unibody MacBook Pro 15″, 2.66 GHz Core2Duo
Oracle 10g
Netbeans 6.9
Ruby 1.7
Rails 2.3.8

20 Jul 10 Gather Statistics for Oracle

Oralce requires that you periodically gather statistics on the queries you are running. The following command will do that for your local schema. It can be run as the schema owner or sysdba


exec dbms_stats.gather_schema_stats(ownname=> '', cascade => true)

21 Apr 10 text_field_with_auto_complete pass multiple field values

In ruby on rails there is a method called text_field_with_auto_complete. By default it will call a method on your controller with the name auto_complete_for_<form>_<field>. It will pass in a param value for the field you are updating. The details of this I am not going into here, they are well documented elsewhere.

For this exercise I am going to show how to setup the tag so that you can pass multiple field values.

Example:

<%= text_field_with_auto_complete :user,
:habitat_name,
{:class => 'input'},
{:with => "'&user[state]=' + jQuery('#user_state').val() +
'&user[habitat_name]=' + jQuery('#user_habitat_name').val()",
:skip_style => false} %>

In the example above I am using the jrails plugin to implement jQuery so the syntax is for jQuery. The key clause is the :with class. Here you will need to implement not only the primary field you want to pass, but can add any others you wish. In my case I have a user[:habitat_name] and user[:state]

20 Apr 10 Thinking Sphinx doesn’t execute query when you think it will

I was working late tonight (ok, technically it was last night, but the nights and days are blurry sometimes) and I was having trouble seeing a new ThinkingSphinx query in the searchd.query.log file.

After much WTF, I realized that I was not really using the search results yet. As a result of this I also discovered that Sphinx has a feature that it does a lazy execute of the search query. This is a great idea for performance, but when developing a search function it can be a bit maddening.

Fortunately there is a solution. ThinkingSphinx offers a property called :populate. Just set this property to true when searching and it will not wait for the lazy load.

Also as an aside and maybe another post when I figure out how to repeat it. If you make a change to class that is indexed and don’t restart the server, even in development there is a chance that when using the multi-class search ThinkingSphinx.search method you will get a strange error. Just restart the server and it will go away. When I get this to reproduce again I will capture the actual error.

26 Mar 10 Dual View Monitor on Ubuntu (karmic)

I have been cursing Linux and specifically Ubuntu’s lack of out of the box Dual View support for some time now. I am using an older computer, a Dell Latitude 120L. The Latitude is a nice computer and served me well as a windows machine before converting it to Ubuntu about 6 months ago. I have been very happy with Linux with the one exception of Dual View support. On a Mac or Windows machine, you plug in the second monitor and presto you have a dual view setup (well on the Mac it is more like hey it just works and Windows you have to poke around with displays but it worked).

Fast forward and I am taking my 4th or 5th attempt at getting this to work and find a package called RandR. You install this using the command:

sudo apt-get install gnome-randr-applet

Then I ran it by just typing

xrandr

Presto, it detected the displays and set them up correctly with Dual View.

Now I am sure there is a console plug-in somewhere. But in the past when I tried to use the built in screen manager I would just hang my system, have a mouse but no screens. This time presto it detects my displays and setups dual display. I am happy with Linux again.

18 Jan 10 Ruby on Rails vs. Java

Whenever I bring up Ruby on Rails to Java programmers I always get an immediate defensive. For some reason Java programmers seem threatened by Rails. I am sure it is more to do with fanatisim that both camps have for their language. When evaluating a new endeavor however, it is wise to make an open minded decision about the framework to use.

Now there are some areas where these two languages overlap like JRuby. However, JRuby is really just Ruby compiled in Java. There are some benefits if you have some legacy Java system to integrate with, but the overhead of running on the JVM instead of the native Ruby engine really eat up some of the benefits of Ruby on Rails in the first place. The main area where JRuby has a home is in close minded organizations that won’t “allow” another operating platform to be used. Enterprising developers then develop a full blown Ruby or Ruby on Rails applicaiton and just deploy it on the Java EE platform in use by the enterprise.

There are strengths and weaknesses to both of these platforms. Evaluating these and looking at your target are essential to making a good decision. Rails is very good when you have total control over your design including database platform, table designs, graphic layouts. Rails is also a good choice for design shops that are heavy on graphic designers and light on programmers. Where Java and it’s many platforms shine is in environments where you have a legacy system that can’t be changed. It is also very good for times when you have other systems particularly SOAP or other EE systems to interface with.

With all this said I am about to enbark a new adventure. The primary platform is going to be Rails. The reasoning behind this is the lighweight deployment architecture, built in support for many web based functions, and the active community. I am already faced though with a shortcoming in the Ruby on Rails architecture. Threads. I have a data structure that is not well suited to a database it is going to be a Graph of user relationships that I need to parse out at least 3 degrees deep for many operations. The standard MySQL database doesn’t really have anything yet to support these types of complex relationships. I could implement a graph object in Ruby, however, it can’t be shared between the processes running on the application server very easily.

In comes the Java EE server. I am looking at a very light RESTfull web service to handle my relationships. I will post some additional posts and guides once I have things up and running as I am not really finding many examples where Rails ActiveResource is a consumer of a Java service.

05 Jan 10 Dynamically add data to a jsf form

I have been learning JSF recently and found a very nice article at http://balusc.blogspot.com/. I keep going back to it for more information. After banging my head a bit trying to get a grasp on how to dynamically add fields to a form I remembered the article and there in the middle was information about dynamically adding data to a JSF form.

Add new rows to datatable

Adding new rows to the datatable is in fact easy, just add a new and empty MyData item to the dataList and let the rendered attribute of the components intercept on the ID being null. Also add a counter to inform the bean how many rows are been added so that it knows how to prepare the list and how many of the last rows have to be saved.

But in the request scope you’ll have to store the counter in a HtmlInputHidden component bound to the page so that its value can be retained in the next request, regardless the outcome of the validations phase.

04 Jan 10 Rands talks about how to land a new hire

The last several interviews for jobs I have done the recruiters or HR personnel spend a lot of time trying to down sell me on the job. They start the down pressure on salary or benefits right from the beginning. This week Rands talks about how to go about landing a high quality candidate. This is not a warm body to fill a slot, but the grade A candidate that is going to really get things done.

The part I like the best is when they get to negotiations. It is all about the company saying they “understand” and “want” the candidate. It seems like companies I have dealt with are afraid to say this for fear it will make them weak in negotiations. I once spent an hour with the HR representative during the interview “negotiating” my expectations. They didn’t just listen as described here, but countered every point I made. Needless to say I didn’t get the job and it would have been a bad move if I had.

When we started the offer negotiations, she’d worked with the recruiter and knew exactly what we’d need to do to lure the candidates. She knew that base salary was a big deal for Alex. She knew Sean was going to be a stickler about stock. There was no offer negotiation because Michele constructed offers that were going to be accepted. She presented them: “This is the offer you wanted. This gig is perfect for you. We want you.”

Read more at Rands in Repose: Wanted

01 Jan 10 Backup your personal computer

If you are anything like me, I have a lot of personal files on my home computer. I have 150Gb just in photos alone. I recently had a hard drive fail, and it failed pretty bad. I was unable to recover the files through basic means. Re-installing the operating system is one thing to deal with, but loosing personal files is devastating. Fortunately I have a personal backup plan.

A personal backup plan is something that everyone with a personal computer should have. It can be simple or complex. I used to use a separate internal disk drive with a script I setup in the scheduler to run every day. This isn’t too bad, but in a recent move the drive I used for this crashed and didn’t even power on any more. Additionally if we were to have a catastrophic event such as a flood or fire we would loose both the primary and backup. This is pretty rare, but does happen and it is something I have my home insured for, but nobody really thinks to insure their personal files and photos.

Fortunately there are a number of services available to handle backups. I decided about a year ago to use a backup service. I am using Carbonite to handle my backups. Their service is fairly reasonable in price and easy to setup and use. Once I did the original configuration I don’t have to think about it anymore. It just quietly backs up everything in my personal folders and a few others I manually added through their Explorer extensions.

So now back to my personal backup plan. Once I put the operating system back on and a few of my more common applications like Office, iTunes, etc. I started the restore process. It is all managed through the Internet so a good broadband connection is required but most people have that. I logged into Carbonite and selected to install the software and it connected up right away and started the download process. I have over 190Gb on this service, so it’s going to take a few days to get it all back, but I AM going to get it all back.

A good backup strategy should be something every computer user has. It is just one of those basic services everyone should have.

17 Dec 09 Netbeans 6.7.1 hangs on Subversion until you set it up

The default install of Netbeans comes with the Subversion plug-in, but it is not setup. Attempting to do anything with Subversion will hang the system.

  1. Browse to Tools -> Options -> Miscellaneous -> Versioning -> Subversion
  2. Fill in the “Specify SVN Home Folder” field with “/usr/bin”, without the quotes.
  3. Done, you will need to provide your connection and repository information when prompted
    1. Tags: , ,