<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[DotNetSurfers]]></title>
  <link href="http://dotnetsurfers.com/atom.xml" rel="self"/>
  <link href="http://dotnetsurfers.com/"/>
  <updated>2011-12-26T16:26:17-06:00</updated>
  <id>http://dotnetsurfers.com/</id>
  <author>
    <name><![CDATA[Latish Sehgal]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Migrating from Wordpress to Octopress]]></title>
    <link href="http://dotnetsurfers.com/blog/2011/12/15/migrating-from-wordpress-to-octopress/"/>
    <updated>2011-12-15T20:35:00-06:00</updated>
    <id>http://dotnetsurfers.com/blog/2011/12/15/migrating-from-wordpress-to-octopress</id>
    <content type="html"><![CDATA[<p>Over the last week, I have migrated this website from Wordpress to <a href="http://octopress.org/">Octopress</a>.
Wordpress has served me well over the last year, but it was starting to feel bloated and an overkill for my requirements.
I really like the simplicity of Octopress. The blog posts are written in <a href="http://daringfireball.net/projects/markdown/">Markdown</a> and the final result is a static HTML site.
I have also been spending some time learning Ruby, and this gave me a chance to become more familiar with the ecosystem.</p>

<p>Besides the information available on the Octopress website, here are the steps I had to take:</p>

<ol>
<li>Install <a href="http://octopress.org/docs/setup/">Octopress</a>.</li>
<li>Download <a href="https://github.com/thomasf/exitwp">Exitwp</a> and install its dependencies.</li>
<li>Upgrade Wordpress install to version later than 3.1 to be compatible with Exitwp.</li>
<li>Enable <a href="https://disqus.com/">Disqus</a> on Wordpress and export comments. Also, disqus was configured in the Octopress configuration.</li>
<li>In Wordpress, under Tools->Export, generate an xml file for the website. Run Exitwp on this file to generate the posts in Markdown.</li>
<li>The comments are turned off in these posts. I ran the following script (found in comments <a href="http://www.benjiegillam.com/2011/09/octopress-slash-disqus-issue-resolved/">here</a>) in terminal to turn comments on:

<pre><code> for I in *.markdown; do sed -i '' -e ':a' -e 'N' -e '$!ba' -e 's/\n---\n/\
 comments: true\
 ---\
 /' "$I"; 
</code></pre></li>
<li>Generate aliases for posts/pages if you want to maintain your old urls by adding the <a href="https://github.com/tsmango/jekyll_alias_generator">Jekyll Alias Generator</a> plugin.</li>
<li>Deploy to <a href="http://octopress.org/docs/deploying/heroku/">heroku</a>.</li>
<li>Point domain to <a href="http://blog.heroku.com/archives/2009/10/7/heroku_casts_setting_up_custom_domains/">heroku</a>.</li>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Continuously Improving as a Developer]]></title>
    <link href="http://dotnetsurfers.com/blog/2011/11/13/continuously-improving-as-a-developer/"/>
    <updated>2011-11-13T14:25:03-06:00</updated>
    <id>http://dotnetsurfers.com/blog/2011/11/13/continuously-improving-as-a-developer</id>
    <content type="html"><![CDATA[<p>(This post is based on a talk I was supposed deliver to Computer Science
students at Texas A&amp;M. I had to back out because of medical issues; this is my
attempt to convey the same information.)</p>

<script src="http://speakerdeck.com/embed/4ec0140a1940aa0054006943.js"></script>


<p>You spend almost than half your waking hours at your job. Your job
satisfaction will have a big impact over your happiness, and you owe it to
yourself to work at a job that love. Before we discuss how you can improve
yourself as a developer, make sure that you are in this for the right reasons.
Quoting <a href="http://www.codinghorror.com/blog/2004/09/skill-disparities-in-programming.html">Jeff Atwood</a>:</p>

<blockquote><p>Be realistic: are you programming to collect a paycheck, or are you
programming because you are driven to? I know this sounds harsh, but it&#8217;s an
economic reality&#8211; in an environment of global offshoring, the world simply
can&#8217;t support any more highly paid mediocre coders. There are a hundred
thousand well educated Indian developers who will do what you do at a fraction
of the price, and thousands more coming of age in other third world countries.
Blame the Internet if you want, but just being &#8220;good with computers&#8221; is no
longer a free ticket to a high paying tech job.</p></blockquote>

<p>Your college education will teach you to be competent (at the best) when you
graduate. That might not be enough to get you the job you want. At <a href="http://blog.businessofsoftware.org/2011/09/seth-godin-are-you-afraid-to-truly-make-an-impact-video-and-transcript-of-business-of-software-talk-.html">his
talk</a>
at Business of Software 2010, Seth Godin emphasized his preference for
brilliant vs competent programmers</p>

<blockquote><p>If there&#8217;s any job that could be written down, it gets done by freelancer.
Because if we can write down exactly what we want, why on earth we need a
brilliant person to do it? We get a competent person to do it. There are no
competent people that work at our company.</p></blockquote>

<p>Here are 10 things that can help you on your journey to improve as a
developer:</p>

<p><strong>1. </strong><a href="http://c2.com/cgi/wiki?EmptyYourCup"><strong>Empty your cup</strong></a><strong> </strong><br/>
As you learn new technologies and ways of doing things, don’t let what you
know right now interfere with the learning process.</p>

<p><strong>2. Read more books </strong>Get in the habit of reading books (technical or otherwise) regularly. I recommend that you start with the following 3<br/>
<a href="http://www.amazon.com/Pragmatic-Programmer-%0AJourneyman-Master/dp/020161622X">The Pragmatic Programmer</a></p>

<p><a href="http://www.amazon.com/Joel-Software-Occasionally-%0ADevelopers-Designers/dp/1590593898/">Joel On Software</a></p>

<p><a href="http://www.amazon.com/Getting-Things-Done-Stress-Free-%0AProductivity/dp/0142000280/">Getting Things Done</a></p>

<p>Ask the people you admire for books that significantly influenced them. Check
out <a href="http://www.codinghorror.com/blog/2004/02/recommended-%0Areading-for-developers.html">Jeff Atwood’s</a> and <a href="http://www.hanselman.com/%0Ablog/SixEssentialLanguageAgnosticProgrammingBooks.aspx">Scott Hanselman’s</a> recommendations.</p>

<p><strong>3. Read Code </strong><br/>
Try to read more code from other programmers. You will pick up useful gems
from seeing how they work. Check out the <a href="http://www%0A.hanselman.com/blog/googleresults.html?&amp;sa=Search&amp;domains=www.hanselman.com&amp;si%0Atesearch=www.hanselman.com&amp;client=pub-7789616507550168&amp;forid=1&amp;ie=UTF-8&amp;oe=UTF%0A-8&amp;safe=active&amp;cof=GALT%3A%23B47B10%3BGL%3A1%3BDIV%3A%23A9501B%3BVLC%3A6F3C1B%%0A3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3A336699%3BALC%3AB47B10%3BLC%3AB47B10%3BT%%0A3A000000%3BGFNT%3AA9501B%3BGIMP%3AA9501B%3BFORID%3A11&amp;hl=en&amp;q=weekly%20source%%0A20code">Weekly Source Code posts</a> by Scott Hanselman if you are looking for a place to start.</p>

<p><strong>4. Meet other passionate developers</strong></p>

<hr />

<p><strong> </strong>Try and attend as many user groups, conferences, coding dojos and nerd dinners as you can. You can find local events at <a href="http://www.communitymegaphone.com">www.communitymegaphone.com</a>.<br/>
You are the <a href="http://bufr.tumblr.com/post/12126279275/you-are-the-average-of-your-%0Afive-closest-friends">average of five people you spend the most time
with</a>. Education is in a way soaking up knowledge from people
smarter than you. College is one place to do that, where you learn from your
professors, but it might nor be the most  efficient way. Try and find a
mentor, but be respectful of his/her time. You should not be asking them for
answers that a simple Google Search can provide you.</p>

<p>(Your goal is not to exploit your friends, but remember that most job
positions are filled by recommendations/references from other employees rather
than through job boards.)</p>

<p><strong>5. Social Media </strong><br/>
Use Google Reader, or a RSS feed aggregator of your choice and keep up with
blogs of other developers. A few to get started are <a href="http://www.hanselman.com/blog/">Scott Hanselman’s
blog</a>, <a href="http://codebetter.com/">CodeBetter</a>,
<a href="http://www.codinghorror.com/blog/">CodingHorror</a>, <a href="http://blog.cwa.me.uk/">The Morning
Brew</a>, <a href="http://www.dzone.com/links/index.html">DZone</a>
and <a href="http://www.randsinrepose.com/">Rands In Repose</a>.</p>

<p>Podcasts are another excellent way to learn about the latest and the greatest
going on in the tech world. My favorites are <a href="http://www.dotnetrocks.com/">.Net Rocks</a>,
<a href="http://hanselminutes.com/">Hanselminutes</a>, <a href="http://startupsuccesspodcast.com/">The Startup Success Podcast</a> and <a href="http://herdingcode.com/">Herding Code</a>.</p>

<p>You can pick up a lot on Twitter, depending on whom you are following. I also
learn a lot by monitoring sites such as <a href="http://news.ycombinator.com/">Hacker News</a>.</p>

<p><strong>6. Help Others</strong></p>

<hr />

<p><strong> </strong>An excellent way to learn is to help other people with their problems. You can try contributing to open source projects, answering questions on <a href="http://stackoverflow.com/">Stack Overflow</a> or even building an application that satisfies somebody’s needs.<br/>
<strong>7. Certifications </strong><br/>
This is kind of a mixed bag. Just having a certification may or may not help
your personal brand, but preparing for a certification is a great way to pick
up the basics in a new technology and timeboxing it at the same time.</p>

<p><strong>8. Don’t restrict yourself to one platform</strong></p>

<hr />

<p><strong> </strong>Technologies, frameworks will come and go many times during your career. Try to be a well rounded developer and pick up the good parts from multiple technologies rather than invest all your time in one particular one.<br/>
<strong>9. Write (more) code </strong><br/>
Try to work on a side project to play around with technologies you don’t get
to use at your day job. Also, <a href="http://codekata.pragprog.com/">code katas</a> are
an excellent way to hone your craft.</p>

<p><strong>10. Share what you learn</strong></p>

<hr />

<p><strong> </strong>If you try to teach something to your friends, you’ll end up mastering the topic yourself in the process. Try and host technical brownbags, or volunteer to present at a user group meeting. The fear of public embarrassment due to not knowing your subject well is a great motivator to understand something inside out.<br/>
A few more general tips before finishing this:</p>

<ol>
<li><p>Work Out: Take care your body, or you will pay the price later. When
Richard Branson was asked on how one can became more productive, his answer
was to work out. He said that it gave him an additional four hours of
productive time everyday.</p></li>
<li><p>Take Breaks: Take regular breaks from your computer. It’s very easy to get
burnt out by working too hard.</p></li>
<li><p>Use the 80/20 principle: Use the Pareto’s principle to your advantage.
It’ll take you 20% time to learn 80% of the programming language or framework
you are trying to learn and vice versa. You do not need to know 100% of a
language before starting to work in it, so plan accordingly.</p></li>
<li><p>Invest in the best hardware and software you can afford: You are going to
spend a lot of time on your computer. Even though I am a big fan of frugality
as well as minimalism, this is one place I do not recommend that you try to
save money. Use what makes you the most effective.</p></li>
<li><p><a href="http://www.youtube.com/watch?v=UF8uR6Z6KLc">Stay hungry, Stay foolish</a>:
Steve Jobs ended his Stanford commencement speech with these words. I try to
remind myself about those words regularly, and I honestly can’t think of
anything better to tell you.</p></li>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Synchronize and Auto-Update your Visual Studio Extensions now with ExtensionSync 0.2.0]]></title>
    <link href="http://dotnetsurfers.com/blog/2011/09/07/synchronize-and-auto-update-your-visual-studio-extensions-now-with-extensionsync-0-2-0/"/>
    <updated>2011-09-07T20:50:36-05:00</updated>
    <id>http://dotnetsurfers.com/blog/2011/09/07/synchronize-and-auto-update-your-visual-studio-extensions-now-with-extensionsync-0-2-0</id>
    <content type="html"><![CDATA[<p>I released a new version of ExtensionSync today. You can get it on the <a href="http://visualstudiogallery.msdn.microsoft.com/dbaf0ac9-fb7b-4fb3-b34d-ea2269276d3c">Visual Studio Gallery</a>. Read <a href="http://dotnetsurfers.com/blog/2011/03/14/extensionsync-a-visual-studio-extension-to-synchronize-other-extensions/">this post</a> to get an idea of how the
extension works. Besides bug-fixes (and refactoring), the new features in this
release are:</p>

<ol>
<li><p>AutoUpdate: You can enable autoupdate of installed extensions now, instead
of manually having to install updates to all your extensions. Previously, you
had to do this <a href="http://rachelappel.com/visual-studio/visual-studio-2010/visual-studio-2010-extensions-magic-automatic-updates/">manually</a>.</p></li>
<li><p>Logging: The ExtensionSync activity can now be logged to a file.</p></li>
<li><p>ExtensionSync now watches for file change and updates extensions on
settings file change rather than on Visual Studio startup. This feature was
added after I found that some of the users use ExtensionSync to share
extensions with other devs, and that the settings file can be updated while a
Visual Studio instance is still open.</p></li>
</ol>


<p>All the settings can be configured in Tools->Options->ExtensionSync.</p>

<p><img src="http://dotnetsurfers.com/images/ExtensionSync2.PNG" alt="" /></p>

<p>The code is available on
<a href="https://github.com/latish/VisualStudioExtensionSync">github</a>. If you face any
problems with the extension, please open a bug there.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Slides and downloads for Dallas TechFest Presentations]]></title>
    <link href="http://dotnetsurfers.com/blog/2011/08/30/slides-and-downloads-for-dallas-techfest-presentations/"/>
    <updated>2011-08-30T18:39:00-05:00</updated>
    <id>http://dotnetsurfers.com/blog/2011/08/30/slides-and-downloads-for-dallas-techfest-presentations</id>
    <content type="html"><![CDATA[<p>I recently presented 2 sessions at the <a href="http://dallastechfest.com/">Dallas TechFest</a> (&#8220;The .Net Ninja&#8217;s toolbelt&#8221; and
&#8220;Extending Visual Studio&#8221;). The tools that I covered in the first session can
be found <a href="http://dotnetsurfers.com/blog/tools/">here</a>. The slides and code
demos for the second session can be downloaded
<a href="http://dotnetsurfers.com/utils/Visual%20Studio%20Extensibility.zip">here</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Using Git on top of TFS]]></title>
    <link href="http://dotnetsurfers.com/blog/2011/04/03/using-git-on-top-of-tfs/"/>
    <updated>2011-04-03T17:30:51-05:00</updated>
    <id>http://dotnetsurfers.com/blog/2011/04/03/using-git-on-top-of-tfs</id>
    <content type="html"><![CDATA[<p>I have been using Git lately for my personal projects, and though I am still a
noob user, I have been very happy with it. My current client uses TFS, and I
have been trying to come up with a way to use Git on top of TFS. This lets me
work in a disconnected mode (for example, while working from a coffee shop),
while having the ability to commit, branch, view history etc. The speed
benefits from having the repository on the local machine rather than accessing
it over the network don’t hurt either. Thanks to the excellent <a href="https://github.com/spraints/git-tfs">Git-Tfs</a> bridge developed by
<a href="http://mattonrails.wordpress.com/">Matt</a>, this was pretty easy to set up. To
get started, <a href="https://github.com/spraints/git-tfs/downloads#uploaded_downloads">download</a> the latest version and add the directory
that contains git-tfs.exe to your PATH variable.</p>

<ol>
<li>Launch Git Bash. If you access TFS from a different account than what you are logged in as, you can launch it under the TFS account by entering the following at Start->Run <br/>
runas /netonly /user:your_domain\your_user_name &#8220;cmd /c sh &#8211;login -i&#8221;</li>
</ol>


<p>(sh.exe resides at “C:\Program Files (x86)\Git\bin” on my computer which is
added to the PATH variable.)</p>

<ol>
<li><p>Navigate to the directory you want to work in and clone the TFS repository using “git tfs clone repository_url source_path”. You can use the “quick-clone” option if you want just the snapshot of the latest code rather than the complete history. I setup a test project on Codeplex to play with git-tfs, and I had to issue the following command to get the complete repository: <br/>
git tfs clone https://tfs.codeplex.com/tfs/tfs24 $/gittfstest</p></li>
<li><p>Now you can work offline. Add gitignore file to ignore bin directories, temporary files etc, and open your project and make your changes. Visual Studio will warn you on opening the project that TFS is unavailable, since you do not have the code in TFS mapped to this directory. Just choose the “Temporarily work uncontrolled” option.</p></li>
</ol>


<p><img src="http://dotnetsurfers.com/images/TFS_Unavailable.JPG" alt="" /></p>

<ol>
<li>You can commit to your local git repository at any time you want. Whenever you are ready to commit back to TFS, you have 3 options:

<ol>
<li>git tfs checkin: Allows you to check in code directly into TFS. Can associate the change with commit message, work items etc.</li>
<li>git tfs checkintool: Allows you to review your changes in the TFS check in tool before checking them in.</li>
</ol>
</li>
</ol>


<p><img src="http://dotnetsurfers.com/images/GitTfs_CheckinTool.JPG" alt="" /></p>

<pre><code>3. git tfs shelve: Creates a shelveset that you can review and check in. 
</code></pre>

<ol>
<li>Whenever you are ready to pull the latest code changes from TFS, use <br/>
git tfs pull</li>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[ExtensionSync: A Visual Studio extension to synchronize other extensions]]></title>
    <link href="http://dotnetsurfers.com/blog/2011/03/14/extensionsync-a-visual-studio-extension-to-synchronize-other-extensions/"/>
    <updated>2011-03-14T21:57:54-05:00</updated>
    <id>http://dotnetsurfers.com/blog/2011/03/14/extensionsync-a-visual-studio-extension-to-synchronize-other-extensions</id>
    <content type="html"><![CDATA[<p><strong>Update</strong>: I have released a new version of ExtensionSync. Details <a href="http://dotnetsurfers.com/blog/2011/09/07/synchronize-and-auto-update-your-visual-studio-extensions-now-with-extensionsync-0-2-0/">here</a>.<br/>
One of the things I love about the Google Chrome browser is how it seamlessly
synchronizes my bookmarks and extensions across multiple installations. Visual
Studio 2010 has a really good extensibility model, and developers are
contributing all sorts of awesome extensions to  the <a href="http://visualstudiogallery.msdn.microsoft.com/">Visual Studio Gallery</a>. As somebody who uses
Visual Studio extensions and codes at more than one pc on a regular basis, I
thought it would be interesting to see if I could synchronize my extensions
automatically. I have been working on an extension to do this and have had
some success with it. This has been implemented using interfaces like
<a href="http://msdn.microsoft.com/en-%0Aus/library/microsoft.visualstudio.extensionmanager.svsextensionmanager.aspx">SVsExtensionManager</a>
and <a href="http://msdn.microsoft.com/en-us/library/microsoft%0A.visualstudio.extensionmanager.svsextensionrepository.aspx">SVsExtensionRepository</a>, which are subject
to change according to the documentation, so use this extension at your own
risk. The code is available at
<a href="https://github.com/latish/VisualStudioExtensionSync">Github</a> if you would
like to change something.</p>

<p>You can download the extension from the
<a href="http://visualstudiogallery.msdn.microsoft.com/dbaf0ac9-fb7b-4fb3%0A-b34d-ea2269276d3c">Gallery</a>, or by searching for ExtensionSync in the Visual Studio
Extension Manager. Once the extension has been installed, configure the
directory you want to use for storing your settings by going to
Tools->Options->ExtensionSync. Visual Studio will save your settings in this
directory every time it closes, and it’ll also read the settings file and
update extension every time it starts (It also does this when you configure a
new Settings directory, but this should be a one time thing). I recorded a
screencast to explain the workflow. This is my first screencast, hopefully the
quality improves as I practice more <img src="http://dotnetsurfers.com/images/wlEmoticon-smile.png" alt="Smile" />.</p>

<p>I think Microsoft would probably roll out something like this as a part of
Visual Studio sometime down the line. It would be nice to use the cloud and
have Visual Studio remember all my settings for me (Maybe the user’s settings
could be associated with his Windows Live ID). Till then, I hope my extension
can be of some use to you.</p>

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="MOVIE" value="/images/ExtensionSync2.swf" /><param name="PLAY" value="true" /><param name="LOOP" value="true" /><param name="QUALITY" value="high" /><param name="SCALE" value="noborder" /><param name="src" value="/images/ExtensionSync2.swf" /><param name="allowfullscreen" value="true" /><param name="quality" value="high" /><embed type="application/x-shockwave-flash" width="600" height="400" src="http://dotnetsurfers.com/images/ExtensionSync2.swf" allowfullscreen="true" scale="noborder" quality="high" loop="true" play="true" movie="/images/ExtensionSync2.swf"></embed></object>


<p>Update: I got back feedback from a user that Visual Studio was crashing for
him while syncing with Windows Live Mesh. I have not been able to replicate
the issue, but if you face any problems, deleting the settings file should let
you get back to normal. You can also file an issue on
<a href="https://github.com/latish/VisualStudioExtensionSync/issues">Github</a>, if you
find any. I would love to get some feedback (good or bad). Update2: The issue
should hopefully be fixed with version 0.1.2. This extension can only
synchronize VSIX extensions and not those installed by MSIs. Hat Tip to
<a href="http://graemef.com/">Graeme Foster</a> and
<a href="https://twitter.com/#!/efvincent">@efvincent</a> for helping me replicate the
issue.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[KillCassini: A Visual Studio extension to kill Asp.Net Web Development Server]]></title>
    <link href="http://dotnetsurfers.com/blog/2011/02/19/killcassini-a-visual-studio-extension-to-kill-asp-net-web-development-server/"/>
    <updated>2011-02-19T16:07:00-06:00</updated>
    <id>http://dotnetsurfers.com/blog/2011/02/19/killcassini-a-visual-studio-extension-to-kill-asp-net-web-development-server</id>
    <content type="html"><![CDATA[<p>I am a big fan of minimizing mouse usage and relying on keyboard shortcuts. I
find it to be more efficient in general and healthy for my wrists. If you work
with Asp.Net and use the Asp.Net Web Development server on your local box, you
would have noticed that you need to stop the server in order for the cache to
clear and Application level events to fire again. And right now, you have to
do this using a mouse.</p>

<p><img src="http://dotnetsurfers.com/images/cassini.jpg" alt="" /></p>

<p>I have had a Visual Studio macro for a long time that kills all the instances
of the local Asp.Net Development Server, but in the interest of sharing it
more easily with my peers, and to play around with Visual Studio 2010
extensibility, I have written a Visual Studio extension that allows you to do
the same. You can get the extension
<a href="http://visualstudiogallery.msdn.microsoft.com/1269c9a1-fcfe-%0A4b47-91e7-22c7027f3c41">here</a>. If you want to play around with the code or change
something, you can access the code on
<a href="https://github.com/latish/KillCassini">GitHub</a>. Once you download the
extension and install it, it’ll show up under your Tools Menu in Visual
Studio.</p>

<p><img src="http://dotnetsurfers.com/images/KillCassini_Menu.jpg" alt="" /></p>

<p>You can change your keybinding by going under Tools->Options->Keyboard and
searching for KillCassini.</p>

<p><img src="http://dotnetsurfers.com/images/KillCassini_Keyboard.jpg" alt="" /></p>

<p>And that’s it. You can invoke the extension by using the Tools Menu or your
keyboard shortcut. If you are interested in what the extension is doing, it
writes down some information in the Debug Output Window every time you run it.</p>

<p><img src="http://dotnetsurfers.com/images/KillCassini_Output.jpg" alt="" /></p>

<p>One of the problems I used to face with my Visual Studio Macro for doing the
same was that the orphaned icon for the killed server process used to stay
around till you hovered your mouse over it. This is not a problem for most
people (unless your OCD runs as deep as me). In this extension, I have made an
attempt to rectify that problem by refreshing the <a href="http://dotnetsurfers.com/blog/2011/02/16/refreshing-the-windows-system-%0Atray-programmatically/">Taskbar System tray</a>. This seems to work on my system at least (64 bit
Windows 7).</p>

<p>It has been fun playing with the Visual Studio extensibility and I hope to
work on some more extensions in the near future.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Refreshing the Windows System Tray programmatically]]></title>
    <link href="http://dotnetsurfers.com/blog/2011/02/16/refreshing-the-windows-system-tray-programmatically/"/>
    <updated>2011-02-16T19:00:20-06:00</updated>
    <id>http://dotnetsurfers.com/blog/2011/02/16/refreshing-the-windows-system-tray-programmatically</id>
    <content type="html"><![CDATA[<p>I have been working on a project where I need to kill a process
programmatically. Unfortunately, that leaves behind the orphaned icon for that
process in the system tray (also known as the taskbar notification area). The
icon goes away when you hover your mouse over it, but in interest of providing
a better User Experience,  I have been trying to find a way to make the
orphaned icon go away programmatically. Windows does not expose any API to
refresh the system tray area, so the next best working solution I have been
able to come up (thanks to <a href="http://malwareanalysis.com/Community%0AServer/blogs/geffner/archive/2008/02/15/985.aspx">this article</a>) involves sending the Mouse
Move Windows Message over the system tray area. It involves calling unmanaged
Windows API and is not very pretty, but like I said, it’s the best solution I
have been able to come up with. If you know of a better way to achieve this,
please do leave a comment. Also this works for me on 64 bit Windows 7, but I
think it should be compatible with other versions of Windows. The code is
below and you just need to call TaskBarUtil.RefreshNotificationArea() from
your client.</p>

<p>using System;</p>

<p>using System.Runtime.InteropServices;</p>

<p>using Microsoft.VisualStudio.OLE.Interop;</p>

<pre><code>internal class TaskBarUtil
{
    public static void RefreshNotificationArea()
    {
        var notificationAreaHandle = GetNotificationAreaHandle();  
        if (notificationAreaHandle == IntPtr.Zero)
            return;  
        RefreshWindow(notificationAreaHandle);
    }  
    private static void RefreshWindow(IntPtr windowHandle)
    {
        const uint wmMousemove = 0x0200;
        RECT rect;
        GetClientRect(windowHandle, out rect);  
        for (var x = 0; x &lt; rect.right; x += 5)
            for (var y = 0; y &lt; rect.bottom; y += 5)
                SendMessage(
                    windowHandle,
                    wmMousemove,
                    0,
                    (y &lt;&lt; 16) + x);
    }  
    private static IntPtr GetNotificationAreaHandle()
    {
        const string notificationAreaTitle = "Notification Area";
        const string notificationAreaTitleInWindows7 = "User Promoted Notification Area";  
        var systemTrayContainerHandle = FindWindowEx(IntPtr.Zero, IntPtr.Zero,
                                                    "Shell_TrayWnd", string.Empty);
        var systemTrayHandle = FindWindowEx(systemTrayContainerHandle, IntPtr.Zero,
                                                    "TrayNotifyWnd", string.Empty);
        var sysPagerHandle = FindWindowEx(systemTrayHandle, IntPtr.Zero, "SysPager", 
                                                    string.Empty);
        var notificationAreaHandle = FindWindowEx(sysPagerHandle, IntPtr.Zero, 
                                                    "ToolbarWindow32", 
                                                    notificationAreaTitle);  
        if (notificationAreaHandle == IntPtr.Zero)
            notificationAreaHandle = FindWindowEx(sysPagerHandle, IntPtr.Zero, 
                                                    "ToolbarWindow32",
                                                    notificationAreaTitleInWindows7);
        return notificationAreaHandle;
    }  
    [DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, 
                                                    string className, 
                                                    string windowTitle);  
    [DllImport("user32.dll")]
    static extern bool GetClientRect(IntPtr handle, out RECT rect);  
    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    static extern IntPtr SendMessage(IntPtr handle, UInt32 message, Int32 wParam, 
                                                    Int32 lParam);
}
</code></pre>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Book review: Pomodoro Techniques Illustrated]]></title>
    <link href="http://dotnetsurfers.com/blog/2011/02/01/book-review-pomodoro-techniques-illustrated/"/>
    <updated>2011-02-01T22:44:50-06:00</updated>
    <id>http://dotnetsurfers.com/blog/2011/02/01/book-review-pomodoro-techniques-illustrated</id>
    <content type="html"><![CDATA[<p>The <a href="http://www.pomodorotechnique.com/">Pomodoro Technique</a> is a time
management method developed by Francesco Cirillo in the late 1980s. The
technique uses a timer to break down periods of work into 25-minute intervals
called &#8216;pomodoros&#8217; (from the Italian word for &#8216;tomato&#8217;) separated by breaks.
The book <a href="http://www.amazon.com/gp/product/1934356506?ie=UTF8&amp;tag=dotn047-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1934356506">Pomodoro Techniques Illustrated</a> (affliate link) is written by Staffan Nöteber (a software
programmer) and describes how you can be more productive using the technique.
I picked up the book last week after reading <a href="http://www.swaroopch.com/blog/pomodoro/">Swaroop’s review</a>. It was an easy read and I
finished most it in the car going from Dallas to Houston (My friend Tim was
driving).</p>

<p>The book breaks down the technique into 5 stages:</p>

<ol>
<li>Planning: Extract the most important things from your overall task list into your daily to-do list. This is done once at the beginning of the day.</li>
<li>Tracking: Track metrics per pomodoro, like interruptions, completed vs abandoned pomodoro, etc.</li>
<li>Recording: File your observations at the end of the day.</li>
<li>Processing: Analyze your recorded raw data and turn it into information you can act on.</li>
<li>Visualizing: Organize the information to improve your process.</li>
</ol>


<p>A couple of other things from the book that I need to remember:</p>

<ul>
<li>Work on the most important thing on your daily to-do list.</li>
<li>If you can’t help but interrupt your pomodoro, void it, take a break and start a new one rather than pausing and resuming the current one.</li>
<li>We procrastinate because it gives us temporary relief from the stress of doing the task.</li>
<li>Estimation is just guessing based on empirical knowledge. A good way to estimate the number of pomodori you will finish today is to look at how many you did yesterday.</li>
<li>If an activity estimate is bigger than 7 pomodori, break it down into smaller activities.</li>
<li>Make sure you do not try to get things done like responding to email in your rest period between different pomodori.</li>
<li><strong>Working overtime is not sustainable</strong>.</li>
</ul>


<p>I give the book a rating of 5/5 and recommend it to my friends. I have used
the Pomodoro Technique before, but reading this has book makes me feel much
more prepared to utilize it fully. Another lesson I have learned is that I do
not have to use the Pomodoro Technique all the time. I find it ideal to use
when I am procrastinating a lot, or having a hard time focusing.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Continuous Testing using AutoTest.Net]]></title>
    <link href="http://dotnetsurfers.com/blog/2011/01/23/continuous-testing-using-autotest-net/"/>
    <updated>2011-01-23T20:27:07-06:00</updated>
    <id>http://dotnetsurfers.com/blog/2011/01/23/continuous-testing-using-autotest-net</id>
    <content type="html"><![CDATA[<p>My friend <a href="http://mentalpandiculation.com/">Brett</a> posted the following on
<a href="http://twitter.com/BrettBim/status/24203073027055617">twitter</a> a couple of
days ago.</p>

<p><img src="http://dotnetsurfers.com/images/Brett_Tweet.JPG" alt="" /></p>

<p>So AutoTest goes on my list of things to play with over the weekend, you know
because I could use some giddiness in my life right now. I haven’t been
regular with my Ruby hacking, so I decided to check out AutoTest.Net, the .Net
counterpart for the same framework. AutoTest.Net was created all the way back
in Nov 2007 <a href="http://averyblog.com/net/announcing-autotest-net-0-1/">by James Avery</a> (I live on the bleeding edge, don’t I). Lately, it is being
maintained and worked on by <a href="http://ackenpacken.blogspot.com/2010/08/continous-testing-with-%0Aautotestnet.html">Svein Arne Ackenhausen on GitHub</a>.</p>

<p>To get started, download the latest code from
<a href="https://github.com/acken/AutoTest.Net">GitHub</a> and build it. I initially
tried downloading just the binaries and making it work, but kept on getting
errors. I think the binaries at this time are out of sync with the latest
source code so I would recommend compiling the code yourself. Update the
AutoTest.config with the correct location for your build executable as well as
your test runners. Now if you launch AutoTest.WinForms.exe, it’ll look
something like this:</p>

<p><img src="http://dotnetsurfers.com/images/AutoTest0.JPG" alt="" /></p>

<p>Choose your code directory and click on “Ok”, and it should be up and running.</p>

<p><img src="http://dotnetsurfers.com/images/AutoTest1.JPG" alt="" /></p>

<p>If I make a change to a source file now, AutoTest.Net runs all the unit tests
for me.</p>

<p><img src="http://dotnetsurfers.com/images/AutoTest2.JPG" alt="" /></p>

<p>Pretty neat, huh! Now, if you do not have a dual monitor setup, it might be
kind of a pain to navigate to the status window every time you make a change
to ensure that everything is green. The icing on the cake is that AutoTest.Net
integrates with <a href="http://www.growlforwindows.com/gfw/default.aspx">Growl for Windows</a>. After turning on
growl, I get:</p>

<p><img src="http://dotnetsurfers.com/images/AutoTest3.JPG" alt="" /></p>

<p><img src="http://dotnetsurfers.com/images/AutoTest4.JPG" alt="" /></p>

<p>And, if I add a failing test, I get</p>

<p><img src="http://dotnetsurfers.com/images/AutoTest5.JPG" alt="" /></p>

<p>So I can continue coding without having to move focus to another application
and get continuous feedback at the same time. Brett was right, this setup does
make me feel pretty excited. I am definitely going to use this in my side
projects, where I have been following a TDD workflow lately. For all you
cross-platform folks, AutoTest.Net works with Mono as well. And based on the
<a href="https://github.com/acken/AutoTest.Net/commits/master">commit history</a>, it
looks like that Svein is checking in updates and fixes very regularly, kudos
to him for that.</p>

<p>A couple of things to remember:</p>

<ul>
<li>If your tests start running in an infinite loop, that’s because AutoTest.Net is being triggered by updates in your TestResults. Use the “IgnoreFile” element in the config to specify an ignore file (similar to .gitignore), and AutoTest.Net wil ignore those changes.</li>
<li>If you run into any issues, set the “Debugging” element to “true” in the AutoTest.Config file, and monitor the Debug.log file in your AutoTest.Net directory. That is how I found the previous issue.</li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[My GTD System]]></title>
    <link href="http://dotnetsurfers.com/blog/2011/01/15/my-gtd-system/"/>
    <updated>2011-01-15T23:42:23-06:00</updated>
    <id>http://dotnetsurfers.com/blog/2011/01/15/my-gtd-system</id>
    <content type="html"><![CDATA[<p>Do you know anybody who is not busy? A lot of my friends are programmers like
me, and always juggling multiple tasks and priorities. Rather than keeping all
my TODO things in my head, I have experimented with several alternatives over
the last few years. The basic idea is the same that David Allen outlines in
<a href="http://www.amazon.com/gp/product/0142000280?ie=UTF8&amp;tag=%0Adotn047-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0142000280">Getting Things Done</a>
(affliate link), that you should have a dependable system to store and
retrieve your tasks. Here’s what works for me right now:</p>

<p>I split my tasks into 2 categories</p>

<ul>
<li><strong>Time sensitive and/or Recurring Events</strong>: This incudes meetings, appointments, birthday/anniversary reminders. I use Microsoft Outlook in the office, and GMail Calendar for personal stuff. My Gmail calendar is synced with my IPhone. Using the <a href="http://www.google.com/support/calendar/bin/answer.py?hl=en&amp;answer=89955">Google Calendar Sync</a> utility, I keep the Outlook and GMail Calendar in sync, so all my commitments are available to me in Outlook as well as on my IPhone all the time.</li>
<li><strong>One Time tasks</strong>: This can vary from anything like picking up the drycleaning to buying stationary, or perhaps checking out a new technology framework in spare time. I use <a href="https://mail.google.com/tasks/canvas">Google Tasks</a> to store my tasks under different lists. I have lists for the items to do for my blog, things to do for the Dallas C# SIG, project ideas that I might want to pursue later, groceries to pick up and so on. The tasks can also be accessed from my IPhone using gmail.com/tasks.</li>
</ul>


<p>And that’s it. Between Google calendar and Google Tasks, I am able to keep
track of all my tasks.</p>

<p>I want to mention two other online tools that help me organize my online
information significantly. Both of these are available in the form of
JavaScript bookmarklets and always live in the bookmarks bar on my browser.</p>

<ul>
<li><a href="https://www.evernote.com/">Evernote</a>: This is permanent catalog for information that I want to access later. I organize information using appropriate tags. Evernote also has native Windows, Mac, Blackberry, Palm, Windows Mobile and IPhone apps.</li>
<li><a href="http://www.instapaper.com">Instapaper</a>: I use this as a temporary store for links that I want to go through when I have more time on my hands.</li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Personal Update]]></title>
    <link href="http://dotnetsurfers.com/blog/2011/01/08/personal-update/"/>
    <updated>2011-01-08T17:14:00-06:00</updated>
    <id>http://dotnetsurfers.com/blog/2011/01/08/personal-update</id>
    <content type="html"><![CDATA[<p>I have been busy over the last few months with personal stuff. On Nov 25, I
got married to my girlfriend in India. It was a small function with close
family and friends. Here’s a picture of us from our wedding day.</p>

<p><img src="http://dotnetsurfers.com/images/marriage.JPG" alt="" /></p>

<p>I have been hacking on some personal projects in the little time I have found
over the last 3 months, mostly on flights
<img src="http://dotnetsurfers.com/images/wlEmoticon-smile.png" alt="Smile" />. I also spent some time learning and understanding <a href="http://git-scm.com/">GIT</a>, something that has been on my TODO list for a while. I am
fascinated by the DVCS model and am excited by the improvements it offers over
a centralized source control repository. I have started to use GIT on my side
projects for now and plan to evaluate
<a href="http://mercurial.selenic.com/">Mercurial</a> somewhere down the line.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Mocking an Indexed Property using MOQ]]></title>
    <link href="http://dotnetsurfers.com/blog/2010/09/24/mocking-an-indexed-property-using-moq/"/>
    <updated>2010-09-24T11:15:10-05:00</updated>
    <id>http://dotnetsurfers.com/blog/2010/09/24/mocking-an-indexed-property-using-moq</id>
    <content type="html"><![CDATA[<p>I was writing unit tests for some code today that updated the value of an
indexed property, and I could not find a straightforward way to do this with
MOQ. For regular properties, you can enable value tracking by calling
SetupProperty() or SetupProperties() on the mock object, but this does not
seem to work for indexed properties. So I worked around this by using the
Callback() method. Below is an example of the approach I took.  Here I am
using a dictionary that contains ages and I am setting up value tracking for a
person named Sara.</p>

<pre><code>        private IDictionary&lt;string, int&gt; _ages;




 




        [TestInitialize]




        public void Setup()




        {




            var mockDictionary = new Mock&lt;IDictionary&lt;string, int&gt;&gt;();




            mockDictionary.SetupSet(m =&gt; m["Sara"] = It.IsAny&lt;int&gt;())




                .Callback((string name, int value) =&gt; mockDictionary




                                            .SetupGet(m =&gt; m["Sara"])




                                            .Returns(value));




            _ages = mockDictionary.Object;




        }




 




        [TestMethod]




        public void Test_Indexed_Property_Using_MOQ()




        {




            _ages["Sara"] = 15;




            IncrementAge(_ages,"Sara");




            Assert.AreEqual(16,_ages["Sara"]);




        }




 




        static void IncrementAge(IDictionary&lt;string,int&gt; ages,string personName)




        {




            ages[personName] = ages[personName] + 1;




        }
</code></pre>

<p><strong>Update</strong>: Looks like Bertrand Le Roy had already blogged about a <a href="http://weblogs.asp.net/bleroy/archive/2009/06/15/mocking-indexer-setters-with-moq.aspx">similar solution</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[BarCamp Dallas Review]]></title>
    <link href="http://dotnetsurfers.com/blog/2010/08/21/barcamp-dallas-review/"/>
    <updated>2010-08-21T22:55:00-05:00</updated>
    <id>http://dotnetsurfers.com/blog/2010/08/21/barcamp-dallas-review</id>
    <content type="html"><![CDATA[<p>I went to my first <a href="http://barcamp.org/BarCampDallas">Barcamp</a> today, held at
<a href="http://improvingenterprises.com/">Improving Enterprises</a> in Dallas. It was a
technology agnostic event, and It was good to see the cool things developers
on other platforms are playing with. I also gave a condensed version of <a href="http://dotnetsurfers.com/blog/2010/05/10/bdd-mspec-presentation-at-the-dallas-c-sig/">my BDD talk</a> and it was pretty well received. The following topics were
presented:</p>

<ul>
<li>Visual Studio Tips &amp; Tricks by <a href="http://blogs.msdn.com/b/zainnab/">Zain Naboulsi</a><a href="http://blogs.msdn.com/b/zainnab/">:</a>:) Zain covered some useful Visual Studio tips and tricks that he has been outlining on twitter and his blog lately. Of course, the most remarkable shortcut he showed (and nobody in the audience knew about) was that pressing F7 in a command prompt gives a dropdown of all previously executed commands :).</li>
<li>Delightful forms plug-in for Ruby On Rails: The speaker outlined his inspiration behind this forms plug-in, and the output looked very clean and user friendly.</li>
<li>The CAP theorem by <a href="http://qedcode.com/blogs/michael-l-perry">Michael Perry</a><a href="http://qedcode.com/blogs/michael-l-perry">:</a>:) Michael gave an overview of the CAP theorem (only 2 out of 3 features from the list of Consistency, Availability and Partition Tolerance can be achieved at one time for a distributed computer system).</li>
<li>NoSQL/MongoDb 101.</li>
<li><a href="http://www.foldertrack.com/">FolderTrack</a> application overview.</li>
<li><a href="http://lesscss.org/">Less CSS</a><a href="http://lesscss.org/">:</a>:) allows use of variables, mixins and nested rules in CSS.</li>
<li>Windows Phone 7 overview by <a href="http://chriskoenig.net/">Chris Koenig</a>.</li>
<li>SEO optimization and hacks: This was my favorite session for the day and the presenter showed very impressive hacks and examples for manipulating SEO.</li>
<li>Targeting Mobile CSS media.</li>
<li>Overview of <a href="http://www.dallasmakerspace.com/blog/about-us/">DallasMakerSpace community</a><a href="http://www.dallasmakerspace.com/blog/about-us/">:</a>:) Another cool presentation about the hackerspace community in Dallas.</li>
<li>My <a href="http://dotnetsurfers.com/blog/2010/05/10/bdd-mspec-presentation-at-the-dallas-c-sig/">BDD talk</a>.</li>
</ul>


<p>A big thanks to the organizers for putting this up and I look forward to
attending this next year.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Useful MacBook accessories]]></title>
    <link href="http://dotnetsurfers.com/blog/2010/08/19/useful-macbook-accessories/"/>
    <updated>2010-08-19T20:14:03-05:00</updated>
    <id>http://dotnetsurfers.com/blog/2010/08/19/useful-macbook-accessories</id>
    <content type="html"><![CDATA[<p>I have <a href="http://www.dotnetsurfers.com/Blog/2009/07/31/MyNewMacBookPro.aspx">had my MacBook Pro</a> for a
year now and it’s my primary machine both at work and at home. I have since
upgraded it with <a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16820231297">8GB RAM</a> (which
has come down in price by more than half in the last 9 months) and a 160GB
SSD. At my day job, I work with <a href="http://dotnetsurfers.com/blog/2009/08/15/working-with-visual-studio-on-a-mac/">Visual Studio inside a VMWare Fusion VM</a> and have been pretty happy with the performance. Here are some
accessories that I have found useful for my MBP:</p>

<ol>
<li><a href="http://www.amazon.com/gp/product/B0029TNH3C?ie=UTF8&amp;tag=dotn047-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B0029TNH3C">Anti-Reflective Screen Protector</a><img src="http://www.assoc-amazon.com/e/ir?t=dotn047-20&amp;l=as2&amp;o=1&amp;a=B0029TNH3C" alt="" />: I bought the glossy screen MBP, and that turned out to be a big mistake since I  frequently hack at coffee shop/restaurant patios and the glossy screen made the code unreadable. This Moshi iVisor screen protector fixed that and gave the screen a matte finish. It was also very easy to apply without any air bubble issues.</li>
<li><a href="http://www.amazon.com/gp/product/B001QKI2DA?ie=UTF8&amp;tag=dotn047-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B001QKI2DA">Keyboard Cover</a><img src="http://www.assoc-amazon.com/e/ir?t=dotn047-20&amp;l=as2&amp;o=1&amp;a=B001QKI2DA" alt="" />: I bought the keyboard cover after it showed up in my Amazon recommended products list (probably because the screen protector is from the same company), and I have been pleasantly surprised with it. It is quite thin and does not take much time to get used to. It has also already saved me from serious trouble once when I spilled Diet Coke on the keyboard.</li>
<li>Spare <a href="http://store.apple.com/us/product/MC556LL/A?n=notebook_power_adapters&amp;fnode=MTY1NDEwMQ&amp;mco=MTc0NzA0MjY&amp;s=topSellers">Apple MagSafe Power Adapter</a><a href="http://store.apple.com/us/product/MC556LL/A?n=notebook_power_adapters&amp;fnode=MTY1NDEwMQ&amp;mco=MTc0NzA0MjY&amp;s=topSellers">:</a>:) I haven&#8217;t been able to find a good docking solution for the MBP, but carrying a spare power adapter saves me the trouble of crawling under the desk every day to plug/unplug it.</li>
<li><a href="http://store.apple.com/us/product/MB441Z/A">Apple MagSafe Airline Adapter</a>: I have already flown to India (>20 hour flying time) twice this year, and the airline adapter is a lifesaver for such long flights. Just make sure you get a seat with a power port (I use <a href="http://www.seatguru.com">www.seatguru.com</a> to choose good seats), and you are good to go.</li>
<li><a href="http://www.amazon.com/gp/product/B000OOYECC?ie=UTF8&amp;tag=dotn047-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B000OOYECC">mStand Laptop Stand</a><img src="http://www.assoc-amazon.com/e/ir?t=dotn047-20&amp;l=as2&amp;o=1&amp;a=B000OOYECC" alt="" />: I use this at home, and find it to be quite elegant looking. It also has a gap at the front for easy access to the laptop lid for opening/closing.</li>
</ol>


<p>I have been meaning to check out the <a href="http://www.hypershop.com/HyperMac-External-Battery-for-MacBook-%0AiPhone-iPad-iPod-s/91.htm">HyperMac external battery</a>, looks like a great product if you go to
conferences frequently, or are a road warrior. If any of you have tried it
out, please do leave a comment about your experience with it.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Working with a Windows Workflow Service in a non-Workflow client project]]></title>
    <link href="http://dotnetsurfers.com/blog/2010/08/17/working-with-a-windows-workflow-service-in-a-non-workflow-client-project/"/>
    <updated>2010-08-17T21:19:25-05:00</updated>
    <id>http://dotnetsurfers.com/blog/2010/08/17/working-with-a-windows-workflow-service-in-a-non-workflow-client-project</id>
    <content type="html"><![CDATA[<p>I just wasted a day trying to figure out something that should have worked out
of the box with Visual Studio. Hopefully, this can save somebody some time. I
have been working with Windows Workflow (.Net 4, Visual Studio 2010) over the
last week and my project required me to call a Workflow Service from another
workflow hosted within a Windows/NT Service. I created the Workflow Service
and when I built a test client for it using a Workflow Console application,
the activities from the service show up just fine in the client workflow.</p>

<p>However, when I add reference for the Workflow service in the NT Service, no
new activities are available in a workflow inside the NT Service project. It
looks like Visual Studio parses the service reference differently based on the
type of client project. I ended up comparing the csproj files manually for my
console workflow client and NT service workflow client. By copying the
following entry to the NT service project file, I was able to get it to behave
consistently:</p>

<p><ProjectTypeGuids>{32f31d43-81cc-4c15-9de6-3fc5453562b6};{FAE04EC0-301F-11D3
-BF4B-00C04F79EFBC}</ProjectTypeGuids></p>

<p>It seems that the first guid represents a workflow project type and the second
one stands for a Windows C# project.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Migrating from dasBlog to WordPress]]></title>
    <link href="http://dotnetsurfers.com/blog/2010/07/21/migrating-from-dasblog-to-wordpress/"/>
    <updated>2010-07-21T18:43:31-05:00</updated>
    <id>http://dotnetsurfers.com/blog/2010/07/21/migrating-from-dasblog-to-wordpress</id>
    <content type="html"><![CDATA[<p>I migrated this blog from dasBlog to WordPress a couple of weeks ago, to take
advantage of the large number of WordPress plug-ins and themes available. Here
are the steps I had to follow:</p>

<ol>
<li><p>Created Local backup of my dasBlog site.</p></li>
<li><p>Used <a href="http://merill.net/2008/03/dasblog-to-blogml-converter/">this tool</a> to
create BlogML file from dasBlog.</p></li>
<li><p>Installed WordPress on a test directory on my host (GoDaddy), since it
provided a 1-click install.</p></li>
<li><p>Configured the permalink structure in WordPress.</p></li>
<li><p>Used <a href="http://www.kavinda.net/content/other/BlogML-WordPress-Import.zip">BlogML to WordPress Import Module</a>
mentioned <a href="http://www.kavinda.net/2008/10/23/migrating-from-dasblog-to-%0Awordpress.html">here</a> to import all my old data.</p></li>
<li><p>Installed Redirection plug-in for WordPress. Under
Redirection->Options->Import, I used the CSV file containing the mapped URLS
to set up URL redirection so that all the old links remained intact.</p></li>
<li><p>Renamed the test directory to my desired blog directory name in the host.</p></li>
</ol>


<p>In case you are subscribed to the old RSS feed URL, please be sure to update
it to the <a href="http://dotnetsurfers.com/blog/feed/">new one</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Connecting to a local resource or service from the Smart Device Emulator in Visual Studio]]></title>
    <link href="http://dotnetsurfers.com/blog/2010/06/06/connecting-to-a-local-resourceservice-from-the-smart-device-emulator-in-visual-studio/"/>
    <updated>2010-06-06T13:27:33-05:00</updated>
    <id>http://dotnetsurfers.com/blog/2010/06/06/connecting-to-a-local-resourceservice-from-the-smart-device-emulator-in-visual-studio</id>
    <content type="html"><![CDATA[<p>I am working on a project right now that has a smart device component, and we
use the Pocket PC 2003 SE Emulator to test and debug the application locally.
It took me a while to get the environment setup for the first time; hopefully
this post can save some time for other people. <a href="http://blogs.msdn.com/b/akhune/archive/2005/11/16/493329.aspx">This post</a> helped me
in getting the emulator connected to the internet. Accessing a web service on
my local computer from inside the emulator was a little harder to figure out.
It turns out that:</p>

<ol>
<li><p>You cannot use ‘localhost’ from inside the emulator to refer to your local PC. You have to use either the computer name or the IP address. However, even after I use the computer name, I get this when trying to access a local resource. <br/>
<a href="http://dotnetsurfers.com/images/emulator1.jpg"><img src="http://dotnetsurfers.com/images/emulator1_thumb.jpg" alt="emulator1" /></a></p></li>
<li><p>The Windows firewall blocks the emulator from accessing anything on port 80 by default. I had to pull up the Windows Firewall settings and create a new Inbound Rule (I am using 64-bit Windows 7 here). The screenshots below should be self-explanatory. <br/>
<a href="http://dotnetsurfers.com/images/firewall6.jpg"><img src="http://dotnetsurfers.com/images/firewall6_thumb.jpg" alt="firewall6" /></a>
<a href="http://dotnetsurfers.com/images/firewall1.jpg"><img src="http://dotnetsurfers.com/images/firewall1_thumb.jpg" alt="firewall1" /></a><a href="http://dotnetsurfers.com/images/firewall2.jpg"><img src="http://dotnetsurfers.com/images/firewall2_thumb.jpg" alt="firewall2" /></a></p></li>
</ol>


<p><a href="http://dotnetsurfers.com/images/firewall3.jpg"><img src="http://dotnetsurfers.com/images/firewall3_thumb.jpg" alt="firewall3" /></a>
<a href="http://dotnetsurfers.com/images/firewall4.jpg"><img src="http://dotnetsurfers.com/images/firewall4_thumb.jpg" alt="firewall4" /></a>
<a href="http://dotnetsurfers.com/images/firewall5.jpg"><img src="http://dotnetsurfers.com/images/firewall5_thumb.jpg" alt="firewall5" /></a></p>

<p>And Voila! The emulator is now able to access local resources.</p>

<p><a href="http://dotnetsurfers.com/images/emulator2.jpg"><img src="http://dotnetsurfers.com/images/emulator2_thumb.jpg" alt="emulator2" /></a></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[BDD & MSpec presentation at the Dallas CSharp SIG]]></title>
    <link href="http://dotnetsurfers.com/blog/2010/05/10/bdd-mspec-presentation-at-the-dallas-c-sig/"/>
    <updated>2010-05-10T07:43:39-05:00</updated>
    <id>http://dotnetsurfers.com/blog/2010/05/10/bdd-mspec-presentation-at-the-dallas-c-sig</id>
    <content type="html"><![CDATA[<p>Thanks to all who came to my BDD/MSpec talk. If you want, you can watch a
video of the talk below.</p>

<p>The code that we developed during the talk can be downloaded
<a href="http://www.dotnetsurfers.com/utils/bowling.zip">here</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Getting Started With Mocking - Part 2- Using MOQ]]></title>
    <link href="http://dotnetsurfers.com/blog/2010/04/02/getting-started-with-mocking-part-2-using-moq/"/>
    <updated>2010-04-02T12:25:41-05:00</updated>
    <id>http://dotnetsurfers.com/blog/2010/04/02/getting-started-with-mocking-part-2-using-moq</id>
    <content type="html"><![CDATA[<p><a href="http://www.dotnetsurfers.com/utils/mocking2.zip">Download Code</a></p>

<p>This is the second part of the 2 post series on Mocking. In the <a href="http://www.dotnetsurfers.com/Blog/2010/02/10/GettingStartedWithMockingPart1TheBasics.aspx">last post</a>, we discussed the basics of Mocking and how Adam (the intern) used
Manual Mocking to unit test the simple Shopping Cart application he’s
building. In this post, we’ll see how using a Mocking library can make the
process of mocking out dependencies simpler.</p>

<p><strong>Why use a mocking library? <br/>
</strong>The projects you work on are usually nowhere as simple/small as the Shopping Cart example Adam is working on (If they are, is there room for one more on the team?). If you have to build a new mock class for each of your classes, the amount of new code you have to write increases significantly. Also, you might want to reuse your test infrastructure across different classes, or just want the mock object to act dumb.</p>

<p>It’s also harder to do interaction based testing using Manual Mocks. In the
manual mock for Logger, we had to add a new field to track how many times it
is called. As the behavior to test becomes complicated, so does your mock
class. Using a mocking library can take care of all these mundane things.</p>

<p> <strong>Why MOQ?</strong></p>

<p><a href="http://code.google.com/p/moq/">MOQ</a> is a simple and easy to learn mocking
library for .NET that takes advantage of .NET 3.5 (i.e. Linq expression trees)
and C# 3.0 features (i.e. lambda expressions). There are other mocking
libraries like RhinoMocks and TypeMock Isolator, and MOQ is relatively new to
the scene. The main reason I recommend using MOQ is because it has a really
low learning curve and is intuitive to use. Unlike other libraries, it does
not force you to distinguish between a mock and a stub, which makes it easier
for developers new to mocking to work with.</p>

<p><strong>MOQ Basics</strong> <br/>
To create a mock of type T, you will use the Mock<T> class. Any interface type
can be used for mocking, but for classes, only abstract and virtual members
can be mocked. Let’s walk through a few common scenarios and the corresponding
MOQ usage.</p>

<p>Creating Mock objects</p>

<pre><code> Mock&lt;IProduct&gt; _mockProduct = new Mock&lt;IProduct&gt;();




 Mock&lt;ILogger&gt; _mockLogger = new Mock&lt;ILogger&gt;();
</code></pre>

<p>Mocking a method implementation and returning fake data</p>

<pre><code> _mockProduct.Setup(m =&gt; m.GetProductCategory()).Returns("Test Category");
</code></pre>

<p>Mocking a property and returning fake data</p>

<pre><code>_mockProduct.SetupGet(m =&gt; m.Name)




            .Returns("Product 1");
</code></pre>

<p>Throw exception</p>

<pre><code> _mockLogger.Setup(m =&gt; m.Log(It.Is&lt;string&gt;(p =&gt; p == null)))




            .Throws(new ArgumentNullException());
</code></pre>

<p>Validate Parameters</p>

<pre><code> _mockLogger.Setup(m =&gt; m.Log(It.IsRegex("[1-9]+")))




            .Callback(() =&gt; Console.WriteLine("Numbers passed"));
</code></pre>

<p>Verify Interactions</p>

<pre><code> _mockLogger.Object.Log("test");




 _mockLogger.Verify(m =&gt; m.Log(It.Is&lt;string&gt;(s=&gt;s=="test")),Times.Once());
</code></pre>

<p>Invoke Callback</p>

<pre><code> int counter = 0;




 _mockLogger.Setup(m =&gt; m.Log(It.IsAny&lt;String&gt;())).Callback(() =&gt; counter++);
</code></pre>

<p>Even if you are new to MOQ, you’ll find the API very intuitive and easy to
pick up.</p>

<p><strong>Back to the Shopping Cart</strong></p>

<p>So Adam sees how easy it is easy to work with MOQ and how much code/effort it
saves him, and he updates his unit tests for the Shopping Cart accordingly.
Note that these unit tests are independent of the manual mock classes as well
as from external resources like the filesystem/database.</p>

<pre><code>   1:  [TestMethod]




   2:  public void AddProduct_AddingProductWithPrice10_ShouldMakeTotal10()




   3:  {




   4:      var mock = new Mock&lt;IProduct&gt;();




   5:      mock.SetupGet(m =&gt; m.Price).Returns(10.00M);




   6:      var cart = new ShoppingCart(null);




   7:      cart.AddProduct(mock.Object);




   8:      Assert.AreEqual(10.00M, cart.Total);




   9:   




  10:  }




  11:   




  12:  [TestMethod]




  13:  public void AddProduct_AddingProduct_ShouldCallLogger()




  14:  {




  15:      var mockProduct = new Mock&lt;IProduct&gt;();




  16:      var mockLogger = new Mock&lt;ILogger&gt;();




  17:      mockLogger.Setup(m =&gt; m.Log(It.IsAny&lt;string&gt;())).Verifiable("Log should have been called");




  18:      var cart = new ShoppingCart(mockLogger.Object);




  19:      cart.AddProduct(mockProduct.Object);




  20:      mockLogger.Verify();




  21:  }
</code></pre>

<p><strong>Later….</strong></p>

<p>You are satisfied with the ShoppingCart project and the corresponding tests
that Adam built. When you run into him in the evening, you commend him on the
nice work and invite him to have a couple of beers with you. As you are
sitting at the bar, you glance at the mirror and you see something that makes
the hair at the back of your neck stand up. Instead of Adam and you at the
bar, it’s just you sitting there with 2 beers in your hand talking to
yourself. You then realize that Adam was a figment of your imagination and you
might have suffered from some sort of a dual personality disorder (Kind of
like <a href="http://en.wikipedia.org/wiki/Fight_Club_(film">Fight Club</a>)). Your brain
created Adam so that you could face your fears and misconceptions about Unit
Testing and Mocking. On the bright side, you realize that you have finished
your project and are sitting in a bar with 2 beers. Cheers!</p>

<p><a href="http://www.dotnetsurfers.com/utils/mocking2.zip">Download Code</a></p>
]]></content>
  </entry>
  
</feed>

