Replacing text in files using powershell

We restructured our source trees and so I had to update a bunch of HintPaths in my project files.

Here’s a simple powershell script to accomplish that:


gci -r -include *.csproj | %{
    $file = $_
    (gc $file) | %{ 

        if( ($_ -like "*<HintPath>..\..\..\_*") ) {
            $_.Replace("..\..\..\_", "..\..\..\..\_")
        } else {
    } | Set-Content $file

Dumping webforms views

Want to switch from using the Webforms ViewEngine to the Razor ViewEngine?
Got a lot of Webforms views? I know they can be used side by side, but if you feel like converting and are comfortable with vi then these substitutions can help you along your way

Replace <% if and <% foreach (or anything but <% { really) with @if and @foreach
:%s/<% \([^}]\)/@\1

Replace any <%= followed by a space with @
:%s/<%= /@

Same as above but omit the space

Get rid of any remaining <%

Get rid of any %>

This won’t be perfect, but will get you close with very little effort.

Add this to your .vimrc file and do it with one command


function! DumpWebforms()
  %s/<% \([^}]\)/@\1
  %s/<%= /@
Then invoke using :call DumpWebForms()

Designer for a day

I am horrible at design. horrible.

Every once in a while I get a wild hair and want to start to do something about it. And today is just one of those days.

I’ve had the domain for several years now and have never done anything with it. So I figure while I’m exploring design concepts it is a good opportunity to kill 2 birds with one stone.

Right now I’m watching this video about typography by Robby Ingebretsen and reading through this tutorial about page layout.

My plan is to take what I learn and then apply to the design of my site will keeping things to an absolute bare minimum.

To start with I tried to sketch a rough idea of what I might want and wound up with this:

Photo Apr 16, 1 34 45 AM

The one thing I was pretty sure of was that I wanted to have my most recent tweet act as the main heading.

I then thought to incorporate pictures of my kids along the bottom but then started getting some creative ideas for how to position the pictures differently. I also seemed to be running out of realestate.

I really liked the three column and full screen picture layouts

websitelayout_threeboxes websitelayout_fullscreenphoto

The three column felt a bit simpler so decided to pursue that first. The design evolved to this

Photo Apr 16, 1 34 15 AM

Here I wound up with 2 sections 1 for work/technical stuff and one for life. This illustrates the whole work / life balance thing. The curly braces will also be part of the design as sort of a hat tip to my programming side. I also want a callout that will have my next speaking gig or conference. But may decide to put other stuff in there as well.

Getting started with chocolatey

Well, looks like I can cross one more thing off my list of todos.

Take a look at chocolatey

What Rob has done is to give us a way to have a machine wide nuget repository. It reminds me a lot of homebrew if you are familiar with that sort of thing.

Because it is machine wide I wasn’t quite sure how to get started with this, however once I just tried it I noticed that Rob already had instructions setup (you just don’t see them until you try to install)

So, either open up an existing project or just create a new blank one in visual studio.
Then do install-package chocolatey and follow the instructions. When finished you can uninstall the package or if you created a new project just throw it away.

Nice work Rob!

What’s in System.Uri

I can never seem to remember just what each property on System.Uri means so I have this little powershell one liner that will do the trick:

$uri = new-object -TypeName System.Uri http://localhost:880/vdir/file.xml?q=1

$uri | format-list

Here’s the results, makes a nice cheat sheet


AbsolutePath   : /vdir/file.xml
AbsoluteUri    : http://localhost:880/vdir/file.xml?q=1
Authority      : localhost:880
Host           : localhost
HostNameType   : Dns
IsDefaultPort  : False
IsFile         : False
IsLoopback     : True
IsUnc          : False
LocalPath      : /vdir/file.xml
PathAndQuery   : /vdir/file.xml?q=1
Port           : 880
Query          : ?q=1
Fragment       :
Scheme         : http
OriginalString : http://localhost:880/vdir/file.xml?q=1
DnsSafeHost    : localhost
IsAbsoluteUri  : True
Segments       : {/, vdir/, file.xml}
UserEscaped    : False
UserInfo       :