Friday, July 27, 2007

Terminal shell in eclipse


The state of working with Grails in Eclipse is not the best for me. Using the external tool call has been a pain and I have been using an external terminal shell. Today I went looking for a terminal shell solution built into Eclipse and found the Target Management Project.

You can install the components for this via the Eclipse update manager with the information from: http://europa-mirror1.eclipse.org/dsdp/tm/updates/.

Once this is done use the menu sequence Window -> Show_View -> Other and select the Remote Systems folder. From there I added "Remote System Details" (not really needed) and "Remote Shell". Using the triangle menu for this latter element I selected the default local connection.

After all this though.. failure.. it exec's each command out to the shell and as such there is no way to re-attach and kill a process easily. If you run grails run-app it's disconnected to one has to ps its PID and kill it. (not optimal).

After some looking I found sshView (http://www.eclipse-plugins.info/eclipse/plugin_details.jsp?id=1187). This installed but gave some very strange behavior and never was able to get it to successfully work. You can access it in the same sequence as above and look for sshview.

In the end there is easyShell. However, all this does is launch the shell I was using when I started this journey. Yes, you can configure it to open up in the directory the file is in and you can get to rather easily through the contextual menu. In the end not really worth the time and effort and still no good built into the IDE view shell solutions that I can find at least.

Thursday, July 19, 2007

Using Grails GSP to provide alternating colors in a table

Using Grails GSP to provide alternating colors in a table

I saw something related to this a while ago on the net but was not able to find it again. So I just came up with my own approach.

I wanted a table that had alternating rows highlighted. There are many ways to approach this. This solution is what I am going to use since it all falls on the view side of things and as such is rather easy to code. It is based on the code examples from http://grails.org/GSP+Tag+-+set

<table width="50%" align="right" border="0" cellpaddinng="0" cellspacing="0">
<g:def var="counter" value="${1}" />

<g:each in="${lastElement}">

<tr>

<td style="background:
${counter % 2 == 0 ? 'white' : 'grey'">
<g:showElementResults id='${it.id}'/>

</td>

</tr>

<g:set var="counter" value="${counter + 1}" />

</g:each>

</table>


It is the "${counter % 2 == 0 ? 'white' : 'grey'}" that does all the work. The only other interesting elements are in bold. Simply change the two colors to get the banding effect you want. A more advanced version of this could set a style name or some other CSS element to improve the approach. I am sure there are several ways to do this. This seems to work for me. The "<g:showElementResults id='${it.id}'/>" code is not relevant here. It's just a taglib I use to create the formatted text of the cell based on an id and the rest is the just the <g:each> tag boilerplate.

Thursday, July 12, 2007

Keyboard shortcut for grails external tool in Eclipse


Somehow I think this should have been much easier to do. Since it didn't seem to be I am placing it here.

Using Grails in Eclipse (IDE integration information here), I wanted to make a shortcut for the external tools command which is used so much in this set up.

To do this you need to go to preferences (under the window menu), and select Keys -> Modify (Tab) -> Run/Debug (Category pull down) -> Run Last Launched External Tool (Name pull down) then assign the key in the key sequence and be sure to click the "Add" button.

Once all that is done you have a keyboard shortcut for the external tool.

(Please.. I'd like to see netbeans and grails integration)

Tuesday, June 26, 2007

Perm gen size and Grails

I've been continuing to work with the Grails framework and found an interesting issue. When working with the Tomcat application server I run into several issues related to out of memory errors with Grails applications.

Attempts to resolve this with -Xmx512m or some other setting for the memory heap size failed to work. This seems to be due to the large number of elements (controllers, domains, etc) in my grails app that load classes. I believe this is related to issues of lots of use of reflection (not sure). It does appear that this memory is alive during the entire life of the application (not garbage collected). After installing several plug-ins and increasing the size of the application quite a bit this occurred. It also seems to be partly related to the creation of an additional "Context Path" for an application in Tomcat.

I found some reference to Tomcat 6 having better "perm size" management on the net vs Tomcat 5 series. Though nothing of a definitive nature. I saw it seems related since it removing the extra "Context Path" for this grails application seemed to resolve things. Perhaps it is an issue with grails applications in multiple Context Path's but the perm gen size increase did resolve it cleanly.

My current options line for catalina.sh:
JAVA_OPTS='-Xmx512m -XX:MaxPermSize=256m -server -Djava.awt.headless=true'

Friday, May 18, 2007

CBS bought me (well, last.fm)

So I didn't want this blog to become abandoned, and in fact I have several items throughout the last weeks that I have felt worthy of blogging about and have not. I think I just need to discipline myself to post my thoughts when I have them and not "I'll do that later".

But yesterday when I heard CBS bought last.fm (and being a last.fm user) it got me to thinking and motivated to post this thought. I have just been bought... along with my data. Will CBS keep it, take it, toss it out? Indeed if you look around I have relationships with Google, Amazon, Last.fm, Digg and other sites. All this data is valuable to me and what might happen to it in a merger, take-over, bankruptcy?

Do we need a Federal DATA Insurance Corp.
I had this thought a few weeks ago when talking to Josh, regarding my use of Amazon S3 to backup my data. I was looking at various on-line data backup sites. There are many and for my small amount several I could get free (add supported). However, I liked the Amazon S3 due to it's use of services and quite frankly the size and apparent strength of Amazon.

We began talking about the amount of data a person has on the net. I have data I would call valuable with Google (mail, RSS, this blog and a bit more), Amazon (data via S3) and Yahoo (they own del.icio.us now).

However, if any of these were to go away what would happen to my data? Gone? It got me to thinking about the Federal Deposit Insurance Corp. Established to provide some assurance that money (or at least some) would be safe.

Though the analogy is obviously not one to one it does make me wonder if there isn't some general consumer SLA that needs to be established with on-line data "deposit" sites. A Federal DATA Insurance Corp. to provide the public with some level of trust, confidence that data stored on-line in places like Flicker, MySpace, S3, Google, etc are retrievable when/if a company goes south.

Sunday, March 04, 2007

IDE for jRuby

I went looking for the current state of IDE's for Ruby and in particular Ruby on Rails. In fact even more specifically for jRuby since I am not very interested in Ruby or ROR unless it is hosted on the JVM.

I found RadRails and RDT. Both of these are based on the Eclipse IDE platform. The former apparently based on the later. I installed and attempted to use both with jRuby. I had little success in this effort and from what I can gather jRuby support is yet to come for these packages.

I grabbed one of the Netbeans 6 nightly builds and was presently surprised to find jRuby there. A little more searching reveled this site which has done a far further exhaustive review of various Ruby IDE's than I have seen so far. Tor Norbye's blog section on Ruby also provides news straight from the source on this effort.

Thursday, March 01, 2007

February Errata

So it has been some time since I made a post. Been busy but I hope to manage my time better in future so that I can post my thoughts more often. The main reason I do this is to benefit myself in terms of aligning what I see and experience in the community into a coherent philosophy.

I wanted to touch on several things in the last few weeks I have been interested in. Actually sitting down and writing this was sparked by this news item (Adobe to take Photoshop online at Cnet) that caught my eye in my RSS feeds.

It caught my eye due to a discussion I had with Josh, where we debated a bit this very concept. Word processing and excell spread sheets aside it seemed unlikely that the on-line application model as exemplified by Google docs would work for something like GIMP or Photoshop. It is interesting to look at this in light of things like Joyent though. Correl is looking to take a variation of Word Perfect into a model that uses both on-line and off-line elements in collaboration with Joyent. This mix of on-line and off-line aspects to an application is very interesting to me. It is all part of the development that is taking place where API's like XUL, XAML etc are getting attention in the same context as GTK and QT. However, how much application API's matter is up to debate. Is it only the movement and management of information in an open and extensible manner that really is important?

One element of that did catch my eye was Remix which uses Flex. This is more interesting to me as it brings up the issue of rich client development. I have been watching XUL, XAML (Windows Presentation Foundation) and things like FLEX and Laszlo for some time now. Mix in things like the rich client platforms from Eclipse and Netbeans and you have the making of new "internet aware application API's" forming. This would be great. GTK, QT, Cocca etc. aside what is more interesting to me is the ability to make "application" that come to the user over the net.

Grails Update
Grails has a new major number out and a major shift in the way it deals with incorporating third party features. A very nice plug in approach. The jump from .3 to .4 was a bit painful as you have to un-weave the code you have done in the old approach for the new. I updated an Acegi security based application from .3 to .4. The biggest pain is removing the controller, domain, and other classes that were required prior to the plugin approach. Though this was a bit tedious it is well worth it for the nice new plugin based system. Hopefully such a major effort will not be required in the future. I suspect the Acegi package is one of the bigger ones to migrate.

Seems they also changed the way to they do the creation of URL's and several of my relative links got broken. I should be using more of the Grails link tag (http://grails.org/Tag+-+link) more than using relative URL linking.

This blog visualization is cool
This is neat.. http://twingly.se/ScreenSaver.aspx useful? Not so sure, but for sure neat. If I ran windows I would likely install it and play with it some.

Yahoo Pipes
Yahoo Pipes came out, this one one of those things I was interested in blogging about. I even retrieved/reactivated my Yahoo account just to play with this. While I found it very interesting, I can not say I found it highly useful. This idea implemented as an API I could embed in my app server, that would be far more interesting.

There are several other packages like this out there too. xFruits and even www.yourminis.com.

Don't get me wrong, the idea behind Pipes is very much along the route I would like to see things going. Mechanisms to collect, relate and cross reference data generated on the net. I'd just rather have it as an API for my applications rather than a third party service provide to/for me.

Get things done
I was only tangentially aware of the GTD approach. The book has spawned several packages on-line and I reviewed a few of them listed in the post at Center Networks. One, Tracks, caught my eye and I actually installed and got ruby working (which can be a pain with regard to DB access at times). (rant) The Ruby on Rails database API and interface is archaic in comparison to Java JDBC let alone persistence aspects (/rant)

I got it set up and working and played around with it some. It took a while to get this done due to the poor, IMHO, ruby database approach. Anyway, Tracks is interesting, but I think I was more interested in the experience it gave me with Ruby on Rails than anything else. I may try and play with it some more in the future though and revisit it as a utility and approach to time management. On a side note the Joyent package mentioned above is a Ruby on Rails application. The note some interesting news coming from them based on the collaboration with Sun. One might speculate on them switching to jRuby in the near future. jRuby plus the Java VM could be a very powerful combination for an application like this. I am still a Grails person until jRuby evolves more. When it does I will give it a try again.