Re-doing a paver path

So I wanted to redo the paver path behind my house.  After I tore the old one out, I only had a few good pavers left and couldn't find matching ones.  Being that my budget was tight on the redo before a family picnic, I decided to rip some 2x4 s into 2x2 and create a frame for the existing pavers to elevate them above the ground and fill the rest in with a washed stone.  I also put the new planter in on the left, but that's a job for another post. 
So first the final product in case you don't want to look any further.  Now how I did it.
I started by laying out the blocks I had and figuring out the gap I needed between each to make my distance.

Once I had this, I started making a frame for the blocks.
I put a little strip of wood under each one to make sure the paver wouldn't work its way through and the wood become elevated around them.  
It was about 20 feet so I made 2 of them that fit together.  I then stained them up to match the deck stain on the house.  It took a few coats, I realize they won't last forever, but it should get me a decade or so, at which point it will probably need to be freshened up again anyways, so a quick fix that I think turned out good.  One last pic after install before the gravel.

Tree House Build

So the kids wanted a tree house, this is what they got.
I know, not exactly a tree house, but its sitting around 200+ year old oaks, and I really didn't feel confident in injuring them at all.  So perhaps elevated playhouse is a better name.  In any effect, here is my build.

I started by clearing the area with my tractor and digging 4 foot post holes, one was only 3 foot when I hit bed rock.  
I put in 8 inch tubes and filled them with cement.  I put a 3/4 lag in the top of each to tie to.

Next I put a post plate on each for a 6x6.
Everything went together good here and the measuring and cross corner checking when I dug the holes really paid off, the entire thing was very square.  Next, I set 2x12 beams (2 on each) on the top of the posts.  I notched the posts to make it super solid and used 3/4 inch lags to hold them together.
From there I was able to build the joists that would be the floor of the playhouse.  I used 14 foot 2x8 with a 3 foot cantilever on all sides.
The top of the deck is now 6 foot off the ground for scale.  Next I decked the front 4 feet for porch and put sheeting down in the back half for the house.  I used all green treated lumber to this point I should mention.  Even the sheeting, which is extremely heavy (3/4 inch 4x8 green treated).
So then I framed up my walls all the way around with openings for the door only.  I didn't have windows to begin so didn't bother framing them in at this point.  I will cut and frame them in as I get them so I have more options for finding used windows.

So next I framed up a loft on the back 60 inches of the house using 2x6 boards.  I doubled up the 2x6 on the front to make a beam that could support the loft.  I used joist hangers to put them all in.  After that I swung joists.

So at this point we have the skeleton and I started sheeting it.  I just used A11 grade siding plywood in 4x8 sheets with galvanized #8 nails.  The walls were all 6 foot 3 so I can walk in without hitting my head so the sheets hang down a bit.

Once that was all in place, I started sheeting the roof with half inch OSB.

This picture has the drip edge on already.  So the final step was putting the metal roof on.  We also put a railing up by pocket screwing 2x4 on the posts that hold the roof up and putting spindles in.  We had created a 2 level playset the year before and moved that to the other side of the tree and build a bridge with some short 2x8.  The entire thing is 14 x 12 with a 10 x 12 playhouse 4x12 deck, and 5x12 loft.  I still need to make a door, frame in windows, fur the edges, and stain the whole thing.  But I will follow that up later.

Simple use of the JQuery TableSorter

I have had quite a few web pages recently that could use a little love in the display of large tables of data.  For one, we wanted paging and sorting of the columns.  This is a common problem, and the JQuery TableSorter makes easy work of doing this on your front end.  Here is what you need to do to make it work.

1. The first thing to do is include the correct JQuery files.  I did this using the Scripts.Render function in MVC.

2. Next, you must give the table containing your results a good name, I used tablesorter as the class name of the table to index from.

<table class="tablesorter" width="100%">

3. Next, make sure the header row is wrapped in a thead tag and each of the header row cells is a th, not a td.

4. Finally, after the table, put the following code in place.  Its a new div that will be the pager for paging and some javascript to set up the table and render it correctly.  I also added a section that does mouse over highlighting of rows since alternating row text isn't available through this technique, or at least that I could find.

<div id="pager">
            <img src="@Url.Content("~/Content/images/first.png")" class="first" />
            <img src="@Url.Content("~/Content/images/prev.png")" class="prev" />
            <input type="text" class="pagedisplay" />
            <img src="@Url.Content("~/Content/images/next.png")" class="next" />
            <img src="@Url.Content("~/Content/images/last.png")" class="last" />
            <select class="pagesize">
                <option selected="selected" value="20">20</option>
                <option value="40">40</option>
                <option value="80">80</option>
                <option value="160">160</option>
<script type="text/javascript">
    $(function () {
        $("table.tablesorter").tablesorter({ widthFixed: true, sortList: [[0, 0]] })
        .tablesorterPager({ container: $("#pager"), size: $(".pagesize option:selected").val() });
    $('td').mouseover(function () {
        $(this).siblings().css('background-color', '#EAD575');
        $(this).css('background-color', '#EAD575');
    $('td').mouseleave(function () {
        $(this).siblings().css('background-color', '');
        $(this).css('background-color', '');

Pentaho Salesforce Foreign Key Loading

I was tasked with loading data into SalesForce from Pentaho.  There is a built in upsert command to do this, so it should be easy.  And for the most part it was, however, one issue that I came across is using external keys for linking objects in salesforce.  You can simply load values with the upsert, but if you are referencing another object by a key, it isn't straight forward or built well into the UI.  What needs to be done is almost an xslt type reference to the key of the other object.  

In my case, I had loaded all the accounts and needed to load orders.  The orders referenced the account by Account Number, which was a key on our custom account object in Sales Force.  After much trial and error, I was forced to do the following to tie the two together.

In the Module Field (Sales Force Field) I had to reference the object (Account) followed by a colon and then Acct_Number_C/Client_Account_R which the first half is the field on account and after the / is the field on the order object.  Once you do that, the objects are inserted and tied together correctly.


How to Tag Classes To Determine Which to Reflect with MEF

So my last post covered loading classes dynamically from a directory in a plug-in fashion using MEF.  What I am going to talk about to day is how to customize that implementation to determine which plug-in to load.  This isn't a standard workflow with plug-ins, however it has its uses.  Generally with a plug-in, you load them all up and run the functions in each.  In my case, I have a database I am storing records to, and each record has a particular record type associated with it.  Depending on the record type, I want to load a particular plug-in to do processing. 
You may be thinking, this makes the client know about the plug-in's and makes them useless, however I in this case, I am creating records and assigning type at run time.  To assign type, I simply load the plug-in folder, and give the user a drop down list of the plug-ins to choose from then store the selection as a string in the database, so the client itself doesn't know about what plugins are there and adding a new plug-in will "just work" and dynamically load to the UI and can be used without any further configuration, so still holds true as a plug-in in my opinion.
The challenge with implementing this is to correlate the string with the class.  It would be easy enough to just use the class name, however that wouldn't be very user friendly.  Instead, I found the ExportMetadata tag to put on my classes.  Let's take a look.
    [ExportMetadata("Identifier", "Add")]
    public class Addition : ICalculationService
        public override int Calculate(int number1, int number2)
            return number1 + number2;
As you can see, the class is the same as my previous post with the addition of the ExportMetadata tag which creates a name value pare.  I did string as my storage type.  Now I need to declare an interface for this metadata, the reason why will show up when we reflect it below.
    public abstract class ICalculationService
        public abstract int Calculate(int number1, int number2);

    public interface ICalculationServiceData
        string Identifier { get; }
So there is the interface, rather simple.  It only includes the attribute Identifier which will map to the key in the key value pair created with the ExportMetadata.  Now time for the magic, how to get this info when MEF reflects the classes.
public class PluginRepository
        public IEnumerable<Lazy<ICalculationService, ICalculationServiceData>> CalculationServices { get; set; }

        public PluginRepository()
            var catalog = new DirectoryCatalog(Environment.CurrentDirectory + "/Plugins/");
            var container = new CompositionContainer(catalog);
That's my simple Plugin Repository class.  It looks in a passed in a Plugins directory under the current running directory and reflects out my ICalculationService objects into a Lazy object.  The lazy object has the ICalculationService object as well as the ICalculationServiceData object which contains my Metadata.  Now I can find my object in the array with the following simple Linq.  Very simple and relatively clean.
var obj = pluginRepository.CalculationServices.Where(c => c.Metadata.Identifier == "Addition").FirstOrDefault();
I haven't looked too much into the performance impact of reflecting all classes each time to load 1 for 1 function, however the Plugin Repository could be implemented as a singleton as to not allow the loading to happen more than once.  Content for another post.