Blog Home  Home Add to any service  
Beckshome.com: Thomas Beck's Blog - Java - .NET - RoR
Musings about technology and things tangentially related
 
 Sunday, March 16, 2008
Having non-static machine keys when hosting on IIS is just one of those things that's just bound to cause trouble eventually. This holds true equally for single server hosting environments and load balanced web farm environments. Especially if your goal is to shield your users from any knowledge of IIS lifecycle activities (e.g. application pool recycles), the use of static machine keys is to be strongly recommended. The implications of static versus dynamic keys are enumerated for several different hosting situations below:


  • Single Machine - Most of the recommendations around machine keys involve synchronizing machine keys across multiple machines. There is, however, value in setting static machine keys for a single machine, single worker process environment. Quite simply, if machine keys are not static, the generation of a dynamic machine key for an IIS reboot or application pool recycle will cause any machine key related elements (e.g. view state) rendered before the event to be invalid. This will likely result in exceptions that will impact normal user processing.
  • Single Machine / Web Garden - The introduction of the Web Garden option to IIS can be viewed as the "poor man's load balancing". This option provides for a simple round robin routing across multiple worker processes, usually with each process owing affinity to a particular processor. Due to the simple load balancing approach taken, there is no option for web gardens but to synchronize machine keys. This is of course, unless you've managed to make your application completely stateless, in which case (congratulations) none of this advice applies to you.
  • Multiple Machines / Web Farms - The applicability of static machine keys to a web farm environment applies, theoretically, only to web gardens in which the load balancing approach does not guarantee server affinity. Once again, to avoid impacting user processing during load balance machine failover or due to recycles or reboots, I'd always recommend using static machine keys. Even when these areas are not concerns, I've found other troubles just seem to arise when you can't guarantee static machine keys across machines. For web events regarding cryptographic exceptions or viewstate verification issues, I've found it best to start troubleshooting with synchronizing machine keys and then working down from there.
The definitive guide to configuring machine keys in ASP.NET 2.0, including .NET code for generating the keys, can be found here. Microsoft has never revisited their ruling that machine key issues can arise outside of web farms. Once again, if you're observing cryptographic or viewstate errors, I'd advise that you start with static machine keys. If compiling and running Microsoft's code to generate a machine key is asking too much, this online program will generate a key for you.

Finally, I've been asked a couple of times about the downsides of sharing static machine keys across machines. This depends upon what you use the machine key for. In most cases, I wouldn't advise that you use the machine key for anything more than viewstate encoding. In this case, a machine key compromise will mean that someone can theoretically hack your viewstate. If they got your machine key, it also means that they have access to your web.config file, in which case you usually have bigger concerns than viewstate hacking.
Sunday, March 16, 2008 10:31:52 PM (Eastern Standard Time, UTC-05:00)  #    Comments    |  Trackback
 Monday, March 10, 2008
I've been contemplating the move towards a self-hosted Subversion repository for quite a while. My earlier attempts worked but left me with a lot of inconvenient and sometimes quirky side effects. These experiences always led me back to hosting Subversion on Linux, which is really where it works most naturally. Recently, however, I decided to retry my luck with Subversion hosting on Windows and I made the call to go with a "package" instead of doing the Apache / Subversion integration myself.



The tool that I went with, VisualSVN, is a Windows version of Subversion that targets primarily Microsoft developers using VisualStudio as their development platform. Matter of fact, the Subversion server package is freely distributed and the actual product that is sold is the Visual Studio plugin that allows you to tap into Subversion from Visual Studio. With a 30 day trial period and $49 price tag, I decided that it couldn't hurt to try it out. My findings are below:
  • VisualSVN Server - The VisualSVN server, as mentioned earlier is a freely distributed product. You can get this piece of software whether or not you ultimately decide to buy and use the Subversion Visual Studio plugin. The server runs exclusively over HTTP / HTTPS (using OpenSSL) and does not support Subversion's binary protocol or running Subversion over SSH. Obviously, this means that Apache is in play. A version of Apache is included in the distribution. Initial configuration of the server is very easy, the setup instructions describe the extent of it. As I blogged about previously, this changes a bit if you try to get Apache and IIS to run side-by-side. In this case, you need to be very explicit and tell the very greedy IIS to stop listening on other IP addresses so that port 80 can be shared by IIS and Apache. I included links to the Microsoft article in my earlier post. In this case, you'll want to use httpcfg delete iplisten -i xxx.xxx.xxx.xxx to stop IIS from listening on the port Apache is running on.      
The folks who designed VisualSVN added some cool management functionality that shields the administrator from lower level Subversion commands. Implemented as a Windows MMC snap-in, Subversion repository administration be performed right alongside other server management tasks. The MMC enables one step creation of repositories (with or without the standard Subversion folder structure), creation of users and groups, and assignment of user privileges to repository actions.
  • VisualSVN Visual Studio Plugin - As useful as the server is, the real product is the VisualStudio plugin. The most recent version of this plugin works on VisualStudio 2008 so I thought I'd install it and give it a whirl. Installation is fairly easy. Both TortoiseSVN and the VisualSVN plugin must be installed. I don't know exactly how VisualSVN communicates with Tortoise but it seems to make sense to leverage an existing Windows Subversion library rather than building everything from scratch. Using both the plugin and Tortoise gives you two ways to work with Subversion. In my experience with other Java IDE plugins (Netbeans and Elcipse), this is sometimes necessary to get around the shortcomings of the browser plugin.
Adding a project to VisualSVN using the plugin is, as it well should be, a relatively easy task. VisualSVN has some intelligence built in above and beyond the basicTortoiseSVN libraries. In my case, the plugin didn't add my Visual Studio settings, binaries, or a bunch of MP3 and JPEG photos that represent content and really didn't belong under source control. Other than that, a lot of the processing is just handed over to TortoiseSVN. The SVN UI presented by the plugin should all be pretty familiar to you if you've ever used TortoiseSVN before.

This looks to be my keeper for Subversion hosting. Now I need to port over my existing repositories into the VisualSVN server.
Monday, March 10, 2008 10:37:01 PM (Eastern Standard Time, UTC-05:00)  #    Comments    |  |   |  Trackback
 Sunday, October 07, 2007

Another in the installment of Rails on Windows “gotchas”, there are some things to be wary of when working with the Simple_Captcha plugin in the Windows environment. In terms of basic background, the Simple_Captcha plugin facilitates the integration of CAPTCHA (Computer Automated Public Turing test to tell Computers and Humans Apart) image recognition tests, like the example below, into a Rails application. Facilitates is perhaps not a strong enough term. The plugin makes CAPTCHA integration dirt simple.


The Simple_Captcha plugin uses RMagick for generation of the CAPTCHA recognition images, allowing for various image styles and distortion levels. The CAPTCHA can be integrated via the controller (this one is dirt simple) or via the model (this one is just silly simple). You can find out more about these and various other integration options on the plugin’s page.  

If you’re doing Rails development on the Windows platform and are not feeling especially masochistic, the rmagick-win32 gem, which is bundled with a copy of the ImageMagick Windows installer, is really the only way to use RMagick. For a long while, the 1.13.0 rmagick-win32 gem was the standard. However, this gem is likely to cause you issues and you should really upgrade your gem to the 1.14.1 gem or greater. These gems are fixed to work with RubyGems 0.9.4, which is the most recent version of this gem as of this blog post. If you don’t perform this update, you’re likely to see ImageMagick issues bubble up at runtime.

On Windows, these runtime errors frequently manifest themselves as ‘cur_image’ issues. Several of these issues have been reported on the plugin’s page. My post on 10/6 covered fixing these issues by upgrading your RMagick gem. Please don’t downgrade other gems, as suggested in some other posts; this will only make your life more miserable in the future.

All-in-all, the RMagick Windows gem is an excellent way to make powerful image processing capabilities available to all, including those unfortunate enough to be stuck on a Rails on Windows development platform. The plugins built on top of RMagick such as Simple_Captcha and Attachment_Fu are incredibly powerful and remain very simple by leveraging RMagick’s capabilities. Just beware if you’re developing on Windows, a little bit of tweaking and debugging may be necessary to get these plugins to work as advertised.

Sunday, October 07, 2007 3:29:01 PM (Eastern Standard Time, UTC-05:00)  #    Comments    |   |  Trackback
 Monday, October 01, 2007

I’ve posted about how impressed I was with NetBeans as a Java IDE and the incredible progress this product has made in the last couple of years. I knew for a while that Ruby on Rails and JRuby support was coming for the next major Netbeans release (v 6.0), but I hesitated moving from RadRails to NetBeans until the feature set had stabilized. Last week, the Netbeans 6.0 beta was released and, with RadRails stagnating somewhat under the Aptana brand, I caved in and made the switch.

 

George Cook does an excellent Job of running through the new features with lots of nice pretty screenshots. If you’re looking at moving to Netbeans as a Rails IDE, it’s the first place I suggest that you go. Some of my favorite features of Netbeans (with screens shamelessly stolen from George’s site) include code completion

 

 

 

…and debugging

 

 

There are several features from RadRails that I miss and that I hope the NetBeans team will consider integrating over time. These include the ability to import a project directly from Subversion and the test window that allows you to visually check the status of your tests and select particular tests to run. Those features aside, I don’t plan on going back to RadRails. NetBeans has made so much progress so quickly, I can only imagine that it’s going to put significant distance between itself and RadRails in the near future.

 

You can get Netbeans 6.0 here, available as a skinnied-down Ruby only version if you want. Finally, since Netbeans uses JRuby as the default interpreter and expects the Derby Java database, this article on wiring NetBeans for InstantRails should get you up and moving with the standard Ruby interpreter and MySQL database configuration, regardless of whether you’re using InstantRails or not.

 

Final note if you're brand new to Ruby on Rails and reading this post. Skip right to Rails 2.0, which is now in preview mode, to avoid dealing with Rails 1.2.x deprecations and to benefit from some of the new defaults. Enjoy!

Monday, October 01, 2007 5:21:36 AM (Eastern Standard Time, UTC-05:00)  #    Comments    |  |   |  Trackback
 Friday, July 27, 2007

Tad Anderson posted about the release of an SOA-related e-book from Microsoft concerning Service Oriented Architecture (SOA). This is one area in which Microsoft has remained notably quiet compared with competing enterprise software vendors such as IBM and Sun. As Tad points out in his post, Microsoft has made some forays into SOA publications and they have been pretty readable.

Their most recent publication, SOA in the Real World (mirrored here), is one of the better pieces of SOA writing that I’ve encountered, vendor-specific or otherwise. It uses Microsoft technologies to illustrate certain principles but it manages to maintain a largely implementation-agnostic viewpoint. The e-book has multiple authors but it was edited together in a very seamless way, which is not always the easiest thing to pull off.

The e-book appears to have been pulled together by Microsoft’s Architectural Resource Center (ARC). No authors are listed specifically and the ARC branding is new, somewhat resembling the branding used for Microsoft’s Architecture Journal. The publication includes a pretty sound enterprise SOA approach, detailed explanations of how some of the major pieces of a SOA come together and a description of how Microsoft’s technologies fit in the mix. Whether one architect’s opinion or the Microsoft party line, there are some insightful and succinct explanations provided, such as the differences between Workflow Foundation and BizTalk when it comes to implementing workflow.

This book is a great read for anyone looking for a solid introduction to SOA and could well be the definitive read for anyone dealing with SOA and Microsoft technologies.

Friday, July 27, 2007 3:34:19 PM (Eastern Standard Time, UTC-05:00)  #    Comments    |  |   |  Trackback
 Sunday, July 08, 2007

I’ve been putting a good deal of time recently into converting GeoGlue from .NET to Rails. One of the things that I’m looking to get into the alpha release is the dynamic creation of podcasts. This is really nothing special since a podcast is little more than a special case of an RSS feed that points at external media files (i.e. audio or video).

I plan on covering the audio/video entry in an upcoming post about the nuances of the Attachment_Fu plugin on Windows. In this post, I’m going to just lay out the code for the podcast creation, since this is nothing more that a simple rxml file. I’ve sprinkled in comments liberally but most of the code should be fairly self explanatory to those familiar with Ruby and RSS feeds.

xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
xml.rss('version' => '2.0') do
  xml.channel do
    xml.title @podcast.name
    # Self-referencing link
    xml.link url_for(:only_path => false)
    # Important --> RFC-822 compliant datetime
    xml.pubDate(Time.now.strftime("%a, %d %b %Y %H:%M:%S %Z"))
    xml.language "en-us"
    xml.ttl "40"
    # User who caused the feed to be generated
    xml.generator User.find(:first, session[:user_id]).name
    xml.description @podcast.description
    # 'public_filename' is a method from the Attachment_Fu plugin
    xml.image do
        xml.url url_for(:controller => @podcast.images[0].public_filename, :only_path => false)
        xml.link url_for(:only_path => false)
        xml.title @podcast.name
        xml.width @podcast.images[0].width
        xml.height @podcast.images[0].height
    end
    @podcast.entries.each do |entry|
      xml.item do
        xml.title(entry.title)
        xml.link(url_for(:controller => entry.audios[0].public_filename, :only_path => false))
        # User who actually generated the media (i.e. audio)
        xml.author(entry.user.name)
        xml.category "Uncategorized"
        xml.guid(url_for(:controller => entry.audios[0].public_filename, :only_path => false))
        xml.description(entry.description)
        # Simplification, you should pull from updated_at/updated_on
        xml.pubDate(Time.now.strftime("%a, %d %b %Y %H:%M:%S %Z"))
        # The enclosure is very important!!
        # If you use Attachment_Fu, everything you need is included in the model

        xml.enclosure(:type=>entry.audios[0].content_type,
                :length=>entry.audios[0].size.to_s,
                :url=>url_for(:controller => entry.audios[0].public_filename, :only_path => false)
          )
      end
    end
  end
end


A couple of lessons learned from my experience. Firstly, Apple provides some good resources on generating podcasts. This is especially important since the iTunes crowd is a large and important contingent of the feed consuming world. There are iTunes-specific tags (and a schema) available. These tags are not mandatory (I didn’t use them here) but they will help you produce a richer feed for consumption within iTunes. Secondly, since the RXML file is just another view, make sure to turn off any default layouts that you might have applied to your other views. I’ve included a snippet below to demonstrate how to do this. Check your version of Rails, mileage may vary with exempt_from_layout based upon your release.

class ApplicationController < ActionController::Base

  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key => '_trunk_session_id'
  layout 'default'
  exempt_from_layout :rxml
  ...

end

My final caveat is not to apply forms-based authentication to your podcast (RXML view). Either make the view public or, if you wish to protect it, do so using HTTP Basic authentication instead. If you’re using both forms-based and HTTP Basic authentication, you’ll probably need to sync the two by using a single LDAP repository. That’s fodder for a completely different post.

Sunday, July 08, 2007 6:46:34 AM (Eastern Standard Time, UTC-05:00)  #    Comments    |  |   |  Trackback
 Monday, June 25, 2007

As soon as you’ve spent some time dealing with Rails, you’re bound to hear the fact quoted that the entire Core Rails Team does their work on Macs. There are likely several reasons for this: (1) these folks really like Macs (you can’t fault them for that); (2) they’re getting kickbacks to use Powerbooks (could be; not likely though); or (3) Rails is fun, and using Windows puts a bit of damper on that fun. I think the last answer is the most likely even though I’d like to think that Steve Jobs has some skin in the Rails game.



What you’ll also hear and experience when dealing with Rails is that it’s “opinionated software”, which it is. It just so turns out that the prevailing Rails opinions tend to align more closely with the UNIX-derivative camp (like Mac’s OS-X) than with the Windows camp. There’s a price to pay for working against the prevailing opinions and using a Windows environment to do your development. In most cases, the community that supports Rails has done a great job to make sure that this cost is very miniscule. However, once in a while, when you’re working with a Ruby Gem or Rails Plugin that is outside the core framework, you’ll hit the opinionated software wall head-on.

This is not meant to be a critique of Rails or the concept of opinionated software. Rather, the things that make Rails and some of these Gems and Plugins so special is that they leverage existing capabilities of the underlying operating system (that’s Rail’s DRY principle in action) such as the UNIX symlink command that powers Capistrano. These capabilities are difficult or impossible to replicate across operating systems; leaving the Windows-based developer with three choices: buy a Mac; install Linux, or hack your way through.

In the first of x installations of my experiences with Rails on Windows, I’ll touch on some of the learning points I had with Capistrano. As a refresher, or for the completely uninitiated, Capistrano is, in the simplest sense, a Rails deployment utility. It provides a collection of tasks that anyone with experience in deploying Web applications will immediately recognize as extremely useful. Tasks like automated deployments, checking the differences between your most recent source and the existing deployment, temporarily disabling an application and putting up a maintenance page, performing database migrations, and rolling back your application to previously deployed versions can each be performed using a single Capistrano command. Like many things Rails, the obvious utility of such functionality may lead you to wonder why a tool like this wasn’t invented much sooner and used universally.

Capistrano is quite overt about being opinionated software, going as far as to clearly document the assumptions it makes. Amongst these assumptions is that you are deploying to a POSIX-compliant UNIX shell (sorry, no Windows), you are using Subversion for source control, and that all your passwords (i.e. production server and Subversion) are synchronized. Once again, following the Rails convention, some things that Capistrano assumes are overridable. Other things, however, are not. Some of the learning points I touch on below are directly related to Windows; others are not.
  • You’re going to need the full Subversion binaries. If you, like me, had gotten by using various Subversion clients (e.g. TortiseSVN and Subclipse), the gig is up. You’re going to need Subversion anyway if you ever plan to run EdgeRails
  • Some installation instructions for Capistrano will specify that you should --include the termios Gem when installing Capistrano. Normally, termios removes the need to display and manually enter your password during the execution of Capistrano tasks. However, since the termios Ruby Gem is simply a wrapper around the POSIX termios command, this won’t fly with Windows. Solution: don’t include a termios dependency and get used to entering your password each time you invoke Capistrano from Windows.
  • If your Capistrano install fails with a Zlib::BufError, don’t fret it. Try updating your gems (gem update –-system). This seems to be a fairly common occurrence with Windows. I’ve heard of folks having to update gems multiple times for this to take.
  • Another must for Capistrano deployment, and one that escapes folks who have spent life in the Windows world, is the need to chmod files so that they have the appropriate permissions set. This is especially true for the Ruby and FCGI dispatch files (if you’re using FCGI). Ideally, you should create your Rails projects on the UNIX box you plan on deploying to, check it into Subversion, and then begin work on your Windows development machine from there. This helps to avoid a host of issues such as chmod problems and bad shebang lines that routinely plague Windows users.
  • Select a hosting provider that has one or more sample Capistrano deployment files available or that have customized the standard Shovel file for their environment. You’ll still have to do some tweaking but this will help save a good deal of time. Suffice it to say that if your hosting provider doesn’t know how Capistrano works, turn and run… fast.
  • If you maintain critical files outside of Subversion such as your database.yml or if you have multiple copies of the same file (e.g. different environment.rb files for staging and production deployments), the simple Ruby put command goes a long way. For example:

put(File.read('config/database.yml'),"#{deploy_to}/current/config/database.yml", :mode => 0444)

put(File.read('config/environment.staging.rb'),"#{deploy_to}/current/config/environment.rb", :mode => 0664)

There are plenty of purists out there that have invented all sorts of ways to get unversioned files onto your productions server if need be. I don’t see the need for such complexity, especially if only one or two people have been granted deployment rights with Capistrano.

Monday, June 25, 2007 6:57:26 AM (Eastern Standard Time, UTC-05:00)  #    Comments    |   |  Trackback
 Tuesday, May 08, 2007

Eliminating or reducing enterprise system batch processing is the bane of many architects looking to convert large-scale legacy systems to current platforms. Some believe, rightly or wrongly so, that mainframe-style batch has no place in modern system architectures and attempt to eradicate its existence entirely. Others are a bit more accepting and attempt to understand the role that batch processing fills in enterprise application architectural space. Even for these people, finding people with the skills to engineer batch processing systems with these newer technologies is not an easy proposition since little or nothing has been written about batch on the Java or .NET platforms.

I’ve seen various attempts at non-mainframe batch processing over the years from the simple CRON / Quartz type attempts to more sophisticated approaches that handled concepts such as scheduling, job control, retry and rollback, and parallel processing. There are commercial applications that purport to take care of much of this for you. Many of these are, for better or worse, nothing more than mainframe tools ported to the Java and .NET platforms with little regard for the differences between mainframe and non-mainframe architectures.

I’ve seen several attempts at batch processing frameworks in .NET. The earlier versions (pre .NET 2.0) of Rocky Lhotka’s Component Scalable Logical Architecture (CSLA) included admittedly simple batch functionality. Avanade’s Avanade Connected Architecture (ACA.NET), which formed the backbone of Microsoft’s Enterprise Library, had a batch element, entitled fittingly ACA Batch. Until recently, the Java open source community had only produced several half-hearted batch processing architectures which, given their lineage as the first “true” legacy replacement technology, is actually more than a bit disappointing.

A couple of month’s back, word got out that Rod Johnson, the brains behind the widely respected Spring framework, was going to be presenting the Spring Batch Framework at this year’s JavaOne conference. Yesterday, the formal announcement was made of the addition of Spring Batch to the Spring portfolio. A combination of Interface21 (the folks behind Spring) and Accenture (the folks behind Avanade) resources have collaborated in the creation of this batch framework.

I haven’t checked out the source code yet but Spring Batch purports to be non-dependant on other Spring facilities. The architectural diagram for Spring, which is shown below, won’t tell you much.


Perhaps more telling are the use cases upon which their framework is based:

  • Simple Batch Repeat
  • Automatic Retry After Failure
  • Commit Batch Process Periodically
  • Asynchronous Chunk Processing
  • Copy File to File in a Batch
  • Massively Parallel Batch Processing
  • Manual Restart After Failure
  • Sequential Processing of Dependant Steps
  • Partial Processing
  • Whole-Batch Transaction
  • Scheduled Processing.

If any or all of these things are present needs of your existing system and will need to be replaced over time, I encourage you to look at Spring Batch. Even if you’re developing in a language other than Java, take a look at Spring Batch. If historic success provides even the slightest indicator of future success, than Spring Batch will be another exciting and innovative addition to the Spring Suite.

Tuesday, May 08, 2007 10:25:41 PM (Eastern Standard Time, UTC-05:00)  #    Comments    |  Trackback
 Thursday, April 12, 2007

The recent announcement that Google will support GeoRSS in addition to KML as a data format for geographic content in Google Maps is long overdue. This is one of those rare areas where Google trailed both Microsoft and Yahoo and did not seem at all willing to budge. Google's announcement also seals the deal on GeoRSS as the way to syndicate geo-specific data. However, despite the obvious importance of GeoRSS, there is little written material on producing GeoRSS feeds.


I promised a brief tutorial on creating a GeoRSS feed with my post on Yahoo's Tag Maps. More specifically, my post will focus on a boundary update GeoRSS feed. That is, you pass in the maximum and minimum latitudes and longitudes for your map in question and only data about the points that correspond to that particular latitude / longitude box is actually fetched. Obviously, if the user interacts with the map (i.e. panning or zooming), you can use the map's API and some AJAX'y goodness to make calls to the GeoRSS feed to pick up a new set of points that correspond to the updated map's boundaries.

The code below represents the most rudimentary and explicit way to construct a GeoRSS feed using ASP.NET and C#. For the purposes of illustration, no third party GeoRSS libraries are used. It's all basic I/O, streams, and very manual XML construction. Also note a single monolithic call in Page_Load, lack of exception handling and parameterized queries may or may not be the way you want to do things. Try it out though; it does what it's supposed to do really well. If you have any comments or corrections, just drop me a line.

I plan on posting a follow up in a couple of days with a live GeoRSS feed. I just need to find a nice sized set of simple data that I can load into a database and point my code at. Expect to see this soon.

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Xml;

public partial class BlogGeoRss : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Response.Clear();
this.Response.ContentType = "text/xml";
this.Response.ContentEncoding = System.Text.Encoding.UTF8;
System.IO.MemoryStream stream = new System.IO.MemoryStream();
XmlTextWriter XMLWrite = new XmlTextWriter(stream, System.Text.Encoding.UTF8);

XMLWrite.WriteStartDocument();
XMLWrite.WriteWhitespace(Environment.NewLine);
XMLWrite.WriteStartElement("rss");
XMLWrite.WriteAttributeString("version", "2.0");
XMLWrite.WriteAttributeString("xmlns:georss", "http://www.georss.org/georss");
XMLWrite.WriteAttributeString("xmlns:gml", "http://www.opengis.net/gml");
XMLWrite.WriteWhitespace(Environment.NewLine);

XMLWrite.WriteStartElement("channel");
XMLWrite.WriteWhitespace(Environment.NewLine);
XMLWrite.WriteElementString("generator", "geoglue.com");
XMLWrite.WriteWhitespace(Environment.NewLine);
XMLWrite.WriteElementString("title", "GeoGlue GeoRSS Feed");
XMLWrite.WriteWhitespace(Environment.NewLine);
XMLWrite.WriteElementString("language", "en-us");
XMLWrite.WriteWhitespace(Environment.NewLine);

// Pick up the query strings for the latitude / longitude boundaries
float UpperBound = 0F, LowerBound = 0F, LeftBound = 0F, RightBound = 0F;
try { UpperBound = float.Parse(Request.QueryString["UpperBound"]); }
catch (Exception ex) { };
try { LowerBound = float.Parse(Request.QueryString["LowerBound"]); }
catch (Exception ex) { };
try { LeftBound = float.Parse(Request.QueryString["LeftBound"]); }
catch (Exception ex) { };
try { RightBound = float.Parse(Request.QueryString["RightBound"]); }
catch (Exception ex) { };

// Build the item nodes for each of the specific tours
SqlCommand cmd = new SqlCommand("SELECT Name, Description, Latitude, Longitude " +
     "FROM TOUR WHERE (Latitude < @UpperBound) AND (Latitude > @LowerBound) " +
"AND (Longitude > @LeftBound) AND (Longitude < @RightBound)",
new SqlConnection(ConfigurationManager.ConnectionStrings["GeoGlueDev"].ConnectionString));
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add(new SqlParameter("@UpperBound", SqlDbType.Float)).Value = UpperBound;
cmd.Parameters.Add(new SqlParameter("@LowerBound", SqlDbType.Float)).Value = LowerBound;
cmd.Parameters.Add(new SqlParameter("@LeftBound", SqlDbType.Float)).Value = LeftBound;
cmd.Parameters.Add(new SqlParameter("@RightBound", SqlDbType.Float)).Value = RightBound;
cmd.Connection.Open();
SqlDataReader dr = cmd .ExecuteReader();

while (dr.Read())
{
XMLWrite.WriteStartElement("item");
XMLWrite.WriteWhitespace(Environment.NewLine);
XMLWrite.WriteElementString("title", (string)dr["Name"]);
XMLWrite.WriteWhitespace(Environment.NewLine);
XMLWrite.WriteElementString("description", (string)dr["Description"]);
XMLWrite.WriteWhitespace(Environment.NewLine);
XMLWrite.WriteElementString("georss:point", Convert.ToString(dr["Latitude"]) + " " + Convert.ToString(dr["Longitude"]));
XMLWrite.WriteWhitespace(Environment.NewLine);
XMLWrite.WriteEndElement();
XMLWrite.WriteWhitespace(Environment.NewLine);
}
cmd.Connection.Close();

XMLWrite.WriteEndElement();
XMLWrite.WriteWhitespace(Environment.NewLine);
XMLWrite.WriteEndElement();
XMLWrite.WriteWhitespace(Environment.NewLine);
XMLWrite.WriteEndDocument();
XMLWrite.Flush();

System.IO.StreamReader reader;
stream.Position = 0;
reader = new System.IO.StreamReader(stream);
Byte[] bytes = System.Text.Encoding.UTF8.GetBytes(reader.ReadToEnd());
this.Response.BinaryWrite(bytes);
this.Response.End();
}
}
Thursday, April 12, 2007 12:15:53 AM (Eastern Standard Time, UTC-05:00)  #    Comments    |   |  Trackback
 Thursday, March 29, 2007

The more I use Ruby on Rails, the more I become convinced that it is damn near the perfect framework for state government Web-based applications. That said, I don’t know of a single state, local, or municipal government that is experimenting with Rails in any meaningful fashion. I have a bunch of stored Google queries that have yielded woefully little information about the penetration of Rails into state government over the past year or so. I fear that is because there really has been little or no penetration.

When I think through the merits of Ruby on Rails and apply the pragmatic brush of my experience with state governments, I’m torn as to whether I believe Rails will ever gain a foothold in this arena. To articulate my ideas, I’ve enumerated, on one hand, my top three compelling arguments why Rails should be overwhelmingly successful in state government. On the other hand, I’ve listed the top 3 reasons why Rails doesn’t really stand a fighting chance. I’ve omitted what some would consider the “classic” selling points of RoR: ActiveRecord, Scaffolding, etc. By all means, I encourage you to look into these if you’re new to Rails. It’s just that they aren’t particular to adoption in state government. In the spirit of remaining optimistic, I’ll list the top 3 reasons Rails has a chance first.

Top 3 Reasons Rails Could Find a Home in State Government

  1. Convention Over Configuration – With this mantra, the Rails community initiated a full-frontal attack against the J2EE crowd (pre-EJB3, have you), where XML configuration files had become the tail wagging the dog. Ruby on Rails, on the other hand, makes all sorts of assumptions about what how things will work and requires developer intervention as the exception rather than the norm. In an environment where developers really do work an 8 hour day (or less), focus on delivering functionality and not on tweaking and re-tweaking the application architecture means significantly greater productivity.
  2. Painless Objects – For many developers, especially those transferring from procedural languages like COBOL or Visual Basic, objects do not come naturally. I’ve seen many state government developers spend years trying to catch onto the concept and still not get it. In Rails, objects just work out of the box, knowing how to deal with the database, providing easy validation hooks and manageable relationships. As a bonus, Ruby tends to be less intimidating to look at for COBOL or classic VB developers than do the C family of languages (C# and Java, in our case).
  3. Embodiment of Best Practices – From unit tests and separation of concerns to database migrations and standard environment definitions, everything is built into Rails. These things can certainly all be done in the Java and .NET worlds, the practices and tools just seem so much more external to the way of doing things and have not been universally integrated into the standard way of doing things in these languages. As an example, how many C# texts talk about unit testing? How many RoR texts don’t talk about unit testing?

Top 3 Reasons Rails Will Fail To Find a Home in State Government

  1. No Salesforce – Surprised that I didn’t mention cost in the reasons contributing to Ruby on Rails success in state government? That’s because it isn’t. The fact that the entire RoR stack is free means less “conventional” ways to make money on the software side of things. You won’t find IBM, BEA, or Microsoft pitching Ruby on Rails solutions to state governments. Furthermore, the large system integration vendors won’t be pitching it either. Without the software vendors and the SI’s, it’s really hard to get in the door at state governments.
  2. Knocked as Not Enterprise-Worthy- Ruby and Rails have been knocked since their inception as great for hobbyist but not enterprise worthy. This is a knock that open source software gets in general and when it’s a scripting language to boot, you might as well be buying your technology from Toys-R-Us. For the real story on this, I suggest that you take a look at Dare Obasanjo’s classic blog post My Website is Bigger Than Your Enterprise. Dare’s points are very good, and although they’re not 100% accurate, you gotta think, “if this works for Google and Yahoo, why can’t it work for me?”
  3. No Formalized Training Program – This may sound even more ludicrous than my first two points. What’s the right way of saying this… “it’s true.” Believe me, it’s a known fact that until there is formal training available for a technology and the big vendors are pitching it, it’s not enterprise worthy. Right?
Thursday, March 29, 2007 1:17:26 AM (Eastern Standard Time, UTC-05:00)  #    Comments    |  |   |  Trackback
 Friday, March 23, 2007

For those Rails developers using RadRails as your IDE, you might have noticed that, in the last several days, the RadRails site has slipped off of the face of the earth. Due to a very unfortunate run-in with their registrar and DNS provider, the nice folks at RadRails are apparently stuck in DNS purgatory. This little mishap coincided with the announcement of the Aptana IDE / RadRails merger. Due to the site outage, many folks missed out on the announcement all together... so I'll repeat Aptana and RadRails are merging. You can now find the mirrored RadRails site here. The location of the RadRails download on SourceForge has not changed.

Aptana has posted a brief roadmap for the new combined product. This should be exciting new for folks using RadRails. It was apparent that RadRails grew far beyond the initial expectations of its creators and, as Ruby on Rails skyrocketed in popularity, support was going to be an issue. The creators of RadRails did a great job of maintaining and expanding the IDE for a long time. They then made the greatest of sacrifices and, instead of letting their product die on the vine, they merged it with a likeminded product for the greater good of their RadRails users. It would be great if all open source project owners functioned in this fashion. 1 or 2 great products is much better than 9 or 10 mediocre products.

If you haven't tried out Aptana, I encourage you to give it a look. It's a great Eclipse-based JavaScript IDE. With planned support for RHTML integration and hopefully more extensive code assist capabilities to come, there is much promise in this merger. Not that it is required, by any means, but a high quality IDE will only serve to further Ruby on Rails case and attract more and more developers from the Java and .NET camps to at least give RoR a look.

Friday, March 23, 2007 5:29:03 AM (Eastern Standard Time, UTC-05:00)  #    Comments    |   |  Trackback
 Tuesday, January 30, 2007

Windows Power Tools is a collection of brief tutorials and overviews of freeware and open source .NET development tools. What kind of rating you might give this book depends largely upon what type of background that you’re coming from. If you’re the kind who has stuck religiously to the Microsoft Press series of books and acknowledge only the old testament, than this book will be either an epiphany (5 stars) or outright blasphemy (1 star). If continuous integration, test-driven development, and object relational mapping (new testament type stuff) are terms that you are fairly conversant with, then this book will probably land somewhere in the 2-4 star range.

Since I put myself in the 2-4 star group, I’ll start by mentioning that there are great online tomes of knowledge that contain most of the tools listed in this book and a bunch others not listed here. One of the most respected and well linked lists belongs to the author of this book’s forward, Scott Hanselman. His Ultimate Developer and Power Users Tool List for Windows has been dutifully updated on an annual basis. Despite the fact that there are free, decent resources out there that fill some of the same purposes as this book, I enjoyed thumbing through the book and picking out tools I hadn’t heard of to fill in some knowledge gaps.

The main reason that I landed on a 3 star rating instead of a 4 star rating is that the brief tutorial format that worked so well for James when describing Visual Studio functionality is his previous book, Visual Studio Hacks, just doesn’t do justice to tools that represent significant pieces of an application or support infrastructure. I would have preferred to see less tools and deeper coverage in certain areas. Understandably, since not everyone would want to see the same tools as me; a broader, shallower approach trades off depth and detail for marketability. I’ve included my complete list of pros and cons below so that you can see how I came to my rating:

Pros

  • Great reference book with enough of an introduction to get you started with a broad array of tools
  • If you’re an O’Reilly Safari subscriber, this book is included in your subscription
  • The authors aspire to keep materials current on the book’s companion Web site. At the time of this review, the site is little more than a list of tools in the book

Cons

  • Lots of this material is available for free on the Web, if you have the time and inclination to find it
  • Introductions to tools are not sufficiently in depth to communicate any more than the most rudimentary of use cases
Tuesday, January 30, 2007 10:57:17 PM (Eastern Standard Time, UTC-05:00)  #    Comments    |   |  Trackback
 Wednesday, January 03, 2007

Try this on for size – the EPAct2005 is the Y2K of Y2K’07.  No, this is not an anagram. No sooner is 2006 behind us and folks are already worried about “the next Y2K”, the Energy Policy Act of 2005. Between January 1st and January 3rd, I’ve received no fewer than 8 emails on this topic. These emails include everything from details about software and hardware that will require some form of remediation to EPAct2005-related business opportunities.

 

 

What is the Energy Policy Act of 2005 exactly, you ask. If you read the Wikipedia entry on EPA2005, you will get a face-full of legislative overload. What’s important to look at, at least if you’re in the IT industry, is the one section titled Change to daylight savings time:

 

“The bill amends the Uniform Time Act of 1966 by changing the start and end dates of daylight saving time starting in 2007. Clocks will be set ahead one hour on the second Sunday of March instead of the current first Sunday of April. Clocks will be set back one hour on the first Sunday in November, rather than the last Sunday of October. This will make electronic clocks that had pre-programmed dates for adjusting to daylight saving time obsolete and will require updates to computer operating systems. The date for the end of daylight saving time has the effect of increasing evening light on Halloween (October 31).”

 

“Will require updates to computer operating systems”. Ugh, that sounds both nebulous and uggy. The links below lead to the vendor specific remediation instructions.

 

From the links it doesn’t really look like things are so bad. What makes this a bit less containable than it appears at first glance is the pervasive nature of embedded devices, occasionally connected devices, and computing systems other than the ones with keyboards and monitors on them. Y2K turned out not to be so bad because it was a bit easier to quarantine the old iron running the offending code. With EPAct2005, getting to the desktops and big machines is only part of the battle. There are just so many other devices out there running on computers of some form that much is bound to slip through the cracks. Then again, your DVR and your kids’ robotic dog aren’t exactly air traffic control systems.

Wednesday, January 03, 2007 11:10:31 PM (Eastern Standard Time, UTC-05:00)