Your leaking thatched hut during the restoration of a pre-Enlightenment state.

 

Hello, my name is Judas Gutenberg and this is my blaag (pronounced as you would the vomit noise "hyroop-bleuach").



links

decay & ruin
Biosphere II
Chernobyl
dead malls
Detroit
Irving housing

got that wrong
Paleofuture.com

appropriate tech
Arduino μcontrollers
Backwoods Home
Fractal antenna

fun social media stuff


Like asecular.com
(nobody does!)

Like my brownhouse:
   code nostalgia
Thursday, December 18 2003
Gretchen and I were awaken this morning by the phone, as usual. This time it was the guy who was coming to make a template of our kitchen counters so they could be replaced with a wild and crazy form of granite (trust me, this isn't the ugly granite you're thinking of). He was already at Exit 17 on the Thruway, and we were supposed to have the old counters ripped off of our cabinets by the time he arrived. So there we were, down in the kitchen, snapping off those old counters in record time. I knew they were going to come off easily, but I hadn't known it would be quite as easy as it was. It reminded me a little about the time I first tore down a SheetrockTM wall mostly with my bare hands.
The guy who came out to do the templating had a funny accent - European of some kind. I couldn't understand the most important words in any of the sentences he spoke, but somehow he made me feel like it was me who was stupid and not he who was incomprehensible. Then I heard Gretchen talking to him and she seemed to have no problem discerning what he was saying. I think part of my problem was unfamiliarity with the matters being discussed. Gretchen had been researching this stuff on the web and talking about it with people on the phone. But it was mostly a big mystery to me. I didn't know, for example, what "finish" meant with regard to granite. I thought the templating guy was asking when I wanted it finished and so I answered "as soon as possible." He just shrugged like I was a moron. My response made no sense. I also wasn't sure whether or not the granite was cut in such a way that it came with a backsplash, so when the guy asked whether or not we'd be getting a backsplash I didn't know what to say.
Further complicating matters was Eleanor's prolonged absence. It turned out that she'd only gone to the downhill neighbors' place, perhaps to root around for ham hocks. But while she was gone, Gretchen and I were in a panic that she'd been hit by a car and was dead in some ditch. [REDACTED]

After much procrastination, I finally got around to doing a major update for the Catskill Animal Sanctuary website. This update featured a display of various farm animals needing sponsorship. At first I was just going to do it the straightforward way and make a big HTML table containing a bunch of image tags and text captions. But then I got to thinking about how to make the system flexible, which it will need to be as animals come and go into and out of the sanctuary. Big messy HTML tables are difficult to maintain, since the ratio of information to formatting instructions is low, and data are hard to find in the monotonously repeating cell layouts. I don't have access to a relational database on the CAS server, but long ago I developed methods for creating database-type systems using either flat files or double-delimited configuration strings embedded in code (the latter being easy to migrate to the former). Using only a backend scripting language like PHP (and a growing library of query functions), I can completely segregate my data from the algorithms that format and display it. Since this particular project would be displaying an array of images with captions, I thought I'd dig through my old code to see how I tackled this problem in the past. There's no sense in re-inventing the wheel.
Fortunately for me, I have a good memory of all the programming projects I worked on back in the heady days of dotcom excess. Equally fortunately, I saved copies of all of that code. In terms algorithmic similarity to the CAS project, the first project that occurred to me was a CollegeClub.com programming job where I built a complete wishlist system (similar at the time to the new Amazon.com wishlist system) using nothing but the ASP FileSystemObject and whatever third party adserver technology we were then using. (You can imagine how much the marketing people loved me, since I could implement such systems rapidly without DBA approval.) I looked through the code looking to see how I handled the arrays of ads and was disappointed to discover that the algorithms were unflexibly designed to generate three-column tables. Mind you, I was impressed with the things in there, but I'd coded this in the Fall of 1999 when functionality still mattered more than elegance and flexibility. I knew I'd done better elsewhere, so I kept my search up. Eventually I found the code fragment I was looking for; it was part of the 2.0 version of the CollegeClub Ecards project. It looked like this:
response.write vbNewLine &  "<table border=0>" & vbNewLine 
	do until rstCategory.eof
		'if rstWorks.recordcount>0 then
			if rstCategory("CategoryID")<>intEcardRoot then
				'response.write rstCategory("CategoryName")
				if rstCategory("CategoryName")<>"untitled" and left(rstCategory("CategoryName"),1)<>"*" then
					if int((intProduced+0)/intDisplayWidth)=(intProduced+0)/intDisplayWidth then
						response.write vbNewLine &  "<tr>"
					end if
					intCategoryID= rstCategory("CategoryID")
					if CategoryInfo(intCategoryID, 1)<>"" then
						response.write vbNewLine & "<td valign=top><center><table height=100% cellspacing=0 cellpadding=0 border=0><tr><td align=center><font face=verdana size=1>"
		
					
						if fso.fileexists(server.mappath("/ecard/category_images/" & CategoryInfo(intCategoryID, 1 ))) then
							response.write "<b><a href=browser.asp?categoryid=" & rstCategory("CategoryID") & ">" & ReasonableString(CategoryInfo(intCategoryID, 2)) & "</a></b></td></tr><tr><td align=center valign=top>"
							response.write "<a href=browser.asp?categoryid=" & intCategoryID & "><img src=/ecard/category_images/" & CategoryInfo(intCategoryID, 1 ) & " width=75 height=75 border=1></a></td></tr><tr><td align=center valign=top>"
							response.write "<font size=1 face=arial>" &  CategoryInfo(intCategoryID, 0 )
							response.write "</td></tr></table>"
							intProduced=intProduced+1
						end if
						intOut=intOut+1
						
						response.write vbNewLine &  "</td>"
					end if
					if int((intProduced+intDisplayWidth)/intDisplayWidth)=(intProduced+intDisplayWidth)/intDisplayWidth then
						response.write vbNewLine &  "</tr>"
					end if
				else
					'response.write "!!!"
				end if
			end if 
		'end if
		rstCategory.movenext
	loop
	response.write  vbNewLine &  "</table>" &  vbNewLine 
 
Wow, looking at that code really made me nostalgic for the good old days when I programmed for a living. The stuff I did on the Ecards project was pretty good despite my tendency in those days for writing spaghetti code. But then, just to remind myself of the algorithmic hurdles I leaped at the height of my career, I looked at the Launch.com hub system publishing code (created in 2001; it still delivers content to the Yahoo.com site). The things I achieved in those days! I was writing complete XML parsing systems all by myself in fucking VBScript. That's almost like building a locomotive using Mayan technology. Or presenting Existentialist Philosophy using nothing but monosyllabic words.

Somehow, though, I got distracted from the task at hand and ended up building yet another copper pipe menorah, this one a possible Chanuka gift for some of Gretchen's maternal second-aunts we may or may not be visiting this weekend. It took me about two hours to make, including the sanding and burnishing that followed the layout, cutting, and soldering.


The menorah I made today, complete with laboratory clutter.
Bathtubgirl sent me Into the Wild recently but I've yet to read it.


Another view of the menorah. There's a picture of Mary Purdy on the floor.

When I finally snapped out of my procrastination, the Catskill Animal Sanctuary stuff went quickly. I converted the formatting algorithm in the aforestated ASP code to PHP and it ended up looking like this:

function animaldisplay($strConfig, $intDisplayWidth)
	{
	$rowdelimeter=chr(13);
	$strConfig=str_replace( chr(10), "", $strConfig);
	$out= chr(13) .  "<table border=0>" . chr(13);
	$arrRows=explode($rowdelimeter, $strConfig);
	$intOut=0;
	$intProduced=count($arrRows);
	for($t=0; $t<$intProduced; $t++)
			{
		 		if (strlen($arrRows[$t])>3)
					{
						if (intval($intOut/$intDisplayWidth)==$intOut/ $intDisplayWidth) 
							{
								$out=$out. chr(13).  "<tr>";
							}
				 
						$arrThis=explode("|", $arrRows[$t]);
						$out=$out. chr(13) . "<td valign=top>";
						$imageurl=$arrThis[0];
						$width=$arrThis[1];
						$height=$arrThis[2];
						$caption=$arrThis[3];
						$name=$arrThis[4];
						$type=$arrThis[5];
						$bigger=$arrThis[6];
						$out=$out .animalcell($imageurl, $width, $height, $caption, $name,$type,$bigger);
						$out=$out. chr(13).  "</td>";
						$intOut++;
						if (intval(($intOut+$intDisplayWidth)/$intDisplayWidth)==($intOut+$intDisplayWidth)/$intDisplayWidth)
							{
								$out=$out. chr(13).  "</tr>";
							}
					}
			}
	$out=$out.  "</table>".chr(13);
	return($out);
	}

I find that it isn't difficult switching between ASP and PHP. Algorithms developed in ASP are so easy to convert to the more C-like environment of PHP that I actively look for the ASP version before attempting to code something in PHP from scratch.


For linking purposes this article's URL is:
http://asecular.com/blog.php?031218

feedback
previous | next