CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Brendan Tompkins [MVP]

Blog First. Ask Questions Later.

April 2005 - Posts

  • CodeBetter.Com in Your Language?

    CodeBetter. Com Blogs (Dutch Version)

    A. NETTO Gemeenschap: Het materiaal dat u hebt moeten om beter coderen!

    I was just playing around with Babelfish, and noticed that you can translate an entire site, and any link you follow into your language.  This is pretty neat!  I just have to ask Peter is it's accurate.  I was thinking of adding links for different languages to the CodeBetter.Com site redesign that's currently ongoing.  Do you think it would be useful?

    Brendan

  • RSS in my Real Job - Container Tracking via RSS

    Last week, my boss asked me if I knew anything about this new “RSS” technology, and wondered if I thought there was any use for it in our business.  I was immediately struck by all of the ways we could integrate RSS into our information offerings here at the port.  Most of what we do in the web group here  is come up with new ways to increase the accessibility of information to our different types of customers.  They all have slightly different needs, but most of these needs revolve around one all important question: “Where is my container?”

    Guess what? RSS makes perfect sense for tracking containers!  The idea we had was that a customer could subscribe to a Container’s RSS feed, and get updates whenever there was a status change for that container.  We had just found the killer business app for RSS, we thought.  Well, as it turns out (as it always does), we weren’t the first (or even the second) group to have this bright idea.  In fact, you can read all about tracking packages with RSS over at XML.com: Tracking Packages with RSS.

    The idea of using RSS for tracking packages is not mine. Back in July of 2004, Ben Hammersley wrote a screen scraping script for parsing HTML data produced by FedEx's online tracking system into RSS. Unfortunately, screen scraping is often unreliable, since carriers can change their websites at any time. This led to the creation of a UPS tracking service as a .net dll by Jason Young in December of 2004 that utilized UPS's XML API instead of screen scraping. Because I wanted something that would run on Linux without Project Mono, I chose to write my own alternative and with that the track2rss project was born. Current support is provided for FedEx, UPS and USPS, with DHL USA support coming soon.

    It still being a great idea, I spent the better part of the day working on an RSS feed syndication engine for use here at the port.  The only real difference between the FedEx solution and ours is that our packages are made of steel and are about 40 feet long.

    The Solution

    The solution turned out to be so simple, it doesn’t even really deserve much explanation.  Basically, I just hooked an IHttpHandler which creates an RSS feed, and adds an item for each ContainerEvent (arrive, depart, ready for pickup, etc.)

    For the RSS feed building, I used the Racoom.XML (yes that’s racoom, not racoon – try reading that all day without getting a little nutty).

    The Code Project - RSS 2.0 Framework - C# Programming
    RSS 2.0 framework implements the RSS 2.0 specification in strongly typed classes. The framework enables you to create and consume valid RSS 2.0 feeds in your code in just a few minutes.

    It really did work as promised, it’s a very well designed library.  Here’s my IHttpHandler Code that creates the feed:

        ///

        /// Processs the request.

        ///

        /// Context.

        public void ProcessRequest(HttpContext context)

        {

          string containerNumber = context.Request.Params["CONTAINER"];

     

          if(containerNumber != null && containerNumber.Length > 0)

          {

            containerNumber = ContainerUtils.AddCheckDigit(containerNumber);

     

            // create channel

            RssChannel myChannel = new RssChannel();

            myChannel.Title = String.Format("VIT Container RSS ({0})", containerNumber);     

            myChannel.Copyright = "Copyright 2005, Virginia International Terminals, Inc.";

            myChannel.TTL = 20;

            myChannel.Generator = "VIT RSS Handler version 1.0";

     

            //get the data … code removed for security

     

            if(historyEvents.Count > 0)

            {

              myChannel.PubDate = historyEvents[0].ServiceDate;

     

              foreach(ContainerHistoryEvent historyEvent in historyEvents)

              {

                // create item

                RssItem myRssItem = new RssItem();

                myRssItem.PubDate = historyEvent.ServiceDate;

                myRssItem.Title = historyEvent.EventDescription;

                myRssItem.Description = historyEvent.ToHtml();

                myRssItem.Link = VIT.Common.Util.ContainerUtils.GetPublicContainerTrackingUrl(containerNumber);

                myRssItem.Source.Url = context.Request.Url.AbsoluteUri;

     

                // add item

                myChannel.Items.Add(myRssItem);

              }

            }

     

            context.Response.ContentEncoding = Encoding.UTF8;

            context.Response.ContentType = "text/xml";

            myChannel.Save(context.Response.OutputStream);

     

           }

        }

    And here’s what it looks like in JetBrain’s Omea Reader:

    You can see that this container has had three events so far.  As it goes through it’s life-cycle here at the port, it’ll have a bunch more, and they’ll pop up in the end user’s RSS reader. 

    Now, I’m fairly certain that most of our end users won’t be using this anytime soon, but for us, it was a no-brainer to implement.  We already have our re-usable service tier in place, so it’s just one more way to provide our customers visibility of their shipments.  I also have confidence that RSS and other similar technologies are going to scale after all and will be used for lots of stuff in the future.  Finally, for the one or two people that actually do end up using this feed to track their containers in the near future?  Well, how cool is that?

    -Brendan

  • Is eLearning the $500 Toilet Seat of the Technology Industry?

    This is something that I’ve always wanted to rant about, but never had quite the right reason to post.   Well, this morning I noticed a link on Computer Zen.com - Scott Hanselman's Weblog to the new Microsoft eLearning site, and the door was opened.

    In my previous life, I used to develop eLearning courseware.  My post-graduate degree is in eLearning, (well, technically my degree is in instructional technology but it’s the same thing) and I also worked for a time creating this crap for one of the biggest US eLearning vendors.  I tried to start a company with the bright idea of delivering this crap on tiny devices. What did I learn from my experience?

    eLearning is Condescending Fluff

    Most of the eLearning content out there is cranked out by IDs (instructional designers) who don’t know the content.  They try to quickly learn the material using SMEs (subject matter experts) and other resources. The end result is usually content that is bland and boring at best. At worst, the student is presented with content that is insulting to their level of knowledge of the subject.

    Students Hate It 

    If they’re not totally insulted, they hate the entire experience nonetheless.  Tell someone that they have to complete some eLearning, and you'll hear an audible groan. I was part of a roundtable discussion for a popular industry magazine in 1999.  I asked all the experts at the table “Does anyone here actually use this stuff?”  A few of the “experts” admitted that they use eLearning, but I’m not sure I believed them.  I never spent any real time  eLearning, and by the same token, not one person I knew in the industy did either. In my experience, the eLearning industry doesn’t dog food their products.  If they did, they’d realize how truly crappy it is.

    HR Departments Love It

    Compared to “butts in seats” training, it’s cheap.  And since the results of learning can’t really be accurately measured, the fact that no one is really learning much goes un-noticed.  For the HR person who heads up training, eLearning it's like a present from above. Their costs go down.  They get to report to the president that they’ve managed to train all 3000 employees on the latest and greatest technologies.  Everyone wins!  (er, except the employees, who don’t get trained, but who can tell?)

    It’s a Huge Waste of Time and Money.

    Even though it's cheap as compared to instructor-led training, it's expensive when you consider what you get.  If the world only knew how much money and time was wasted on this stuff, it’d make the front page of all the newspapers.  This stuff is relatively expensive to create, it’s costed in terms of  an “hour” of courseware, and costs about 25–35 K per hour.  It’s a big industry.  It’s thriving because of basically a flaw in the structure of corporate spending and the inability to accurately measure the products of learning.

    If you want to teach someone how to do something, sit down next to them and show them.  If this is impractical, get them in a classroom for a week with someone who is passionate and knows their stuff.   If you can’t do this, send them to a conference for a week.  If this is too costly, send them to a code camp. If all else fails, buy them a library of books.  

    If you don’t care about true learning, but need to spend your training budget anyhow, then eLearning is for you.

    -Brendan

  • ClassMemberDisplayLayout Attribute Classs?

    A few weeks ago, Raymond IM’d me and asked if I remembered the attribute that you can apply to your class to force the explicit layout of members.  I asked him why he would need or care about the layout of his class members, and he asked me: “Do you use NUnit?” and I immediately understood why he cared.

    NUnit, in it’s GUI, presents your test cases in alphabetical oder, not in the order that you created them in your class. Other programs like Reflector also present the methods in alpha order, in fact it looks like members are laid out in IL in this order.   This can be a little confusing when you’re doing TDD, and you’ve written a bunch of test cases, and you go to implement them.  So say you have this test fixture:

      [TestFixture]

      public class LiveLinkServiceTest

      {

        LiveLinkPrincipal [] liveLinkUsers;

     

        [SetUp]

        public void SetUp()

        {

          LiveLinkConfigInfoProvider llcip = new  LiveLinkConfigInfoProvider();

          liveLinkUsers = llcip.GetAllLiveLinkUsers(); 

          Assert.IsNotNull(liveLinkUsers, "LiveLinkPrinipal Array is NULL");

          Assert.IsTrue(liveLinkUsers.Length > 0, "LiveLinkPrinipal Array is EMPTY");

        }

     

        [Test]

        public void TestGetLiveLinkTransactions()

        { 

          LiveLinkService lls = new LiveLinkService();

          ContainerTransactions cts = lls.GetNewTransactions(System.DateTime.Now.Subtract(TimeSpan.FromMinutes(10)),liveLinkUsers[0]);

          Assert.IsTrue(cts.CONTAINER_TRANSACTIONS.Count > 0, "Container Transactions is empty");

          Console.Out.WriteLine(cts.GetXml());

        }

     

        … // Rest of class removed

    }

    Here’s how it ends up looking in NUnit… Note that the order of my tests are alphabetical, not in the order I arranged them in my class.

    Unittest1

    NUnit will load the DLL, and display your methods in alphabetical order, unless it’s already loaded and cached the tests, in which case it adds new methods that it finds to the bottom of the tree.  This only happens when the DLL is re-loaded.

    It’d be nice to test them one at a time, from top-to-bottom, as you write the code and go “green”, in the order that you arrange them in code.

    So, here’s the point of this post.  Is there an attribute that you can use to order these methods inside an assembly?  I’ve researched StructLayout Attribute Class. and while it will affect your assembly class’ fields, methods are not affected.

    If there’s not an existing attribute, would it make sense to have one that programs like Reflector and NUnit, that use reflection to determine class members, can use to determine method ordering for display purposes?

    How about ClassMemberDisplayLayout Attribute Classs? Would this make sense?

    -Brendan

  • Dave Burke : Pimp My Blog

    Dave Burke is rapidly becoming my "Go-To Guy" for Community Server modifications.  His blog is so decked out with customization, he ought to re-name it "Pimp My Blog."  Some of his recent modifications include:

    CSBlogs : Expanded Panel Post Display. No longer a compromise
    This is a very cool expand-collapse mod for posts.  Look for this soon on CodeBetter.Com.

    CSBlogs : Abbreviated post list display with Expanded Panel

    A nice home page post list display.

    Or, just visit his entire category on Community Server.

    Makes me feel like I'm driving a beat up old ford. ;)

    -Brendan

  • Disk Space Exhaustion via Crystal Reports Vulnerability

    Today, I noticed some suspicious activity on one of our web servers here at work.   I quickly discovered that we were being scanned for vulnerabilities, from what looks like a security company!

    Now, the way I see it, there's a few possible explanations to this.

    1. They’re doing a scan and they’re going to give us a sales pitch for security consulting. (they’d have to be idiots to do this, but who knows)
    2. They’ve been hacked, and this assault is coming from one of their servers. (they’d be idiot-filled, idiot-covered idiots if this were true)
    3. Or someone is spoofing their IP address. Anyone know of a way to determine if this is the case?

    Well, anyhow, the scary thing about this is that one of the exploits they’re trying to use is this one:

    Business Objects Crystal Reports vulnerability advisory

    2. Disk Space Exhaustion

    The Crystal Reports web delivery module relies on the image delivery module to both deliver the image file and cleanup the disk space it occupies. Hence, calling the report generation modules repeatedly without retrieving the related images (e.g. by using a Perl script) causes the report engine to take up more and more space in the image file folder. Not only that disk space is consumed quickly but response time for other users become substantially longer as the number of files in the folder increase. Eventually disk space will become exhausted.

    Exploit

    The exploit is carried out by simply sending a request URL to the crystal reports server looking like this:

    http://foo,bar/crystalreportviewers/crystalimagehandler.aspx?dynamicimage=..\..\..\..\..\my documents\private\passwords.txt

    I’d suggest that you patch your server, if you’re suffering from even a mild case of Crystal Reports, but then I read this:

    So, my suggestion to you my friend is run - far far away from Crystal.

    -Brendan

  • Brand your CS Feeds with the RSS 2.0 image Tag

    If you subscribe to a CodeBetter.Com blog with Bloglines, for example, you may have noticed that we’ve added an RSS 2.0 image tag to our feeds.

    This involved just a few lines of code, all added to Community Server’s $\Components\Syndication\BaseRssWriter.cs class. Here's the step-by-step if you want to do it yourself.

    Step 1: Add an AddImageElement Method.

    Add this code somewhere in the BaseRssWriter class:

        /// <summary>

        /// ADDs the image element.

        /// </summary>

        /// <param name="link">Link.</param>

        /// <param name="description">Description.</param>

        protected void AddImageElement(string link, string description)

        {

          // Image Example

          //<image>

          //  <title>Joel On Software</title>

          //  <url>http://www.joelonsoftware.com/RssJoelOnSoftware.jpg</url>

          //  <link>http://www.joelonsoftware.com</link>

          //  <width>144</width>

          //  <height>25</height>

          //  <description>Painless Software Management</description>

          //</image>

          this.WriteStartElement("image");

          this.WriteElementString("title",Title);

          this.WriteElementString("url", BaseUrl + "/RSS2Image.gif");

          this.WriteElementString("link", FormatUrl(link));

          this.WriteElementString("width", "144");

          this.WriteElementString("height", "25");

          this.WriteElementString("description", description);

     

          this.WriteEndElement();

        }

    Step 2: Add Calling Code to the BuildChannel Method.

    Add the bolded statement below after the “generator” element in the BuildChannel method.

        protected void BuildChannel(string link, string description, string lang)

        {

          this.WriteElementString("title", Title);     

          this.WriteElementString("link", FormatUrl(link));

          this.WriteElementString("description", description);

          this.WriteElementString("dc:language", lang);

          this.WriteElementString("generator", SiteStatistics.CommunityServerVersionVersionInfo);

     

          this.AddImageElement(link, description);

        }

    Step 3 Create your RSS Image:

    Create a 144 x 25 pixel gif image, and place it in the root of your Community Server Site.

    Okay, if you’ve looked at the code above and thought to yourself, “What if my image is a different size?” or “What if I want a different image for each blog?” or “What if I want to use a JPEG or PNG image instead?” 

    Well, then you’ve got some code to write!  For now, this was a quick fix, and I only wanted to add one image to all feeds so I didn’t make it configurable.  You should be able to add these as configuration properties, but this will involve additional coding.  If you only want one image for all feeds, my code will work fine for you.

    That’s it! 

    -Brendan

  • Are there any good DNN E-Commerce solutions?

    Believe me, I've Googled this one first.  I can't seem to find one good e-commerce solution for DotNetNuke.  This is really surprising.  The ones that I have found either 1) randomly speak German or 2) aren't at all configurable.   I've spent a couple of weeks searching, but so far have drawn a blank. 

    So, does anyone know of any DNN shopping cart/product catalogs that they can recommend?  I'm at my wits end looking for this.

    -Brendan

    [p.s. I'm more than halfway to my $250 goal for the MS Walk-A-Thon. Thanks to everyone who's pledged so far!]
  • Cool DHTML/DOM Scripting Site

    The nice thing about having a father who teaches digital art at a university is that he sends you cool sites like this from time to time... These have got to be some of the most impressive examples of cross-browser DHTML/DOM scripting I've seen.

    -Brendan
  • GOF Design Pattern Examples in C#

    At Data and Object Factory I just found a great set of C# examples based on the Gang of Four Book.

    The Gang of Four (GOF) patterns are generally considered the foundation for all other patterns. They are categorized in three groups: Creational, Structural, and Behavioral. Here you will find information on these patterns together with downloadable source code in C#. (from Design Patterns)

    These examples are really helpful in understanding these patterns, especially if you’re a C# developer.

    -Brendan

    [I’ve raised $95 via my blog, for the MS walk. I hope to get to $250 by next week]

More Posts