Uncategorized

Using PowerShell to Ease the Pain of Branch-per-feature in Web Applications

Posted in Uncategorized on May 10th, 2010 by Brian – 1 Comment

I’m currently using Mercurial for source control at work, and I absolutely love it.  I love the cheap branching, fast operations, and merging that actually works.  One of the side effects of using a branch-per-feature workflow in Mercurial is that you’re constantly creating new copies of your project structure in the file system.  Unlike Git, where the guidance is to create branches within one working copy of the repository and switch between them, the Mercurial community recommends creating full clones instead.

Even when doing development work, I like to use IIS for serving my web applications rather than the Visual Studio web server (Cassini), so my development environment is as close to production as possible.  I’ve gotten bitten a couple of times when transitioning from Cassini during development to IIS in production, so I decided to just use IIS from the start.

Using these technologies in combination, I started to run into a problem.  Every time I created a clone of my web app’s repository, I had to set up the directory as an IIS application, plus add the permissions required for IIS to read static files (and in my case, write to a temp images directory, since I’m using the Microsoft charting tool).  To make this process easier, I whipped up a couple of PowerShell scripts to take care of all those tasks in one fell swoop.

   1: # New-App.ps1

   2: # usage: New-App "VirtualDirectoryName"

   3: param([string]$appName = "appName")

   4: $path = $pwd.Path

   5: $fullAppName = 'IIS:\Sites\Default Web Site\' + $appName

   6: pushd

   7: cd iis:

   8: ni $fullAppName -physicalPath $path -type Application

   9: cd c:

  10: popd

  11: $acl = Get-Acl $pwd.Path

  12: $inherit = [system.security.accesscontrol.InheritanceFlags]"ContainerInherit, ObjectInherit"

  13: $propagation = [system.security.accesscontrol.PropagationFlags]"None"

  14: $arIUSR = New-Object system.security.AccessControl.FileSystemAccessRule("IUSR", "FullControl", $inherit, $propagation, "Allow")

  15: $arIISIUSRS = New-Object system.security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "FullControl", $inherit, $propagation, "Allow")

  16: $acl.SetAccessRule($arIUSR)

  17: $acl.SetAccessRule($arIISIUSRS)

  18: Set-Acl $pwd.Path $acl

A couple of things about this one. A few things are hard-coded, like the site name (this will probably be “Default Web Site” on your machine, too unless you’re running a server OS) and the “FullControl” access, which can be changed to whatever minimum level of access you need the IIS accounts to have, like “Read” or “ReadAndExecute”.

I wish there was an easier way to set the permissions on the directory, but the System.Security .NET API was the only way that I found.  I’ve always felt that calling .NET code from PowerShell was a little bit kludgey, but I’m glad it’s at least possible to fill in the gaps in functionality.

In order to not leave an orphaned IIS virtual directory when I’m done with a branch, I use this script, which will search for the app by the physical path. This one could be fleshed out a little more.  It assumes that the virtual directory exists at the root of the default web site, and that you’re executing the script from the directory itself.

   1: #Remove-App.ps1

   2: $path = $pwd.Path

   3: pushd

   4: cd iis:

   5: cd 'IIS:\sites\Default Web Site'

   6: $site = ls | Where-Object {$_.PhysicalPath -eq $path}

   7: ri $site.Name

   8: cd c:

   9: popd

One more note: you’ll need to import the “WebAdministration” PowerShell module to get this to work. If you’re on Windows 7 and you’ve got PowerShell docked on your task bar, you can just right click and choose “Import System Modules”, the web admin module (along with a few others) will be imported into your PS session.  Otherwise, you can execute “Import-Module WebAdministration” at the PowerShell prompt or in your profile script.

Hope this helps somebody!

I Love Lucy

Posted in Uncategorized on February 24th, 2010 by Brian – 4 Comments

This past Friday, the Sullivan family got a little bit bigger.

Lucy Sullivan

Mom and baby are both doing fine.  I have to say, at least from the daddy perspective, the prior experience definitely helps.  I feel like things are going much easier than they did with our first daughter, Molly.  We’re still getting quite a bit less sleep than normal, but there aren’t as many unknowns, and we don’t get stressed out about everything the way we did the first time.

And Lucy herself has been making it pretty easy; she’s a champion sleeper, just like her daddy!

Needless to say, blogging has taken kind of a back seat, but I hope to start back up again soon.

Upgrading to Windows 7 RC

Posted in Uncategorized on May 30th, 2009 by Brian – 2 Comments

I’ve had Windows 7 Beta installed on my personal laptop since it became available for download back in January, and I’ve really enjoyed using it. However, since I found out that, starting July 1st, copies of Windows 7 Beta will shut down every 2 hours, I thought it might be time to go ahead and install the RC.  The thing that was holding me back was that there’s not an upgrade path from the Beta to the RC, so I would have to do a clean install of the OS.  My machine was probably not due for a Windows reinstall quite yet, but it never hurts.  ;-)

I also decided to take the plunge into 64-bit for the first time, and it hasn’t been too painful.  The only thing that I ran into was that shell extensions for 32-bit programs don’t show up.  Fortunately, the three programs that I want the shell extensions for (Tortoise SVN, 7-Zip, and Vim) all have some form of 64-bit version available, so I’m all good.

The most painful part of the rebuild process by far was installing SQL Server 2008.  There are several downloads on the download site, and the descriptions of each have been so marketing-ized that you’re not even sure what the difference is between them all.  Once you’ve got the right one (maybe, who can tell?) downloaded, the installer is so cluttered with options and “upgrade analyzers” that it’s difficult to tell how to actually install the product.  The install experience needs some serious rework.

The other thing I’m going to have to do is reinstall GRUB, because right now I can’t get to my Ubuntu install, but I think I’ve found a good guide to doing that here.  Wish me luck!

NHibernate ICriteria Queries – Way Too Many Strings

Posted in Uncategorized on May 22nd, 2009 by Brian – 2 Comments

I hoped to have a lengthier blog post ready for tonight, but I just didn’t end up with enough time.  Instead, I’m just going to use this opportunity to say that I’m really looking forward to NHibernate.Linq being production ready.  The following block of code is more or less the query I have to build up to execute that search I talked about last post, not including the extra filters that are appended for each user-input value:

ICriteria query = session.CreateCriteria(typeof(Campaign));
query.CreateCriteria("CampaignStatus", "s");
query.CreateCriteria("CampaignType", "ct");
query.CreateCriteria("CampaignLocations", "cl")
    .CreateCriteria("Location", "l")
    .CreateCriteria("County", "c")
    .CreateCriteria("Territories", "t")
    .CreateCriteria("Company", "com")
        .Add(Restrictions.Eq("com.CompanyID", 1));
IList cams = query.SetProjection(Projections.ProjectionList()
                  .Add(Projections.Count("cl.DateResponseReceived"), "ProspectCount")
                  .Add(Projections.CountDistinct("l.LocationID"), "LocationCount")
                  .Add(Projections.GroupProperty("CampaignName"), "CampaignName")
                  .Add(Projections.GroupProperty("ct.Name"), "CampaignType")
                  .Add(Projections.GroupProperty("s.Message"), "CampaignStatus")
                  .Add(Projections.GroupProperty("StartDate"), "StartDate")
                  )
                  .SetResultTransformer(Transformers.AliasToEntityMap)
                  .AddOrder(new Order("StartDate", false))
                  .List<IDictionary>();

Waaaay too many strings for my taste.  Looking forward to completely strongly-typed queries.

One Year at Praeses

Posted in Uncategorized on May 20th, 2009 by Brian – Be the first to comment

May 7 marked one year since I started my current job here at Praeses, back home in Louisiana.  It’s been a pretty good year, and I’ve come away with some valuable experiences.

Apart from some playing around (and I realize now that that’s what it was) with ASP.NET at Data-Tronics, my first real-world experience with the platform came when I started here.  At my previous job, all web work was done with classic ASP, and I was anxious to start using a more modern technology.  I still have nightmares about the awful spaghetti-code reporting system that I worked on when I started at DTC.  When I got to Praeses, I discovered that ASP.NET had its own set of anti-patterns and pitfalls; no technology is a panacea (no matter what the Rails guys try to tell you).  That said, I do definitely enjoy developing on this platform more.  WebForms may be full of cruft, but writing in C# beats the pants off of writing in VBScript any day.

I also got my first three Microsoft certifications during my first year here.  I wasn’t sure what to think about the prospect of getting these certs before I started, but now my opinion is pretty well formed.  Like a BS in computer science, certifications prove that you can take tests, mostly.  You may learn a thing or two during the process, but most of your learning is really going to take place on the job and through personal study.  At the end of the day, it’s mostly just a line on your resume, but a line that may open up opportunities for you, and so one that may be worth pursuing.  I had a very interesting discussion with our CEO via email when he asked me if I thought that studying for the exam I had just passed had made me a better developer.  That entire story is probably worth a post of its own, but suffice it to say that I’ve done my best to influence the way our company thinks about developer education.

A couple months after my arrival in Louisiana, I decided to take advantage of an interesting opportunity.  I had just started attending the Fort Smith DNUG when I left, and I had greatly enjoyed the additional learning and networking opportunities it provided.  However, there was no .NET user group closer to Shreveport than Dallas, so I decided to start one.  It has been an interesting experience, but one which I in no way regret undertaking.  I think the Shreveport .NET community needs this resouce, whether I was the one who got the ball rolling or not, but I’m glad that it was me.  It’s been a great way to improve my organizational skills, and I think it will serve me well in the future.

In addition to all the professional stuff that I accomplished this year, my personal life has also been quite busy.  We sold a house, bought a house, and lived through staying at my in-laws for 5 months.  Our baby went from a cooing, screaming infant to a walking, talking, singing, dancing little person.  My wife Rachel became a tutor with a substantial client-base, and I became much more adept at taking care of Molly by myself in the evening, at least for a couple of hours at a time.  We found a good chruch home in River Valley Church, and a pastor that we can really look up to as a spiritual guide and mentor in Lowell Kenyan.

All in all, it’s been a pretty good year.  We still miss our friends from Fort Smith (Josh and Jen, our LTD friends, all my buddies from work), but Bossier City is really starting to feel like home again.  And it’s good to be home.

 

P.S. - Yeah, I know, I forgot to post yesterday.  Two days into it and I already goofed.  Not exactly the picture of good follow-through, am I?  Well, it was the spirit of the exercise, anyway, so I’ll just extend the timeline by one day.

Back Up and Running

Posted in Uncategorized on January 16th, 2009 by Brian – 1 Comment

Okay, so here’s what happened.  Kevin Dente twittered about the hosting deal he got a couple of weeks ago at Dreamhost.com, which was much better than what I was paying at GoDaddy.  Since my renewal was coming up soon anyway, I thought it was a great opportunity to save some money.  So I filled out all the forms, paid my $20, and was quite happy with myself.  I quickly realized my mistake, however.  The one choice the forms at Dreamhost didn’t offer me was which OS to run on.  That’s right, Dreamhost is Linux only, and I was running on BlogEngine.NET.  Fail.

It turned out not to be that bad, though.  One of the auto-installable applications Dreamhost offers is WordPress, so I just had to figure out how to import my blog entries to WordPress from BlogML, the export format used by BlogEngine.NET.  Fortunately, Aaron Lerch had developed a module to do just that.  After following his and Nate Irwin’s instructions, all my old posts were imported, albeit with some weird question-mark-looking characters in the posts.  I’ve cleaned up a lot of those, but if you look at some of my older posts that I was too lazy to clean up, you’ll see what I’m talking about.

I have to say, after using dasBlog and BlogEngine.NET, the WordPress management interface is like a breath of fresh air.  People talk about the codebase being crappy, but the user experience is excellent.  Lots of features, a pleasant UI, and stuff just works.  I’m quite happy I made the move, even if it was by accident.

Another couple of plusses because of the Dreamhost move:  unlimited storage space, ssh access, and Rails.  I’ve really been wanting to dig more into Rails lately, and having the opportunity to put stuff out on the intarwebs if I happen to create something cool is great.

Thanks for bearing with me as I transitioned!

New Job Update

Posted in Uncategorized on May 20th, 2008 by Brian – 2 Comments

I’m on my third week at my new job, and I’m starting to get a better idea about what it’s like to work there. Every place has it’s quirks, but I think I’ll be able to live with the ones here.

After I successfully reconfigured my machine’s development environment, (since the first time I had some trouble with the Active Reports designer) my new boss said, “Hey, now that you know how to do this, why don’t you refresh a couple of our test VMs to get them current with production.”

Epic. Fail.

It wasn’t actually that bad, but I was a bit disgruntled to be doing admin work when I was hired to be a developer, and the company has two full time admins plus a remote part-timer. But wait, it gets better. A few days later, when I had another error that was occurring on my machine but not on the one belonging to the developer I was working with, we decided that my machine was just crap, and we just needed to get me a laptop. The image used for laptops is different (needing different drivers, after all), so we figured there must just be something wrong with the desktop image.

Turns out it wasn’t that after all, but I’m glad I got the laptop anyway. That way I can work from home if I need to. Needless to say, with all the starting over I had to do, I’d had quite enough by the time I was done.

After my admin stint, however, I got into making real changes to the site. Actual user requests, too, not “Alphabetize all the procedures in this program.” Even though, most of my changes were in the Active Reports designer, I got a glimpse at how things are structured here. All of the data access (and it seems some of the business logic) is in SQL Server stored procedures. This is an interesting concept for me, since my former employer didn’t use any stored procedures. I suppose it’s good thing that the first certification I’ll be working on is for SQL Server.

I’ve had all kinds of idea for blog posts over the past couple of days, but with things as hectic as they have been, I just haven’t had the opportunity. Since my wife is up in Arkansas and I’m down in Louisiana for the rest of the week, I’ll probably get an opportunity to post a couple more times. Perhaps that will help alleviate the guilt of infrequent posting!

My First Week

Posted in Uncategorized on May 11th, 2008 by Brian – Be the first to comment

I just finished my first week at my new job. Unfortunately, there’s not a whole lot to tell about the differences in development experience at this point, because I haven’t gotten the development environment totally set up yet. I thought we were there at the end of Thursday, but Friday we found out that my machine wouldn’t display the ActiveReports designer correctly, no matter what we tried. So I’m going to have to go through the whole setup process again (not to mention reinstall all my pet tools like VIM) on another machine. Looking forward to actually being productive sometime next week.

The first day was mostly signing stuff and meeting everyone. There are about 50 or so developers, contrary to what I may have told people earlier. Enough that it will still take me a while to remember everyone’s names. One thing that was kind of disappointing that I discovered was that I’m not allowed to do paid consulting work outside my job, since this would be a conflict of interests with my employer. I can still do things for free, though, so I can help out whatever church I end up attending.

That’s it for now, I suppose. I’ll post again when I have a better picture of what the development experience is going to be like

Dallas Tech Fest 08

Posted in Uncategorized on May 4th, 2008 by Brian – Be the first to comment

I’m so glad I decided to go to Dallas this weekend. Since I’m starting a new job this Wednesday, I almost skipped out to clean the house more in preparation to sell it. In the end, though, my wife and I decided that we’d gotten enough done already that it would be okay if I went.

I got to hear some great talks, participate in an alternate languages open spaces, and sit in on a .NET Rocks episode recording on building community. And on top of that, I won a Mac Mini and a copy of Vista to dual boot on it! That’s right, I’m composing this blog post from that very computer. Makes the $60 in gas to get down and back up seem like a good investment, huh? ;-)

I’ve got material for several posts from the stuff I got to do there, so stay tuned!

A Big Decision

Posted in Uncategorized on April 25th, 2008 by Brian – 6 Comments

This past Tuesday, I resigned from my job of three and a half years, and my last day is May 2nd. This wasn’t caused by any real dissatisfaction with my job. Though not perfect, I enjoyed my work and liked my co-workers. My wife and I had decided shortly after our daughter was born that we wanted to be closer to family. A five hour drive may not seem like a long way to some of you, but it meant that our parents only got to see Molly once every couple of months, which is huge when you’re talking about a seven-month-old.

In a lot of ways, it feels like a graduation. It began recently enough that I can still remember my first couple of weeks vividly, but long enough ago that it feels extremely odd to think about not going there and seeing the same people every day.

I wonder if it might also be like a graduation in that I feel like where I’m going is more like the “real” world. Even though my old shop makes use of the .NET platform, it really doesn’t feel like a .NET shop. It’s an IBM mainframe shop that dabbles in .NET. The place I’m going has been using the .NET platform since its inception, and uses it as their primary development environment. There a little bit of RoR going on (which I take as a good sign; they’re open to new and non-MS things), but mostly ASP.NET in C#.

Also, rather than being an in-house IT provider, my new employer is a consulting firm. This will be a bit of a change for me. I’m used to dealing with one particular business (transportation), but now I’ll have exposure to all different kinds of industries. My customers used to be just a flight of stairs away, and were almost always willing to sit down with you to discuss a feature that you were working on. I have no idea now how accessible my new customers will be, or how much interaction I’ll have with them.

Another thing that will be new is certifications. I’m not sure which (if any) devs at my old employer have MS certifications. Since they have their own training department, it’s assumed that everything necessary will be covered in training classes. The new place doesn’t have it’s own training department, and besides, they want to give outside customers the warm fuzzy feeling that all the developers are “Microsoft Certified.” I’ve been told that when I start, I’ll have a goal set for a certain number of certifications by the end of my first six months. The company will pay for the books, plus my first attempt at the test. Fail, and I’ll have to pay for the next test myself. :-/

Related to that, I’ll also have a training budget for books, conferences, etc., which ought to be cool. Something like $3k a year, plus about three weeks per year of dedicated training time. Not sure exactly how I’ll use it yet, but I’m sure I’ll figure out something. ;-)

I’ve made a lot of friends in Fort Smith, and I’m going to miss them all a lot. I’m not sure how I’m going to be able to work without getting Travis Ebert’s weekend updates, and without being able to run over to David Mohundro’s cube when I have a design question. Not living next door to Josh and Jennifer Pense (our best friends and carbon-copies) will feel so strange, and we will miss them terribly.

On top of everything, our house was recently damaged by hail, so we have to get all of the siding and windows on the front of the house replaced and get a new roof before we can put it on the market.

I apologize if I’ve rambled a bit. My brain has been a bit addled since Tuesday, but I knew I had to get this post done soon, or I would never do it. I’ll be able to post more descriptive updates regarding the new job once I start on the 7th.

It’s a huge decision, and kind of scary, but I know God will guide our family in the direction He wants us to go. “And we know that in all things God works for the good of those who love him, who have been called according to his purpose.”