Archive for the ‘Uncategorized’ Category

View YouTube videos in high def

Wednesday, March 26th, 2008

YouTube offer a higher definition version of their videos. It doesn’t seem to be available by default. You need to append this string to the end of your URL, and reload the page:

If you have Firefox, you can add this as a Bookmarklet. Then when you are viewing a video on the YouTuby website, click this bookmarklet, and the page will reload in HD.

Here is the bookmarklet

Right-click, and select “Bookmark this link”, or just drag it into your Bookmarks Toolbar.

View in HD

More details are available on the YouTube blog

spec’ing with BigDecimal

Wednesday, March 26th, 2008

If you are creating specs comparing BigDecimals to a hard coded float value, you may find that some comparisons just dont work even when the numbers are supposedly the same (see Floating point accuracy problems)

What we are testing is the value and the type, the correct way of achieving this may be…

If you want to round the big decimal to a float with 2 decimal places you could also use

Installing Git on Mac OS X 10.5 Leopard

Saturday, March 15th, 2008

I’m a recent convert to Git, and have had trouble finding decent installation instructions for Leopard. Here are the steps I followed to successfully install Git on Mac OS X 10.5.2 Leopard.

Prerequisites

  1. The OS X Developer tools installed from the Leopard DVD
  2. Download the latest Git source package from git.or.cz
  3. Download the latest version of Gettext

Step 1: build and install Gettext

Gettext is required for building Git. If you don’t have it available, you’ll get an error such as:

First extract the archive:

Next, read any updated instructions and build it:

Finally, install it

Step 2: build and install Git

These instructions are fairly similar, except for a small configuration setting. Again, extract the archive:

Next, read any updated instructions and build it. If you omit the --prefix setting, git will be installed into your ~/bin directory.

Finally, install it

Once this is complete, you should be able to run it. Try this:

That should do it!

mail_queue

Monday, March 10th, 2008

We recently switched www.sharesight.co.nz to use mail_queue, a ruby on rails plug-in. This helped decouple our application from the mail server – improving the performance of page request/response times and isolating any mail server problems away from our application.

We have ended up making a few tweaks to the plug-in, detailed below:

The tweaks

  1. Added a sent flag onto the queued_mails, so we keep all mail sent out from our server. This proves may not be required but gives us a little confidence in seeing the sent mail, when it was queued and when it was sent, and provides an added bonus – if needed (in times of trouble) to reset the flag and have the mail sent out again.
  2. Added a failure count on the queued_mails, if a mail message is failing, we increase the count and the process will retry again during the next sweep – giving up on the message after several retries.
  3. Increase the size of the object to store the mail

Some problems we experienced

With large emails the ‘text’ field in mysql was not large enough to store the entire email message . The mail object then failed to be created and with no exception handling in place the email queue was blocked by one overlarge corrupt email – hence the failure count and the increase from text to mediumtext for the mail object.

With a large number of queued emails, the mail server started rejecting emails (due to our limited email account plan we are currently on) – and responding very slowly – this caused the MailQueue.process job to run before the previous job had completed – causing some emails to be sent twice – arghhh – hence see additional enhancements below.

Additional enhancements (TODO)

  1. Ensure that the process can not run – by either synchronising with a database flag (in_process) or exiting the process before the next one starts by keeping a tab on the time taken to run.
  2. Use backgroundrb to start the processing so the whole ruby environment does not have to be loaded every minute to check for mail.

Abletech develops Sharesight

Sunday, December 16th, 2007

Able Technology has designed and developed Sharesight – an online share portfolio management system. The system has been developed using Ruby on Rails and MySQL with interfaces to ASX, NZX and Strikeiron. Registered users have access to alerts, automated dividends and reconstructions, annualised performance reports and tax reports.

Abletech invites anyone wishing to try out the system to use the ‘secret’ campaign code: abletech

“www.sharesight.co.nz”:http://app.sharesight.co.nz/signup?campaign_code=abletech

Updated: My Auctions Gadget for TradeMe

Sunday, May 20th, 2007

There is a new release of the My Auctions Gadget for TradeMe. This new release adds a number of new features. Changes include:

* a new website – “www.trademe gadgets.com”:http://www.trademegadgets.com/my_auctions/
* time till auction ends
* visual refresh – cleaner layout

More information can be found in “my posting to the TradeMe Gadgets Google Group”:http://groups.google.com/group/trademe-gadgets/browse_thread/thread/c15dd6f98c2c123.

TradeMe Gadget for iGoogle

Thursday, May 10th, 2007

I’ve been trialling the new TradeMe API that Rowan Simpson announced yesterday by building an iGoogle gadget called the “TradeMe Member Details Gadget”:http://www.trademegadgets.com/my_auctions/. It takes your TradeMe ‘username’ and displays a list of your current auctions and their prices.

Screenshots and further details are available on “Nigel’s Blog”:http://blog.wellies.org/post/1608836

URL Anchors conflict with JavaScript focus routines

Wednesday, April 4th, 2007

I have been using some simple JavaScript to focus and select the contents of an form input box when a page first loads. But, was finding that it only works intermittently.

h3. Websphere Portal

To add some context, we’re using Websphere Portal – and it has some unique behavior. When you load a page that has a portlet embedded in it, it adds a hidden anchor near the top of the portlet. The portal-generated URL to the page includes an anchor to the portlet that generated the “render event”.

The standard behavior is that the browser jumps to the position of the referenced anchor when the page has finished loading.

But, if you have an inline JavaScript command to set focus to a field, it will only have focus for the small period of time. This is between the JavaScript commands running, and when the page finishes loading. Note: this is the behavior in Firefox.

h3. Solutions

There are two options for resolving this issue:

# Disable the use of anchors; or
# Connect your initialisation/focusing routines to the “onload” event

Tumblr blogging engine

Monday, April 2nd, 2007

We’ve been trailing a new blogging engine called “Tumblr”:http://www.tumblr.com/. Technically, it is called a “tumblelog”:http://en.wikipedia.org/wiki/Tumblelog – an online scrapbook of sorts. Both Koz and I now have it up and running for our personal blogs.

Check out “Nigel’s Blog”:http://blog.wellies.org and “Koz’s Web”:http://tumble.koziarski.net/ to see the working product.

Introducing Ruby on Rails to your workplace

Saturday, February 17th, 2007

Perhaps you are an architect or a software developer working for a large company. You would like to try out using Ruby on Rails for that next project coming along at work. It would be a perfect fit, so you speak to your boss and he says *NO*.

In this paper, we will explore how to change that answer to *YES*.

h3. Risk

The main reason why your manager said “no” is because of risk. Managers are afraid of risks – in fact, it is part of their job description to mitigate any risks. Introducing a new programming language and a new application framework are two very big risks that most managers will avoid.

h3. Baby steps

To minimise the perceived risk, we need to take “baby steps”, or small increments along the pathway to introducing Ruby on Rails. If you can show the Ruby technologies being used successfully in some lower risk scenarios, then your manager may be willing to try it out for a larger project.

h3. Our experience

Some of our clients are beginning to trial Ruby for very simple tasks. Others are now using it for intranet style applications. Some have totally embraced the Rails framework, and are using it for all of their new development.

h3. Watir

“Watir”:http://wtr.rubyforge.org/ provides a Ruby API for controlling the Internet Explorer web browser. This may not sound particularly exciting, but if you combine this product with the unit testing abilities of Ruby – you have an excellent functional testing tool.

There is also a Firefox variant being developed called “FireWatir”:http://wiki.openqa.org/display/WTR/FireWatir+-+WATiR+for+FireFox

We have used Ruby and Watir for developing the functional test scripts for several clients – with excellent success.

h3. Scripting

Ruby is a scripting language. If you have a scripting task to perform, it may makes sense to use Ruby for achieve it. An advantage to scripting in Ruby (compared with shell scripts), is that they can be easily run on Windows too.

There is a new book from the Pragmatic Programmers called “Everyday Scripting with Ruby”:http://www.pragmaticprogrammer.com/titles/bmsft/index.html which may be worth a look.

h3. Scaffolding

As most Rails developers know, scaffolding is not intended to be used by end users. But, an opportunity you have is to use Rails scaffolds for data maintenance.

It is possible to devote a lot of effort in building data maintenance screens – for just one or two system administrators. What you can do instead, is to use the scaffolding approach to quickly build some basic, yet functional administration screens.

h3. Fixtures for test data

The fixtures facility that is built into Rails provides a powerful way to define and maintain test data. You can use the Rail based fixtures in combination with your Java or C# based application. All of your test data will be defined in a YAML file, and you use rake to deploy it.

You could also define your database schema with the Ruby migrations facility. And then push out your schema changes in an iterative manner.

h3. Intranet applications

Before you build a public web application based on Rails, you probably want to try it out internally first. This will allow you to become familiar with some of the non-coding features of Rails. For example, you will need to learn the appropriate way for your organisation to deploy the application, the database schema, batch tasks, load balancing, etc.

h3. Conclusion

Deploying any new technology can be a risky business. These risks can be minimised by taking small steps along the pathway towards the goal of a fun, productive web development.

h3. Further reading

Why not read some of our other “papers”:papers, or subscribe to our “Blog”:blog. Feel free to “contact us”:contacts for more information.