Tim Hibbard

Software Architect for EnGraph software
posts - 605, comments - 395, trackbacks - 507

My Links

News



Add to Google





Twitter












Tag Cloud

Article Categories

Archives

Post Categories

Image Galleries

EnGraph Blogs

Links

Other

Roll

Tuesday, November 25, 2008

Visual Studio Team System Unit Testing Keyboard Shortcuts

I try to use keyboard shortcuts as much as possible.  Here are some that are handy when unit testing with Visual Studio:

Ctrl + R, A – Run all tests
Ctrl + R, T – Run tests in context (based on if cursor is in function, class, or namespace)
Ctrl + R, F – Runs all tests that are checked in Test Results – very handy because that window is impossible to navigate without a mouse

Ctrl + R, Ctrl + A – Run all tests in debug mode
Ctrl + R, Ctrl + T – Run all tests in context in debug mode
Ctrl + R, Ctrl + F – Run all checked tests in debug mode

 

posted @ Tuesday, November 25, 2008 11:24 AM | Feedback (2) | Filed Under [ .NET TFS Keyboard Shortcuts ]

Friday, November 21, 2008

Google Sync for Blackberry now syncs contacts

The newest version of Google Sync adds a great new feature of syncing contacts.  Now your Gmail contacts will stay up to date with your Blackberry contacts and vice versa.

Very nice!

Download page here.

Technorati Tags: ,

posted @ Friday, November 21, 2008 9:52 AM | Feedback (1) |

Wednesday, November 19, 2008

TFS - Publish Web Service with TeamBuild

TeamBuild is such a powerful tool.  We use it to run our unit tests and publish our apps using ClickOnce.  Recently we started using it to publish a web service.  This code depends on MSBuildTasks from Tigris.

<PropertyGroup>
  <DeploymentFolder>**SHARED FOLDER ON WEB SERVER**</DeploymentFolder>
  <DeployServerName>**WEB SERVER NAME**</DeployServerName>
  <ApplicationPoolName>ReportingWS</ApplicationPoolName>
  <VirtualDirectory>ReportingWS</VirtualDirectory>
  <WebBinariesLocation>$(BuildDirectoryPath)\Binaries\Release\_PublishedWebSites\ReportingWS</WebBinariesLocation>
</PropertyGroup>
 
<Target Name="AfterCompile">
  <RemoveDir Directories="$(DeploymentFolder)" ContinueOnError="true" />
 
  <Exec Command="xcopy /y /e /i $(WebBinariesLocation) $(DeploymentFolder)"/>
 
  <WebDirectoryDelete VirtualDirectoryName="$(VirtualDirectory)"
                      ContinueOnError="true"
                      ServerName="$(DeployServerName)"/>
  <WebDirectoryCreate VirtualDirectoryName="$(VirtualDirectory)"
                      VirtualDirectoryPhysicalPath="$(DeploymentFolder)"
                      ServerName="$(DeployServerName)"/>
</Target>

Essentially, we just copy the executable files from the Web Service to a shared folder on our web server and map a virtual directory to that shared folder.

posted @ Wednesday, November 19, 2008 5:39 PM | Feedback (0) |

Tuesday, November 18, 2008

VS2008 code snippet for Properties that support INotifyPropertyChanged

This code snippet extends the functionality found in prop code snippet.  It will populate the backing field in the property, check for equality in the setter and call PropertyChanged.  It assumes you have a base class that handles the implementation of INotifyPropertyChanged.

When the snippet is called, it will generate code that looks like this:

private int myVar;
 
public int MyProperty
{
    get { return myVar; }
 
    set
    {
        if (!myVar.Equals(value))
        {
            myVar = value;
            base.OnPropertyChanged("MyProperty");
        }
    }
}

To use this snippet, create a new text file at:
C:\users\<your user name>\Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets

Call it “propINP.snippet”

Populate the contents of the file with this:

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
      <Title>propINP</Title>
      <Author>Microsoft Corporation</Author>
      <Description>Code snippet for property and backing field and INotifyPropertyChanged</Description>
      <HelpUrl>
      </HelpUrl>
      <Shortcut>propINP</Shortcut>
    </Header>
    <Snippet>
      <Declarations>
        <Literal Editable="true">
          <ID>type</ID>
          <ToolTip>Property type</ToolTip>
          <Default>int</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>property</ID>
          <ToolTip>Property name</ToolTip>
          <Default>MyProperty</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>field</ID>
          <ToolTip>The variable backing this property</ToolTip>
          <Default>myVar</Default>
          <Function>
          </Function>
        </Literal>
      </Declarations>
      <Code Language="csharp"><![CDATA[private $type$ $field$;
 
public $type$ $property$
{
get { return $field$;}
 
set 
{ 
if(!$field$.Equals(value))
{
$field$ = value;
base.OnPropertyChanged("$property$");
}    
}
}
$end$]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

posted @ Tuesday, November 18, 2008 2:19 PM | Feedback (0) |

Monday, November 17, 2008

Something in the water

On another personal note, Chels and I are expecting our first child (a strapping young man) on 12-26.  My good buddy Matt, who stood at our wedding, and his wife are also expecting a few days before us.  I wonder if our kids will ever figure out they were championship babies.

DSC03252

posted @ Monday, November 17, 2008 7:13 AM | Feedback (0) |

19:29

For a while now, one of my goals has been to run a 5K (3.1 miles) in under 20 minutes.  This morning I finally broke that number. 

Technorati Tags: ,,

posted @ Monday, November 17, 2008 6:54 AM | Feedback (2) |

Friday, November 14, 2008

What web search market?

According to my Blogflux search engine results for the last month, Google has not just cornered the market, they have virtually snuffed out the competition.

Engine Hits Percentage
Google 17596 98
Yahoo 202 1
Ask Jeeves 36 0
AOL 35 0
MSN 18 0
Search.com 6 0

 

Technorati Tags: ,,

posted @ Friday, November 14, 2008 8:48 AM | Feedback (1) |

Installing Windows Live Writer on Server 2008

I prefer to use web-based solutions when possible, but the other day the publish feature of google docs wasn’t working right, so I needed to install Windows Live Writer.  I quickly found out that WLW doesn’t play nicely with Windows Server 2008.

Since WLW is written in .NET, I just installed it on an XP virtual machine and copied the Program Files folder over to my Server 2008 machine.  Simple.

posted @ Friday, November 14, 2008 5:09 AM | Feedback (0) |

Wednesday, November 12, 2008

Kansas vs Emporia State

I went to the KU game last night with KyleWe won very easily.  On an odd note, the singer of the National Anthem was the daughter of the Emporia State coach, and was wearing a KU shirt.

At the KU bball game with @kylejarcher

IMG00096.jpg

posted @ Wednesday, November 12, 2008 2:59 PM | Feedback (1) |

Tuesday, November 11, 2008

WPF - Using SystemColors to add color to ListBox

Using colors is a simple way make your application less boring. You can change the color of the selected and unselected item in a ListBox by using code like this:

<Style TargetType="ListBoxItem">
    <Style.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="LightGreen"/>
        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="LightBlue"/>
    </Style.Resources>
</Style>


This style can be put in the resources of the ListBox to just affect that ListBox, or it can be put in resources of the Window and it will apply these styles to all ListBoxes in the window. You can also use the Application.Resources of App.xaml and all ListBoxes in your application will have the same look and feel.

Technorati Tags: ,,

posted @ Tuesday, November 11, 2008 4:41 PM | Feedback (0) |

Monday, November 10, 2008

Getting BrightKite friends using C# and LINQ

BrightKite is a location aware social network.  It allows you to post notes and pictures at a specific place.  It also will write to your Twitter stream so your friends can keep up with your latest activity.

They also have an API, which I had the chance to play with the other night.  Here is some very simple code that will write out a list of all your friends:

        public static void ListFriends(string username, string password)
        {
            string url = "http://brightkite.com/me/friends.xml";
            WebRequest WRequest = WebRequest.Create(url) as HttpWebRequest;
            WRequest.Timeout = 10000;
            WRequest.Headers.Add("Authorization", 
                "Basic " + Convert.ToBase64String(
                Encoding.ASCII.GetBytes(username + ":" + password)));
 
            using (HttpWebResponse response = WRequest.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());
                XElement element = XElement.Load(reader);
                foreach (XElement node in element.Elements("person"))
                {
                    string place = node.Element("place").Element("name").Value;
                    string person = node.Element("fullname").Value;
                    
                    Console.WriteLine("{0} checked in at {1}",person,place);
                }
            }
        }

My BrightKite = timhibbard
My Twitter = timhibbard



posted @ Monday, November 10, 2008 2:19 PM | Feedback (0) |

Friday, November 07, 2008

RAM usage when running SQL on development machine

Like most developers, I run SQL on my main work computer.  I find that the RAM usage gets quite bloated at times, so I have a handy bat file that I run to restart the SQL service, giving me my RAM back.  Here are the simple steps to achieving this:

1) Right click on your desktop and create a new text document.
2) Rename file to restartSQL.bat
3) Click yes on confirmation to change a file name extension.  If you did not get this error, you will need uncheck "Hide extensions for known file types" on the View tab of Folder Options.
4) Right click restartSQL.bat and select "Edit"
5) In the document that opens up, type
net stop mssqlserver
net start mssqlserver

*note if you have a named instance of SQL, change "mssqlserver" to what your instance is named
6) Close document and save changes when prompted

Now when your RAM is getting a bit high, just double click the file and it will give you your RAM back from SQL (for a little bit anyways).

P.S.  I know I've been a really bad blogger and Jeff yelled at me the other day about it.  It's annoying when people give a million excuses for not blogging for the last couple of months, so I won't do that :)

posted @ Friday, November 07, 2008 6:52 PM | Feedback (0) |

Thursday, June 26, 2008

C# DateTime extension method

Currently DateTime.ToShortDateString will not include any "0" prefixes. I think this makes any vertical lists of dates look funky:
Here is a very simple extension method that will append any needed leading "0" to the date:
namespace ParaPlan.Extensions
{
public static class DateHelper
{
public static string ToShortDateEqualLengthString(this DateTime dt)
{
var rv = new StringBuilder();
if (dt.Month.ToString().Length ==1)
{
rv.Append("0");
}
rv.Append(dt.Month.ToString());
rv.Append("/");
if (dt.Day.ToString().Length == 1)
{
rv.Append("0");
}
rv.Append(dt.Day.ToString());
rv.Append("/");
rv.Append(dt.Year.ToString());

return rv.ToString();
}
}
}
Changing our dates to call .ToShortDateEqualLengthString will make our listbox look much more pretty:

posted @ Thursday, June 26, 2008 3:43 PM | Feedback (6) |

Friday, May 23, 2008

Twitter + GeoRSS = GeoTwitter

Al Pascual has been working on GeoTwitter, a website (open source on CodePlex) that add geographical context to your tweets. That is pretty cool and he is looking at ways to automate it (IP, cell GPS), but what I think is really cool is that he provides a GeoRSS feed of your tweets (with others).

Check out the site here.

He posts about the project, submitting it to open source and future ideas on his blog.





posted @ Friday, May 23, 2008 1:21 PM | Feedback (1) |

Tuesday, May 20, 2008

WPF - CollectionViewSource that updates automatically

Using the CollectionViewSource is a good way of binding to a datasource and letting the XAML determine the sorting and grouping of the data. However, as your datasource changes, the grouping and sorting is not automatically "re-calculated", forcing your code to be smarter that it should be. I found a class today on MSDN forums that inherits from CollectionViewSource and adds automatic refresh capabilities. This code is smart enough to resort your items, regroup your items and even add new groupings as needed.

Some good CollectionViewSource links:


posted @ Tuesday, May 20, 2008 5:19 PM | Feedback (0) |

Tuesday, May 13, 2008

WPF - Changing the content of a ToggleButton when checked

I don't think the WPF ToogleButton has a distinct visual difference between it's checked and unchecked state.  So I wanted to change the text displayed when the button was checked.  So I created a trigger that looked at the IsChecked property and changed the content property accordingly.  However, the default template of a ToggleButton changes it's appearance when it is checked, so certain properties are not written as expected.  To fix this, I set the content property in the styles of the toggle button and it worked.  Here is the code:
<ToggleButton Name="showStopsCheckBox">
    <ToggleButton.Style>
        <Style TargetType="{x:Type ToggleButton}">
            <Setter Property="Content" Value="Stops"/>
            <Style.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter Property="Content" Value="Trips"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </ToggleButton.Style>
</ToggleButton>

posted @ Tuesday, May 13, 2008 11:54 AM | Feedback (0) |

How to post to GWB from Google Docs

Here is how to post to GeeksWithBlogs from Google Docs.
  1. Click New -> Document
  2. Select "Publish as web page" from the Share menu
  3. Click setup your blog
  4. Select "My own server/custom"
  5. Select "MetaWeblog API" from the drop down list
  6. Enter (no www) http://geekswithblogs.net//services/metablogapi.aspx
  7. Populate your user name, password and blog title
  8. Click Test




posted @ Tuesday, May 13, 2008 3:55 PM | Feedback (2) |

Posting from Google Docs

Testing publishing a post to GeeksWithBlogs from Google Docs.


posted @ Tuesday, May 13, 2008 3:35 PM | Feedback (0) |

Saturday, May 10, 2008

Google Maps Presentation at BarCampKC

I just finished my presentation about consuming Google Maps at BarCampKC.  Thanks to everybody who attended.

We talked about the three different ways of using Google Maps in your applications or websites.
  • Static Map Image API
  • My Maps
  • JavaScript API

The slideshow is available via Google Docs or dowload the PPT

The code is available for download here, make sure you change your api key.

posted @ Saturday, May 10, 2008 12:49 PM | Feedback (0) |

Thursday, May 08, 2008

The one they call "Sparky"

reesing

Chelsea and I went to the movies last night and saw Todd Reesing (the KU quarterback) and Derek Fine (former KU tight end) standing in line at the ticket counter.  Turns out they went to the same movie as us too (Baby Mama - which was pretty funny).

 

posted @ Thursday, May 08, 2008 11:46 AM | Feedback (0) |

Powered by: