<?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>Draconis Software&#187; Development</title>
	<atom:link href="http://www.draconis.com/blog/category/web-20/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.draconis.com</link>
	<description></description>
	<lastBuildDate>Fri, 02 Dec 2011 15:20:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Updating Rubygems in Leopard (Mac OS 10.5)</title>
		<link>http://www.draconis.com/blog/2007/10/28/updating-rubygems-in-leopard-mac-os-105/</link>
		<comments>http://www.draconis.com/blog/2007/10/28/updating-rubygems-in-leopard-mac-os-105/#comments</comments>
		<pubDate>Sun, 28 Oct 2007 22:05:31 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Emerging IT]]></category>

		<guid isPermaLink="false">http://www.dracoware.com/blog/2007/10/28/updating-rubygems-in-leopard-mac-os-105/</guid>
		<description><![CDATA[After updating my Mac to Leopard (MacOS X 10.5), I noticed I had a couple issues when updating Rubygems. For instance, when running “gem update mongrel_cluster”, I would constantly get build errors. After doing some digging, I found that you need to set ARCHFLAGS to your system type. Here’s how you would update all your [...]]]></description>
			<content:encoded><![CDATA[<p>After updating my Mac to Leopard (MacOS X 10.5), I noticed I had a couple issues when updating Rubygems.  For instance, when running “gem update mongrel_cluster”, I would constantly get build errors.  After doing some digging, I found that you need to set ARCHFLAGS to your system type.  Here’s how you would update all your rubygems on Leopard:</p>
<pre>sudo su
[Enter your password]
bash
export ARCHFLAGS="-arch i386"
gem update
</pre>
<p>Note that you’ll want to change the i386 to the actual architecture you have (my MacBook, for instance, is an Intel processor, while you would want to use “ppc” for non-Intel Macs).</p>
<p>Once I had updated my gems, things started working fine again.  For instance, mongrel_cluster was having issues configuring a new project, but after updating the gem using this method, it seemed to be working fine.  Hope you find this useful!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.draconis.com/blog/2007/10/28/updating-rubygems-in-leopard-mac-os-105/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java through the ages</title>
		<link>http://www.draconis.com/blog/2007/10/19/java-through-the-ages/</link>
		<comments>http://www.draconis.com/blog/2007/10/19/java-through-the-ages/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 14:12:06 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.dracoware.com/blog/2007/10/19/java-through-the-ages/</guid>
		<description><![CDATA[I wanted to point out a great article on ReadWriteWeb today, by Alex Iskold, about the history of Java and the missed opportunities the language has had over the years.  Even if you’re not a software developer, it’s still a great overview of a language that is both elegant and powerful, and the drama of [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to point out <a href="http://www.readwriteweb.com/archives/java_a_retrospective.php" title="Java: A Retrospective">a great article on ReadWriteWeb today, by Alex Iskold</a>, about the history of Java and the missed opportunities the language has had over the years.  Even if you’re not a software developer, it’s still a great overview of a language that is both elegant and powerful, and the drama of free market competition.</p>
<p>Of course, don’t get the impression that Java is dead!  <a href="http://www.java.com/en/everywhere/" title="Java Everywhere">It’s anything but</a>: kiosks and embedded devices run it, along with consumer-facing websites and plenty of enterprise software.  Many other technologies have been eating away at it over the years, and will continue to do so, unfortunately, for many of the reasons in the article.</p>
<p>Like Alex, I think the biggest issue Java faced (and got wrong) was with the web.  Before there was web 2.0 (and web 1.0 was still being explored), Java applets were the way to integrate interactivity inside web pages.  But applets were horribly slow, limited in their abilities, and complicated.  I think if Sun were able to do it all over again, they shouldn’t have focused on placing Java applets inside web pages, but focused more closely on making Java the core of web development.  Like Alex states, imagine how great it would be if we could manipulate the DOM using Java, say if it were an integrated part of the browser.</p>
<p>But, alas, that didn’t happen.  There’s still time to reinvent how Java and the web co-exist, but for the time being, it’s being edged out in favor of new technologies and languages.  So here’s to you, Java!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.draconis.com/blog/2007/10/19/java-through-the-ages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The future of AJAX web applications</title>
		<link>http://www.draconis.com/blog/2007/09/19/the-future-of-ajax-web-applications/</link>
		<comments>http://www.draconis.com/blog/2007/09/19/the-future-of-ajax-web-applications/#comments</comments>
		<pubDate>Wed, 19 Sep 2007 19:23:52 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Emerging IT]]></category>
		<category><![CDATA[Web 2.0]]></category>

		<guid isPermaLink="false">http://www.dracoware.com/blog/2007/09/19/the-future-of-ajax-web-applications/</guid>
		<description><![CDATA[There’s an interesting opinion up by Joel Spolsky, a software developer and founder of FogCreek Software, about where the direction AJAX-based web applications are headed. He makes an interesting, and I feel very apt, comparison with the olden days of mainframes and Lotus 1-2-3, and the current state of the interactive web. For instance, he [...]]]></description>
			<content:encoded><![CDATA[<p>There’s <a href="http://www.joelonsoftware.com/items/2007/09/18.html" title="Joel on Software">an interesting opinion up by Joel Spolsky</a>, a software developer and founder of FogCreek Software, about where the direction AJAX-based web applications are headed.  He makes an interesting, and I feel very apt, comparison with the olden days of mainframes and Lotus 1-2-3, and the current state of the interactive web.  For instance, he likens the idea of sites like Google’s Gmail with Lotus 1-2-3, where the development team spent all of their time writing code and optimizing it for the current day’s limitations, rather than looking ahead and adding new wiz-bang features that would give them their “long-term competitive advantage.”</p>
<p>And I think Joel is completely right.  Gmail, for one, has been stagnant for the last three years or so, and haven’t been preparing for the future.  Check out <a href="http://lifehacker.com/software/email/yahoo-mail-innovates-gmail-stagnates-293929.php" title="Lifehacker">this blog article from Lifehacker</a> about a comparison between Gmail and Yahoo Mail.  Their conclusion?  Yahoo Mail has spent the last two years innovating and adding all sorts of new features, while Gmail has very little improvements (except, perhaps, incrementally increased storage levels).</p>
<p><span id="more-119"></span>As Joel has pointed out, the future of web applications is going to involve a standardized interface, providing UI-level features, interoperability, and a common platform for development.  And there’s evidence of this happening.  Several frameworks have come out recently that are generally very good: my favorites are <a href="http://developer.yahoo.com/yui/" title="YUI">YUI</a> and <a href="http://www.prototypejs.org/" title="prototype">prototype</a>/<a href="http://script.aculo.us/" title="script.aculo.us">scriptaculous</a>.  Very helpful, though the YUI is, I think, especially useful, as it provides a lot of very clean, useful interface-based functionality perfect for developing rich applications.  But, it’s far from lightweight.  And Joel’s point is: that’s okay.</p>
<p>I think we’re nearing a critical mass when more online software development will use an existing framework like YUI, so the common code between these sites will more likely be in users’ caches, therefore speeding up load times and reducing bandwidth costs.  And, on top of that, there is likely to be further innovation to speed this up: building some amount of the framework code into browsers, say, or different, longer-lasting caching mechanisms strictly for Javascript framework files, or a whole number of other options.</p>
<p>Whatever happens, I think the biggest winners over the next several years will be with the developers who spend their time making the best applications, and let others (like browser developers) worry about keeping it fast.  That’s not to say, “go out and make super-slow sites”, but rather to realize you shouldn’t spend all your time developing faster applications while neglecting features and other forward-looking progress.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.draconis.com/blog/2007/09/19/the-future-of-ajax-web-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Application development on the iPhone</title>
		<link>http://www.draconis.com/blog/2007/08/28/application-development-on-the-iphone/</link>
		<comments>http://www.draconis.com/blog/2007/08/28/application-development-on-the-iphone/#comments</comments>
		<pubDate>Tue, 28 Aug 2007 15:05:38 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Emerging IT]]></category>
		<category><![CDATA[Web 2.0]]></category>

		<guid isPermaLink="false">http://www.dracoware.com/blog/2007/08/28/application-development-on-the-iphone/</guid>
		<description><![CDATA[Just like every other techie in the world, we recently got our hands on some iPhones.  And, as software developers, our first thoughts were: what can we write for this thing?  Well, as everyone else has already pointed out, you’re pretty much limited to writing web apps for the iPhone only, but this doesn’t impact [...]]]></description>
			<content:encoded><![CDATA[<p>Just like every other techie in the world, we recently got our hands on some <a href="http://www.apple.com/iphone/" title="iPhone">iPhones</a>.  And, as software developers, our first thoughts were: what can we write for this thing?  Well, as everyone else has already pointed out, you’re pretty much limited to writing web apps for the iPhone only, but this doesn’t impact us as much: we’re doing web apps exclusively at the moment anyway!  I’ve been looking into creating an <a href="http://www.invotrak.com" title="invotrak">invotrak</a> app for the iPhone recently, and believe I should have something available in the near future.</p>
<p><a href="http://hunter.pairsite.com/blogs/blog20070820.html" title="iPhone web app development has its limitations">Craig Hunter has a good article up</a> on his site that discusses some of the limitations of creating applications for the iPhone, though his standpoint is coming as a traditional Mac developer (and he makes great points: it doesn’t make any sense for a user to connect to a web app to input to-do list items):</p>
<blockquote><p>Business aspects aside, the main issue I see as a traditional developer is that iPhone web app development is still very limited. Outside of some viewport settings, a couple special link types (really only the &#8220;tel:&#8221; link is new), and some new &#8220;-webkit&#8221; style attributes, there is little about making iPhone-specific web apps that differs from generic web apps. And that&#8217;s possibly the most disappointing aspect of all from my standpoint. Apple&#8217;s announcement states that &#8220;developers can create Web 2.0 applications which look and behave just like the applications built into iPhone&#8221;, but that&#8217;s not the case.</p></blockquote>
<p>I believe there’s a lot that can still be done with the tools we’re given, and I look forward to Apple creating more tools in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.draconis.com/blog/2007/08/28/application-development-on-the-iphone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Capistrano deployments and MediaWiki</title>
		<link>http://www.draconis.com/blog/2007/08/23/capistrano-deployments-and-mediawiki/</link>
		<comments>http://www.draconis.com/blog/2007/08/23/capistrano-deployments-and-mediawiki/#comments</comments>
		<pubDate>Thu, 23 Aug 2007 20:47:04 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.dracoware.com/blog/2007/08/23/capistrano-deployments-and-mediawiki/</guid>
		<description><![CDATA[A friend alerted me to an article he put together recently regarding deployments in a custom build environment.  It’s intriguing, as my own software company has a similarly-setup system.  The idea is to keep logs of deployments on a MediaWiki-powered internal wiki automatically, allowing developers to see what repository revision was rolled out, the build [...]]]></description>
			<content:encoded><![CDATA[<p>A friend alerted me to <a href="http://www.plasticvicar.com/capistrano.html" title="Integrating Capistrano, MediaWiki, and Bugzilla">an article</a> he put together recently regarding deployments in a custom build environment.  It’s intriguing, as my own software company has a similarly-setup system.  The idea is to keep logs of deployments on a <a href="http://www.mediawiki.org/wiki/MediaWiki" title="MediaWiki">MediaWiki</a>-powered internal wiki automatically, allowing developers to see what repository revision was rolled out, the build version number, along with other salient information.</p>
<blockquote><p>For our internal processes, we wanted to keep a running list of the code release version (such as &#8220;0.9.1&#8243;), the SVN repository revision that was deployed, the timestamp Capistrano used as the folder name in the Releases directory, and a more human-readable date and time of deployment. The first field, the release version, is an arbitrary string given by the person making the deployment; Capistrano prompts the deployer for this string as the first step in the deployment. The repository revision and release timestamp are both provided by Capistrano, and the human-readable date is provided by Media Wiki.</p></blockquote>
<p>Some additional coolness: automatically linking to <a href="http://www.bugzilla.org/" title="BugZilla">BugZilla</a> bug numbers whenever they’re referenced in the commit messages, and automatically creating “readme” files containing commit messages for each new build.  Check out <a href="http://www.plasticvicar.com/capistrano.html" title="Integrating Capistrano, MediaWiki, and Bugzilla">the article here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.draconis.com/blog/2007/08/23/capistrano-deployments-and-mediawiki/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remote editing Ruby code and timestamps</title>
		<link>http://www.draconis.com/blog/2007/08/02/remote-editing-ruby-code-and-timestamps/</link>
		<comments>http://www.draconis.com/blog/2007/08/02/remote-editing-ruby-code-and-timestamps/#comments</comments>
		<pubDate>Thu, 02 Aug 2007 14:21:58 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.dracoware.com/blog/2007/08/02/remote-editing-ruby-code-and-timestamps/</guid>
		<description><![CDATA[This is a programming quickie, but can be one of those gotchas if you don&#8217;t know what to look for. As I mentioned recently, I had to temporarily switch back to the Windows side of things when my MacBook died, and in doing, had to learn new tools for getting my work done. One of [...]]]></description>
			<content:encoded><![CDATA[<p>This is a programming quickie, but can be one of those gotchas if you don&#8217;t know what to look for.  As I mentioned recently, I had to temporarily switch back to the Windows side of things when <a href="http://www.dracoware.com/blog/2007/07/20/my-macbook-died/" title="My MacBook died">my MacBook died</a>, and in doing, had to learn new tools for getting my work done.  One of those tools was to replace <a href="http://cyberduck.ch/" title="Cyberduck">Cyberduck</a>, which I used to open a remote connection (via SFTP) to edit files live.  Well, I was recently working on a Ruby on Rails project, and I noticed a strange side effect: whenever I would edit a file (a view, controller, etc), and hit reload in my browser, I never noticed the change.  It could be the simplest or most complex, but it never seemed to appear unless I restarted Mongrel.</p>
<p>Turns out the problem was actually quite simple: <a href="http://winscp.net/eng/index.php" title="WinSCP">WinSCP</a>, the replacement I was using for Cyberduck, was set to preserve timestamps on files by default.  Mongrel checks timestamps of files to determine whether to reload them live (in development mode, mind you, where I wasn&#8217;t doing any caching), and these timestamps need to be changed by WinSCP in order to show up to Mongrel.</p>
<p>To fix the problem, just click the Preferences icon in WinSCP, click the Transfer selection on the left, then uncheck the &#8220;Preserve timestamp&#8221; option under Common options.  This should now update timetamps correctly and your changes should appear to Mongrel.  Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.draconis.com/blog/2007/08/02/remote-editing-ruby-code-and-timestamps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How I work: Web browsers</title>
		<link>http://www.draconis.com/blog/2007/07/05/how-i-work-web-browsers/</link>
		<comments>http://www.draconis.com/blog/2007/07/05/how-i-work-web-browsers/#comments</comments>
		<pubDate>Thu, 05 Jul 2007 14:41:16 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.dracoware.com/blog/2007/07/05/how-i-work-web-browsers/</guid>
		<description><![CDATA[I was thinking I&#8217;d start a new thread on this blog about some of the things I do on a regular basis to get work done. Lately (like since the release of the new Safari beta), I&#8217;ve been trying out different web browsers to find one that really fits. For a long time, I was [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.caminobrowser.org/" title="Camino Browser Logo"><img src="/wp-content/uploads/2007/07/appicon3.jpg" title="Camino Logo" alt="Camino Logo" align="right" border="0" /></a>I was thinking I&#8217;d start a new thread on this blog about some of the things I do on a regular basis to get work done.  Lately (like since the release of the new Safari beta), I&#8217;ve been trying out different web browsers to find one that really fits.  For a long time, I was using <a href="http://www.mozilla.com/en-US/firefox/" title="Firefox">Firefox</a> on my Mac and was doing just fine, until I really gave <a href="http://www.apple.com/safari/" title="Safari">Safari</a> a chance and realized how much FASTER Safari is over Firefox (and how much that really makes a difference for me).</p>
<p>Using Safari was good for some time, though my biggest issues were the plugins (I really need a good ad-blocking program, and SafariBlock seemed buggy and missing some features), and site support.  Since many sites are setup to allow only the most popular browsers, certain features weren&#8217;t available within Safari.  With Apple&#8217;s latest version of the browser being released for Windows as well (most likely in a ploy to get more developers on board for the iPhone), this will probably change.  But for now, I found Firefox was still a better choice for me over Safari.</p>
<p>I then tried out <a href="http://www.caminobrowser.org/" title="Camino">Camino</a> (which is what I&#8217;m using currently).  Camino is different from Safari in that it uses the same rendering engine as Firefox (so pages that work in Firefox should also work in Camino), though has a much more MacOS-friendly interface than Firefox (and seems a bit faster).  So far, I&#8217;ve been very happy with Camino, and I like the built-in ad-blocking feature.  One downside, however, is the lack of a Javascript console.  Since I do a lot of web development, I&#8217;ve come to rely on Firefox&#8217;s Javascript console (and the <a href="https://addons.mozilla.org/en-US/firefox/addon/1843" title="FireBug">Firebug</a> plugin), so unfortunately, I still need to use Firefox to do this.</p>
<p>Hope you found this useful.  I&#8217;d like to turn this into a regular thing: discussing what tools I use in my work, why I choose to use that tool, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.draconis.com/blog/2007/07/05/how-i-work-web-browsers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Footnotes: Improving Rails / TextMate Synergy</title>
		<link>http://www.draconis.com/blog/2007/06/14/footnotes-improving-rails-textmate-synergy/</link>
		<comments>http://www.draconis.com/blog/2007/06/14/footnotes-improving-rails-textmate-synergy/#comments</comments>
		<pubDate>Thu, 14 Jun 2007 12:02:10 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Web 2.0]]></category>

		<guid isPermaLink="false">http://www.dracoware.com/blog/2007/06/14/footnotes-improving-rails-textmate-synergy/</guid>
		<description><![CDATA[As a Rails developer on OS X, I spent a lot of time bouncing back and forth between my web browser and the incredible editor TextMate. Often times, I will complete my latest modification to the source and I&#8217;ll load it up in Firefox only to find an ambiguous page with the title &#8220;Action Controller: [...]]]></description>
			<content:encoded><![CDATA[<p>As a Rails developer on OS X, I spent a lot of time bouncing back and forth between my web browser and the incredible editor <a href="http://macromates.com/" title="macromates - home of TextMate" target="_blank">TextMate</a>. Often times, I will complete my latest modification to the source and I&#8217;ll load it up in Firefox only to find an ambiguous page with the title &#8220;Action Controller: Exception Caught&#8221;. Usually, a quick look through the stack trace reveals the line that is causing the problems. Then, it is back to TextMate to open the offending file, find the mistake and reload the web browser.</p>
<p>This can get tedious rather quickly. I have found that the <a href="http://blog.inquirylabs.com/2006/09/28/textmate-footnotes-v16-released/" title="The release notes for v16 of footnotes">Footnotes</a> plugin for Rails does wonders and increases my productivity dramatically. It turns all of the lines in the stack trace into clickable <code>txmt://</code> links. TextMate registers itself with the OS X so that it receives all clicks of this type &#8211; a quick click on the stack trace will open the relevant file and place the cursor at the correct line. In addition, Footnotes adds some extremely useful debug information (and more TextMate links!) to the bottom of every view when the application is launched in the debug environment.</p>
<p>Footnotes is incredibly easy to install directly from within TextMate. To do it, just follow these instructions:</p>
<ol>
<li><a href="/wp-content/uploads/2007/06/textmatescreensnapz002.jpg" onclick="return false;" title="Direct link to file"><img src="/wp-content/uploads/2007/06/textmatescreensnapz002.thumbnail.jpg" alt="TextMate Context Menu - Install Plugin" style="float: right" height="128" width="157" /></a>Open up your application as a TextMate project by issuing &#8220;<code>mate ."</code> from Terminal.app in the application&#8217;s root. Then, open any file (I chose <code>application.rb</code> in the <code>app/controllers</code> directory).</li>
<li>Make sure that the editor has focus and then press Ctrl-| to bring up the Rails bundle&#8217;s context menu. Select item #2 (Install plugin) from this menu.</li>
<li>In the Plugin Search dialog that appears, type &#8220;Footnotes&#8221; and then press Go. This should bring up the Textmate Footnotes plugin as the only result. To install it, click the down arrow button on the right. If all is well, the Footnotes plugin should now be installed.</li>
<li>Start up <code>script/server</code> and see the pretty links!</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.draconis.com/blog/2007/06/14/footnotes-improving-rails-textmate-synergy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scripting with PHP</title>
		<link>http://www.draconis.com/blog/2007/05/23/scripting-with-php/</link>
		<comments>http://www.draconis.com/blog/2007/05/23/scripting-with-php/#comments</comments>
		<pubDate>Wed, 23 May 2007 05:38:56 +0000</pubDate>
		<dc:creator>costa</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.dracoware.com/blog/2007/05/23/scripting-with-php/</guid>
		<description><![CDATA[Normally if I&#8217;m going to write a script to automate a task via cron, I&#8217;ll use Perl (or lately, Ruby). Recently though I needed to use PHP in order to take advantage of common code from a web application. I was expecting this to be an unpleasant experience, using PHP outside of web programming, its [...]]]></description>
			<content:encoded><![CDATA[<p>Normally if I&#8217;m going to write a script to automate a task via cron, I&#8217;ll use Perl (or lately, <a href="http://www.dracoware.com/blog/2007/04/23/system-administration-with-ruby/">Ruby</a>).  Recently though I needed to use PHP in order to take advantage of common code from a web application.  I was expecting this to be an unpleasant experience, using PHP outside of web programming, its <em>raison d&#8217;être</em>.  However I ended up being pleasantly surprised with the results.</p>
<p>There are a few cases where it may make sense to write scripts in PHP:</p>
<ol>
<li><strong>Code reuse</strong>.  This was my reason for going with PHP.  If a script is related to a web application written in PHP, it&#8217;s good practice to avoid reinventing as much functionality as possible. This also makes it easier to write tests directly in PHP.</li>
<li><strong>Availability</strong>.  PHP tends to be widely installed on most machines, especially those with a web server.  If you&#8217;re not sure what type of system the script may be running on, PHP might be safest bet.</li>
<li><strong>Widely known</strong>.  There are a lot of languages out there nowadays, but PHP tends to a common denominator among developers due to its age and ease of learning.  This is useful if the code is being written in a team that doesn&#8217;t have the same knowledge base.  Even if someone doesn&#8217;t know PHP, it&#8217;s usually pretty easy to pick up given it&#8217;s similarity to languages like C, Java and Perl.</li>
</ol>
<p>Luckily, PHP makes it very easy to move out of the web area into scripting.  Recent versions of PHP include a Command Line Interface (CLI) which allows code to be run outside of a web server.  The CLI also provides for parsing of command-line arguments and easy access to stdin/stdout/stderr.  I had never used the PHP CLI before but was able to pick it up very quickly.</p>
<p>My foray into PHP scripting was also made a lot easier though various helper functions.  PHP includes quite a few functions that can come in handy when writing a script or doing administration.  For file I/O, the file_get_contents()/file_put_contents() pair of functions can be used to read or write the contents of a file in a single line of code, and I found them to be particularly useful.  PHP&#8217;s functions for dealing with the filesystem, image parsing, string manipulation, and database processing are also helpful and may come in handy for the system administrator.</p>
<p>So the next time you need to write a script, consider using PHP, especially if it relates to a web application that&#8217;s written in the language. And if the decision to use PHP is forced upon you, don&#8217;t despair, as it might be a lot easier than you think.</p>
<p><strong>Additional Reading:</strong><br />
<a href="http://us.php.net/features.commandline">Using PHP from the command line</a><br />
<a href="http://enterprise.linux.com/article.pl?sid=04/12/22/0028257&amp;tid=129&amp;tid=64&amp;tid=94">SysAdmin to SysAdmin: Scripting admin tasks with PHP</a><br />
<a href="http://www.developer.com/lang/php/article.php/3400581">System Administration with PHP</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.draconis.com/blog/2007/05/23/scripting-with-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Grokking WordPress: The WordPress Loop and Theme Files</title>
		<link>http://www.draconis.com/blog/2007/02/08/grokking-wordpress-the-wordpress-loop-and-theme-files/</link>
		<comments>http://www.draconis.com/blog/2007/02/08/grokking-wordpress-the-wordpress-loop-and-theme-files/#comments</comments>
		<pubDate>Thu, 08 Feb 2007 14:29:51 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.dracoware.com/blog/2007/02/08/grokking-wordpress-the-wordpress-loop-and-theme-files/</guid>
		<description><![CDATA[There are a lot of people out there using WordPress to run their blog (this one does), and understanding a bit of how it works can go a long way to wrangling it to meet your needs. Recently, I wanted to add several buttons to the bottom of my post pages: buttons to submit the [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.dracoware.com/images/blog/wordpressicon-hanttula2.gif" alt="WordPress" title="WordPress" align="right" />There are a lot of people out there using <a href="http://wordpress.org/" title="WordPress">WordPress</a> to run their blog (this one does), and understanding a bit of how it works can go a long way to wrangling it to meet your needs.  Recently, I wanted to add several buttons to the bottom of my post pages: buttons to submit the pages to <a href="http://www.digg.com/" title="digg">digg</a>, <a href="http://reddit.com/" title="Reddit">Reddit</a>, and other sites.  The trick is, I didn&#8217;t know how to make changes to just the post pages (read: singles) and not to my index page.  This article outlines the basics of how WordPress handles displaying pages, and how you can start customizing it a bit beyond just pluggable themes.</p>
<p><span id="more-162"></span> WordPress works in an interesting way: posts are displayed as query results, which means a list of posts that meet certain criteria (either as search results, or time-based, as specified in the URL) are displayed per-page.  This can get tricky when you start to dig into the theme code for your site (especially if you&#8217;re not familiar with PHP).  The solution is to learn a little about how WordPress works.</p>
<p>First, when displaying posts, WordPress works by looping through a list of posts that meet the criteria specified, and displaying each (<a href="http://codex.wordpress.org/The_Loop_in_Action" title="The Loop in Action">The Loop</a>).  This is done by checking if any posts meet the criteria, and if so, to iterate through each and print the title, a blurb about the post, and any other information the designer decides to include.  A simple example, from the WordPress Wiki, looks as follows:</p>
<p>[php]<br />
if (have_posts()) :<br />
while (have_posts()) :<br />
the_post();<br />
the_content();<br />
endwhile;<br />
endif;<br />
[/php]</p>
<p>This loop can be used for both your index page, and for individual (single) pages.  The only difference is the number of posts returned – your index page, for instance, may have dozens of posts come up when no criteria is specified, while an individual page, with enough criteria to select exactly one posting, will display the entire article.  WordPress does all of this in your index.php template file.</p>
<p>For most <a href="http://codex.wordpress.org/Using_Themes" title="Using Themes">themes</a>, this is enough: the major difference between a list of posts and an individual page displaying all content for a given post is often that the content is either cut off (with a Read More… link included), or displayed in its entirety.  But what if you want to get into further customization?  In my case, I had just an index.php file and wasn&#8217;t quite sure how to add my &#8220;post to&#8221; buttons (I wanted them to only show up on a complete post page, and not on any list pages).  Well, the solution is to copy your index.php file and name it single.php.  The single.php temple file is used instead of index.php (when it exists) to display a single posting page.</p>
<p>Using the single.php file, you can customize how your individual story postings will appear without affecting the appearance of other pages (your index page, search results pages, special pages, etc).  Hope you found this useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.draconis.com/blog/2007/02/08/grokking-wordpress-the-wordpress-loop-and-theme-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

