java ruby

if they’re the same thing do nothing, if they’re different things do something

So I’m inspired by this post at the Daily WTF. The problem happens quite a lot in Java and I’m sure I’ve come across it myself at least once.

The central issue is, how do you safely (i.e. no NPE!) and cleanly compare two values where both could be null?

It’s only a small challenge, I grant you, but the code sample they have at WTF will return false if two Boolean’s have the same value, including nulls.

article finance

refused by my own credit scoring system!

My wife and I recently purchased a new car. After much looking around on the market and test driving and the like we decided to purchase a vehicle through a company that I had previously worked for.

I agreed to purchasing the car on 0% finance and was promptly taken to a private room to go through their credit searching system. No one was as surprised as me to discover that the credit searching system I had worked on 10 years previously, at the finance arm of the company, was still functioning and was about to credit check me!

There was a brief moment when I had to cast my mind back to make sure that I hadn’t left any ‘testing’ back doors in the application that I might trigger if I was to apply but then I remembered that I had not because I had a feeling that one day it might come back to haunt me. Relieved about this I settled down to the long drawn out question and answer process that is credit scoring in the UK. But then something strange happened (room spins)

database sql

rozenshtein method for pivoting relational data

I came across this blog entry while trying to make up for the fact that SQL server 8 does not have the PIVOT statement that I needed. It’s taken from a book (that I don’t have) by Rozenshtein on advanced database queries.
The blog explanation is lengthy and a little confusing but the idea is deceptively simple. It hinges around being able make a column expression that can ‘select’ data.

database sql

secondary school mathematics that was almost useful

For the first time in my career I came across the need to make use of a PRODUCT() SQL aggregate function today. To my dismay SQL Server 8 doesn’t have such a function and so I figured out it can be simulated by use of logarithims and the SUM() function (since (log10(a) + log10(b))^10 = a * b) Therefore my query could read:

SELECT POWER(10, SUM(LOG10(value)))
FROM table

But this query doesn’t work if there are negative numbers in the PRODUCT() list because LOG10(x) where x<0 is undefined. Guess what, there’s a bunch of negative numbers in my list. Arghh …