Mar 262009

I have absolutely no creativity when it comes to things like design, clothing, conversation, etc. I am at a loss for how I should layout my home office. I have a pretty decent sized space to work with, about 24 ft. x 15 ft. I have a desk and two bookshelves and I want to fill out the other half of the room. I really want to make it “feel” like an office. I’m currently thinking about:

  • A second desk for the occasional pair programming session
  • A couch/table for a mini “reception” area
  • A conference table

But I don’t want it to be too crowded or too sparse. The couch would be a nice place for me to lounge and read books (can’t do this upstairs in the living room with a 2 year old and wife) but a conference table in my basement would be so cool.

Of course there’s the issue of how to pay for it all. We have so far resisted the urge to put anything on our credit cards and everything we’ve bought has been with cash, so we don’t have a lot of extra spending money right now.

EBay has some good deals…. hmm…

HomeOfficeDiagram

It’s the little things in PowerShell that make a rigid C# developer smile… In the following example, I distribute an array result to separate variables in one line.

$NPA,$NXX,$Digits = Split-Phone 202-456-1111

# In C#, the equivalent would be
# string[] results = SplitPhone("202-456-1111");
# string npa = results.Length > 0 ? results[0] : null;
# string nxx = results.Length > 1 ? results[1] : null;
# string digits = results.Length > 2 ? results[2] : null;

And even the C# syntax mentioned above doesn’t exactly do the same thing because in PowerShell, if the array contains more elements than you’re distributing, the last variable can receive the “remainder” of the array. Since C# doesn’t really have a concept of singleton arrays being treated as strings, there is no direct analogy.

##############################################################################
#.SYNOPSIS
# Splits a phone number into NPA, NXX, and 4 digit components.
#
#.PARAMETER TN
# The telephone number to split.
#
#.RETURNVALUE
# If the specified number is a valid US telephone number, the return value is
# a 3 element array containing NPA, NXX, and the 4 digit line. Otherwise, an
# exception is thrown.
##############################################################################
function Split-Phone {

    param ( [String]$TN )

    
    $Pad = '\s*'
    $Sep = '(\s+|\.|\-)?'
    $Intl = '(?<intl>\+?1)?'
    $NPA = '(\s*\(?\s*(?<npa>\d{3})\s*\)?\s*)'
    $NXX = '(?<nxx>\d{3})'
    $Digits = '(?<digits>\d{4})?'
    
    $Pattern = "^$Pad$Intl$Sep$NPA$Sep$NXX$Sep$Digits$Pad`$"
    
    Write-Debug "Split-Phone Pattern: $Pattern"
    
    if ( $TN -match $Pattern ) {
        if ( $Matches['digits'] ) {
            @(  $Matches['npa'],
                $Matches['nxx'],
                $Matches['digits'] )
        }
        else {
            @(  $Matches['npa'],
                $Matches['nxx'] )
        }
    }
    else {
        throw "Invalid TN: $TN" 
    }
       
}
Mar 252009

This is funny. I installed Netscape Navigator in a virtual machine for that “blast from the past” feeling and I got this familiar message. Why was common sense so uncommon in software back then?

Nutscrape

Dick Morris says:

In an effort to promote liquidity and boost the economy, the Federal Reserve yesterday announced plans to grow the money supply by another 50 percent to 60 percent. This ignores the profound observation of Gen. George Patton: “You can’t push a string.”

But my friend Andre de Cavaignac proves that you can… Smile

var stack = new Stack<string>();
stack.Push(new string());

This makes me sick. We watched for months as the Obama smear campaign replayed the famous sound bite from John McCain saying “the fundamentals of the economy are strong.” Despite what the news would have you believe, the fundamentals of our economy ARE strong and they’ve been strong all along. There are a few weak sectors that are spilling over into the rest of our economy, but in the majority of industries, it’s business as usual despite some prudent (and probably long overdue) cutbacks on spending.

So now President Obama is saying nearly the EXACT SAME THING as Senator McCain and even his own economic advisor, Christina Romer, sounds like a complete shill trying to explain how President Obama’s version is correct while Senator McCain’s made him “out of touch.” On Meet the Press this morning, it took her almost 10 seconds before the word “inherited” came out of her mouth and despite David Gregory’s repeated attempts to get clarification on the “fundamentals”, all she could say is that we’re just misinterpreting the President’s comments. What else is new.

PRES. BARACK OBAMA:  If we are keeping focused on all the fundamentally sound aspects of our economy, then we’re going to get through this.  And I’m very confident about that.

SEN. JOHN McCAIN (R-AZ):  You know that there’s been tremendous turmoil in our financial markets and Wall Street, and it is–it’s–people are frightened by these events.  Our economy, I think–still, the fundamentals our–of our economy are strong, but these are very, very difficult time.

Anyway, just listening to her talk, with that big smile and word for word script recitation makes me worry. Are all of President Obama’s closest advisors such “yes men” (or in this case “yes women”)?

http://www.foxnews.com/story/0,2933,508966,00.html

I am so glad to see this. I thought for sure they would have let him off the hook. Everybody thought it was so funny to see a guy hurling shoes at our Commander in Chief, without even considering the fact that it could have been a hunting knife or a ziplock bag full of anthrax.

Personally, I think 3 years is kinda steep but considering that under Saddam’s reign, this guy’s whole family would have been tortured and killed, he ought to be grateful. And every idiot that cheered this guy on, regardless of how you feel about Bush, should strongly consider moving to Venezuela with Keith Olberman and Bill Ayers. I’m no Obama fan, but as our president, if anyone tried messing with him, especially someone outside the USA, I’d be pissed and offended as an American.

BrokeniPhone

SQLMemoryLimitIf you use Microsoft SQL Server Developer Edition on your laptop or desktop that you develop on, particularly if you’re using a 64 bit operating system, you may want to check out the setting that allows you to cap its memory usage. On my machine with 4GB of RAM, sqlservr.exe grabbed about 3GB of that while doing some large bulk inserts and effectively crippled my machine until it was done.

Fortunately this is easy to prevent. Since you probably don’t want SQL Server having unrestricted access to all of your physical memory on your workstation, you can right click the server in SQL Management Studio, click Properties, then on the memory tab, set its “Maximum Server Memory” to something reasonable like 1,024 MB. Restart the service when you’re done for it to take effect.

imageI love the new per-application MRU list that appears when you right click a pinned taskbar item. As I mentioned in a previous post, this seems to be driven off the existing API’s that the shell and applications use to populate the “Recent Documents” list in previous versions of Windows.

One annoying thing I noticed was that Visual Studio solutions were never showing up in the MRU list for Visual Studio. In fact, nothing was. It took about 5 seconds before I realized “duh… solutions aren’t associated with Visual Studio”. They’re actually associated with a stub called “Visual Studio Version Selector” which looks inside the .sln file and launches the appropriate version of Visual Studio if it is installed on your machine.

Personally, one version of Visual Studio is big enough for me so I always run the latest (currently Visual Studio 2008). I don’t need this version selector. Right Click –> Open With just screwed up the icons and didn’t help the MRU list problem but there was a very simply registry fix to make .sln files associate with Visual Studio 2008.

Windows Registry Editor Version 5.00 
[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Open\Command]
@="\"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\IDE\\devenv.exe\" \"%1\""

Put the above in a .reg file or go into regedit.exe and do it by hand. If you need more instructions then the hack probably isn’t for you. Note that this will eliminate the ability to double click a .sln file and have it open in the version of Visual Studio that created it. But who really does that anyway.

Mar 012009

Live Mesh is a great piece of software. But you may or may not be aware that it doesn’t synchronize all files. There’s various reasons why it might exclude a particular file, which are detailed here.

If you’re like me and spend a lot of time evaluating beta software and operating systems, juggle multiple machines, etc. you may be tempted to blow away your hard drive’s contents assuming that Live Mesh has you covered. In most cases you’ll be fine but for a sanity check, here’s a PowerShell script that will show you which files in a particular folder will not be synchronized due to Mesh’s exclusion criteria.

Note: This script requires PowerShell 2.0 CTP 3 as all of my scripts do.

Note: This will only tell you which files meet the exclusion criteria and does not guarantee that files not reported are actually synchronized.

##############################################################################
#.SYNOPSIS
# Lists the files in a directory that are excluded from live mesh synchronization.
#
#.PARAMETER Path
# Specifies the path to an item. Wildcards are permitted.
#
#.PARAMETER LiteralPath
# Specifies the path to an item. Unlike Path, the value of LiteralPath is
# used exactly as it is typed. No characters are interpreted as wildcards.
# If the path includes escape characters, enclose it in single quotation marks.
# Single quotation marks tell Windows PowerShell not to interpret any
# characters as escape sequences.
#
#.PARAMETER ShowProgress
# If specified, a progress indicator will show the files being processed.
#
#.EXAMPLE
# Get-MeshExclusions C:\Personal
##############################################################################
function Get-MeshExclusions {

[CmdletBinding(DefaultParameterSetName='Path')]
param(

    [Parameter(ParameterSetName='Path', Position=1, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
    [String[]]$Path='.',
    
    [Alias("PSPath")]
    [Parameter(ParameterSetName='LiteralPath', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
    [String[]]$LiteralPath,
    
    [Parameter()]
    [Switch]$ShowProgress
    
)

begin {

    $ExcludedExtensions = @('.bak','.gfs','.laccdb','.lnk','.mbf','.mny','.mpc','.pst','.sav','.tmp','.wlx')
    $ExcludedNames = @('desktop.ini','thumbs.db')
    $ExcludedFolders = @([Environment]::GetFolderPath('DesktopDirectory'))


}

process {

    switch ($PSCmdlet.ParameterSetName) {
        Path            { $ResolveArgs = @{Path=$Path} }
        LiteralPath     { $ResolveArgs = @{LiteralPath=$LiteralPath} }
    }

    if ($ShowProgress) { $PathResolver = { Resolve-Path @ResolveArgs | Progress-Object } }
    else { $PathResolver = { Resolve-Path @ResolveArgs } }
    
    &$PathResolver | %{

        Write-Verbose "$($PSCmdlet.MyInvocation.MyCommand.Name) Processing $_"

        #################
        # PUT CODE HERE #
        #################
        
        Get-ChildItem -Path $_ -Recurse -Force | %{

            $Exclusion = 'Included'

            if ($ExcludedExtensions -contains $_.Extension) {
                $Exclusion = 'Blocked Extension'
            }
            elseif ($ExcludedNames -contains $_.Name) {
                $Exclusion = 'Special File'
            }
            elseif ($_.Name -like '~*') {
                $Exclusion = 'Tilde'
            }
            elseif ($ExcludedFolders -contains $_.DirectoryName) {
                $Exclusion = 'Blocked Directory'
            }
            elseif ($_.Attributes -band [IO.FileAttributes]::Hidden) {
                $Exclusion = 'Hidden File'
            }
            elseif ($_.Attributes -band [IO.FileAttributes]::System) {
                $Exclusion = 'System File'
            }
            
            if ($Exclusion -ne 'Included') {
                $_ | Add-Member NoteProperty Exclusion $Exclusion -PassThru
            }
        
        } | Select Name,DirectoryName,Length,Exclusion

    }

}

}