Marketing 101. Consulting 101. PHP Consulting. Random geeky stuff. I Blog Therefore I Am.


The FuzzyBlog!

January 2003
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Dec   Feb

Updated: 2/1/2003; 5:47:32 AM.
Search

My Newest Product!

  • Makes email not suck!
  • Works with Outlook
  • Eliminates Spam
  • Color Codes Your Email

Appreciation

Give me a Gift

Amazon Honor System Click Here to Pay Learn More

Books I've Written







Marketing

 Tuesday, January 21, 2003

Goodbye Sunny, Rest in Peace

As a cat owner I don't know what I'd do if I lost one of mine.  Ealasaid says it nicely:

Sunny was the perfect cat to have for a child - patient with being held awkwardly or dressed up in doll clothes or put in an upside-down laundry basket to be a 'tiger' in a 'zoo.' When I was very little and the cats were still allowed upstairs, he sometimes would sleep on my bed until it was time for the cats to be fed. He wandered away from home three times when I was little, but we always found him again and once he got out of his wandering years he never strayed far and always came in for dinner. [_Go_]


9:08:03 AM      Google It!   comment []    IM Me About This   

How Annoying is This? or Always, Always Blame the Data !

I was just debugging code as part of Mark's new online magazine Tekka.  I wrote the login code and the way we wanted it to function was that if you tried to view something you didn't have access to then it would display a preview of the content (we originally were going to have it automatically create the previews based on the source text but we opted to create them manually to make sure that everything looked as good as possible; it made sense since the preview is essentially "marketing" for the article itself). 

What started happening over the weekend was that the previews worked fine for content I created.  Of course as soon as the real content and previews flowed into the "system" (and I use the term "system" loosely; very loosely) then we started to see errors.  In specific we saw that the previews were getting arbitrarily clipped.  Now the previews I had made were quite short (probably between 1K and 4K of data) and the real ones were much longer. 

Of course the very first thing I thought of was some kind of byte size limitation.  I knew that I was passing a much larger chunk of content into my templating class and perhaps that was it.  So I merrily plunged into Google looking for information on string size limits in PHP.  Sigh.  Since Google seems to treat the extension of a url as a word (at times; it is bizarre) within the url's content it means that searching for PHP content can be difficult at times.  I did find a most helpful bit of content on string size limits in BEALogic application servers though.  Nothing to do with PHP of course but helpful to someone I guess.  So then I delved into the source code for the templating library, FastTemplate.  Nothing. 

Then I stopped reacting and started thinking.  Yes that is the hardest part of debugging and one that all of us just plain hate to do.  What I did was setup a simpler test case, pulling JUST the display code out of the logic and then taking my own data and making it larger.  No problem.  Worked fine.   ###?*($#*#  (fill it in).  Hrm...  Then I started thinking about the content I was getting from Mark and what I knew about it.  Well I know Mark is an all Mac shop so I started to wonder about lower order ASCII characters being hidden in the content.  You know -- what about ASCII 17?  Or ASCII 3?  So I scp'd the content back to my own server Windows box and used a gui editor.  Sure enough there turned out to be two ASCII 0s embedded in the content EXACTLY where the content was being truncated.  Mark and I hashed it out and I'm still not sure where these came from but it really doesn't matter.  He made sure to get rid of them and so did I. 

What was happening was that the ASCII 0s were acting to truncate the string of preview content as it was passed to the display method.  I ended up adding this to the routine before passing the content off for display:

$preview = str_replace("\0","",$preview);

Moral of the Story? 

  1. Think before debugging.
  2. Simply your test case as much as possible.
  3. Check the data; even invisible things can screw you up.

9:04:09 AM      Google It!   comment []    IM Me About This