Archive for March, 2008

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.