<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Matt Harrington</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/matt-harrington/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/matt-harrington/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 07 Apr 2015 19:06:56 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>How Unity game Drive Me Bananas succeeds with Windows Phone</title>
      <link>https://docs.microsoft.com/archive/blogs/matt-harrington/how-unity-game-drive-me-bananas-succeeds-with-windows-phone</link>
      <pubDate>Thu, 11 Dec 2014 15:09:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Harrington MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/matt-harrington/2014/12/11/how-unity-game-drive-me-bananas-succeeds-with-windows-phone/</guid>
      <description><![CDATA[&nbsp;
Unity3D is certainly one of the most popular ways to make 3D games for mobile phones. There...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p>
<p>Unity3D is certainly one of the most popular ways to make 3D games for mobile phones. There are thousands of games made with it, by students and large studios alike. I recently helped the team behind a Unity game called <a href="http://www.windowsphone.com/en-us/store/app/drive-me-bananas/86487076-128d-437a-a9fc-1cae72147167">Drive Me Bananas</a>, and I'd like to share three tips with you about how they succeeded.</p>
<ol>
<li><strong>Target Windows Phone.</strong> It&rsquo;s natural to target iOS and Android with your game, and you wouldn&rsquo;t be wrong to do so, but many developers find it hard to get their game noticed there. It&rsquo;s so simple to also target Windows Phone with your Unity game, which lets you reach a whole new market. You&rsquo;ve already done the hard work by making your game, and targeting one more platform is easy.</li>
<li><strong>Target a global market.</strong> A lot of my readers are in the United States, and it would be natural for them to target the US market.&nbsp; There&rsquo;s nothing wrong with that, but keep in mind that it&rsquo;s an enormous world and the US is just one part of it.&nbsp; The Drive Me Bananas team put special attention on Latin America, and released a localized version called <a href="http://www.windowsphone.com/en-us/store/app/changos-y-bananas/ef19f182-c0a0-4842-8b7d-9419ec65dda9">Changos Y Bananas</a>. There were several reasons for this. Windows Phone sells quite well there, especially in countries where Nokia has been a household name. Also, because of Nokia&rsquo;s long history in the region, there are more mobile operator billing arrangements there for Windows Phone than for iOS and Android. In markets where consumers can make purchases on their cell phone bill, they spend much more than in markets where they need credit cards or some other payment option.&nbsp; Windows Phone is the leader in Latin America for this.</li>
<li><a href="https://www.youtube.com/watch?v=oNZove4OTtI">Merchandising</a>. The Drive Me Bananas team not only created a fun game, but they&rsquo;re working to drive awareness of their game through merchandising. They&rsquo;re starting to make elements of the game available from <a href="https://sandboxr.com/user/shop.php?world=101">a 3D printing store called Sandboxr</a>.&nbsp; Models are printed on demand, so they don&rsquo;t have to spend a lot of money on inventory.</li>
</ol>
<p>Here's Press Start Studios describing their experience:</p>
<blockquote>
<p>Drive Me Bananas, or &ldquo;DMB&rdquo;, is an amazing mobile endless runner game with unique art and game mechanics in this genre. The game has been translated into five languages and reached a global audience after its launch in May 2014. This journey started three years ago while Luis Parra, Press Start's CEO, was in the middle of his Masters program at the Academy of Art University in San Francisco. Drive Me Bananas started as an inflection point from Facebook games to mobile games, and with the support of the Academy of Art and the studio R3dPixel, the game was initiated.</p>
<p>As Drive Me Bananas was being developed, it was also being used as the central project for several classes at the Academy of Art.&nbsp; This helped both the students who were working on it to gain exposure in a published game, and also helped Luis Parra to transition from academia to his company, Press Start Studios. Working on a game from idea to working prototype proved to be a long and valuable learning experience, especially as this was the first game of such scope that Press Start Studios had developed. During the development of Drive Me Bananas, one of the Academy of Art professors, Pryce Jones, now head of the graduate program at the Academy of Art, was also able to bring an experienced perspective to the creative and production process. After two years of development, Press Start Studios took Drive Me Bananas live with great reviews and download metrics across the US and Latin American markets. In fact, Drive Me Bananas has been one of the top rated games in the top app charts in Latin America. With Drive Me Bananas, and its innovative art and game mechanics, Press Start established itself as a leading game development studio.</p>
<p>Shortly after being launched on iOS and Android, Drive Me Bananas was ported to Windows Phone.&nbsp; This took less than a month&rsquo;s time and the results were terrific. The Windows Phone Store provided great visibility to Drive Me Bananas, and Microsoft&rsquo;s support has been valuable to Press Start Studios. Microsoft approved the game immediately upon submission, and Press Start found porting to Windows to be worthwhile as that version has achieved close to 50% of the game&rsquo;s total downloads on all platforms. This was with zero marketing budget. The Spanish version, <a href="http://www.windowsphone.com/en-us/store/app/changos-y-bananas/ef19f182-c0a0-4842-8b7d-9419ec65dda9">Changos Y Bananas</a>, is also available in the Windows Phone Store, creating an opportunity to reach an ever widening global audience.</p>
<p>&nbsp;</p>
</blockquote>]]></content:encoded>
    </item>
    <item>
      <title>JavaScript unit testing: using the Chutzpah test runner in Visual Studio</title>
      <link>https://docs.microsoft.com/archive/blogs/matt-harrington/javascript-unit-testing-using-the-chutzpah-test-runner-in-visual-studio</link>
      <pubDate>Mon, 27 Oct 2014 15:33:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Harrington MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/matt-harrington/2014/10/27/javascript-unit-testing-using-the-chutzpah-test-runner-in-visual-studio/</guid>
      <description><![CDATA[Welcome to the third and final installment of my blog series on JavaScript unit testing. Part one...]]></description>
      <content:encoded><![CDATA[<p>Welcome to the third and final installment of my blog series on JavaScript unit testing. <a href="http://blogs.msdn.com/b/matt-harrington/archive/2014/10/03/javascript-unit-testing-guiding-principles-and-common-excuses.aspx">Part one</a> introduced some general principles of unit testing, and why unit testing is especially important for JavaScript. <a href="http://blogs.msdn.com/b/matt-harrington/archive/2014/10/03/how-to-write-javascript-unit-tests-with-mocha.aspx">Part two</a> introduced the Mocha test framework. In part three, I'll show you how to run your JavaScript unit tests directly in Visual Studio using a plugin called Chutzpah.</p>
<p>Start with the files you downloaded and used in part two. Visual Studio should have these files in the Solution Explorer view:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/7608.unit-test-project-file-list_72611779.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/7608.unit_2D00_test_2D00_project_2D00_file_2D00_list_5F00_72611779.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="unit-test-project-file-list" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/7142.unit-test-project-file-list_thumb_026FE631.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/7142.unit_2D00_test_2D00_project_2D00_file_2D00_list_5F00_thumb_5F00_026FE631.png" alt="unit-test-project-file-list" width="492" height="452" border="0" /></a></p>
<p>&nbsp;</p>
<p>Select <strong>File -&gt; Save All</strong> to save this as a solution. Test runners in Visual Studio seem to require that a <em>*.sln</em> file has been saved.</p>
<p>We need to add the Chutzpah test runner to Visual Studio. Go to <strong>Tools &ndash;&gt; Extensions and Updates</strong>. On the left side of the dialog box, select <strong>Online</strong>. Then type c<em>hutzpah</em> into the search field in the upper right corner. You&rsquo;ll be shown two results:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/2728.install-chutzpah-vs_121281F3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/2728.install_2D00_chutzpah_2D00_vs_5F00_121281F3.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="install-chutzpah-vs" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/7484.install-chutzpah-vs_thumb_05A6EF7B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/7484.install_2D00_chutzpah_2D00_vs_5F00_thumb_5F00_05A6EF7B.png" alt="install-chutzpah-vs" width="830" height="576" border="0" /></a></p>
<p>&nbsp;</p>
<p>Download and install the first one. You&rsquo;ll have to then restart Visual Studio. Repeat this process with the second extension.</p>
<p>Chutzpah needs to know about the test file and all of its dependencies. Open calculator-tests.js, and add these lines to the top of the file:</p>
<div class="highlight highlight-javascript">
<pre><span class="c1">/// &lt;reference path="../js/vendor/mocha.js" /&gt;</span>
<span class="c1">/// &lt;reference path="../js/vendor/expect.js" /&gt;</span>
<span class="c1">/// &lt;reference path="../js/calculator.js" /&gt;</span>
</pre>
</div>
<p>This tells Chutzpah that you&rsquo;re using the Mocha test framework, and that you have a dependency on Expect. It also tells Chutzpah that the test file depends on calculator.js.</p>
<p>Right-click on calculator-tests.js, and you&rsquo;ll now have a few options from Chutzpah. Select <strong>Run JS Tests</strong>:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/6013.chutzpah-run-js-tests_3734EDC1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/6013.chutzpah_2D00_run_2D00_js_2D00_tests_5F00_3734EDC1.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="chutzpah-run-js-tests" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/0083.chutzpah-run-js-tests_thumb_449B00C7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/0083.chutzpah_2D00_run_2D00_js_2D00_tests_5F00_thumb_5F00_449B00C7.png" alt="chutzpah-run-js-tests" width="632" height="619" border="0" /></a></p>
<p>&nbsp;</p>
<p>Visual Studio will then display your unit tests and their results in Test Explorer:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/0842.chutzpah-test-explorer_28F90582.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/0842.chutzpah_2D00_test_2D00_explorer_5F00_28F90582.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="chutzpah-test-explorer" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/6354.chutzpah-test-explorer_thumb_5FD5EA79.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/6354.chutzpah_2D00_test_2D00_explorer_5F00_thumb_5F00_5FD5EA79.png" alt="chutzpah-test-explorer" width="692" height="517" border="0" /></a></p>
<p>&nbsp;</p>
<p>You can also run your tests by selecting <strong>Test &ndash;&gt; Run &ndash;&gt; All Tests</strong>:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/4606.chutzpah-run-tests-from-menu_7C72664C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/4606.chutzpah_2D00_run_2D00_tests_2D00_from_2D00_menu_5F00_7C72664C.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="chutzpah-run-tests-from-menu" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/5633.chutzpah-run-tests-from-menu_thumb_17AABF4E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/5633.chutzpah_2D00_run_2D00_tests_2D00_from_2D00_menu_5F00_thumb_5F00_17AABF4E.png" alt="chutzpah-run-tests-from-menu" width="772" height="302" border="0" /></a></p>
<p>&nbsp;</p>
<p>You could stop here and stick with just using Chutzpah to run your unit tests, but there are more features worth exploring. For example, you can use Chutzpah to tell you something about code coverage:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/5732.chutzpah-show-code-coverage_5BEDB74B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/5732.chutzpah_2D00_show_2D00_code_2D00_coverage_5F00_5BEDB74B.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="chutzpah-show-code-coverage" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/0638.chutzpah-show-code-coverage_thumb_25136305.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/0638.chutzpah_2D00_show_2D00_code_2D00_coverage_5F00_thumb_5F00_25136305.png" alt="chutzpah-show-code-coverage" width="720" height="359" border="0" /></a></p>
<p>&nbsp;</p>
<p>Select that, and you&rsquo;ll see results like this:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/3806.chutzpah-code-coverage-output_48CF1B50.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/3806.chutzpah_2D00_code_2D00_coverage_2D00_output_5F00_48CF1B50.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="chutzpah-code-coverage-output" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/7450.chutzpah-code-coverage-output_thumb_2D2D200B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/7450.chutzpah_2D00_code_2D00_coverage_2D00_output_5F00_thumb_5F00_2D2D200B.png" alt="chutzpah-code-coverage-output" width="886" height="236" border="0" /></a></p>
<p>The results for our own code look good, but there&rsquo;s no reason to unit test a library such as Expect, unless of course you&rsquo;re the author of Expect. We can tell Chutzpah to ignore Expect by creating a file called <em>Chutzpah.json</em>. Right-click the test folder and select <strong>Add &ndash;&gt; Add New Item</strong>. Add a file called <em>Chutzpah.json</em>. Erase anything which Visual Studio might have put in that file, and put this:</p>
<div class="highlight highlight-javascript">
<pre><span class="p">{</span> 
    <span class="s2">"CodeCoverageExcludes"</span><span class="o">:</span> <span class="p">[</span> <span class="s2">"*\\expect.js"</span> <span class="p">]</span> 
<span class="p">}</span>
</pre>
</div>
<p>This tells Chutzpah to exclude Expect. Re-run <strong>Show Code Coverage</strong>, and the output will look better. Chutzpah now only looks at your own code.</p>
<p>To get even deeper with Chutzpah, check out the documentation <a href="https://github.com/mmanela/chutzpah">on its GitHub repo</a>. In particular, look at the documentation for <a href="https://github.com/mmanela/chutzpah/wiki/Chutzpah.json-Settings-File">Chutzpah.json</a>.</p>]]></content:encoded>
    </item>
    <item>
      <title>How to write JavaScript unit tests with Mocha</title>
      <link>https://docs.microsoft.com/archive/blogs/matt-harrington/how-to-write-javascript-unit-tests-with-mocha</link>
      <pubDate>Fri, 03 Oct 2014 15:19:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Harrington MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/matt-harrington/2014/10/03/how-to-write-javascript-unit-tests-with-mocha/</guid>
      <description><![CDATA[In part one of this series on JavaScript unit testing, we covered some guiding principles and common...]]></description>
      <content:encoded><![CDATA[<p>In <a href="http://blogs.msdn.com/b/matt-harrington/archive/2014/10/03/javascript-unit-testing-guiding-principles-and-common-excuses.aspx">part one of this series</a> on JavaScript unit testing, we covered some guiding principles and common excuses. Let's continue with part two, where we'll write unit tests using Mocha.</p>
<h2>Get Visual Studio</h2>
<p>First of all, you need Visual Studio. If you don't have it already, you can download a free edition called <a href="http://www.visualstudio.com/en-US/products/visual-studio-express-vs">Visual Studio 2013 Express for Web</a>. If you're a student, check with your administrators to see if your college is enrolled in <a href="https://www.dreamspark.com/">DreamSpark</a>. If so, you'll have free access on the DreamSpark site to paid versions of Visual Studio such as the Professional edition. This gives you more features. If you're a startup, enroll in <a href="http://www.microsoft.com/bizspark/">BizSpark</a> to get a MSDN license for 3 years. This also gives you paid versions of Visual Studio such as Professional and Ultimate.</p>
<h2>Create a web site and add unit tests</h2>
<ol class="task-list">
<li>Download the following code sample: <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/code_2D00_samples/5025.Calculator.zip" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-code_2D00_samples/5025.Calculator.zip">5025.Calculator.zip</a>. Right click on it, and choose <strong>Extract All</strong>.</li>
<li>In Visual Studio, go to <strong>File -&gt; Open Web Site</strong>. Select the <strong>Calculator</strong> folder you unzipped in step 1.</li>
<li>Launch the website by choosing <strong>Debug -&gt; Start Debugging</strong>. Or, you can just hit F5. This is the Mocha test runner and you'll see the output for a single unit test. It tests the <code>add</code> function on the <code>Calculator</code> object.</li>
<li>Close the browser window that just launched.</li>
<li>In Visual Studio, open <code>index.html</code>, <code>js/calculator.js</code>, and <code>test/calculator-tests.js</code>.</li>
<li>In <code>index.html</code>, you'll see the unit test framework <strong>Mocha</strong> referenced. You'll also see a reference to <strong>Expect</strong>. That's an assertion library. It then references the JavaScript being tested, <code>calculator.js</code>, and then the unit tests themselves, <code>calculator-tests.js</code>.</li>
<li>In <code>calculator.js</code>, you'll see a JavaScript <a href="http://benalman.com/news/2010/11/immediately-invoked-function-expression/">IIFE</a> which defines a <code>Calculator</code> constructor and the <code>add</code> function.</li>
<li>In <code>calculator-tests.js</code> you'll see 3 sections. The <code>describe</code> at the top defines the test suite. The <code>beforeEach</code> sets up any necessary state. Perhaps your unit test relies on things being set up a certain way. Do that in <code>beforeEach</code>. The remaining <code>describe</code> function describes the specification. It corresponds to a particular feature. The call to the <code>it</code> function defines what the test should do. Be as explicit as possible. Lastly, <code>expect</code> asserts what the result of the test should be.</li>
<li>Let's add a new test. In <code>calculator-tests.js</code>, copy this code for the <code>subtract</code> test and paste it below the <code>add</code> test:</li>
</ol>
<div class="highlight highlight-javascript">
<pre><span class="nx">describe</span><span class="p">(</span><span class="s2">"Subtract"</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
    <span class="nx">it</span><span class="p">(</span><span class="s2">"should return the difference of both operands"</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
        <span class="nx">expect</span><span class="p">(</span><span class="nx">calculator</span><span class="p">.</span><span class="nx">subtract</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">3</span><span class="p">)).</span><span class="nx">to</span><span class="p">.</span><span class="nx">be</span><span class="p">(</span><span class="mi">2</span><span class="p">);</span>
    <span class="p">});</span>
<span class="p">});</span>
</pre>
</div>
<ol class="task-list" start="10">
<li>Hit F5 to run the tests, and it should fail. This is called TDD: Test-Driven Development. In TDD, you write your unit test first, run it to verify it fails, and only then implement the code you're testing. This prevents you from accidentally writing a unit test which always passes, giving you a false sense of safety.</li>
<li>In <code>calculator.js</code>, create this <code>subtract</code> function. Note that the function body is incorrect. That's on purpose:</li>
</ol>
<div class="highlight highlight-javascript">
<pre><span class="nx">Calculator</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">subtract</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">operand1</span><span class="p">,</span> <span class="nx">operand2</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">return</span> <span class="nx">operand1</span> <span class="o">+</span> <span class="nx">operand2</span><span class="p">;</span>
<span class="p">};</span>
</pre>
</div>
<ol class="task-list" start="12">
<li>Run the tests again by hitting F5. This time you'll get a different error.</li>
<li>Change the <code>subtract</code> function in <code>calculator.js</code> to correctly implement subtraction:</li>
</ol>
<div class="highlight highlight-javascript">
<pre><span class="nx">Calculator</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">subtract</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">operand1</span><span class="p">,</span> <span class="nx">operand2</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">return</span> <span class="nx">operand1</span> <span class="o">-</span> <span class="nx">operand2</span><span class="p">;</span>
<span class="p">};</span>
</pre>
</div>
<ol class="task-list" start="14">
<li>Run the tests a final time by hitting F5. This time both tests should pass. If you don't notice a difference, it could be because your web page is cached. Reload the page by hitting <strong>Control-R</strong>.</li>
</ol>
<h2>Commentary</h2>
<p>Recall the principles of unit testing from part one in this series. How do the above unit tests stack up?</p>
<ol class="task-list">
<li>The unit tests are <strong>predictable</strong>. We pass in static arguments and everything is reproducible.</li>
<li>It's obvious when the unit tests <strong>pass or fail</strong>.</li>
<li>The tests are <strong>self-documenting</strong>. A quick look at the <code>Add</code> unit test tells us that "Add should return the sum of both operands". We know what that means without having to look anything up.</li>
<li>The unit tests have a <strong>single responsibility</strong> and only test one thing at a time.</li>
<li>When the tests fail, we get <strong>useful error messages</strong>.</li>
<li>They don't test multiple components, so they're <strong>not integration tests</strong>.</li>
</ol>
<p>&nbsp;</p>
<p>How about the excuses we listed in part one? Were these tests too hard to write, or too cumbersome? Once you learn how tests are written, they should be pretty simple especially when compared with debugging code without unit tests.</p>
<p>Want to learn more? Take a look at the <a href="http://pluralsight.com">Pluralsight</a> course <em>Front-end First: Testing and Prototyping JavaScript Apps</em> by Elijah Manor. That's where this example is from.</p>
<p>In part three of this series, we'll see how to use the Chutzpah unit test runner in Visual Studio.</p>]]></content:encoded>
    </item>
    <item>
      <title>JavaScript unit testing: guiding principles and common excuses</title>
      <link>https://docs.microsoft.com/archive/blogs/matt-harrington/javascript-unit-testing-guiding-principles-and-common-excuses</link>
      <pubDate>Fri, 03 Oct 2014 12:25:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Harrington MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/matt-harrington/2014/10/03/javascript-unit-testing-guiding-principles-and-common-excuses/</guid>
      <description><![CDATA[There's a lot of interest in JavaScript at Microsoft. Did you know that:

JavaScript is one of the...]]></description>
      <content:encoded><![CDATA[<p>There's a lot of interest in JavaScript at Microsoft. Did you know that:</p>
<ul class="task-list">
<li>JavaScript is one of the officially supported languages for Windows 8 and Windows Phone development</li>
<li><a href="http://azure.microsoft.com/en-us/documentation/services/mobile-services/">Azure Mobile Services</a>, a mobile backend-as-a-service, is written in Node.js</li>
<li><a href="https://store.office.com/en-us/">Apps for Office</a> are written in JavaScript</li>
</ul>
<p>&nbsp;</p>
<p>As a consequence, Visual Studio is an excellent tool for writing JavaScript, even if you're just writing a web app and not a Windows app. In my opinion, if you want to write reliable code in a dynamically typed language such as JavaScript, you really need to write unit tests. Part one of this blog series will offer some guiding principles for writing unit tests, and common excuses people give when they don't. In part two, we'll write a JavaScript unit test using Mocha. In part three, we'll use a Visual Studio extension called Chutzpah to run your tests.</p>
<h2>What are unit tests?</h2>
<p>Let's make sure we're all on the same page. A unit is a small section of code. Unit testing means you test that bit of code to make sure it functions properly. This increases confidence in your code.</p>
<p>Unit tests are important when many people work on the same codebase. If one engineer changes code in one part of the project, you want to ensure that the rest of the project still works.</p>
<p>Unit tests are especially important in dynamically typed languages such as JavaScript, since there is no compiler to catch common problems.</p>
<h2>Guiding principles for unit tests</h2>
<ol class="task-list">
<li><strong>Predictable.</strong> If you have a certain input, you should always get the same output. Your input should always be static. For example, don't pass a random number or the current time as an input.</li>
<li><strong>Pass or fail.</strong> It should be obvious if your test passed or failed.</li>
<li><strong>Self documenting.</strong> Your code should describe what the test is meant to do. Another engineer looking at your test should immediately be able to understand it. It helps if you use testing and assertion frameworks which read like English.</li>
<li><strong>Single responsibility.</strong> Unit tests should only test one single thing at a time. If you want to test more things, then write more unit tests.</li>
<li><strong>Useful error messages.</strong> When a unit test fails, the error message should be useful.</li>
<li><strong>Not integration tests.</strong> Unit tests don't test multiple components. Unit tests come first, then integration tests, then validation tests.</li>
</ol>
<h2>Common Excuses</h2>
<ol class="task-list">
<li><strong>Too busy.</strong> "I have too many other things to do." "There's plenty of time after development to catch bugs." When you fix a bug and it breaks something else, it's called a regression. Unit tests can prevent regressions.</li>
<li><strong>Too hard.</strong> "It's too difficult to write unit tests." "It'll take too long because I'm not experienced."</li>
<li><strong>Too confident.</strong> "I don't need unit tests. My code works." "Why waste time writing unit tests because my code works?"</li>
<li><strong>Too lazy.</strong> "There are other things I'd rather be doing." "I just don't want to write unit tests."</li>
<li><strong>Too cumbersome.</strong> "It takes too long to run the unit tests." "I keep forgetting to run the unit tests."</li>
</ol>
<p>&nbsp;</p>
<p>If you find yourself making one of the excuses above, do yourself a favor and work to get over it. Like anything, there's a bit of a learning curve. However, you'll save yourself countless frustrating hours down the road if you put in a little time now to learn this. It's not as burdensome as you might think.</p>
<p>In the next post in this series, we'll start writing JavaScript unit tests with Mocha.</p>
<p>Acknowledgments: This blog series is based on this excellent course on <a href="http://pluralsight.com/">Pluralsight</a>: <em>Front-end First: Testing and Prototyping JavaScript Apps</em> by Elijah Manor. Content reproduced with Pluralsight's permission.</p>]]></content:encoded>
    </item>
    <item>
      <title>What's New with Azure Mobile Services for Spring 2014</title>
      <link>https://docs.microsoft.com/archive/blogs/matt-harrington/whats-new-with-azure-mobile-services-for-spring-2014</link>
      <pubDate>Wed, 14 May 2014 20:21:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Harrington MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/matt-harrington/2014/05/14/whats-new-with-azure-mobile-services-for-spring-2014/</guid>
      <description><![CDATA[Azure Mobile Services is a turnkey backend for your mobile and web apps. You get 10 for free. Yes,...]]></description>
      <content:encoded><![CDATA[<p><a href="http://azure.microsoft.com/en-us/develop/mobile/">Azure Mobile Services</a> is a turnkey backend for your mobile and web apps. You get 10 for free. Yes, free. It allows you to easily add database support, authentication, and push notifications to your iOS, Android, Windows, and web apps. This spring, the team released a bunch of new features:</p>
<ul>
<li>Backend services can now be written in .NET languages in addition to JavaScript</li>
<li>Offline sync lets you handle scenarios where mobile phones lose cell service. It queues up database operations and synchronizes data when you get back in range.</li>
<li>Enterprise apps using Active Directory authentication are now supported</li>
</ul>
<p>Here's the first in a series of episodes I'm doing on DevRadio on the new features. In this episode, <a href="http://hashtagfail.com/">Yavor Georgiev</a> talks about what's new, and then gives a deep dive into the new .NET backend.</p>
<p><iframe style="height: 281px; width: 500px;" src="https://channel9.msdn.com/Blogs/DevRadio/Microsoft-DevRadio-Microsoft-Azure-Mobile-Services-Overview-the-New-NET-Backend/player?h=281&amp;w=500" frameborder="0" scrolling="no"></iframe></p>]]></content:encoded>
    </item>
    <item>
      <title>Tips for winning hackathons</title>
      <link>https://docs.microsoft.com/archive/blogs/matt-harrington/tips-for-winning-hackathons</link>
      <pubDate>Sat, 03 May 2014 12:45:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Harrington MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/matt-harrington/2014/05/03/tips-for-winning-hackathons/</guid>
      <description><![CDATA[I&rsquo;ve organized more hackathons than I can count. Here&rsquo;s a list of tips for...]]></description>
      <content:encoded><![CDATA[<p>I&rsquo;ve organized more hackathons than I can count. Here&rsquo;s a list of tips for contestants:</p>
<ol>
<li>Read and understand the hackathon&rsquo;s official rules before the event. Ask questions if needed.</li>
<li>Understand the judging criteria. Devote attention to all judging criteria, not just one criterion in particular.</li>
<li>Don&rsquo;t have AV problems. At the beginning of the event, ask how presentations will be made. If you&rsquo;ll be presenting from your own laptop, test it out on the venue&rsquo;s projector early on. Bring all necessary video converters. Don&rsquo;t expect the venue to have what you need. If you&rsquo;ll be presenting from a mobile phone, find out if you&rsquo;ll use an overhead projector or a <a href="http://blogs.msdn.com/b/matt-harrington/archive/2014/05/02/how-to-project-from-a-computer-to-a-tv.aspx">Miracast receiver</a>. Test things before you get fully focused on building your entry.</li>
<li>Android presentations should not use the ARM emulator from Google. It&rsquo;s too slow. Use Genymotion instead. Better yet, deploy right to your phone and <a href="http://blogs.msdn.com/b/matt-harrington/archive/2014/05/02/how-to-project-from-a-computer-to-a-tv.aspx">present using a Miracast receiver</a>. Bring your own receiver in case the venue&rsquo;s does not work.</li>
<li>Don&rsquo;t begin with a long PowerPoint presentation. Dive right in and show your app. I&rsquo;ve seen too many presenters run out of time before actually showing their entry.</li>
<li>Consider using an opening line which clearly tells the judges and audience what your app does.&nbsp; For example, &ldquo;Contoso saves money on healthcare by making providers compete for your business.&rdquo; Consider landing that point in a closing statement too.</li>
<li>A more advanced technique is to start telling a story to appeal to judges on an emotional level. Your story should lead to a problem, and then explain how your hackathon entry solves that problem. All too often this technique fails though, because many developers aren&rsquo;t good storytellers and they run out of time to show their entry.</li>
<li>Make sure judges can summarize your app in one sentence. When deliberating, judges will remind each other about each entry. Don&rsquo;t make a judge search through notes to remember your entry.</li>
<li>Clearly state who your intended user is. If the hackathon has an entrepreneurial feel to it, this will give judges an idea of your total addressable market.</li>
<li>Land your most important points early. Don&rsquo;t wait until the end. You might forget, or run out of time.</li>
<li>Know who the judges are, and what&rsquo;s important to them. If one judge is a designer, emphasize your entry&rsquo;s beautiful design. Certainly don&rsquo;t disparage something which is important to a judge if you want to win them over.</li>
<li>Don&rsquo;t spend time explaining what you couldn&rsquo;t accomplish. I&rsquo;ve heard presenters list everything they attempted to do, but failed. Focus on what you built, not on what failed.</li>
<li>If you&rsquo;re entering a specific category, such as Best Use of the Fabrikam API, make sure you explicitly state how you use their API. I&rsquo;ve seen too many presentations which forget to mention how they use a particular technology.</li>
<li>When using a handheld microphone, keep it right in front of your mouth. Don&rsquo;t hold it at chest level.&nbsp; A rule of thumb, no pun intended, is to keep the microphone a distance of one thumb&rsquo;s length away from your mouth.</li>
<li>Pretend that you&rsquo;re only presenting to someone in the very back of the room. This ensures that you&rsquo;re loud enough for all to hear.</li>
<li>If the hackathon rules state that only work accomplished during the event is eligible, don&rsquo;t enter work you&rsquo;ve previously done. I&rsquo;ve seen people present apps they did absolutely no work on during the hackathon.</li>
<li>Don&rsquo;t make JPEGs and pretend it&rsquo;s a real app. I&rsquo;ve seen this happen.</li>
<li>Don&rsquo;t lie and say you used a particular technology when you didn&rsquo;t. I&rsquo;ve seen this happen.</li>
<li>Be prepared to answer any questions about the technologies you used. I&rsquo;ve seen people present apps they did not build. When questioned about the simplest details, they could not answer.</li>
<li>Don&rsquo;t waste time building features you intend for a version down the road. Have a singular focus on accomplishing what you intend to present.</li>
<li>In the days before the event, watch <a href="https://www.youtube.com/results?search_query=hackathon+presentation">hackathon presentations on YouTube</a>. You&rsquo;ll get a feel of what a good presentation looks like.</li>
</ol>
<p>Have tips of your own? <a href="http://blogs.msdn.com/b/matt-harrington/contact.aspx">Contact me</a> if you want me to list them here, and I&rsquo;ll attribute them to you.&nbsp; Or, you can be anonymous if you like.</p>]]></content:encoded>
    </item>
    <item>
      <title>How to project from a computer to a TV</title>
      <link>https://docs.microsoft.com/archive/blogs/matt-harrington/how-to-project-from-a-computer-to-a-tv</link>
      <pubDate>Fri, 02 May 2014 23:13:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Harrington MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/matt-harrington/2014/05/02/how-to-project-from-a-computer-to-a-tv/</guid>
      <description><![CDATA[Want to wirelessly project from a computer to a TV?&nbsp; How about from a Windows Phone or Android...]]></description>
      <content:encoded><![CDATA[<p>Want to wirelessly project from a computer to a TV?&nbsp; How about from a Windows Phone or Android device?&nbsp; What you want is a <a href="http://en.wikipedia.org/wiki/Miracast">Miracast</a> receiver such as the <a href="http://www.microsoftstore.com/store/msusa/en_US/pdp/ScreenBeam-Pro-Wireless-Display-Receiver/productID.288614400">Actiontec ScreenBeam Pro</a>:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/3000.2014-05-14-Screenbeamrcvr_fnl3_1B17B7E8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/3000.2014_2D00_05_2D00_14_2D00_Screenbeamrcvr_5F00_fnl3_5F00_1B17B7E8.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="2014-05-14-Screenbeamrcvr_fnl3" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/4604.2014-05-14-Screenbeamrcvr_fnl3_thumb_07F68B3C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/4604.2014_2D00_05_2D00_14_2D00_Screenbeamrcvr_5F00_fnl3_5F00_thumb_5F00_07F68B3C.png" alt="2014-05-14-Screenbeamrcvr_fnl3" width="244" height="171" border="0" /></a></p>
<p>It&rsquo;s smaller than you might think, and plugs into your TV with an HDMI cable. You then project to it from compatible devices using Miracast.&nbsp; I&rsquo;ll tell you how to determine if your hardware is compatible in a minute, but first let&rsquo;s talk a little more about Miracast.</p>
<p>There really is a bewildering array of choices when it comes to connecting devices in your home, and you&rsquo;ll be forgiven if you&rsquo;ve just about given up trying to make things work.&nbsp; There&rsquo;s Miracast, DLNA, WiDi, AirPlay, Chromecast, and I think one more whose name I forget right now.&nbsp; To cut to the chase, Miracast is the way to go if you want to project exactly what&rsquo;s on your computer or phone's screen to your TV.</p>
<p>Two Miracast-certified devices connect over an ad hoc WiFi network called <a href="http://en.wikipedia.org/wiki/Wi-Fi_Direct">WiFi Direct</a>, which is different from your home&rsquo;s WiFi network.&nbsp; By that I mean a second WiFi network is created just between your PC and the Miracast receiver, without a wireless router in between.&nbsp; Advantages of this are:</p>
<ul>
<li>Devices don&rsquo;t need the WiFi network&rsquo;s password</li>
<li>You can easily bring your Miracast receiver to another location without reconfiguring it</li>
<li>Your home WiFi network is not saturated with traffic you&rsquo;re trying to stream, since you&rsquo;ll be using a separate WiFi Direct network</li>
</ul>
<p>With Miracast, you can stream full HD at 1080p, and it also supports protected content.&nbsp; You can even stream from compatible Windows Phone 8.1 and Android 4.2 phones.&nbsp; Actiontec maintains a <a href="http://www.actiontec.com/wirelessdisplay/sbpro.php">list of compatible devices</a>. Windows Phone 8.1 is available for developers now, and once it's widely available for consumers I suspect Actiontec will update their list.</p>
<p>&nbsp;</p>
<h3>How to tell if your PC is compatible</h3>
<p>Windows 8.1 supports Miracast, but your PC&rsquo;s hardware must also support it.&nbsp; Fourth generation Ultrabooks will work, but most consumers probably don&rsquo;t know if that&rsquo;s what they have.&nbsp; The best way I&rsquo;ve found to determine Miracast compatibility is to see if the <strong>Project</strong> panel contains an option to <em>Add a wireless display</em>.&nbsp; Open the <strong>Devices</strong> charm, select <strong>Project</strong> (or just hit the <em>Windows key</em> and <em>P</em>), and you should see this:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/2477.2014-05-02-project-wireless-display_1F24966B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/2477.2014_2D00_05_2D00_02_2D00_project_2D00_wireless_2D00_display_5F00_1F24966B.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="2014-05-02-project-wireless-display" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/1004.2014-05-02-project-wireless-display_thumb_7A26D5F1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/1004.2014_2D00_05_2D00_02_2D00_project_2D00_wireless_2D00_display_5F00_thumb_5F00_7A26D5F1.png" alt="2014-05-02-project-wireless-display" width="355" height="409" border="0" /></a></p>
<p>Click the <em>Add a wireless display link</em>, select your Miracast receiver, and connect. A password will be displayed on your TV's screen, and you'll enter that password on your PC. After this initial setup, it just works and the receiver will be displayed in the list of available devices, just as <em>ScreenBeam</em> is above. You won't have to enter the password again. Support is built into Windows 8.1, and you don't need to install anything extra.</p>
<p>If the link is missing, as in the following picture, then your system doesn&rsquo;t support Miracast:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/6406.2014-05-02-project-no-wireless-display_6E24E5BD.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/6406.2014_2D00_05_2D00_02_2D00_project_2D00_no_2D00_wireless_2D00_display_5F00_6E24E5BD.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="2014-05-02-project-no-wireless-display" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/2235.2014-05-02-project-no-wireless-display_thumb_5DAF0573.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/2235.2014_2D00_05_2D00_02_2D00_project_2D00_no_2D00_wireless_2D00_display_5F00_thumb_5F00_5DAF0573.png" alt="2014-05-02-project-no-wireless-display" width="318" height="517" border="0" /></a></p>
<p>&nbsp;</p>
<h3>Does your TV already support Miracast?</h3>
<p>Maybe.&nbsp; The technology behind Miracast is called different things by different manufacturers.&nbsp; I wish I could say something definitive here, but I&rsquo;m afraid this part of the Miracast story is still confusing.&nbsp; Of course if your TV supports Miracast directly, you don&rsquo;t need a separate receiver.</p>
<p>&nbsp;</p>
<h3>How does AirPlay compare?</h3>
<p>AirPlay is a similar technology from Apple, and it&rsquo;s only available on their devices.&nbsp; You connect an AppleTV to your TV with an HDMI cable, and then you connect the AppleTV to your home network using WiFi or Ethernet.&nbsp; This is different from Miracast, which creates a WiFi Direct network distinct from your home network.&nbsp; You can project an iPhone or iPad&rsquo;s screen to your TV using AirPlay, but as of right now you can&rsquo;t project a Mac&rsquo;s screen.&nbsp; From a Mac you can project from apps like iPhoto to display pictures on your TV, but you can&rsquo;t just display anything on your screen.&nbsp; To bring your AppleTV to another location, you&rsquo;ll need to reconfigure it to use the other location&rsquo;s WiFi password if you want to use it wirelessly.</p>
<p>&nbsp;</p>
<h3>How does Chromecast compare?</h3>
<p>The Chromecast device from Google is a little different from Miracast and AirPlay.&nbsp; The Chromecast connects directly into your TV&rsquo;s HDMI port, and then you use an app to connect the Chromecast to your home WiFi network.&nbsp; As of right now, your options for projecting from a computer are limited.&nbsp; The Chrome browser can project some content, but not all.&nbsp; A Chromecast is more commonly used from apps which have been built to support it, such as YouTube.&nbsp; You connect to a Chromecast from a mobile phone, and issue a command to do something like play a video.&nbsp; The Chromecast then streams the video directly from YouTube.&nbsp; You can turn your phone off at this point, and the video will continue to play.&nbsp; However, if you&rsquo;ll ever want to project from your computer instead, Miracast is more flexible.</p>
<p>&nbsp;</p>
<h3>What do I use it for?</h3>
<p>My top use of Miracast is for hackathons.&nbsp; I connect the ScreenBeam Pro to a projector, and then hackathon contestants can project straight from their compatible devices.&nbsp; This cuts down on the time required to set up computers between each presentation.&nbsp; Besides this, I also use it to rehearse talks and watch videos from <a href="http://pluralsight.com">Pluralsight</a>, <a href="http://www.buildwindows.com/">Build</a>, and <a href="https://channel9.msdn.com/">Channel 9</a>.</p>]]></content:encoded>
    </item>
    <item>
      <title>Try F# in your browser</title>
      <link>https://docs.microsoft.com/archive/blogs/matt-harrington/try-f-in-your-browser</link>
      <pubDate>Wed, 23 Apr 2014 10:31:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Harrington MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/matt-harrington/2014/04/23/try-f-in-your-browser/</guid>
      <description><![CDATA[Here's a Dev Radio episode I did on TryFsharp.org, a simple way to test out F# in your browser...]]></description>
      <content:encoded><![CDATA[<p>Here's a Dev Radio episode I did on <a href="http://www.tryfsharp.org/">TryFsharp.org</a>, a simple way to test out F# in your browser without having to download anything. F# is an easy language to learn, but also remarkably powerful. You end up writing less code than with other languages, and your code is easier to reason about. It's cross-platform and fully open source under the Apache 2.0 license. <a href="http://www.tryfsharp.org/">TryFsharp.org</a> contains tutorials you can go through at your own pace, perhaps over lunch. Using Silverlight, the site lets OSX and Windows developers run the compiler in their browser.</p>
<p><iframe style="height: 281px; width: 500px;" src="https://channel9.msdn.com/Blogs/DevRadio/Microsoft-DevRadio-Learn-Create-and-Share-with-Try-F/player?h=281&amp;w=500" frameborder="0" scrolling="no"></iframe></p>
<p>Here's a tour of the <a href="http://www.tryfsharp.org/">TryFsharp.org</a> website:</p>
<p><iframe src="https://www.youtube.com/embed/8A9duTwFSjI" frameborder="0" width="560" height="315"></iframe></p>]]></content:encoded>
    </item>
    <item>
      <title>Troubleshooting Azure Web Sites</title>
      <link>https://docs.microsoft.com/archive/blogs/matt-harrington/troubleshooting-azure-web-sites</link>
      <pubDate>Sun, 20 Apr 2014 20:35:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Harrington MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/matt-harrington/2014/04/20/troubleshooting-azure-web-sites/</guid>
      <description><![CDATA[If your app hosted on an Azure Web Site gives you an internal server error, here's what to...]]></description>
      <content:encoded><![CDATA[<p>If your app hosted on an Azure Web Site gives you an internal server error, here's what to do:</p>
<ol>
<li><a href="http://azure.microsoft.com/en-us/documentation/articles/web-sites-enable-diagnostic-log/">Enable Diagnostic Logging</a></li>
<li>Download the logs with a FTPS client such as FileZilla</li>
<li>Open the logs in a web browser or text editor</li>
<li>Fix the problem</li>
</ol>
<p>I made this screencast to walk you through the process:</p>
<p><iframe src="http://player.vimeo.com/video/92481070" frameborder="0" width="500" height="281"></iframe></p>
<p><a href="https://vimeo.com/92481070">Troubleshooting Azure Web Sites</a> from <a href="https://vimeo.com/user22726506">Matt Harrington</a> on <a href="https://vimeo.com">Vimeo</a>.</p>]]></content:encoded>
    </item>
    <item>
      <title>How to host your Django apps on Azure for free</title>
      <link>https://docs.microsoft.com/archive/blogs/matt-harrington/how-to-host-your-django-apps-on-azure-for-free</link>
      <pubDate>Fri, 18 Apr 2014 22:35:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Harrington MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/matt-harrington/2014/04/18/how-to-host-your-django-apps-on-azure-for-free/</guid>
      <description><![CDATA[Microsoft Azure is a feature-rich cloud computing platform. It&rsquo;s designed to handle the...]]></description>
      <content:encoded><![CDATA[<p>Microsoft Azure is a feature-rich cloud computing platform. It&rsquo;s designed to handle the largest projects you can imagine, with datacenters all over the world. You can develop on OSX, Linux, or Windows. You can run Linux and Windows virtual machines, distribute media files through a CDN, create a VPN between Azure and your own datacenter, move virtual machines between Azure and your own datacenter, host a turnkey backend for your mobile apps, use relational and NoSQL databases, and more. Open source SDKs are available for <a href="http://azure.microsoft.com/en-us/develop/python/">Python</a>, <a href="http://azure.microsoft.com/en-us/develop/nodejs/">Node.js</a>, <a href="http://azure.microsoft.com/en-us/develop/java/">Java</a>, <a href="http://azure.microsoft.com/en-us/develop/php/">PHP</a>, and <a href="http://azure.microsoft.com/en-us/develop/net/">.NET</a>.</p>
<p>This post describes how to host Django projects in <a href="http://azure.microsoft.com/en-us/documentation/services/web-sites/">Azure Web Sites</a>, a Platform as a Service (PaaS) offering. As with other PaaS offerings, you the developer concentrate on writing your app and not on infrastructure issues. You deploy to Azure Web Sites, and Azure handles things such as scaling out when your traffic increases, operating system patches, backups, and redundantly storing your data to protect against disasters. PaaS allows developers to focus on their app, and leaves routine maintenance issues to the platform. This post assumes you&rsquo;re on OSX or Linux, and also using <code>git</code>. If you&rsquo;re on Windows, use the free <a href="http://azure.microsoft.com/en-us/documentation/articles/cloud-services-web-sites-python-django-app-with-ptvs/">Python Tools for Visual Studio</a>.</p>
<p>Here's a screencast which quickly goes over the steps in this post and shows the end result:</p>
<p><iframe src="http://player.vimeo.com/video/92581084" frameborder="0" width="500" height="281"></iframe></p>
<p>&nbsp;</p>
<h4>1. Get a free Azure account</h4>
<p>Three options come to mind for getting an Azure account. The best option for many is to enroll in BizSpark. This program from Microsoft <a href="http://azure.microsoft.com/en-us/offers/ms-azr-0064p/">gives $150 per month in Azure credits</a> to startups to use as they like. In addition to this Azure benefit, BizSpark members also get <a href="http://www.visualstudio.com/en-us/products/msdn-subscriptions-vs">MSDN Ultimate subscriptions</a>. Eligible startups need to be in the software business, be privately held, be under 5 years old, and be making less than US$ 1M in revenue. You don&rsquo;t need to be a legal entity such as a partnership or corporation. Apply at <a href="http://www.bizspark.com">http://www.bizspark.com</a> and the BizSpark team will look at your application. This could take a few days.</p>
<p>If you don&rsquo;t qualify for BizSpark, you can apply for one year of $150 per month in Azure credits through a program designed for open source developers. Of course, both Python and Django are open source. This offer also gives you a MSDN Ultimate subscription. To apply for this program, email <a href="mailto:opensource@microsoft.com">opensource@microsoft.com</a> and tell us how you plan to use open source on Azure. The team is also on Twitter, <a href="https://twitter.com/OpenAtMicrosoft">@OpenAtMicrosoft</a>.</p>
<p>Lastly, you can just use a regular Azure account. All Azure accounts come with 10 free Web Sites and 10 free Mobile Services. Currently the Azure landing page emphasizes the free trial offer of $200 in usage or 30 days, whichever comes first. The free trial applies to everything in Azure: virtual machines, the CDN, directory services, and everything else. However, even after your free trial expires you still get 10 free Azure Web Sites and 10 free Mobile Services. This might not be obvious on the current landing page. You need a credit card to sign up for an Azure account, but the card will not be charged unless you explicitly remove the spending limit.</p>
<p>Pro-tip: You'll be asked for a phone number which will be used to verify your account. This seems to fail when Google Voice numbers are used. Try using a regular phone number instead.</p>
<p>&nbsp;</p>
<h4>2. Run your Django project locally with SQLite</h4>
<p>To proceed, you need to have a Django project running locally on your system. Have it working with a local SQLite database. You should be able to successfully run the app with <code>python manage.py runserver</code>. For this post, I&rsquo;ll be using code from the <a href="https://docs.djangoproject.com/en/dev/intro/tutorial01/">Django tutorial</a> which creates polls and keeps track of answers. Here&rsquo;s what my directory structure looks like:</p>
<pre>db.sqlite3
manage.py
polls/
tutorial/
</pre>
<p>&nbsp;</p>
<h4>3. Provision an empty Azure Web Site</h4>
<p>Log onto the portal. Click the <strong>New</strong> button in the lower left corner. Select <strong>Compute &ndash;&gt; Web Site &ndash;&gt; Quick Create</strong>. Choose a host name, and make sure you create your site in a region close to you. I use West US.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/4137.image_0AC33E24.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/4137.image_5F00_0AC33E24.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/6746.image_thumb_182BE1DB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/6746.image_5F00_thumb_5F00_182BE1DB.png" alt="image" width="782" height="587" border="0" /></a></p>
<p>&nbsp;</p>
<h4>4. Provision a ClearDB MySQL database</h4>
<p>You have many options for databases on Azure. This post will use MySQL. Microsoft partners with ClearDB to offer MySQL as a service on Azure. ClearDB handles tasks such as backups and scaling. You get a 20 MB database for free. Create a MySQL database by clicking on <strong>Linked Resources</strong>. Complete the wizard, making sure you create the database in the same region as your website from step 3, and then click on your database&rsquo;s name:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/8168.SNAGHTML24c3423_2A5C2E3F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/8168.SNAGHTML24c3423_5F00_2A5C2E3F.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;" title="SNAGHTML24c3423" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/57/metablogapi/7446.SNAGHTML24c3423_thumb_351C1645.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-57-metablogapi/7446.SNAGHTML24c3423_5F00_thumb_5F00_351C1645.png" alt="SNAGHTML24c3423" width="791" height="309" border="0" /></a></p>
<p>This brings you to a management site on <a href="http://www.cleardb.com">http://www.cleardb.com</a>. In the ClearDB portal, click on <strong>Endpoint Information</strong> and copy your <strong>Hostname</strong>, <strong>Username</strong>, and <strong>Password</strong>. Then click on <strong>Dashboard</strong>. Download these 3 SSL certificates: <strong>ClearDB CA Certificate</strong>, <strong>Client Certificate</strong>, and <strong>Client Private Key</strong>. You&rsquo;ll likely need to right-click on the <strong>Download</strong> link and choose <strong>Save target (or link) as</strong>.</p>
<p>The <strong>Client Private Key</strong> contains an embedded password. However, we need this certificate in a format with that stripped out. Use <code>openssl</code> to make the conversion, and note that your filenames will be different:</p>
<pre>openssl rsa &ndash;in client-key.pem &ndash;out client-key-nopass.pem</pre>
<p>Save the 3 SSL certificates in your app's folder</p>
<p>&nbsp;</p>
<h4>5. Edit <code>settings.py</code> to switch to MySQL</h4>
<p>To convert from SQLite to MySQL, edit your app&rsquo;s <code>settings.py</code> file:</p>
<div class="highlight highlight-python">
<pre><span class="n">DATABASES</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s">'default'</span><span class="p">:</span> <span class="p">{</span>
        <span class="s">'ENGINE'</span><span class="p">:</span> <span class="s">'django.db.backends.mysql'</span><span class="p">,</span>
        <span class="s">'NAME'</span><span class="p">:</span> <span class="s">'DATABASE_NAME_GOES_HERE'</span><span class="p">,</span>
        <span class="s">'USER'</span><span class="p">:</span> <span class="s">'USERNAME_GOES_HERE'</span><span class="p">,</span>
        <span class="s">'PASSWORD'</span><span class="p">:</span> <span class="s">'PASSWORD_GOES_HERE'</span><span class="p">,</span>
        <span class="s">'HOST'</span><span class="p">:</span> <span class="s">'HOSTNAME_GOES_HERE'</span><span class="p">,</span>
        <span class="s">'PORT'</span><span class="p">:</span> <span class="s">'3306'</span><span class="p">,</span>
        <span class="s">'OPTIONS'</span><span class="p">:</span> <span class="p">{</span><span class="s">'ssl'</span><span class="p">:</span> <span class="p">{</span><span class="s">'ca'</span><span class="p">:</span><span class="s">'tutorial/cleardb-ca.cer'</span><span class="p">,</span> 
            <span class="s">'cert'</span><span class="p">:</span><span class="s">'tutorial/client-cert.cer'</span><span class="p">,</span> 
            <span class="s">'key'</span><span class="p">:</span><span class="s">'tutorial/client-key-nopass.cer'</span><span class="p">},},</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre>
</div>
<p>I placed the 3 SSL certificates in the app&rsquo;s folder. Make sure you use the certificate key which you processed with <code>openssl</code> in step 4 to remove the embedded password.</p>
<p>You also need to install the MySQL adapter on your system. A portion of the adapter is written in Python, and a portion is compiled for the specific platform you&rsquo;re on. If you're on OSX, the easiest way forward is to use Homebrew to install MySQL with <code>brew install mysql</code>. You also need Xcode installed so you have a compiler and headers. If you're on Linux, just install MySQL and the development tools through your distribution's package repository. After you have MySQL and a development environment set up on either OSX or Linux, run <code>pip install MySQL-python</code>. Windows users should just install the adapter through <a href="http://www.microsoft.com/web/downloads/platform.aspx">WebPI</a>.</p>
<p>Since you&rsquo;ve switched from SQLite to MySQL, you need to run <code>python manage.py syncdb</code>. This creates your app&rsquo;s tables on MySQL in Azure. Then, run your app locally and save some data. It will be saved in Azure.</p>
<p>&nbsp;</p>
<h4>6. Set up MySQL Workbench</h4>
<p>This step is optional, but worth it. <a href="http://www.mysql.com/products/workbench/">MySQL Workbench</a> is a desktop client from Oracle which talks to any MySQL database, including your database in Azure. Download it from Oracle, and configure it with the hostname, database name, username, password, and SSL certificates you used in step 5. Connect to your database, and you should be able to see your app&rsquo;s tables and data you entered after running your project in step 5.</p>
<p>&nbsp;</p>
<h4>7. Install <code>django</code> and other modules into a local <code>site-packages</code> directory</h4>
<p>The Azure Web Sites platform already contains Python, but it does not contain Django or other modules since versions change so quickly. If you include Django and other modules you&rsquo;ll need in your project, they&rsquo;ll be available for you on Azure. Create a directory called <code>site-packages</code> in the same level as your app's folder, and install your modules there. For example:</p>
<pre>mkdir site-packages
pip install --target site-packages django
pip install --target site-packages pytz</pre>
<p>In a future release, you&rsquo;ll be able to simply include <code>requirements.txt</code>, and Azure will install the modules you need.</p>
<p>In step 5, you installed <code>MySQLdb</code> on your system. Remember that it contains both Python and platform-specific code. Since Azure Web Sites run on Windows, you&rsquo;ll need a Win32 version of <code>MySQLdb</code>. Installing this in the future will be smooth and will use <code>requirements.txt</code>, but here&rsquo;s how to do it right now. If you don&rsquo;t have a Windows PC handy, you can <a href="https://onedrive.live.com/redir?resid=ABF372EAB2716D39!7038&amp;authkey=!AKwhqW3BqOBXwiE&amp;ithint=file%2c.zip">download a Win32 version from my OneDrive</a>. After you manually copy those files into into <code>site-packages</code>, it should look like this:</p>
<pre>django/
Django-1.6.3.dist-info/
MySQLdb/
pytz/
pytz-2014.2-py2.7.egg-info/
_mysql.pyd
_mysql_exceptions.py
_mysql_exceptions.pyc
_mysql_exceptions.pyo</pre>
<p>Of course, yours will only contain <code>pytz</code> if your app requires it. Mine does. Here&rsquo;s a good time to mention that you need to move a module out of a Python egg and put it in <code>site-packages</code>. You can&rsquo;t just include the egg right now.</p>
<p>Be sure to add and commit <code>site-packages</code> to your <code>git</code> repo. When finished, my project looked like this:</p>
<pre>db.sqlite3
manage.py
polls/
site-packages/
tutorial/
</pre>
<p>&nbsp;</p>
<h4>8. Configure your Azure Web Site</h4>
<p>We&rsquo;re almost done. You need to create 3 key/value pairs in the Azure Web Site environment where your app will run, and you also need to configure the <code>wfastcgi</code> handler. In the Azure portal, click on the <strong>Configure</strong> tab and scroll down to <strong>App Settings</strong>. Add these 3 key/value pairs:</p>
<pre>DJANGO_SETTINGS_MODULE    tutorial.settings
PYTHONPATH                D:\home\site\wwwroot;D:\home\site\wwwroot\site-packages
WSGI_HANDLER              django.core.handlers.wsgi.WSGIHandler()</pre>
<p>My starting app is called <code>tutorial</code>, so <code>DJANGO_SETTINGS_MODULE</code> is set to <code>tutorial.settings</code>. Your app name will of course will be different.</p>
<p>Scroll down a little further to <code>Handler Mappings</code> and add this:</p>
<pre>EXTENSION                 *
SCRIPT PROCESSOR PATH     D:\python27\python.exe
ADDITIONAL ARGUMENTS      D:\python27\scripts\wfastcgi.py </pre>
<p>&nbsp;</p>
<h4>9. Deploy to Azure</h4>
<p>We&rsquo;ll use <code>git</code> to push your code to Azure. You can push directly from a local repo, GitHub, BitBucket, Dropbox, TFS, or another external repository. In the portal, go to your site's <strong>Dashboard</strong> and click <strong>Set up deployment from source control</strong>. In the wizard, select where your repo lives. It&rsquo;s pretty straightforward. A cool thing about using BitBucket or GitHub is that when you push to a branch there, Azure will pick up your code and deploy it. After you&rsquo;ve deployed to Azure, simply browse to your site. You&rsquo;re done!</p>
<p>&nbsp;</p>
<h4>Next steps</h4>
<p>If you upgrade your site from the free tier, you can do things such as autoscale to handle traffic bursts, use a custom domain name, and incorporate SSL. Of course your BizSpark credit can be used for this.</p>
<p>Take a look at <a href="http://azure.microsoft.com/en-us/documentation/articles/xplat-cli/">the cross-platform command line interface to Azure</a>. First install Node.js, then run <code>npm install -g azure-cli</code>. Then run <code>azure account download</code> to download your account's publishing settings. With the Azure CLI, you can create Web Sites, create deployment scripts, create Virtual Machines, start and stop services, and more. All of this can be scripted too.</p>
<p>If you need to see your log files, check out another post from me: <a href="http://blogs.msdn.com/b/matt-harrington/archive/2014/04/20/troubleshooting-azure-web-sites.aspx">Troubleshooting Azure Web Sites</a>.</p>
<p>&nbsp;</p>
<h4>Conclusion</h4>
<p>With a PaaS offering, you shouldn&rsquo;t have to care about the underlying platform. Azure Web Sites run on IIS on Windows, but OSX or Linux users can use it without problem. If you think of any features you&rsquo;d like added, or something you&rsquo;d like changed, definitely get in touch with me. We&rsquo;re always looking for ways to improve things and value customer feedback above everything else. Also, if you end up permanently hosting a Django project on Azure, please let me know. <a href="http://blogs.msdn.com/b/matt-harrington/contact.aspx">Email me</a>, or hit me up on Twitter <a href="https://twitter.com/mh415">@mh415</a>.</p>]]></content:encoded>
    </item>
  </channel>
</rss>