This blog has moved!

If you are not automatically redirected to the new address, please direct your browser to
http://www.juxtaservices.com/blog/
and update your bookmarks.

Tuesday, May 08, 2007

Dump stderr to stdout

I recently discovered the solution to a previously baffling problem I was having with the code deployment tool I have been writing as part of my thesis research. By the way, Doba has graciously allowed me to open source the entire project. You can find it here.

Since the project relies on the execution of SVN commands through the use of the exec() function in PHP to perform actions dictated through the web interface, there are alot of exec() calls made in the performance of duty. The output of these commands is generally captured so that it can be displayed back to the user and logged into the system. I was previously baffled however, why sometimes when an SVN error occurred, that it was not returned as output for the function call, but would instead be written to the Apache error log. That was until, upon discussing the issue with a coworker that we stumbled upon the reason. The SVN client was writing the error to stderr instead of stdout! Hello!

In order to solve the error therefore, and thereby prevent myself from having to mow through a bunch of error logs when something failed, I simply had to make sure and pipe stderr to stdout for any svn commands being executed. Here's what I appended to the end of the command to make it happen:

svncommand 2>&1

Since all of the SVN commands are executed through a central function, adding this pipe for all commands was a cinch. Now any and all errors encountered are properly displayed with the SVN output.

The Flaming Cockroach

No, it's not some south of the border concoction having to do with Tequila. It does however have to do with debugging in Firefox. In fact, Firebug may be my most favorite Firefox plugin ever. It makes previously tedious web/bowser debugging a cinch. Instead of a massive number of echo() or var_dump() calls, the current contents of any web page element can be easily inspected, including any and all JavaScript and CSS elements. I have found this tool to be invaluable when debugging AJAX calls since it handily displays all AJAX request results.

In addition to the integrated inspector, Firebug also allows the live alteration and debugging of HTML, CSS, and JavaScript. There is also a graphical means of displaying the alignment of CSS elements to help show you how things are aligned, as well as the ability to profile page functionality and the time it takes various components of the page to function. One of Firebug's most helpful pieces of functionality for DHTML and JavaScript rich web applications, is the ability to inspect and edit the DOM, which can be difficult to debug manually.

If you do any significant amount of web development and its not already in your development arsenal, Firebug is really something you should not be without.

Monday, May 07, 2007

Google Codeage

Recently I went poking around in the "Google extras" section and found some nifty new tools and open source code snippets. Below are some of the highlights:

Send to phone (http://www.google.com/tools/firefox/sendtophone/index.html)
This snazzy Firefox plugin allows you to highlight text to a webpage and then send it via text message to any mobile number. Pretty slick way of sending free text messages to your friends since once you select text, you can edit the message before its sent.

Picasa (http://picasa.google.com/linux/)
This is an older piece of open source Google software, that provides an excellent app for photo management and simple editing. If you haven't ever checked it out, it is really worth it. There is even a Linux version!

Google Maps (http://maps.google.com/maps)
If you're still using Mapquest you are living in the stone ages. Google maps utilizes an AJAX interface to allow real-time scrolling on the map. I've never tried to scroll all the way around the world, but I have a feeling it would work!

Kongolo (http://code.google.com/p/google-kongulo/)
This neat little plugin for Google Desktop allows you to spider and index a specific URL, thereby making it searchable by Google Desktop. It is optimized to allow speedy re-indexing of the site by only handling changes since the last index.

Real Time Syntax Highlighting JavaScript (http://code.google.com/p/rtshjs/)
This is one of the slickest pieces of code I found on the site. It is a piece of JavaScript that will automatically highlight code syntax in an HTML page, based on the programming language used. It will end up looking like the code would appear in an IDE like Eclipse, making it really slick for web pages that embed code snippets.

In compliment to these handy projects and open source code components, there are constantly newly emerging projects that can be tracked on one of the many related Google blogs. A few of my favorites are:

Google Code Blog
Google Web Toolkit Blog
Google Testing Blog (This one is really good!)