Entries in Web (41)

Saturday
Feb132021

The BBC Weather Website

For many years now I have used the BBC Weather website as my main source of weather information. I link directly to the forecast for Reading (https://www.bbc.co.uk/weather/2639577):

The forecast is presented in two rows. The upper row gives a summary forecast for each day in the coming two weeks.  If you click on a particular day then the lower row shows a summary forecast for each hour of that day. Nice and simple, or it should be.

Unfortunately there are a number of things wrong in the implementation that annoy me intensely.

1.  Each day starts at 6am and continues till 5am the following day.  Now I understand that BBC television and radio program listings have always started at 6am (or at least since programs first extended past midnight).  They wanted to break the listings at a time when fewest people would be affected. But this is weather and weather is continuous.  It is just plain stupid to force people to click on Sunday 14th to get the forecast for 5am Monday 16th. And yes, people are affected by this stupidity. Until recently I was getting up at 5am to travel to work and one the first things I would do each day was look at the BBC Weather. I always had to remember that it was yesterday's 5am forecast that I wanted.


2.  Click the right arrow in the lower row to see the forecasts for the first few hours of the following day:

The lower row moves left and now shows forecasts up to 5am the following day.  The right arrow is now disabled and instead we have a link "See more weather for Monday 15th".  This is totally unnecessary.  The arrow could have been left enabled and link omitted and 3 more hours displayed instead.  The only reason I can see for having the link is to explicity move on to the next day in the upper row.  But that can just as well be done with the right arrow.  Making it clear which hours in the lower row belong to which day in the upper row might need some care but it wouldn't be too difficult.

3.  The worst thing about the site are the temperatures shown in the top row.  They appear to be maximum and minimum temperatures for each day but they do not match the maximum and minimum hourly temperatures for the days in the lower row.  For example: on Sunday 14th the hourly figures show 2C at 6am and rise steadily to 7C the following midnight yet the upper row shows a range of 6C to 7C which is clearly wrong. In general the maximum figure in the top row is accurate but the minimum is often grossly misleading.

Now I think about it, 3 is probably just a plain bug. The daily max and min are being calculated over the wrong range of hours or something like that. If so then it is no wonder the developer got confused with all the previous obfuscations over what is a day.  1 and 2 might be results of the developer not having the confidence to say "No this is stupid! I will do it the proper way" or not having the experience to recognise the proper way.

Another thing that occurs to me is that all the data on this page could have been shown just as effectively in one or two simple HTML tables.

Sunday
Oct252020

Linking to a Github Repository

In general, when you link to a Gihub repository you should include the #readme fragment in the URL instead of just linking to the bare repository URL.  This means users don't have to scroll down to find out what he repository holds. For example: you should prefer

https://github.com/rust-lang/rust#readme

over:

https://github.com/rust-lang/rust

Saturday
Mar162013

RVM SSL Certificate Errors

The Ruby Version Manager RVM is one of the key components in a Ruby development environment on non-Windows platforms.

Yesterday I wanted to install it on my Ubuntu laptop.  The recommended way of doing is to run the following command in a terminal:

curl -L https://get.rvm.io | bash -s stable

Unfortunately this gave SSL certificate verification errors.  Visiting rvm.io in Firefox and Chrome indicated that this was due to the site's security certificate having expired.

A little Googling revealed the recommended workaround which is to use Gihub instead of rvm.io:

curl -L https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
Sunday
Dec302012

How to Inhibit Escaping in Rails3 ActionView Custom Helpers

I had bits of code like this scattered throughout my Rails3 views:

  <%= image_tag(thumbnail_image_path(@image.id)) %>

I wanted to enclose each image_tag call in a <div></div> pair to allow styling, so I wrote the following custom helper and placed it in app/helpers/application_helpers.rb:

  def thumbnail_block(image_id)
    "<div>#{image_tag(thumbnail_image_path(image_id))}</div>"
  end

I then replaced the calls to image_tag in my views with calls to thumbnail_block:

  <%= thumbnail_block(@image.id) %>

However, instead of displaying the images, this displayed the HTML code in the browser window.  Rails3 was automatically escaping the string produced by the new custom helper.

A search on Google lead me to this answer by Mike Fisher at StackOverflow and this post by Yehuda Katz at Rails Dispatch.  These gave me the solution: the custom helper needs to mark the string as html_safe before returning it:

  def thumbnail_block(image_id)
    "<div>#{image_tag(thumbnail_image_path(image_id))}</div>".html_safe
  end

Now my images display properly.

Thursday
Jan262012

CodeIgniter Error Reporting

 

CodeIgniter is a popular PHP framework for building websites. I have long suspected that the way it reports errors was unnecessarily complicated. Well, last week I finally got round to really trying to understand what was going on.  The above diagram summarizes what I learnt.  Click through and select 'download' to see a larger version.

This information applies to my current setup which is CodeIgniter 2.1.0, PHP 5.3.2 and Apache 2.2.14 all running under Ubuntu 10.04 LTS.  There might be some differences for other setups.