Archive for the ‘Open Source Software’ Category

Slick Little JavaScript Function to Parse GET Variables in URL

Monday, October 26th, 2009

I was messing around this morning trying to parse the HTTP GET variables in JavaScript so that my web app could "see" the arguments passed into it, and act on them accordingly. This was something that the users have asked for in the alerts from my web app - a link back to the web app so that they can easily "drill down" to the data to see what the alert was really all about.

So I did some Googling on this and I was very pleased to find something like this:

  /**
   * This function parses all the GET variables for the current page
   * and returns a map of the key/value pairs to the caller. This can
   * be used in some pages to get these GET variables for processing.
   */
  function parseGETVars() {
    var retval = [];
    var urlChunks = String(document.location).split('?');
    if (urlChunks[1]) {
      var pairs = urlChunks[1].split('&');
      for (var i = 0; i < pairs.length; ++i) {
        if (pairs[i]) {
          var parts = pairs[i].split('=');
          retval[parts[0]] = unescape(parts[1]);
        }
      }
    }
    return retval;
  }

with this, I can then simply parse the GET variables into a global (page) variable and then use it in the code to see what I need to see.

With this, I was able to pass into one of my pages, the default portfolio to show - as opposed to the first one in the available list. It's a pretty slick little thing. Very nice.

Adium 1.4b12 is Out

Saturday, October 24th, 2009

The beta releases of Adium are coming more quickly now. It seems that maybe they hit a critical point in the Snow Leopard conversion or got through a particularly nasty bug. In any case, 1.4b12 is out today and I had to get it. It's just too much a part of every day usage.

The Black Magic of Optimizing SQL Queries

Wednesday, October 21st, 2009

OK, so maybe it's not really Black Magic but putting yourself in the place of the query planner/optimizer is a really big help. For instance, today I was working on trying to get a little more speed out of the following H2 (JDBC) SQL query:

  SELECT acquired, portfolio, leadFuturePrice, pnlSumNet
  FROM RAT_FirePortfolio
  WHERE acquired >= '2009-10-20 00:00:00'
  AND acquired <= '2009-10-20 23:59:59'
  AND portfolio NOT IN ('ED_NRML')

and the requests were returning in excess of 120,000 rows of data in about 600 - 775 msec. Not bad for an in-memory database, but I was thinking that the use of the "not in ()" was going to slow down the execution of the query because it would have to check each of the row's portfolio fields against each of the elements of the list. Not ideal.

So I got the idea to change it to a more direct version:

  SELECT acquired, portfolio, leadFuturePrice, pnlSumNet
  FROM RAT_FirePortfolio
  WHERE acquired >= '2009-10-20 00:00:00'
  AND acquired <= '2009-10-20 23:59:59'
  AND portfolio <> 'ED_NRML'

So I coded that up. At the same time, I realized that the exclusion of 'ED_NRML' was really a transitional artifact and was no longer needed. There are times when we drop data sources, and this keeps the new version from falsely showing the existing, but old, data. Now that we have completely transitioned off that, we didn't need it and the query simplified to:

  SELECT acquired, portfolio, leadFuturePrice, pnlSumNet
  FROM RAT_FirePortfolio
  WHERE acquired >= '2009-10-20 00:00:00'
  AND acquired <= '2009-10-20 23:59:59'

The times for this guy are in the 50 - 57 msec. Amazing!

We're looking at a factor of ten by removing the test. Now I had suspected that the "not in ()" clause was a little bit of an issue, but I had never guessed it was 90% of the time! That's amazing.

I'll never doubt again. I need to really hit these queries and make sure they are as clean and simple as possible. Simply amazing.

Adium Beta 1.4b10 is Out

Wednesday, October 21st, 2009

I was chatting with friends today and Adium let me know that 1.4b10 was available for updating. I had to say Yes to that! There's a lot of new things in this release - including a new release of libpurple. They are certainly be careful and getting a lot of things fixed in this release, and as long as it's running well on Snow Leopard, I'm content letting them get things done at their own pace. I just would like to know that things run well on Snow Leopard, and I'm not getting the sense of a lot of confidence in that area.

Soon, maybe. I hope.

Upgraded to WordPress 2.8.5 at HostMonster.com

Wednesday, October 21st, 2009

I was looking this morning to see if Tomcat of some kind was available at HostMonster - just in case I was interested in doing a little servlet work or something like that, and found that while they don't support Tomcat, they do support PHP (knew that), and there was an update for WordPress to version 2.8.5.

WordPress is one of the most common platforms, and as such it's open to all kinds of hackers. This means that I need to stay as up to date as possible to make sure I don't get hacked. So I took the few minutes and got everything up to the stable release and now I'm ready to keep going.

Just feeling a little safer. I'll have to find a Tomcat install somewhere else.

Miro 2.5.3 is Out

Monday, October 19th, 2009

I wanted to like Miro, as I like the concept behind it - Community Commons licensed content scoured from the web and displayed in a nice application, but it's the content that has left me wanting more. What's there is nice, but it's just not the content I was looking for. Even so, Miro 2.5.3 is out, and I decided that I needed to get it just on the off-chance that I'll someday find that the content is there, and I'll have a nice tool for viewing it. Hope springs eternal.

Blender 2.49b is Out

Thursday, October 15th, 2009

Blender 2.49b was released this morning and I had to get it. Yeah, it was all about fixes for the game engine part, but I still love it. It's one of the only places that still has a download link for the Irix OS. Cool.

Firefox 3.5.3 is Out

Thursday, October 15th, 2009

With another round of security and stability fixes Firefox 3.5.3 is out. Pretty standard stuff, just needed to update and we're done. Simple, but very effective. Use it every day.

MacVim Snapshot 50 is Out

Monday, October 12th, 2009

MacVim.jpg

This morning I noticed that Björn has released MacVim Snapshot 50 which is now Intel-only and 10.5 or later. I can understand his reasons, and completely agree - it's what most people have, it's the future, and the code still compiles on the older machines and OS versions, it's just not something that he's going to spend time building.

It's wonderfully fast on Snow Leopard on my laptop, and I have to say, if I only had one editor to use for the rest of my professional life, I'd be happy using Vim. It's just that good.

iTerm 0.10 is Out – Long Time Coming

Friday, October 9th, 2009

This morning I noticed that iTerm 0.10 was finally out, and I have to say, it's been ages since a real update to this guy. It's nice, but they are still missing the ability to have workspaces, and the one thing they have that I like is the ability to remove the scrollbar. I've come to terms with this and Terminal.app seems OK to me. Wish I could turn off the scrollbar, though.