revjim.net

January 19th, 2004:

Inklog: HEEEEEEEEEEEEEEELP!

This is driving me crazy. I get so close to being done, and then I realize that I’m not.

I having this huge debate with myself over the way to handle a particular (very important and central) feature. But arguing with myself isn’t very productive. I need a nerd, stat.

Here’s the shortened version of the problem. There are 14,000,000 ways to do anything, I want the best one. At this point in the system, a user has requested to view an object. It doesn’t really matter what but, for fun, we’ll say it’s a page in an image gallery with all the thumbnails of the pictures on it. I’ve narrowed it down to two ways of doing it.

The first method would put most of the work in the gallery handling code. This means that it’s written in PHP and isn’t really meant to be edited by everyday users. In this case, the gallery code would access a configuration variable to determine how many thumbnails to show on a page. Then it would access a parameter passed to it to determine which page the user was requesting. Then it would get the images that were requested and prepare them to be displayed. Then it would pass all of this information on to a template. The template (which should be easily editible by those who know a little HTML) would then cycle through the images and display them. The template would handle deciding when to start a new row and, therefore, must have some notion of how many thumbnails have been requested for each page, although it doesn’t have to… it just means that all of the pages might ALWAYS not have enough images to fill the last row in the display. This is a nice option because the code in the template is kept to a minimum.

The second method is much more flexible, however it puts a lot more code in the template. Instead of using a configuration variable to determine how many items are on a page, the template actually requests the number of items that it would like. This is faster because the data doesn’t have to be preprepared. It’s also more flexible because the template is the source for important information like the number of thumbnails on a page. If the website owner should choose to change how a page looks, she wont have to update the template and the configuration. Just the template will do. However, the code looks MUCH more complex.

Allow me to give you an example of each version of the code.

Simple Template:

<html>  <head>    <title>      Gallery    </title>  </head>  <body>    <p>      <a href="{$selfurl}/{math equation="x - 1" x=$page}">        PREVIOUS PAGE      </a>      |      <a href="{$selfurl}/{math equation="x + 1" x=$page}">        NEXT PAGE      </a>    </p>    <table>      {section name=thumbnail loop=$thumbnails}        {if $smarty.section.thumbnail.index mod 3 eq 0}          <tr>        {/if}        <td>          <p>            <a href="{$thumbnails[thumbnail].url}">              <img src="{$thumbnails[thumbnail].imgsrc}" />            </a>          </p>          <p>            {$thumbnails[thumbnail].description}          </p>        </td>        {if $smarty.section.thumbnail.index_next mod 3 eq 0}          </tr>        {/if}      {/section    </table>  </body></html>

Complex Template:

<html>  <head>    <title>      Gallery    </title>  </head>  <body>    <p>      <a href="{$selfurl}/{math equation="x - 1" x=$pageparams.page}">        PREVIOUS PAGE      </a>      |      <a href="{$selfurl}/{math equation="x + 1" x=$pageparams.page}">        NEXT PAGE      </a>    </p>    <table>      {getchildren type="image" num="9"         start="$pageparams.page * 9" assign="thumbnails"}      {section name=thumbnail loop=$thumbnails}        {if $smarty.section.thumbnail.index mod 3 eq 0}          <tr>        {/if}        <td>          <p>            <a href="{$thumbnails[thumbnail].url}">              <img src="{$thumbnails[thumbnail].imgsrc}" />            </a>          </p>          <p>            {$thumbnails[thumbnail].description}          </p>        </td>        {if $smarty.section.thumbnail.index_next mod 3 eq 0}          </tr>        {/if}      {/section    </table>  </body></html>

In case it’s hard to tell the difference, look at the "getchildren" command being issued in the second template. That’s the biggest change between the two. The nice thing about the second version is it gives the template author so much more power. So many other cool things can be done if the templates work in this fashion. However, this means that the template author must know that he is looking for children of this node that are of type "image". Without this knowledge, her template wouldn’t display any thumbnails at all.

Or maybe there’s a better way. Tell me how YOU would propose the template should look to allow a user to display any number of thumbnails on a page. Anything. Please. I’ll entertain any and all suggestions.

Microsoft allegedly sues Mike Rowe

According to a Slashdot article and Mike Rowe’s website (currently VERY slow due to the article on Slashdot), Mr. Mike Rowe (17) is being sued by the Microsoft Corporation for trademark infringment due to his "confusingly similar" domain name, MikeRoweSoft.com. Microsoft allegedly offered him $10 (which was to include all out-of-pocket expenses) for the domain name. When Mr. Rowe responded stating that his time, effort and materials were worth at least $10,000 the Microsoft corporation filed a law suit through the Canadian Law Firm Smart & Biggar claiming that the MikeRoweSoft.com domain was purchased in bad faith.

Something smells fishy about this whole thing. So I’m not sure how legit I believe it to be just yet.

*nix under MIcrosoft?

Sure, there’s Cygwin. They’ve done a good job. But if I’m going to do it, I want to do it right. I want real integration with Windows. I want windowing integration, and file system integration. I want to have the same users in both places. I want real telnet and and ftp. I want them all to run perfectly, and I want them to be as *nixy as *nix itself.

Well, thanks to Microsoft, this is possible now. Microsoft has updated their Windows Services for Unix package. With this package comes a Perl Interpreter, Korn and Bash, Bind, FTP and Sendmail. Even GCC and all the libraries. [via Anil Dash]

Thank you, Microsoft.

A day off?

I’m very bad at remembering when my company has a holiday and when we do not. I thought that, just maybe, we had today off for Martin Luther King Day, but we don’t. Apparently — I had to ask my dad — we used to have it off. But, as of this year many of the days that we used to get off have been converted to floating holidays (synonymous in almost every way with "vacation day"). So, I don’t get today off.

Weight Loss: week 1 (192.6)

I’ve started a weight loss program… again. This time, I’m not doing anything too drastic with the way that I eat. That’s why I’ve failed every time I’ve tried in the past. I’m not coutning calories or carbohydrates, or anything like that. Doing so only pisses me off because I hate being told I can’t have something, especially when I’m the one telling myself such things. So, I’ve all but cut out soda from my diet. If I do drink soda, I drink Pepsi One. Additionally, I’m trying to eat less refined sugar and less enriched flour. I’m also trying to do my best to eat 4 small meals each day, as opposed to a small lunch and a huge dinner. This should keep my metabolism up much higher.

This "diet", alone, might be enough to keep me from gaining weight, but I want to lose weight. So, I’ve begun an excersize program as well. Again, I’m not being a maniac about it, because if I do, I’ll never keep up with it. Instead, here’s my routine. Every other day I spend 20 minutes on some sort of cardio-vascular machine. I spend another 5 minutes warming up and another 5 minutes cooling down. I don’t have a heart-rate monitor, so I just play it by ear. On the remaining days, I engage in 10 minutes of cardio-vascular and then perform 2 sets of 10 on 7 different machines working 7 different muscle groups. I use as much weight as I can possibly handle for the 10 lifts and I go as quickly as I possibly can while making sure that I am doing the exercize properly. I’ve been doing this for about a week now and it seems to be going well.

I’d like to lose 40 pounds of fat and gain 15 – 20 pounds of muscle. That would put my weight around 170ish. Right now, I’m a hair over 190 which isn’t horrible. But, if you consider the amount of muscle mass I have — very little — it’s not so good. Last week, my first week, I skipped only two days. That’s pretty good for me especially in my first week. I’m begining to learn when good times are for me to go and different ways to motivate myself. I think I’m catching on. Every monday morning, if I can remember, I’ll post my weight so you all can cheer me on.

Weight: 192.6