Gareth Lennox

Refracted

So I’ve decided to start posting my own photo’s onto a dedicated photo blog, you may have noticed the photos appearing in the sidebar (the wonders of rss!). If you’re interested in photography, you might find it interesting. The blog’s address is http://refracted.co.za/. I’m not going to be posting any more photos on this blog, other than the ones in the sidebar.

On the name

Its tricky coming up with unique, short names that can be turned into domain names. I came up with refracted.co.za the other day, and it seems quite fitting, as when a photograph is created, the light cannot help but be refracted and bent, firstly by the interface between the glass in the lens elements and the air (it’s related to the speed of light in the different mediums – see wikipedia for more information), and by the lens elements themselves.

How to sort rated items

This is a fascinating article:

PROBLEM: You are a web programmer. You have users. Your users rate stuff on your site. You want to put the highest-rated stuff at the top and lowest-rated at the bottom. You need some sort of “score” to sort by.

The article goes into detail about how all the most common sorting algorithms are incorrect. We implemented a system a while back, using wrong solution #2 (from the article), and had all sorts of issues with things getting sorted incorrectly. The proposed algorithm looks rather scary though.

Need to keep this in mind when I next implement a rating-based system.

UPDATE: Another article, now bringing in a time component.

Commented out code

One of my pet peeves is opening a source code file, and seeing half of it commented out, or blocks within it commented out. What’s wrong with this?

Commented out code serves no purpose, other than to confuse.

If you try uncomment it, chances are that the code around it has changed, and the uncommented code now won’t even compile.

Also, when reading the code and trying to understand it, the chunks of commented out code get in the way. “Should I be taking this code into account, or not?”

A lot of the time it is not obvious as to why it is commented out. I’ve seen lots of pieces of code commented out, with no reason given as to why. Maybe the developer was testing something and forgot to uncomment the code before checking in? Or is it old code that was not needed any more (then why is it still here?).

Code is usually commented out when the developer is not sure if the code will be needed in the future, and is leaving it there “just in case”.

Ultimately, you don’t need to keep commented code around. Your source control system can handle it. As long as you comment your commit properly, its a matter of 5 minutes work to find the old code and resurrect it.

SARS Scam

I’ve just noticed a new SARS (South African Revenue Services if you’re not South African!) related scam. The e-mail you receive is worded as follows:

Tax Notification

After the last annual calculations of your fiscal activity we have determined that you are eligible to receive a tax refund of ZAR xxxx.xx.
Please submit the tax refund request and allow us 48 hours in order to process it.

A refund can be delayed for a variety of reasons. For example submitting invalid records or applying after the deadline.
To access the form for your tax refund, click here

Regards,
South African Revenue Service (SARS)

Document Reference: (92054568).

The click here link (which I’ve removed) takes you to a very legit looking SARS site, but, its not hosted on any SARS domain, and is not SSL encrypted. The site asks you for your full name, your credit card details (including the PIN number).

I’m pretty sure SARS doesn’t need your credit card details to refund you!