Powered by discountASP.NET
referal ID: sdtref
Why recommend discountASP.NET?
$720 in referrals so far!

About/Contact

Steve Trefethen

Steve Trefethen is a Software Architect and Director of Software Training at Falafel Software in Capitola, CA. You can reach Steve here.

All opinions you read here are Steve's own and are not necessarily those of Falafel Software.

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Disclaimer

The posts on this weblog are provided AS IS with no warranties, and confer no rights. The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
If you're new here, you may want to subscribe to my RSS feed, follow me on Twitter, or subscribe via email. Thanks for visiting!

dasBlog provider for use with BlogEngine.NET

September 14 2009 8:36AM

I’ve used dasBlog since I first began hosting my own blog and previously considered a move to BlogEngine.NET (BE) but the URL’s aren’t compatible so there remains some investigation to figure out the best mechanism prior to switching. Unfortunately, dasblog seems to be on it’s final legs so spending time there at this point doesn’t seem wise.

To that end, I’ve been investigating various issues involved in a switch and in an attempt to make a transition easier I’ve created a BE provider which reads/writes blog posts and comments using dasBlog’s IBlogDataService rather than BE’s own XML provider. Basically, I’ve replace one XML provider with another, actually that’s not entirely true as this new provide is a descendant of XmlBlogProvider included with BE. Using this approach I avoid having to constantly re-import my blog data as I look into solving the URL issues.

I’ve made the code available via SVN on Google Code here so feel free to grab it and give it a go. I chose Google Code over Codeplex because the latter doesn’t want abandoned projects and I don’t see this as an ongoing project as it’s scope is quite narrow. What I’m interested in is any feedback regarding issues using the code and taking this sort of approach. In my initial playing around with BE it seems to function properly and allows me to use the “slug” feature of BE to “fix” at least part of the URL problem by simply removing spaces from Titles rather than replacing then with dashes.

Things I’ve tested (manually)

  • Adding/Editing/Deleting posts
  • Adding/Editing/Deleting comments

I haven’t played with images or attachments though my blog data seems to render fairly well. I can see some limitations such as no support for threaded comments though I don’t view this as a long term solution but I think it’s a step in the right direction.

Things that need testing/implementation:

  • DateTime conversions from dasBlog to BE
  • Image uploads
  • Windows Live support

Btw, I’m looking for help with the problem of retaining my existing URLs so if you’re a dasblog user and potentially interested in switching ping me and perhaps we can collaborate.

FacebookDel.icio.usDigg It!

Tags: , , , .NET | Open Source | Programming

Mail Server Log MIME Header Parsing

September 06 2009 5:12AM

imageThe other day a friend, whose not a developer, approached me looking for help with a problem they were having dealing a few large server log files. The file contained 100’s of MIME headers listed one after the other each with a starting comment and separated by a blank line. I was given a sample containing 1400 MIME headers which at first I opened in Windows Notepad and looked like what you see to the right. They had been trying to work with this file using Excel but not having much luck because the headers were inconsistent sizes and I imagine extracting the right fields was clearly a problem. The desired result was a format from which they could perform some analysis of the data and particularly of the X-Originating-IP field.

After about 10 seconds of staring at the data in Notepad I opened it in Notepad++ and things looked a bit more sane and it sort of dawned on me what my friend’s first thoughts probably were when they first glanced at this file. Excel looked better but didn’t make the process any easier.

image

A few choices entered my mind:

  • Write a simple parser, regex etc.
  • Look for an existing MIME parser
  • Use VS.NET editor Macros to extract the content
  • grep/findstr

My focus desire was to:

  • not spend much time
  • produce a CSV file
  • do something my friend could duplicate (lessen “support”)

I opted to search for a MIME parser largely because I figured one written in C# had to exist then write a tool to spit out a CVS file. My first Google search was “parse email header C#” which gave me a few interesting links but nothing that really caught my eye. The next attempt was “parse MIME header C#”:

image

Bingo.

The CodeProject article is largely code snippets and the first one looked interesting.

Mime m = Mime.Parse("message.eml");
// Do your stuff with mime

I thought, if there is .eml message parsing then I’m good regardless of the fact that it was expecting a file. I downloaded the source and it compiled without error, always encouraging. Next, I looked into the parsing support:

// Summary:
//     Parses mime message from byte[] data.
//
// Parameters:
//   data:
//     Mime message data.
public static Mime Parse(byte[] data);
//
// Summary:
//     Parses mime message from stream.
//
// Parameters:
//   stream:
//     Mime message stream.
public static Mime Parse(Stream stream);
//
// Summary:
//     Parses mime message from file.
//
// Parameters:
//   fileName:
//     Mime message file.
public static Mime Parse(string fileName);

Sweet.

For testing I saved off a single MIME header and created a simple console application to try and parse a fake .eml file which worked like a charm. All that was left to do was write some code to read the log file one header at a time and spit out a .CSV file.

I made one minor change to the MIME parsing code which was to change it’s HeaderFieldCollection from an IEnumerable to IEnumerable<HeaderField> so as to leverage LINQ to search for the “X-Originating-IP”. Of course, I later found out that the code attached to the article is outdated.

At any rate, I quickly had the file parsed, output to .CVS using a simple console application with input and output filename params which I mailed off. So, if you’re looking for MIME header parsing this library worked well for the 1400 headers I tried and I’m glad I could offer this tiny bit of help in a situation that sounds very serious for the folks involved.

Btw, kudos to Ivar Lumi for making this available, heck I think writing this post took longer than developing the solution.

FacebookDel.icio.usDigg It!

Tags: , ,

Simile Exhibit of Falafel Training Sessions

March 20 2009 6:41PM

image I’ve mentioned before part of my job at Falafel Software is online and onsite training which is a great and expanding business (fortunately in this economy). And recently, I’ve been working on training.falafel.com, Falafel’s new training website which includes a Google map driven by Simile Exhibit highlighting Falafel’s training engagements dating back to January of 2007. I’ve blogged about Exhibit before and found it to be a great visualization tool.

Exhibit is a pretty fascinating way to leverage both JavaScript and HTML markup. Using custom attributes on tags HTML tags you craft a page that using Lenses, Views and Facets creating a unique presentation of your data. In fact, the Map View super easy to use and “just works”. For example, the entire markup necessary for this training page looks like this (fyi, the Google Map Key has been removed as it’s very long):

 <html>
   <head>
       <title>Falafel Trainings</title>
       <link href="/trainingmap/trainings.js" type="application/json" rel="exhibit/data" />
       <script src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"
           type="text/javascript"></script>
       <script src="http://static.simile.mit.edu/exhibit/extensions-2.0/map/map-extension.js?gmapkey="
           type="text/javascript"></script>
        <style type="text/css">
        body {
            font-family:Arial,Helvetica,SunSans-Regular,sans-serif;
            font-size:12px;
        }
        </style>
   </head> 
   <body>
    <div style="float:right" ex:role="logo" ex:color="DeepSkyBlue"></div>
    <div ex:role="view" ex:viewClass="Map" ex:latlng=".addressLatLng"
        ex:center="38.479394673276445, -95.361328125" ex:zoom="4"
        ex:showHeader="true" ex:overviewControl="true" ex:colorKey=".type">
    </div>
    <table width="100%">
        <tr valign="top">
            <td width="50%" valign="top">
                <div ex:role="facet" ex:expression=".product" ex:facetLabel="Product"></div>
            </td>
            <td width="50%" valign="top">
                <div ex:role="facet" ex:expression=".location" ex:facetLabel="Location"></div>
            </td>
        </tr>
        <tr>
            <td width="50%" valign="top">
                <div ex:role="facet" ex:expression=".training" ex:facetLabel="Type"></div>            
            </td>
            <td width="50%" valign="top">
                <div ex:role="facet" ex:expression=".startdate" ex:facetLabel="Start Date"></div>
            </td>
        </tr>
    </table>
</body>
</html>

The data is in JSON format and loaded by Exhibit using a special <link> as you can see in the HEAD section above. To find lat/long coordinates for a set of data you can follow this tutorial and fetch them via a simple page loaded in the browser, though it’s limited as Google restricts how many geocode requests you can make within a given timeframe leaving you with partial results, or use a geocoding routine that handles the throttling for you ensuring a complete result set. In this case, I’m using a simple text file as we don’t have hundreds of items, at least not yet :-).

Exhibit supports numerous views though this example uses just the Map View, another example of a view is the timeline, built into dasblog, for displaying blog posts over time. As I’ve said before, if you haven’t looked at the Simile projects you should, they could save you lots of time.

So, how about it, have you used any Simile projects?

[Update: March 21, 2009] Fix typos.

FacebookDel.icio.usDigg It!

Tags:

Trigger exception logging now supported in Cruisecontrol.NET

January 22 2009 10:22PM
A little over a year ago I wrote a post expanding on a problem I was having in CCNET where exceptions thrown by a Source Control  Provider wouldn’t trigger the build publisher meaning there was no easy way to see something went wrong. Well, it took awhile but persistence paid off and thanks to Ruben Willems, who works on CCNET, a recent check-in has addressed this problem. Working from suggestions included in my patch he developed a more complete solution, after several iterations, that deals with a number of build status issues among other things. In case you’re interested the details can be found here and here.

Aside from the details you can now rest assured that if your Source Control Provider throws an exception the build publisher(s) will execute to let you know. Additionally, a new project property was added allowing for control over the number of exception that can occur before the project is simply stopped called maxAmountOfSourceControlExceptions which you’d use like this:

<project name="ProjectName" maxAmountOfSourceControlExceptions="3">
...
</project>
Again, big thanks to Ruben for his time and effort!
FacebookDel.icio.usDigg It!

Tags: ,

Hosting MIT's Simile Exhibit OS project

December 22 2008 6:56AM

I’ve been working on an application that makes use of MIT’s Simile Exhibit Open Source project and the other day the MIT server hosting the related JavaScript files went down. Exhibit is described thusly:

Exhibit enables web site authors to create dynamic exhibits of their collections without resorting to complex database and server-side technologies. The collections can be searched and browsed using faceted browsing. Assorted views are provided including tiles, maps, etc.

Here is an example. Based on what I can glean from the Exhibit newsgroup weather played a role but nonetheless it motivated me to investigate moving the sources to my ISP which happens to be discountASP.NET.While the main server appears to be back up and running at least one service needed for the map view extension is still offline making it more or less just a plain map absent the data points that make it interesting.

There was a request on the newsgroups to explain what I did to "self-host" the code so I figured I’d elaborate a bit. The main issue is that throughout the code there are hardcoded references to an MIT server, namely static.simile.mit.edu.

For starters, you’ll need to grab the Exhibit source code from SVN repository located here:

http://simile-widgets.googlecode.com/svn/exhibit/trunk

Fwiw, on Windows, I’m using TortoiseSVN as my SVN client. Next, correct the URL references in the code that refer to the above server. The source changes look like this:

        /*
         *  Extensions (for backward compatibility)
         */
        if (includeTimeline) {
            scriptURLs.push(useLocalResources ?
                "http://127.0.0.1:8888/exhibit/extensions/time/time-extension.js" :
//                "http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js");
                "http://www.stevetrefethen.com/simile/exhibit/webapp/extensions/time/time-extension.js");
        }
        if (includeMap) {
            scriptURLs.push(useLocalResources ?
                "http://127.0.0.1:8888/exhibit/extensions/map/map-extension.js" :
//                "http://static.simile.mit.edu/exhibit/extensions-2.0/map/map-extension.js");
                "http://www.stevetrefethen.com/simile/exhibit/webapp/extensions/map/map-extension.js");
        }

Basically, a simple search and replace for "static.simile.mit.edu will suffice to identify the locations that need to be changed. I also made one additional change I’m not sure is necessary which is the following query parameter on the script tag that loads the widget:

    

Bundling is not something I’ve examined closely though it’s in the interest of saving bandwidth for the amount of Javascript that has to be downloaded. Here is the set of files I modified with the type of changes described above:

Simile Exhibit modified files

Once you’ve made these changes you’ll need to upload the following source directories to your ISP:

simile/exhibit/ajax
simile/exhibit/webapp
simile/exhibit/graphics

Note, the above ajax and webapp directories each have a subdirectory called "site" that contains an example and should not be uploaded. You should now be set to host Exhibit from your own ISP. The map extension requires a Java servlet which you can also self host but since my ISP doesn’t provide that support I’m still relying on MIT’s server for that portion. I’m aware of one such alternative though I couldn’t get that working in the five to ten minutes I spent trying but I’ll likely revisit it as it’s clearly an important piece.

[Updated: March 28] On a somewhat related note I've created a simple Exhibit for my companies training engagements here.
[Updated: January 2010] Check out my Facebook application using Exhibit.
FacebookDel.icio.usDigg It!

Tags:

Modifying emails sent using CruiseControl.NET's email publisher

November 24 2008 5:24AM

Last year I wrote a brief post on configuring email for CCNET whereas this time I’m looking at changing the content of mail sent by the email publisher. Btw, modifying the email is identical to controlling the look of the web dashboard so this really covers both topics. The first thing to note is that the format of the email is specified in ccnet.exe.config (or ccservice.exe.config) as follows:

<!-- Specifies the stylesheets that are used to transform the build results when using the EmailPublisher -->
<xslFiles>
    <file name="xsl\header.xsl"/>
    <file name="xsl\compile.xsl"/>
    <file name="xsl\unittests.xsl"/>
    <file name="xsl\fit.xsl"/>
    <file name="xsl\modifications.xsl"/>
    <file name="xsl\fxcop-summary.xsl"/>
</xslFiles>

The above collection of XSL files (included, by default, with CCNET) are used to construct the email body in the order they’re listed. To change the layout or add/remove content you can either edit the above .xsl files or add your own to augment the output as you see fit. The down side is you’ll need at least some understanding of XSL to make those changes.

In the case of my EDI work with CCNET I want to publish error details from custom CCNET tasks using the email publisher. By modifying the email content I can include details such as what caused the build to fail. When these custom tasks execute they contribute XML to the build log which looks similar to the following:

<editask warning_count="0" error_count="2">
  <files>
    <error name="c:\edi\partners\inbound\P100451612.850.TXT" message="Invalid buyer or buyer not configured to allow EDI DUNS: 00xxxxxx9" />
    <error name="c:\edi\partners\inbound\SYSCO850.txt" message="Invalid buyer or buyer not configured to allow EDI DUNS: 8xxxxxxx7" />
  </files>
</editask>

To have this content included in the email I modified msbuild2ccnet.xsl which is a stylesheet from Christian Rodemeyer to parse MSBuild output (available here), and tweaked it to handle the above XML. I then added <file name="xsl\edi.xsl"/> to the above <xslfiles> section. When the build fails this content is included in the email that’s published. Btw, making the same change to dashboard.config and copying the .xsl file to the webdashboard\xsl folder will update the CCNET web dashboard.

FacebookDel.icio.usDigg It!

Tags: ,

Free Pascal Team releases version 2.2.2

August 18 2008 3:14AM

I want to highlight a comment (see below) from Marco van de Voort and congratulate the Free Pascal team on their recent 2.2.2 release. Marco originally commented on a post I wrote nearly a year ago regarding potential copyright issues and the source code of the project. It sounds like a lot of time an effort was put in to clear up any issues and further sounds like the project is on a good footing with tools in place to help prevent future issues. The comment from Marco is as follows:

The new release 2.2.2 has the disputed code removed, and the cut was made fairly wide (using a tool to identify candidates), and this has been merged to all currently live branches. This is also why it took so long.

We have retired the old releases from our site. (rather than relicense, which could have been since all the disputed code was available under GPL via FreeCLX. This was deemed to confusing)

Since nearly all public releases were affected by these disputed routines (most disputed routines arrived in one batch in 1998-1999, which was pre 1.0), this is particularly sad for some of the more odd ball platforms (like Atari) that are not supported anymore.

FacebookDel.icio.usDigg It!

Tags: