What if Facebook could auto-tag uploaded photos?

Facebook could become the ultimate platform for training facial recognition systems. Almost every photo uploaded to the site is of someone. The first thing that you do is to tag the people in the photo, creating a link between the photo and the related person.

But what would happen if the tagging process worked in conjunction with facial recognition technology? Every time a person was tagged in an image you could help the system learn what that person looks like. Eventually the system could become “smart” enough to recognise people on its own.

Auto-tagging photos – it’s the way forward, and you heard it here first!

Check constraints that access the table you are inserting into

In SQL Server 2005 you can write a check constraint that can include a function call. For example:

ALTER TABLE [dbo].[TestTable1]
ADD CONSTRAINT [TestConstraint1]
CHECK ([dbo].[TestFunction1]([PrimaryKeyColumn1],[Column1],[Column2]) = 0)

However if the function you are calling tests the contents of that table you must be aware that the row you are trying to insert or update will already be in the table. Therefore if part of the test is, for example, duplicate checking or date range checking (in the case of writing scheduling software) then you must pass into the function the primary key of the row you are inserting and add that as a where clause to your function:

CREATE FUNCTION [dbo].[TestFunction1]
(
@param1 int,
@param2 int,
@param3 int,
)
RETURNS bit
AS
BEGIN
DECLARE @ClashesFound int
DECLARE @Result bit
SET @ClashesFound = 0
SET @Result = 0
SET @ClashesFound = (
SELECT COUNT(*)
FROM [dbo].[TestTable1]
WHERE
[PrimaryKeyColumn1] <> @param1
)
IF (@ClashesFound > 0)
SET @Result = 1
RETURN @Result
END

Researchers put circuits on contact lenses, freak out rabbits

Engadget have been writing that researchers have discovered a way to embed electrical circuits including lights and logic into contact lenses. This sounds pretty cool to me and I think it would be great to have a head-up display as you walk around. It could tell you where you are, the time, how to get somewhere, information about the person you are talking to (good for business meetings where I can never remember a persons name)  or even allow you to watch TV.

I wonder if Specsavers will be selling them.

SQL code to test a date range against existing ranges in a table

The following slice of code will search a table and return any rows where there is a clash between the date range in the row (ValidFrom and ValidTo) and the date range in the variables (@InTo and @InFrom).

Null dates are treated as either infinite past or infinite future accordingly.

WHERE
NOT (
(@InTo < ValidFrom AND @InTo IS NOT NULL AND ValidFrom IS NOT NULL)
OR
(@InFrom > ValidTo AND @InFrom IS NOT NULL AND ValidTo IS NOT NULL)
)