Coding, humour

What’s the color of your name?

 

As a programmer, you learn every day. It doesn’t always have to be a new technology or some state of the art or special stuff. Sometimes it can be just fun stuff you didn’t know yet, just like I discovered something very funny today.

As you may or may not know, the geeks out there on the world wide web sometimes have their own kind of humor. Maybe you know such a person in your family, it could be a friend or maybe you’re just one of them, just like me.

This morning I stumbled upon a strange but quite funny sort of easter egg in color parsing in HTML documents. Apparently, this is a remainder of the old Netscape days. For those of you who don’t know what Netscape is: Netscape Communications was known for its Navigator browser, which was one of the 2 most popular web browsers back in the 90s.

In web design, colors can be defined by using RGB color codes. These codes generate a color based on the Red, Green and Blue values, which are hexadecimal values. Now the real power is that ANY WORD can be converted into a valid hexadecimal value, so your name as well. It goes as follows:

Let’s take the name of our blog ‘Coemgenius’.  We first start off with removing any #’s and replacing all the non-hexadecimal characters (from 0 to 9 and from A to F) with 0’s.

E.g. ‘ #coemgenius ‘ becomes  ‘ c0e00e0000 ‘

Then we need to add 0’s until the length is a multiple of 3.

‘ c0e00e0000 ‘ has a length of 10, so the next multiple of 3 is 12, so it becomes ‘ c0e00e000000 ‘

Next, when the length is longer than 4 characters, we break it into 3 even parts, which will represent the red, blue and green values.

‘ c0e00e000000 ‘ broken into 3 even parts gives us RGB(c0e0 , 0e00 , 0000)

Now we only have to trim the values individually by removing characters from the right until there are 2 digits remaining.

Trimming RGB(c0e0 , 0e00 , 0000) will leave us with the result  RGB(c0 , 0e , 00), better known as #c00e00 = RGB(192 , 14 , 0)

 

So now you know what’s the color of my name and how to convert any other name or word, so there is only one question remaining:

What’s the color of YOUR name?