<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Joe Fleming dot net &#187; Web Development</title>
	<atom:link href="http://joefleming.net/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://joefleming.net</link>
	<description>what you see is what you get</description>
	<lastBuildDate>Wed, 26 May 2010 19:25:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Serving Files in Internet Explorer over HTTPS</title>
		<link>http://joefleming.net/2010/05/11/serving-files-in-internet-explorer-over-https/</link>
		<comments>http://joefleming.net/2010/05/11/serving-files-in-internet-explorer-over-https/#comments</comments>
		<pubDate>Tue, 11 May 2010 21:34:13 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Computers & Technology]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[https]]></category>

		<guid isPermaLink="false">http://joefleming.net/?p=163</guid>
		<description><![CDATA[I recently came across a problem where serving a file to Internet Explorer would result in the following error message.

This affected IE6, IE7 and IE8 in my testing. The way I was serving the file was through PHP via readfile. Before sending the contents of the file, I was, of course, setting some header parameters [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across a problem where serving a file to Internet Explorer would result in the following error message.<br />
<a href="http://joefleming.net/wp-content/uploads/2010/05/Untitled.jpg"><img src="http://joefleming.net/wp-content/uploads/2010/05/Untitled-300x200.jpg" alt="" title="IE_Error" width="300" height="200" class="alignnone size-medium wp-image-164" /></a></p>
<p>This affected IE6, IE7 and IE8 in my testing. The way I was serving the file was through PHP via <a href="http://us2.php.net/manual/en/function.readfile.php">readfile</a>. Before sending the contents of the file, I was, of course, setting some header parameters so that the browser would handle the file and the user wouldn&#8217;t just see some binary garbage on their screen. In my case, I was serving a PDF file that was being generated server-side and sent to the client. The basic header parameters are as follows:</p>
<p><code>// We'll be outputting a PDF<br />
 header('Content-type: application/pdf');<br />
 // It will be called your_file.pdf<br />
 header('Content-Disposition: attachment; filename="your_file.pdf"');<br />
 // declare Files Size here (for the sake pf peoples sanity, please add this<br />
 header('Content-Length: '.filesize($filename));</code></p>
<p>This works just fine in most situations, but once you introduce a secure connection, IE fails with the above error. Of course, like most IE problems, this doesn&#8217;t happen in any other browser. Ugh.<br />
<span id="more-163"></span><br />
Luckily, I noticed some additional parameters in the first example on the readfile page, namely the &#8216;Pragma&#8217; parameter. Reading some comments on the header function, I stumbled upon <a href="http://www.php.net/manual/en/function.header.php#88038">this one</a>. It basically, says that once you add HTTPS, you need to also tell IE how to handle caching the file. So now, my headers look like this:</p>
<p><code>// Force clear cache<br />
header('Pragma: public'); // Fix for IE<br />
header("Expires: 0");  //always expire<br />
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');<br />
// We'll be outputting a PDF<br />
header('Content-type: application/pdf');<br />
// It will be called your_file.pdf<br />
header('Content-Disposition: attachment; filename="your_file.pdf"');<br />
// declare Files Size here (for the sake pf peoples sanity, please add this<br />
header('Content-Length: '.filesize($filename));</code></p>
<p>Directly following these header calls is the readfile call and a call to exit to stop the script from executing anything else and alert the browser that the entire file has been delivered. </p>
<p>It seems like the Pragma parameter controls how browsers handle caching, and adding the other cache parameters to the header are just added enforcement. Now, IE works exactly as expected and I&#8217;ve got happy clients once again!</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2010/05/11/serving-files-in-internet-explorer-over-https/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Asynchronous PHP</title>
		<link>http://joefleming.net/2009/10/16/asynchronous-php/</link>
		<comments>http://joefleming.net/2009/10/16/asynchronous-php/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 18:46:53 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://joefleming.net/?p=144</guid>
		<description><![CDATA[I needed to &#8220;asynchronous PHP&#8221; recently and it took me a little while to find the solution. What my script basically does is generate a PDF file for the user to download based on some parameters they have chosen. The problem was, the PDF generate take a while and during that time I needed to [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to &#8220;asynchronous PHP&#8221; recently and it took me a little while to find the solution. What my script basically does is generate a PDF file for the user to download based on some parameters they have chosen. The problem was, the PDF generate take a while and during that time I needed to show the user a screen explaining that the file was being generated, which would also show the download link once the generation was complete. My setup is as follows:</p>
<p><strong>generate.php</strong></p>
<blockquote><p>This script is where the user is sent when they click &#8220;download&#8221; on the parameter choice page. This is where the asynchronous magic has to happen. From here, the user is immediately sent to <em>download.php</em>.</p></blockquote>
<p><strong>download.php</strong></p>
<blockquote><p>This script gives the user either a &#8220;please wait&#8221; message of a &#8220;click here to download&#8221; message, depending on where the target PDF has been generated yet.
</p></blockquote>
<p>My problem was, even though was added the header redirect code (shown below) to <em>generate.php</em>, the browser would still wait for the PDF to be generated before sending the user to <em>download.php</em>. In other words, it was only synchronous PHP, which didn&#8217;t help me at all.</p>
<p><code>header("Location: download.php");</code></p>
<p>Thanks to <a href="http://www.php.net/manual/en/features.connection-handling.php#89177" rel="ext">this comment</a> on php.net, I was able to make it work! Basically, you need to tell the browser that you are done sending it data, even though the PHP script will keep executing. Code below:</p>
<p><code>//redirects the browser to the new url, but continues processing in the background<br />
        function redirect_and_continue($sURL) {<br />
                header( "Location: ".$sURL );<br />
                ob_end_clean();<br />
                header("Connection: close");<br />
                ignore_user_abort();<br />
                ob_start();<br />
                header("Content-Length: 0");<br />
                ob_end_flush();<br />
                flush();<br />
                session_write_close();<br />
        }</code></p>
<p>So, the user is sent to <em>generate.php</em>, which immediately calls <em>redirect_and_continue(&#8216;download.php&#8217;)</em>, redirecting the user to <em>download.php</em> while still continuing to execute <em>generate.php</em> (and make the PDF file). Once the user is at <em>download.php</em>, the script checks for the existence of the generated PDF file (as indicated by the filename sent through the session) and uses a <a href="http://en.wikipedia.org/wiki/Meta_refresh" rel="ext">meta refresh tag</a> in the HTML to keep reloading <em>download.php</em>. Once the PDF file exists, it provides the user with a link to the PDF file for download.</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2009/10/16/asynchronous-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a Better CAPTCHA</title>
		<link>http://joefleming.net/2009/01/03/building-a-better-captcha/</link>
		<comments>http://joefleming.net/2009/01/03/building-a-better-captcha/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 05:46:29 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Computers & Technology]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://joefleming.net/?p=47</guid>
		<description><![CDATA[CAPTCHAs can be good for stopping SPAM, but the last thing most of them are are usable. Don&#8217;t take my word for it, it&#8217;s a fact. One of the coolest ideas I ever saw was a HotOrNot mashup where you had to pick the three best looking ladies to prove you are a human. It [...]]]></description>
			<content:encoded><![CDATA[<p>CAPTCHAs can be good for stopping SPAM, but the last thing most of them are are usable. Don&#8217;t take my word for it, <a rel="ext" href="http://www.johnmwillis.com/other/top-10-worst-captchas/">it&#8217;s a fact</a>. One of the coolest ideas I ever saw was a <a rel="ext" href="http://valleywag.gawker.com/246656/tech/hot-or-not/a-face-only-a-bot-could-love">HotOrNot mashup</a> where you had to pick the three best looking ladies to prove you are a human. It was both usable and easy for a normal person, like my Grandparents, to use. That&#8217;s pretty unique and hard to come by, and that&#8217;s why I liked it.</p>
<p>One of the other easier CAPTCHAs I&#8217;ve <a rel="ext" href="http://selectitaly.com/contact.php">used at work</a> is a little dynamic images that asks you to do a little simple math. It&#8217;s an idea I saw on another site so I thought I would give it a try and it&#8217;s been extremely effective despite it&#8217;s ease of being broken. Surprisingly, it has completely stopped all SPAM coming through our contact form.</p>
<p>Another one I tried, much less effectively, is a colored word and a dropdown with a number of colors to choose from. It literally asks &#8220;What color is this text?&#8221; and offers a number of possibilities. This, however, was not effective for more than a week or so. The form still sees about one or two SPAM messages a day, which is especially strange because it&#8217;s a site that sees far less traffic. I think if I added more colors that weren&#8217;t even valid selections and changed the order it might be more effective, but I still need to find something better.</p>
<p>I&#8217;m thinking a system that would show three images and ask which one doesn&#8217;t belong could be usable, but it&#8217;s a little more difficult to implement; where do I get the images, how do I randomize the data, etc. I really like the HotOrNot CAPTCHA because the images always change and all of the images and data are crowdsourced, nothing for you to manage.</p>
<p>So, what can one do? Sadly, I don&#8217;t have an answer, but there is a lot of work being done on the topic. I think I need to just keep looking and mull this all over for a bit. We&#8217;ll see what I can find or come up with.</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2009/01/03/building-a-better-captcha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal&#8217;s On Hold</title>
		<link>http://joefleming.net/2008/11/17/drupals-on-hold/</link>
		<comments>http://joefleming.net/2008/11/17/drupals-on-hold/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 23:16:14 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://joefleming.net/?p=41</guid>
		<description><![CDATA[I know I said before that I would be replacing Wordpress with Drupal around here, and I did start working on that. However, the more I read about Drupal, the harder it seems to do custom things. Actually, it&#8217;s more a problem of poor documentation than it is a lack of flexibility. Still, if I [...]]]></description>
			<content:encoded><![CDATA[<p>I know I said before that <a href="http://joefleming.net/2008/08/18/farewell-wordpress/">I would be replacing Wordpress with Drupal</a> around here, and I did start working on that. However, the more I read about Drupal, the harder it seems to do custom things. Actually, it&#8217;s more a problem of poor documentation than it is a lack of flexibility. Still, if I don&#8217;t know what I&#8217;m doing, it&#8217;s hard to learn anything.</p>
<p>Granted, I could easily replace Wordpress for the sake of my blog here (and probably still will at some point), but that&#8217;s not why I was planning to learn it. I wanted something that would allow me to crank out new pages quickly without constantly restarting from scratch. I do have a very weak framework I&#8217;ve written to try to achieve this, but every time I start a new site, I feel compelled to re-do at least part of it, so in the end I don&#8217;t save any time. In fact, I lose time because I have to re-learn the changes I made for each site when I need to maintain them.<br />
<span id="more-41"></span><br />
A while back, I started looking into frameworks to use at work. I&#8217;m still enthralled with <a rel="ext" href="http://www.symfony-project.org/">Symfony</a>, but it&#8217;s way too hard to just jump in to. In order to take advantage of all of its niceties, there&#8217;s a lot you need to learn. It&#8217;s almost like learning a new language on its own, which is fine and all, but it doesn&#8217;t help me get things done quickly. It&#8217;s hard to be motivated to learn new frameworks and techniques unless you have something to work on, and any new projects I have need to be done in a timely manner, so I can&#8217;t take too long to jump into something new.</p>
<p>Anyway, one other framework that stood out when I we were doing our research was <a rel="ext" href="http://codeigniter.com/">CodeIgniter</a>. Not because it&#8217;s better, but because it has more of an a-la-carte mentality. Don&#8217;t want to use the full MVC design pattern? No problem, just use the parts you want to; you can use it as a simple controller mechanism only if you so choose. Don&#8217;t feel like getting into a full <a rel="ext" href="http://en.wikipedia.org/wiki/Object-relational_mapping">ORM</a>? Skip it, they have a built-in ActiveRecord style interpreter, which means you don&#8217;t need to create your own class for each table in your database. Of course, ou can write your queries completely by hand if you choose to too. Best of all, no command line magic to make your code work, and on top of it all, the entire framework is 3.3MB with the user guide included, under 2MB without it.</p>
<p>I&#8217;ve spent a couple nights reading through the documentation (which is pretty well done) and I already have a good understanding of how it all works. And, since it&#8217;s almost Christmas again, it&#8217;s time to get my annual list manager online again. So, I&#8217;ve got a new tool to play with and a simple project to do it with. As a result, Drupal&#8217;s on hold while I work on that. I&#8217;ll report back on how it goes.</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2008/11/17/drupals-on-hold/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Farewell Wordpress</title>
		<link>http://joefleming.net/2008/08/18/farewell-wordpress/</link>
		<comments>http://joefleming.net/2008/08/18/farewell-wordpress/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 03:09:07 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Site News]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://joefleming.net/?p=30</guid>
		<description><![CDATA[In an effort to save time when I put together sites for people, I&#8217;ve been working on a universal engine I can use. It is modeled loosely off the MercuryBoard code and, for the most part, has served me pretty well. Recently, I&#8217;ve tried to revamp it with more object oriented code, integrating PEAR and [...]]]></description>
			<content:encoded><![CDATA[<p>In an effort to save time when I put together sites for people, I&#8217;ve been working on a universal engine I can use. It is modeled loosely off the <a href="http://www.mercuryboard.com/">MercuryBoard</a> code and, for the most part, has served me pretty well. Recently, I&#8217;ve tried to revamp it with more object oriented code, integrating PEAR and a few other niceties. Still, the more and more I use it, the more I realize it saves me very little time. In fact, it actually costs me time when I have to go back and update the sites. It seems, sadly, the idea of a flexible CMS or framework is just too abstract for my skills.</p>
<p>I&#8217;ve spent some time reading about <a href="http://www.symfony-project.org/">Symfony</a>, which looks like an amazing project. I&#8217;m positive I can make it do anything I would need, but the learning curve is pretty steep and I&#8217;m worried that the time I&#8217;d take to learn it wouldn&#8217;t really pay off in the end. I like a lot of the concepts, but I&#8217;m just not completely sold on it.</p>
<p>So what does that have to do with Wordpress? Well, I&#8217;ve recently revisited a project that I spent some time with in the past but never really did much with. That project is <a href="http://www.drupal.org/">Drupal</a>.<br />
<span id="more-30"></span><br />
While it&#8217;s not nearly as flexible as Symfony is, it seems like a very useful platform for putting a site together. I followed a quick tutorial last week that outlined just how easy it was, and after reading through their <a href="http://drupal.org/getting-started">Getting Started</a> guide, I&#8217;m pretty sure it can be bent into anything I might need. To me honest, most of the sites I&#8217;ve put together didn&#8217;t really need much of anything.</p>
<p>But, again, how does this relate to Wordpress? Well, I&#8217;ve grown tired of Wordpress, and it seems like Drupal would make for a great blogging tool. I have no doubt that I could add a lot more than a simple blog should I choose to as well, which makes it that much more appealing. From what I&#8217;ve seen, it also runs significantly faster than Wordpress does, which is always a nice perk. </p>
<p>So, in an effort to spend more time using and learning Drupal, I&#8217;m planning to port all of my Wordpress posts to Drupal and use it exclusively to run this site. Worst case scenario, I end up with nothing more than a blog running on Drupal. That&#8217;s not too different that the blog I have running on Wordpress now, so that&#8217;s not too bad of a worst case. Look for the change to happen soon (hopefully this week). You&#8217;ll know when it happens as it&#8217;s unlikely I&#8217;ll spend the time working on a theme just yet, so this site will live in default Drupal mode while I continue my Drupal education. Fun stuff!</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2008/08/18/farewell-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A History of Coding and Computers</title>
		<link>http://joefleming.net/2008/08/02/a-history-of-coding-and-computers/</link>
		<comments>http://joefleming.net/2008/08/02/a-history-of-coding-and-computers/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 21:49:37 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Computers & Technology]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://joefleming.net/?p=26</guid>
		<description><![CDATA[Apparently one of the people Aaron works with called him out on his programming and computer use history and he posted his response on his blog. In that blog, he took the liberty of calling out a few of his friends, myself included. I put off responding because my computer crapped out on me again. [...]]]></description>
			<content:encoded><![CDATA[<p>Apparently one of the people Aaron works with called him out on his programming and computer use history and he <a href="http://aaronstaves.com/2008/06/21/software-development-meme/">posted his response on his blog</a>. In that blog, he took the liberty of calling out a few of his friends, myself included. I put off responding because my computer crapped out on me again. Now that I&#8217;m back up and running, here is my response. Enjoy.<br />
<span id="more-26"></span><br />
<strong>How old were you when you started programming?</strong></p>
<p>Technically, we started writing BASIC on Apple some Apple IIe&#8217;s (if memory serves me right anyway) in kindergarten. It was all very simple and I don&#8217;t really consider it programming, but that would be the answer to the question. In grade school I started tinkering with QBASIC a little, making some simple calculation programs and stupid little things. I would consider this a more appropriate answer to the question since the kindergarten experience was more of less &#8220;copy what&#8217;s on this piece of paper and see what it does&#8221;.</p>
<p><strong>What was your first language?</strong></p>
<p>As stated in the last question, it was BASIC. I didn&#8217;t actually play with anything besides BASIC until I was in high school and I took a class in C. Truth be told, I was more curious how computers worked than how to make them do what I wanted. I&#8217;m not really an avid programmer and I consider myself more of a scripter than a programmer. Still, I get paid to write HTML, PHP and Javascript all day long, so I guess I am a professional programmer. But I digress&#8230;.</p>
<p><strong>What was the first program you wrote?</strong></p>
<p>Aside from some really simple QBASIC stuff (mostly to speed up math homework in grade and middle school), I didn&#8217;t write a &#8220;real&#8221; program until the C class in high school. I did some things in a Hypercard class I took, but let&#8217;s be honest, Hypercard doesn&#8217;t really write &#8220;real programs.&#8221; Anyway, our final project in the C class was breakout which was actually a pretty fun project. Learning how to do animation, collision detection and I/O through the arrow keys was pretty fun. </p>
<p>The requirements were as basic as you could expect, but you got extra credit for adding your own touches. I remembered playing versions of breakout that would move the ball at different speeds and angles based on where on the paddle you hit it and if the paddle was moving, so I added that to it. Overall though, it was pretty basic, but also a lot of fun. For whatever reason though, I didn&#8217;t really care to write in C.</p>
<p><strong>What languages have you used since you started programming?</strong></p>
<p>Let&#8217;s see if I can do this in order of when I learned them:</p>
<p>BASIC / QBASIC, C, C++, HTML, Access, Visual Basic, PHP, MySQL, CSS, Javascript, bash, Assembly (68HC11), VHDL, Python, Perl. Some I learned while I was in school, the scripting languages I learned pretty much all on my own and are really the only languages I care to use. I&#8217;m still learning Python and Perl.</p>
<p><strong>What was your first professional programming gig?</strong></p>
<p>Actually, the job I have now with Select Italy is the first programming gig I&#8217;ve had. You could call the freelancing I did before that job my first programming gig I guess, but it didn&#8217;t make me a ton of money and I wasn&#8217;t drawing a paycheck from it per se.</p>
<p><strong>If you knew then what you know now, would have started programming?</strong></p>
<p>I don&#8217;t think I would have changed much. I probably would have spent some more time learning programming principles but I&#8217;m pretty happy with the languages I know.</p>
<p><strong>If there is one thing you learned along the way that you would tell new developers, what would it be?</strong></p>
<p>Even more important though, &#8220;release early, release often&#8221; is a good motto to live by. You&#8217;ll never get things right the first time through. One of my co-workers said just yesterday &#8220;there&#8217;s never time to do it right, but there&#8217;s always time to do it over&#8221; and I think it sums up that mentality even better. I&#8217;m still working on taking that advice myself though.</p>
<p><strong>What’s the most fun you’ve ever had programming?</strong></p>
<p>Ever since I learned the MooTools library, it&#8217;s the only thing I&#8217;ve been wanting to look at. I think it&#8217;s really cool to take something that was &#8220;finished&#8221;, spend a couple minutes adding some flair to it and seeing just how much cooler it looks when you are done.</p>
<p><strong>Who am I calling out?</strong></p>
<p>There are a lot of people I&#8217;d like to call out, but none I know that maintain a blog. Since <a href="http://jasonsidabras.com/">Jay</a> still hasn&#8217;t followed up on Aaron&#8217;s calling him out, I might as well call him out myself.</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2008/08/02/a-history-of-coding-and-computers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mootools, I Choose You</title>
		<link>http://joefleming.net/2008/07/04/mootools-i-choose-you/</link>
		<comments>http://joefleming.net/2008/07/04/mootools-i-choose-you/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 15:00:53 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://joefleming.net/?p=24</guid>
		<description><![CDATA[I&#8217;ve always been a &#8220;do it yourself&#8221; kind of web developer, but after reinventing the wheel time and time again and struggling to make my code work in the various different browsers out there, I&#8217;ve come to appreciate that I can save a TON of time through different libraries and toolkits. I&#8217;m no Javascript pro [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been a &#8220;do it yourself&#8221; kind of web developer, but after reinventing the wheel time and time again and struggling to make my code work in the various different browsers out there, I&#8217;ve come to appreciate that I can save a TON of time through different libraries and toolkits. I&#8217;m no Javascript pro (though I am the resident guru at work), but I find the language interesting. Ever since Google came along and showed the world that Javascript can be used for more than just popups and other web annoyances, I&#8217;ve been enthralled with some of the cool things people have done with Javascript. From <a href="http://en.wikipedia.org/wiki/AJAX">AJAX</a> to <a href="http://en.wikipedia.org/wiki/Comet_(programming)">Comet</a>, simple <a href="http://www.dynamicdrive.com/">DHTML</a> to <a href="http://script.aculo.us/">animations</a>, it&#8217;s simply been an amazing evolution.</p>
<p>About a year ago, Aaron tipped me off to the magic of Javascript toolkits, specifically <a href="http://dojotoolkit.org/">Dojo</a>. For a while, I was a proponent of it, opting to use it exclusively to drive an internal application that I had written from the ground up at work. It&#8217;s an extremely powerful toolkit which has been steadily adding more functionality as it ages to that point that it&#8217;s arguably the most powerful toolkit on the market. Unfortunately, I&#8217;ve also found it to be one of the most poorly documented toolkits available as well, which I&#8217;m sure was due in part to my lackluster understanding of some of the more advanced Javascript concepts. Still, looking at some of the more advanced Dojo examples I&#8217;ve seen from Aaron and other sources online, most of the syntax escapes me completely, even as I continue to learn more and more about Javascript.<br />
<span id="more-24"></span><br />
At the time I started using it, I was working with version 0.4.1, and as anyone with some Dojo experience can attest, it&#8217;s a far cry from where the 0.9 and and later branches ended up. I&#8217;ve since upgraded to 0.4.3, but porting everything over to the 1.0 branch would have taken about as much time as moving over to a completely different library. The 0.9+ branches also officially did not support Safari 2, which was a huge problem considering we&#8217;re an all-Mac shop. It also meant that production-side adaptation was pretty much out of the question as it&#8217;s a safe assumption that the majority of people using any software are drastically behind on their updates, if they ever even choose to perform them. For a company that makes most of its money by sales through the website, we just can&#8217;t afford to exclude and entire sector of people like that.</p>
<p>With all that in mind, I decided I&#8217;d poke around and see what else was out there as a possible Dojo replacement. A couple months ago, Aaron tipped me off to <a href="http://www.mootools.net/">MooTools</a>, which seemed like a nice mix of <a href="http://www.prototypejs.org/">Prototype</a> and the Scriptaculous animation library that was built on top of it. I had passed it on to my boss as something to check out but it was kind of left at that, though I did plan to learn it on my own time.</p>
<p>About a month after that, we hired a new designer at work, mostly so my boss could focus more on PHP and MySQL code and not just the design of both the site and various ads (which had become a full-time job). During his first week there, the new guy happened to stumble across the MooTools library on his own and suggested that we use some of the animations in the library to spruce up the site a little, though he knew absolutely nothing about Javascript. Of course, being the resident Javascript guru in the office, I was asked to look into what it would take to make it work. </p>
<p>I had spent a little time the previous week sifting through the APIs and docs of various other toolkits and libraries to try and narrow them down into a proper replacement for my aging Dojo code. I had actually planned to start making use of the <a href="http://extjs.com/">Ext toolkit</a> since it was a good compromise for Dojo; the code and feature set were very similar and their API and documentation was much easier to follow than that of Dojo. But, it wasn&#8217;t enough for me to consider introducing yet another Javascript library into the code base, and it made no guarantee about working with Safari 2. </p>
<p>Of the two other programmers in the office, one had been using <a href="http://jquery.com/">jQuery</a> for about as long as I had been using Dojo while the other had just started to implement MooTools into another piece of software he had written from the ground up. Since those two were already in out code base, they scored extra points and earned my attention over some of the other libraries. </p>
<p>Since MooTools was called for in the case of this particular animation, I spent a little time reading through the <a href="http://docs.mootools.net/">API</a> and the <a href="http://clientside.cnet.com/wiki/mootorial">Mootorial</a> and picking apart some of the <a href="http://demos.mootools.net/">demos</a> available on the MooTools site. To my surprise, it started to make sense very quickly; their API is extremely well put together (with a few fringe exceptions), I found the code and syntax very easy to comprehend, and best of all, I managed to get the animation working in only a few hours having never worked with the library in the past. </p>
<p>I then proceeded to port all of my Dojo code to MooTools, and in about two days time I was done. I even added some snappy fading and scrolling animations to the system with gave it a really nice polish. It all loads significantly faster to boot! I took another day and a half and added some drag-and-drop functionality that I had been planning since very early on in the project, something I still don&#8217;t even know how to approach with Dojo but made quick work of with MooTools, even adding heavy modifications to meet my specific needs. I&#8217;ve also learned a ton more about Javascript, written my own MooTools menu class from scratch (mostly as a learning experience) and rolled out some cool new things to our production website. I&#8217;ve drunk the milk and now I&#8217;m hooked. I can&#8217;t imagine ever working with raw Javascript again to be honest.</p>
<p>But, MooTools isn&#8217;t for everyone. It&#8217;s meant to be more of a core library that you extend and use to build your applications quickly. It also has one very significant downside; like Prototype, it extends the base Javascript prototype, meaning it could break existing code you have. It&#8217;s probably rare that it would (I haven&#8217;t run into it personally), but it&#8217;s a consideration. It also doesn&#8217;t play well with other libraries and toolkits as a result.</p>
<p>The point of this long-winded post is simply that I have become a huge MooTools fan, and if you have a project that would benefit from a well-documented, cross-browser library with some really easy animations and extremely useful functionality, you may too. Check it out, I think it&#8217;ll be worth your time.</p>
<p>One note I want to make is that I wrote this before MooTools 1.2 was released. For the record, I love the changes that were made; it&#8217;s much faster, there are a lot of cool tweaks that make it easier to use and it adds a lot of very useful new methods. That said, I think their new documentation page and demos page are just terrible! In addition, they&#8217;ve completely disabled their forums in favor of Google Groups, which means any old discussions and examples now only live in Google&#8217;s cache despite them coming up in their search very often. Those of you look for 1.11 docs and demos, see <a href="http://docs111.mootools.net">here</a> and <a href="http://demos111.mootools.net">here</a>, respectively.</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2008/07/04/mootools-i-choose-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Valid XHTML and Opening Links in New Windows</title>
		<link>http://joefleming.net/2007/12/16/valid-xhtml-and-opening-links-in-new-windows/</link>
		<comments>http://joefleming.net/2007/12/16/valid-xhtml-and-opening-links-in-new-windows/#comments</comments>
		<pubDate>Sun, 16 Dec 2007 23:28:28 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Site News]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://joefleming.net/2007/12/16/valid-xhtml-and-opening-links-in-new-windows/</guid>
		<description><![CDATA[Well, as you can plainly see (assuming you&#8217;ve been here before), the site has gotten a facelift. Now that Aaron has his blog up and his looking really nice, I felt compelled to try and jazz up mine a little too. It&#8217;s not done, but it&#8217;s nicer than it was. I&#8217;ll probably add a touch [...]]]></description>
			<content:encoded><![CDATA[<p>Well, as you can plainly see (assuming you&#8217;ve been here before), the site has gotten a facelift. Now that <a href="http://aaronstaves.com/" rel="ext">Aaron</a> has his blog up and his looking really nice, I felt compelled to try and jazz up mine a little too. It&#8217;s not done, but it&#8217;s nicer than it was. I&#8217;ll probably add a touch of color to the theme, but it&#8217;ll work for now. BTW, it&#8217;s based off the <a href="http://weyland.be/wrdprss/index.php/2006/01/05/wordpress-theme-milc3-35/" rel="ext">Milc 3.5</a> theme. The code isn&#8217;t super pretty, but it was a good start.</p>
<p>While I was working with the design, I realized that I needed to send over my old bit of code that opened links in new windows. As anyone trying to make valid XHML pages can tell you, the <em>target</em> attribute is no longer valid, so if you want pages to open in a new window and you still want your design to validate properly, you have to do a little scripting. I actually found this script a couple years ago to make MediaWiki links open in new windows and it&#8217;s served me quite well ever since.<br />
<span id="more-16"></span></p>
<pre>
function makeExternal() {
        //make sure the function works
        if (! document.getElementsByTagName) { return; }
        var myRegExp = new RegExp("ext","i");
        var anchors = document.getElementsByTagName("a");
        for (var i=0; i<anchors.length; i++) {
                var anchor = anchors[i];
                if (anchor.getAttribute("alt") &#038;&#038; anchor.getAttribute("alt").match(myRegExp) ) { anchor.className+=" external"; anchor.target="_blank"; }
        }
}
</pre>
<p>You run the function at page load and selected links will now open in a new window. To make a link work this way, you add <em>rel="ext"</em> to the anchor tag, which is still valid because <em>rel</em> is a valid attribute. What's nice is this also sets up a relation between your page and the link; ext being short for external. The script parses all anchors for that <em>rel</em> attribute and if it finds <em>ext</em> in value, it appends the class 'external' and sets the target attribute of the link to '_blank'. It's a little hacky, but it works like a charm and any browser with a DOM that supports getElementsByTagName.</p>
<p>Note that you don't have to append any class name if you don't want to. I like that I can make the links indicate that they will be opening in a new window by using a little icon as you can see on this site. I like the icon MediaWiki uses a lot, but the way it uses (indicating that it's an external link) doesn't make as much sense as using it to show that a new window will open. That's my take anyway.</p>
<p>This isn't the only way to achieve this result, and Google will provide you with a million other ways, but this is what works for me. Just thought I'd share.</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2007/12/16/valid-xhtml-and-opening-links-in-new-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python, Pylons and FastCGI on DreamHost</title>
		<link>http://joefleming.net/2007/12/02/python-pylons-and-fastcgi-on-dreamhost/</link>
		<comments>http://joefleming.net/2007/12/02/python-pylons-and-fastcgi-on-dreamhost/#comments</comments>
		<pubDate>Mon, 03 Dec 2007 01:32:01 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://joefleming.net/2007/12/02/python-pylons-and-fastcgi-on-dreamhost/</guid>
		<description><![CDATA[All of the domains that I oversee (and those of most all my friends as well) all live on a server on DreamHost. Their plans are amazing; tons of storage space, tons of bandwidth, unlimited domains and emails, shell access and a slick administration tool. That being said, I&#8217;ve always stuck with PHP because it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>All of the domains that I oversee (and those of most all my friends as well) all live on a server on <a href="http://www.dreamhost.com/" rel="ext">DreamHost</a>. Their plans are amazing; tons of storage space, tons of bandwidth, unlimited domains and emails, shell access and a slick administration tool. That being said, I&#8217;ve always stuck with PHP because it&#8217;s all I know and it&#8217;s very simple to get working. That all changed recently when a friend of mine and I decided it would be fun to learn Python. </p>
<p>DreamHost is an amazing hosting company. Not the best or fastest servers in the world, but by FAR the cheapest and plenty enough for our needs (and apparently the needs of MANY others too). I learned this weekend that their support for running python over their FastCGI (which you have to use) doesn&#8217;t work as advertised though. And even when I scoured the &#8216;net for answers they all said the same thing. The defacto tutorial seems to be <a href="http://blog.micampe.it/articles/2006/11/26/a-tale-of-pylons-python-and-fastcgi-on-dreamhost" rel="ext">A tale of Pylons, Python and FastCGI on Dreamhost</a>, referenced by several sources and many people in the forums. Sadly, that tutorial doesn&#8217;t work as-is, if it ever did. It&#8217;s extremely close, but not complete. I also found a tutorial for <a href="http://blog.localkinegrinds.com/2007/08/20/custom-python-installation-for-django-on-dreamhost/" rel="ext">rolling your own Python</a> and combined the two (along with <a href="http://forum.dreamhosters.com/programming/79205-Help-with-hello-world-FCGI.htm" rel="ext">this forum post</a>) to get it all working. This worked for me and I&#8217;m guessing it&#8217;ll work for a lot of other people trying to run Python on a DreamHost server (and not using Django I should add).<br />
<span id="more-11"></span><br />
Before we jump into it, I should note that you will need an account with shell access (one you can SSH in to). Since we&#8217;re compiling things, you can&#8217;t just use FTP. If you&#8217;re scared of the command line, there&#8217;s not much help for you. This is mostly copy and paste here though, so try and play along anyway.</p>
<p>First, we might as well roll our own version of Python. We could use what&#8217;s on their servers, but it&#8217;s a little out of date and rolling your own will allow you to more easily tweak things to your needs and install things you need. Thanks to the link above, this couldn&#8217;t be simpler. Start by SSHing into your account, then from your home directory, execute the following.</p>
<pre>mkdir opt
mkdir downloads
cd downloads
wget http://www.python.org/ftp/python/2.5.1/Python-2.5.1.tgz
tar xvzf Python-2.5.1.tgz</pre>
<p>As pointed out on Ryan Kanno&#8217;s page, this will create 2 directories (opt and downloads), download a copy of Python (version 2.5.1) to the download directory and uncompress the file. You&#8217;re going to install everything in opt in your home directory just because that&#8217;s the way he did it, but you can change that to anything you want. Just make sure that if you DO change it, you also change it in the next set.</p>
<pre>cd Python-2.5.1
./configure --prefix=$HOME/opt/ --enable-unicode=ucs4 &#038;&#038; make &#038;&#038; make install</pre>
<p>What this does is configure and compile your new version of Python and install it in the opt directory we made before. Again, if you changed the directory, change it here too. If you get errors, the compilation will stop without installing. Everything went smooth for me, so if you have problems, hit Google or the discussions over at the <a href="http://discussion.dreamhost.com/wwwthreads.pl" rel="ext">DreamHost Forums</a>. Next, we need a way to let Python talk to MySQL (unless you aren&#8217;t using a database, but you probably are, so just continue on).</p>
<pre>cd ..
wget http://internap.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz
tar xvzf MySQL-python-1.2.2.tar.g
cd MySQL-python-1.2.2
python setup.py install</pre>
<p>Couldn&#8217;t be simpler. The last step is to make sure we&#8217;re going to be using the proper version of python when we are logged in. You can copy and paste the code, or if you understand how to add things to your PATH on your own, do it by hand.</p>
<pre>echo "export PATH=\$HOME/opt/bin/:\$PATH" &gt;&gt; ~/.bash_profile
source ~/.bash_profile
which python</pre>
<p>The last commend should echo <em>/home/&lt;username&gt;/opt/bin/python</em> if you left the directory structure alone. If you you see <em>/usr/bin/python</em> then your PATH is wrong. Try again or Google how the PATH works and fix it. You can also remove the download directory if you so choose.</p>
<pre>cd ~
rm -Rf downloads</pre>
<p>We&#8217;re now ready to switch over to Michele Campeotto&#8217;s page. You could set up virtual-python as suggested there, but I&#8217;m a fan of compiling and this makes sure that upgrading and maintaining your own versions is simple and that any DreamHost upgrades won&#8217;t break your code. The flip side is that YOU are in charge of keeping up with upgrades, but I personally don&#8217;t mind that. The call is yours. Anyway, we want to step in where Pylons is installed, so let&#8217;s go ahead and do that. </p>
<pre>easy_install Pylons
easy_install Flup</pre>
<p>Easy once Python is installed isn&#8217;t it? If you paid attention here, I also added Flup here. We&#8217;re going to use Flup instead of the fcgi.py file referenced over there. I&#8217;m not sure why, but that method refused to work for me, but Flup worked without any problems. You can also install QuickWiki to test out Pylons if you&#8217;d like, or just jump into development. <strong>The important differences are in the dispatch.fcgi file</strong>. </p>
<pre>#!/home/&lt;username&gt;/opt/bin/python

import sys

from paste.deploy import loadapp
from flup.server.fcgi_fork import WSGIServer

app = loadapp('config:/home/&lt;username&gt;/&lt;domain&gt;/wiki.ini')
WSGIServer(app).run()</pre>
<p>Note that I added the line &#8216;<em>import sys</em>&#8216; there. I&#8217;ve also used &#8216;<em>from flup.server.fcgi_fork import WSGIServer</em>&#8216; so that we use Flup and not fcgi.py. These are the vital differences between a working Python install and a non-working one. I&#8217;ve been bashing my head against the wall trying to make this work for the last 24 hours and it&#8217;s finally done. Now I can learn Python and Pylons :). Here&#8217;s a simple &#8220;Hello World&#8221; example in the event that you don&#8217;t want to install Pylons, QuickWiki or anything else.</p>
<pre>#!/home/&lt;username&gt;/opt/bin/python

import sys
from flup.server.fcgi_fork import WSGIServer

def myapp(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ['Hello, from python!\n']

WSGIServer(myapp).run()</pre>
<p>Is this the best solution to make Python and Pylons work on a DreamHost server? I have no idea. Are there any security implications with importing sys? Again, no idea. I couldn&#8217;t be any newer to all of this myself, so you tell me. For now, I&#8217;m just happy things work and I hope this helps out some other people as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://joefleming.net/2007/12/02/python-pylons-and-fastcgi-on-dreamhost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
