codeRambler Ramblings on code, the web, and technology

Happy 25th birthday to the Compact Disc
Friday August 17th 2007, 4:04 pm
Filed under: Ramblings

Today the CD turns 25 years old! On 17 August 1982 the first CD rolled off the production line in Hanover, Germany and began our love affair with this forefather of optical technology.

Here are a list of useful factoids about the humble CD and it’s 25 year history to date:

  • The first CD to be manufactured was “The Visitors” by ABBA.
  • The original target capacity for a CD was one hour. However, this was extended to 74 minutes to accommodate a complete performance of Beethoven’s 9th Symphony.
  • In 1985 Dire Straits album “Brothers in Arms” became one of the first fully-digital recordings (DDD) to be brought to market and became the first album to sell more than one million copies (in CD format).
  • Since the first CD was pressed, Phillips estimates more than 200 billion CDs have been sold worldwide.

The introduction of the CD started a revolution in the music industry. In the early 80’s tapes were being demonized as destroying Vinyl – but clearly the CD was more of a threat to both. Now we are about to embrace Blu-Ray as an optical media standard for storing large amounts of data (hi definition video and data). How long before we shelve the CD in favour of something with more “punch”?

Thank you, Phillips and Sony, for the Compact Disc.

Comments Off

From The Book of Mozilla
Friday August 17th 2007, 9:38 am
Filed under: Web development

I’m sure that many of you use Firefox regularly. You may have typed about:config into your browser location bar to manage your internal browser settings.Another useful variation of this is about:cache which will show the browser cache and allow you to view individual items in the cache.Today I stumbled across another one! If you type about:mozilla into the location bar, you get presented with a passage from the “Book of Mozilla” (a play on a religious text):

And so at last the beast fell and the unbelievers rejoiced.But all was not lost, for from the ash rose a great bird.The bird gazed down upon the unbelievers and cast fireand thunder upon them. For the beast had beenreborn with its strength renewed, and thefollowers of Mammon cowered in horror.from The Book of Mozilla, 7:15

The thing I like about programming is that you can sometimes have fun doing this kind of thing. The reference above refers to the name change from Phoenix (the name of the original 2002 project) to Firefox – and reassures it’s followers that the project lives on.Now… time to have some fun…

Comments Off

How much is too much caffiene?
Wednesday August 15th 2007, 5:13 pm
Filed under: Ramblings

A news report recently surfaced on the BBC news website about a 17 year old girl who reportedly overdosed on caffiene.

After downing 7 double espressos in her family-run sandwich shop, she started to suffer side effects including laughing and crying before being sent to hospital for observation (she was later discharged home after a few hours).

Regardless of whether she thought they were single or double shots of espresso (the article indicates she thought they were singles)… why was a 17 year old drinking 7 cups of espresso in the first place?!

I love espresso but I never managed to get such an extreme reaction from over indulging (although I did have a fun morning after drinking 4 doubles once).

So I listed my top 5 beverages and found out just how much caffiene is in each of them:

Name Amount
Coca-Cola Zero 355 34.5 10
Diet Coke 355 45.0 13
Coffee (Instant) 237 57.0 24
Starbucks Grande Latte 473 116.0 25
Coffee (Espresso) 44 77.0 175

So 7 cups of single shot espresso would be about 540 mg of caffiene. Double that (she was drinking double shots of espresso) and you’re talking about 1000 mg of caffiene. The same as scoffing 5 double-strength No-Doz pills!

I’m off for a coffee.

Comments Off

Tips on converting strings into numbers
Monday August 06th 2007, 10:29 am
Filed under: Javascript, Web development

When you are reading a value from a text input, the value is returned as a string. This is not really a problem for Javascript in that it’s loosely typed and converting the string into a number is really straightforward.

As with most things, there are several ways to do this conversion. I’ve used parseInt() a lot in the past to convert a string into a number (although strictly speaking I am converting to an Integer rather than just a Number when using parseInt()), but recently ran into some strange behaviour that I wanted to understand.

var l_sValue = "07";
alert(parseInt(l_sValue)); // alerts 7

This seems to work fine, the string represents the number 7, and the parseInt() correctly parses it into the integer 7. Now we change the string value and something strange occurs:

var l_sValue = "08";
alert(parseInt(l_sValue)); // alerts 0

This is obviously not the expected result! The solution is to use parseInt() correctly, and pass through both parameters (the second parameter is the number base to use).

If you do not pass in the second parameter (the base, or radix) then Javascript will default to base 10, unless:

  • the string starts with ‘0′, then it will default to base 8 (octal)
  • the string starts with ‘0x’, then it will default to base 16 (hexadecimal)

Because the string we used above started with ‘0′, Javascript defaulted to use base 8. The reason we see 0 being returned from parseInt(’08′) is because 8 is not a valid number in octal (we would count in octal 0, 1, 2, … 6, 7, 10, 11, 12, … 17, 20, 21, …).

Now look what happens when we pass in the second parameter and use (the more familiar) base 10:

var l_sValue = "08";
alert(parseInt(l_sValue, 10)); // alerts 8

Lesson for the day: always pass in the base when using parseInt() to parse a string into an integer.