December 18, 2007

links for 2007-12-18

December 5, 2007

November 26, 2007

links for 2007-11-26

November 21, 2007

links for 2007-11-21

November 15, 2007

Sierpinski Triangle

Inspired by Sam Ruby's Penrose Tiling demonstration this week's programming exercise has been an implementation of a Sierpinski Gasket drawn as an SVG graphic using an L-system in ECMAScript.

To get the progressive drawing effect I made each recursive call to the drawing function via the setTimeout function. With that I found that because setTimeout returns immediately and does not block execution I couldn't pass the operational state of the algorithm via the function's parameters or I would wind up with concurrency issues. This also meant I could not simply iterate through all of the steps in a given rule within one call of the function. I had to actually make successive calls to the drawing function for each element in the current rule. See the source code for the details.

November 1, 2007

links for 2007-11-01

October 17, 2007

September 14, 2007

August 30, 2007

August 22, 2007

Loops

Here's a little "gotcha" that I ran across recently. The following code snippet deletes all of the elements in an array called myArray if they are not greater than zero:.


for (i = 1; i LTE ArrayLen(myArray); i = i + 1) {
     if (myArray[i] LTE 0) {
          ArrayDeleteAt(myArray, i);
     }
}

A bit of background for those that are not familiar with ColdFusion Script.

  • The length of an array in ColdFusion is dynamic
  • ArrayLen() returns the length of an array
  • ArrayDeleteAt() deletes the element from the array at the specified index
  • LTE means "Less Than or Equal"; just like <=

At first glance it appears as though this bit of code should work, but in practice it does not. The reason is due to the fact that when an element is removed from myArray the length of the array changes. Therefore as elements are deleted from the array the terminating condition of the for loop may be satisfied before all of the elements in the array are compared.

I will leave the alternative as an exercise for the reader.

links for 2007-08-22

August 8, 2007

links for 2007-08-08

August 1, 2007

June 13, 2007

June 12, 2007

links for 2007-06-12

June 8, 2007

June 6, 2007

links for 2007-06-06

June 4, 2007

Mythbusters

Matt Haughey: Mythbusters is probably doing more to help steer kids into engineering and adults into DIY/hacking projects than anything else on TV today.

I totally agree. I watch Mythbusters more to watch them build stuff and for the science than to see the result of the experiment. Unless, of course, the experiment ends in a giant explosion.

links for 2007-06-04

June 1, 2007

May 10, 2007

May 4, 2007

May 2, 2007

May 1, 2007

April 25, 2007

April 24, 2007

A List Apart Survey

I took the Web Design Survey at A List Apart. Can't wait to see the results to see how my answers compare to the average.

April 19, 2007

April 18, 2007

links for 2007-04-18

April 17, 2007

Installing PHP on Mac OS X

I'm still using Mac OS X 10.3 (Panther). It came with Apache and PHP4 installed, but I'm starting to use some of the features in PHP5 and wanted to upgrade.

Downloading PHP5 and compiling wasn't difficult, but I had some hurdles to overcome. To make things easier and for completeness I used the configure options shown by the phpinfo() function as a starting point. The configure script ran successfully, but make failed immediately because xmlsave.h could not be found. Not wanting to install any more new libraries than I had to; I avoided installing a new libxml2 and disabled all of the XML options and all was well.

Once I did that I broke down I decided I truly couldn't live without XML support and installed libxml2 via fink and reconfigured the PHP build to use that installation. I also had to install an updated copy of MySQL to resolve some linking issues with the MySQL client extension.

After I was satisfied that it was complete I installed the module and reconfigured Apache to use the shiny new PHP5 module instead of the bundled PHP4 module and life is good.

April 10, 2007

Notes

I take notes. All the time.

While I am working on things I my mind will sometimes briefly switch over to another subject and I will have to write that point down so that I remember to come back to it later. This helps me keep myself on task and also helps me to resist the urge to keep my primary focus on the task at hand. As long as I write it down I know that I can come back to it and that has been working for me.

As a result I will sometimes come home with Post-it notes with all kinds of things scribbled on them. Some things that may appear on my notes are:

  • Ideas for (personal) projects that I am currently working on
  • Lists of topics to Google. These typically include things related to topics I've already been researching.
  • Lists of things that I need to pack for when I go out of town.
  • Lists of things that I need to do tonight before I go to bed.

Problems do arise with this system. Notes get lost. Often times a piece of paper with notes like this will find its way into the hands of a woman or small child. At this point the note becomes useless to me. Not because the contents change, but because I will most likely never see the note again. A note is only useful to me if I can see it.

All points considered, I prefer still prefer to take notes on small pieces of paper and carry them around in my pocket. When am finished with the note it can be easily disposed of in the wastebasket and the note's useful lifecycle is complete.

I am always busy and always thinking about new things. That is why I write notes.

March 27, 2007

Twitter

I just signed up for a Twitter account. My twitter page is http://twitter.com/joeltjen. I don't know if I will use it, but I had to see what all the fuss was about.

January 25, 2007

My favorite Firefox Extensions

I've compiled a list of my some of my current favorite extensions for Firefox.

  • Flashblock - Just about everyone already knows about this. I think it was the first Firefox extension I ever installed.
  • Web Developer - If you are in the business this is a must have. It makes it easy to edit CSS and instantly see the changes. Also allows you to disable the cache, view just about everything that's not normally visible on a page (e.g. element class and id names), and has quick access buttons to common functions like "View Source."
  • Colorful Tabs - Changes the tabs' colors. Makes them stand out a little.
  • Live HTTP Headers - Lets you view the HTTP Request and Response headers for a page. Optionally loads in the sidebar so you can watch them in real time.
  • Session Manager - Saves you tabs, current pages, and browsing history when you exit. The next time you start everything goes back to the way you left it.

I have more, but those are the ones I use most often.

Character Sets

It is sometimes easy to forget the importance of character sets when developing web applications. I would venture to guess that many developers don't know how to handle issues such as BiDi text or correctly handle multi-byte characters. I have spent a considerable portion of the last month experimenting with sending Unicode characters to a web browser and I have discovered a few hints and "gotcha's" that I would like to pass along.

  • PHP is pretty much multi-byte handicapped. Period.
  • In Java servlets (and I suppose JSPs) add the preferred character encoding to the Content-type header before getting the PrintWriter from the response. This will set the encoding of the Writer to the charset in the Content-type header. I was doing unnecessarily wrapping OutputStreamWriters around the HttpServletResponse's OutputStream to accomplish this manually. It's so much nicer (and cleaner) to have the underlying implementation do this for you.
  • Since ColdFusion runs in Java, it too automatically determines the character set and encoding to use from the Content-type header if you specify one. To do this use the <cfcontent> tag like this <cfcontent type="text/html; charset=utf-8">.
  • Here's the gotcha with ColdFusion (and JSP perhaps, I haven't tried it): Templates are read using the platform's default character set, Windows-1252 on English Windows systems. The characters are stored internally as UCS-2 (it's Java after all), and encoded using your specified character set before being sent to the output buffer. This can be overridden with the <cfprocessingdirective> tag.

January 16, 2007

Web Site Theme

I've always been first to admit that I'm handicapped in the visual design area. I've been trying to redesign my web site for a couple of years and each time I get started I get frustrated and give up. I've finally resigned myself to using a canned design from Open Source Templates.

At the same time I'm cleaning up some orphaned files and updating the .htaccess files with redirects that work. I guess I've neglected my web site long enough.

January 1, 2007

Stored Procedures in ColdFusion and MySQL

I started using stored procedures in MySQL from ColdFusion.

I began receiving a NullPointerException when calling the stored procedure with the <cfstoredproc> tag. After checking the syntax I consulted Google for a hint. I found the MySQL JDBC driver that is included with ColdFusion is an older version that does not support calling stored procedures. I downloaded version 5 of MySQL Connector/J and copied the JAR to the shared library directory in my Tomcat installation and restarted.

I then created an "other" datasource in ColdFusion Administrator. I specified "com.mysql.jdbc.Driver" as the Driver Class. Stored procedures now work.