Wed, 12 Nov 2008

Three Years on a Novafoam Mattress

My post about the first night on my Novafoam mattress still gets the most traffic on this blog (although a homework assignment about the French health care system has been remarkably popular the past month or so). Every couple of months, I get an email asking about the mattress. Dale emailed me this morning to ask how we like the mattress after sleeping on it for over three years:

Hi,
In searching the web, I found your blog ("first night on..." on pinkhamster) on
shopping for a Novafoam mattress - now that your blog is more than three years
old, I'd like to hear an update if you could take a moment to let me know (or
add a posting and point me to it) as my wife and I are in need of a new
mattress and no better source than a longer-term customer...
Thanks,
Dale

I'm happy to report that we are still satisfied with our Novafoam mattress. It hasn't lost its support, and it still very comfortable. One thing that I didn't mention in the original post is that motion isn't transmitted laterally much when your sleeping companion moves. It's much better than the bouncing that happens on when sleeping on a cheaper spring mattress or an air mattress. Having spent two nights on an air mattress a couple weeks ago reminded me how much I like our mattress. I think we'll probably buy a King Novafoam mattress when we move to a larger home.

p.s. This season of Penn & Teller's Bullshit! has an episode on mattresses and sleep aids.

misc | Comments | Permanent Link

Fri, 07 Nov 2008

Convert 15-character Salesforce IDs to 18-characters IDs with PHP

Saleforce uses 15-character IDs as primary keys for every record. When retrieving an ID over the API, 18-character case-insensitive IDs are returned. Generally, this doesn't cause any problems because the 18-character version can be used anywhere the 15-character one is. One problem arises though when you are storing IDs in a text field. In this case, you may need to convert a 15-character ID into its 18-character version. Salesforce provides a description of how to perform this conversion.

Here is a PHP implementation of the algorithm.

function sf15to18($short) {
   $chunks = str_split($short, 5);
   $extra = '';
   foreach ($chunks as $chunk) {
      $chars = str_split($chunk, 1);
      $bits = '';
      foreach ($chars as $char) {
         $bits .= (!is_numeric($char) && $char == strtoupper($char)) ? '1' : '0';
      }
      $map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345';
      $extra .= substr($map, base_convert(strrev($bits), 2, 10), 1);
   }
   return $short . $extra;
}

tech » salesforce | Comments | Permanent Link

The state is that great fiction by which everyone tries to live at the expense of everyone else. - Frederic Bastiat