<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Degree Blogg</title>
	<atom:link href="http://blog.degree.no/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.degree.no</link>
	<description>Better to be a geek than an idiot!</description>
	<lastBuildDate>Wed, 15 May 2013 05:39:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Define a #Region in javascript files (Visual Studio 2010 / 2012)</title>
		<link>http://blog.degree.no/2013/05/define-a-region-in-javascript-files-visual-studio-2010-2012/</link>
		<comments>http://blog.degree.no/2013/05/define-a-region-in-javascript-files-visual-studio-2010-2012/#comments</comments>
		<pubDate>Wed, 15 May 2013 05:39:48 +0000</pubDate>
		<dc:creator>Andreas</dc:creator>
				<category><![CDATA[Degree Blogg]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Visual Studio 2012]]></category>

		<guid isPermaLink="false">http://blog.degree.no/?p=2844</guid>
		<description><![CDATA[In these times of super responsive client side processing mega javascript extravaganza web applications&#160; you’re more than likely to end up with fairly large .js files in your projects. The standard code file in Visual Studio allows you to define collapsible sections by wrapping them with the #region / #endregion blocks. In javascript files however, [...]]]></description>
				<content:encoded><![CDATA[<p>In these times of <em>super responsive client side processing mega javascript extravaganza web applications&#160; </em>you’re more than likely to end up with fairly large .js files in your projects. The standard code file in Visual Studio allows you to define collapsible sections by wrapping them with the #region / #endregion blocks. In javascript files however, you are restricted to collapsible functions only (“#region” is not recognized as anything valid):</p>
<p><a href="http://blog.degree.no/wp-content/uploads/image95.png" rel="lightbox[2844]" title="image"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://blog.degree.no/wp-content/uploads/image_thumb95.png" width="408" height="221" /></a></p>
<p>Well, I just found out that that’s not entirely true. By marking a section of code (regardless of any logical blocks) and hitting CTRL + M + H you’ll define the selection as a region which is collapsible and expandable</p>
<p><a href="http://blog.degree.no/wp-content/uploads/image96.png" rel="lightbox[2844]" title="image"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://blog.degree.no/wp-content/uploads/image_thumb96.png" width="410" height="177" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.degree.no/2013/05/define-a-region-in-javascript-files-visual-studio-2010-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick row count from Microsoft SQL Database</title>
		<link>http://blog.degree.no/2013/05/quick-row-count-from-microsoft-sql-database/</link>
		<comments>http://blog.degree.no/2013/05/quick-row-count-from-microsoft-sql-database/#comments</comments>
		<pubDate>Mon, 06 May 2013 07:51:36 +0000</pubDate>
		<dc:creator>Njål</dc:creator>
				<category><![CDATA[Degree Blogg]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[EntityFramework]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.degree.no/?p=2830</guid>
		<description><![CDATA[&#160; Recently, I’ve been involved in a cloud provider project where I had to do a row count on a Microsoft SQL Database table with more than 50.000.000 rows in it. Doing SELECT COUNT(*) FROM myTable took about 10 seconds – since it performs a full table scan. &#160; Here’s an alternative way (still accurate) [...]]]></description>
				<content:encoded><![CDATA[<p>&nbsp;</p>
<p>Recently, I’ve been involved in a cloud provider project where I had to do a row count on a Microsoft SQL Database table with more than 50.000.000 rows in it. </p>
<p>Doing </p>
<p>
<pre class="csharpcode"><span class="kwrd">SELECT</span> <span class="kwrd">COUNT</span>(*) <span class="kwrd">FROM</span> myTable</pre>
</p>
<p><style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
</p>
<p>took about 10 seconds – since it performs a full table scan.</p>
<p>&nbsp;</p>
<p>Here’s an alternative way (still accurate) of doing it that takes under 1 sec:</p>
<pre class="csharpcode"><span class="kwrd">SELECT</span> <span class="kwrd">SUM</span> (row_count)
<span class="kwrd">FROM</span> sys.dm_db_partition_stats
<span class="kwrd">WHERE</span> object_id=OBJECT_ID(<span class="str">'myTable'</span>)   
<span class="kwrd">AND</span> (index_id=0 <span class="kwrd">or</span> index_id=1);</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>&nbsp;</p>
<p>You can run this from Microsoft Entity Framework as well:</p>
<pre class="csharpcode"><span class="kwrd">long</span> total = dbContext.Database.SqlQuery&lt;<span class="kwrd">long</span>&gt;(<span class="str">"SELECT SUM (row_count) FROM sys.dm_db_partition_stats WHERE object_id=OBJECT_ID('myTable') AND (index_id=0 or index_id=1);"</span>).First();</pre>
<p><style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.degree.no/2013/05/quick-row-count-from-microsoft-sql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The directory specified for caching compressed content is invalid.  Static compression is being disabled.</title>
		<link>http://blog.degree.no/2013/04/the-directory-specified-for-caching-compressed-content-is-invalid-static-compression-is-being-disabled/</link>
		<comments>http://blog.degree.no/2013/04/the-directory-specified-for-caching-compressed-content-is-invalid-static-compression-is-being-disabled/#comments</comments>
		<pubDate>Sun, 28 Apr 2013 14:30:00 +0000</pubDate>
		<dc:creator>Njål</dc:creator>
				<category><![CDATA[Degree Blogg]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[EventViewer]]></category>
		<category><![CDATA[IISExpress]]></category>
		<category><![CDATA[web.config]]></category>
		<category><![CDATA[Windows8]]></category>
		<category><![CDATA[WTF]]></category>

		<guid isPermaLink="false">http://blog.degree.no/?p=2685</guid>
		<description><![CDATA[&#160; After adding this in my web.config (Azure Project)… &#60;staticContent&#62; &#60;mimeMap fileExtension=".svg" mimeType="image/svg+xml" /&#62; &#60;/staticContent&#62; …IIS refused to serve any static content – such as js and png files. Log entries in Event Viewer said: The directory specified for caching compressed content C:\Users\xxx\AppData\Local\dftmp\Resources\b503ce54-3fba-4772-beaa-415d94ffc214\temp\temp\RoleTemp\iisexpress\IIS Temporary Compressed Files\9ef2ab2d-28fc-4554-a09c-5ba867eb1d19 is invalid. Static compression is being disabled. The problem [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://blog.degree.no/wp-content/uploads/image94.png" rel="lightbox[2685]" title="image"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://blog.degree.no/wp-content/uploads/image_thumb94.png" width="618" height="389"></a></p>
<p>&nbsp;</p>
<p>After adding this in my web.config (Azure Project)…</p>
<p>
<pre class="csharpcode">&lt;staticContent&gt;
    &lt;mimeMap fileExtension=<span class="str">".svg"</span> mimeType=<span class="str">"image/svg+xml"</span> /&gt;
&lt;/staticContent&gt;</pre>
</p>
<p>…IIS refused to serve any static content – such as js and png files. Log entries in Event Viewer said:</p>
<table cellspacing="0" cellpadding="2" width="800" border="1">
<tbody>
<tr>
<td valign="top" width="800">
<p>The directory specified for caching compressed content <br />C:\Users\xxx\AppData\Local\dftmp\Resources\b503ce54-3fba-4772-beaa-415d94ffc214\temp\temp\RoleTemp\iisexpress\IIS Temporary Compressed Files\9ef2ab2d-28fc-4554-a09c-5ba867eb1d19 is invalid. <br />Static compression is being disabled.</p>
</td>
</tr>
</tbody>
</table>
<p>The problem was that .svg files were already added to the staticContent list in my applicationHost.config – but still – the error message shown in the Event Viewer is pretty useless. There is nothing wrong with the directory specified to store compressed content. </p>
<p>So if you suddenly get this error – undo any changes in Web.config (remove all config under staticContent) and restart IIS (Express).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.degree.no/2013/04/the-directory-specified-for-caching-compressed-content-is-invalid-static-compression-is-being-disabled/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Decimal validation with comma in MVC</title>
		<link>http://blog.degree.no/2013/04/decimal-validation-with-comma-in-mvc/</link>
		<comments>http://blog.degree.no/2013/04/decimal-validation-with-comma-in-mvc/#comments</comments>
		<pubDate>Thu, 11 Apr 2013 06:14:34 +0000</pubDate>
		<dc:creator>Stian</dc:creator>
				<category><![CDATA[Degree Blogg]]></category>
		<category><![CDATA[jquery.validate]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://blog.degree.no/2013/04/decimal-validation-with-comma-in-mvc/</guid>
		<description><![CDATA[In MVC 3, when using jQuery validation plugin with unobtrusive validation, you will see that comma in a textbox that is bound to a decimal value will not be allowed by client side validation. Instead of going in and changing the jquery.validate.js, you should override the default behavior by adding these lines to your own [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Decimal_mark" target="_blank"><img style="display: inline; float: right" title="20130228DecimalSeparator.svg" alt="20130228DecimalSeparator.svg" align="right" src="http://blog.degree.no/wp-content/uploads/20130228DecimalSeparator.svg_.png" width="240" height="122" /></a>In MVC 3, when using jQuery validation plugin with unobtrusive validation, you will see that comma in a textbox that is bound to a decimal value will not be allowed by client side validation.</p>
<p>Instead of going in and changing the jquery.validate.js, you should override the default behavior by adding these lines to your own javascript file (make sure it is loaded after the valiate javascript!)</p>
<pre class="csharpcode">$.validator.methods.range = <span class="kwrd">function</span>(value, element, param) {
    <span class="kwrd">var</span> globalizedValue = value.replace(<span class="str">&quot;,&quot;</span>, <span class="str">&quot;.&quot;</span>);
    <span class="kwrd">return</span> <span class="kwrd">this</span>.optional(element) || (globalizedValue &gt;= param[0] &amp;&amp; globalizedValue &lt;= param[1]);
};

$.validator.methods.number = <span class="kwrd">function</span>(value, element) {
    <span class="kwrd">return</span> <span class="kwrd">this</span>.optional(element) || /^-?(?:\d+|\d{1,3}(?:[\s\.,]\d{3})+)(?:[\.,]\d+)?$/.test(value);
};</pre>
<p><br/><br />
This will fix your problem for the number validation and the range validation!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.degree.no/2013/04/decimal-validation-with-comma-in-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VMWare Player (free) &#8211; how to run virtual machine in headless mode</title>
		<link>http://blog.degree.no/2013/03/vmware-player-free-how-to-run-virtual-machine-in-headless-mode/</link>
		<comments>http://blog.degree.no/2013/03/vmware-player-free-how-to-run-virtual-machine-in-headless-mode/#comments</comments>
		<pubDate>Wed, 13 Mar 2013 03:35:20 +0000</pubDate>
		<dc:creator>Andreas</dc:creator>
				<category><![CDATA[Degree Blogg]]></category>
		<category><![CDATA[VMWare]]></category>
		<category><![CDATA[VMWare Player]]></category>

		<guid isPermaLink="false">http://blog.degree.no/2013/03/vmware-player-free-how-to-run-virtual-machine-in-headless-mode/</guid>
		<description><![CDATA[Virtual machine performance can be improved by running your virtual machine in headless mode (e.g. as a background process, without the GUI). Instead of using the console view in the VMWare Player you’ll connect via standard RDP, and in some cases achieve significant performance improvements. There’s a small requirement to the VMWare Player preference file. [...]]]></description>
				<content:encoded><![CDATA[<p>Virtual machine performance can be improved by running your virtual machine in headless mode (e.g. as a background process, without the GUI). Instead of using the console view in the VMWare Player you’ll connect via standard RDP, and in some cases achieve significant performance improvements.</p>
<p>There’s a small requirement to the VMWare Player preference file. You’ll find it under the following directory (at least in Windows 8):</p>
<p>C:\Users\[Username]\AppData\Roaming\VMware\preferences.ini</p>
<p>Add the following line at the bottom:</p>
<p>pref.vmplayer.exit.vmAction = &quot;disconnect&quot;</p>
<p>This will ensure that you only <em>disconnect</em> from the virtual machine when closing VMWare Player, not send it into Suspended mode. </p>
<p>Fire the virtual machine up as normal (throught the player), and then kill the VMWare Player process through Task Manager (closing it by clicking the X icon will <strong>not work – this will also send the virtual machine into Suspended mode</strong>):</p>
<p><a href="http://blog.degree.no/wp-content/uploads/image91.png" rel="lightbox[2640]" title="image"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://blog.degree.no/wp-content/uploads/image_thumb91.png" width="405" height="173" /></a></p>
<p>&#160;</p>
<p>The virtual machine is still running in the background, and you’re now able to connect via RDP.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.degree.no/2013/03/vmware-player-free-how-to-run-virtual-machine-in-headless-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Office 2013 &#8211; Disable Animations and Effects</title>
		<link>http://blog.degree.no/2013/03/office-2013-disable-animations-effects/</link>
		<comments>http://blog.degree.no/2013/03/office-2013-disable-animations-effects/#comments</comments>
		<pubDate>Tue, 12 Mar 2013 10:18:57 +0000</pubDate>
		<dc:creator>Aage Andre</dc:creator>
				<category><![CDATA[Degree Blogg]]></category>

		<guid isPermaLink="false">http://blog.degree.no/?p=2633</guid>
		<description><![CDATA[While I like the new Office, I honestly loath the &#8220;design-guru&#8221; who decided to cross-fade, smooth transitions and in general make everything you do slow down, so you can look at the nice little flow of the programs. The most irritating, for me, the Word typing animations and Excel cell-change. Luckily you can turn them [...]]]></description>
				<content:encoded><![CDATA[<p>While I like the new Office, I honestly loath the &#8220;design-guru&#8221; who decided to cross-fade, smooth transitions and in general make everything you do slow down, so you can look at the nice little flow of the programs.</p>
<p>The most irritating, for me, the Word typing animations and Excel cell-change. Luckily you can turn them off.</p>
<p>Go into your registry:<strong> [HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Common\Graphics]</strong><br />
Create a new dword: <strong>&#8220;DisableAnimations&#8221;=dword:00000001</strong><br />
(I also had to create the Graphic-key)</p>
<p>Reboot and enjoy efficiency once again.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.degree.no/2013/03/office-2013-disable-animations-effects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Long wait-time when taking SQL Server database offline</title>
		<link>http://blog.degree.no/2013/03/long-wait-time-when-taking-sql-server-database-offline/</link>
		<comments>http://blog.degree.no/2013/03/long-wait-time-when-taking-sql-server-database-offline/#comments</comments>
		<pubDate>Thu, 07 Mar 2013 13:48:17 +0000</pubDate>
		<dc:creator>Stian</dc:creator>
				<category><![CDATA[Degree Blogg]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.degree.no/2013/03/long-wait-time-when-taking-sql-server-database-offline/</guid>
		<description><![CDATA[When trying to take a SQL Server database offline, you might find yourself waiting, waiting and waiting because some process is hugging the database. This is how you fix it. Run: ALTER DATABASE &#60;dbname&#62; SET OFFLINE WITH ROLLBACK IMMEDIATE In some cases you might get an error saying: ALTER DATABASE failed because a lock could [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://blog.degree.no/wp-content/uploads/dboffline1.png" rel="lightbox[2626]" title="dboffline"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="dboffline" border="0" alt="dboffline" align="right" src="http://blog.degree.no/wp-content/uploads/dboffline_thumb1.png" width="207" height="174" /></a>When trying to take a SQL Server database offline, you might find yourself waiting, waiting and waiting because some process is hugging the database. This is how you fix it. Run:</p>
<pre class="csharpcode">ALTER DATABASE <span class="kwrd">&lt;</span><span class="html">dbname</span><span class="kwrd">&gt;</span> SET OFFLINE WITH ROLLBACK IMMEDIATE</pre>
<p></p>
<p>In some cases you might get an error saying:</p>
<pre class="csharpcode">ALTER DATABASE failed because a lock could not be placed on database 'dbname' Try again later.</pre>
<p></p>
<p>After you get this error, run</p>
<pre class="csharpcode">EXEC sp_who2</pre>
<p></p>
<p>Look for the database in the result and find the SPID for that connection, then run</p>
<pre class="csharpcode">KILL <span class="kwrd">&lt;</span><span class="html">SPID</span><span class="kwrd">&gt;</span></pre>
<p></p>
<p>That should do the trick!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.degree.no/2013/03/long-wait-time-when-taking-sql-server-database-offline/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Optimizing RAM for Hyper-V</title>
		<link>http://blog.degree.no/2013/02/optimizing-ram-hyper-v/</link>
		<comments>http://blog.degree.no/2013/02/optimizing-ram-hyper-v/#comments</comments>
		<pubDate>Sat, 23 Feb 2013 16:07:39 +0000</pubDate>
		<dc:creator>Aage Andre</dc:creator>
				<category><![CDATA[Degree Blogg]]></category>

		<guid isPermaLink="false">http://blog.degree.no/?p=2612</guid>
		<description><![CDATA[&#160; I&#8217;ve been trying to figure out how to allocate RAM for our guest-servers, and how much is needed for the host. I thought this was a static number, and have been pretty much running it on instinct, usually leaving 2-3GB for my hosts. As it turns out, it’s a bit more complicated. Memory should [...]]]></description>
				<content:encoded><![CDATA[<p>&nbsp;</p>
<p>I&#8217;ve been trying to figure out how to allocate RAM for our guest-servers, and how much is needed for the host. I thought this was a static number, and have been pretty much running it on instinct, usually leaving 2-3GB for my hosts.<img class="alignright" src="http://1.bp.blogspot.com/-11CgQFL7N4c/T-tF387vBoI/AAAAAAAAACs/lL5U-T6Mffc/s1600/ComputerRAM-main_Full.jpg" alt="" width="216" height="144" /></p>
<p>As it turns out, it’s a bit more complicated. Memory should be spread out as such:</p>
<pre>300 MB for the Hypervisor
plus 32 MB for the first GB of RAM allocated to each virtual machine
plus another 8 MB for every additional GB of RAM allocated to each virtual machine
plus 512 MB for the host operating system running on the root partition</pre>
<p>&nbsp;</p>
<p>Digital Library World has a nice calculator for us here: <a style="font-family: Tahoma; font-size: 12px; line-height: 18px;" title="http://digitallibraryworld.com/?p=55" href="http://digitallibraryworld.com/?p=55">http://digitallibraryworld.com/?p=55</a></p>
<pre></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.degree.no/2013/02/optimizing-ram-hyper-v/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Email validation &#8211; finally a .NET regular expression that works!</title>
		<link>http://blog.degree.no/2013/01/email-validation-finally-a-net-regular-expression-that-works/</link>
		<comments>http://blog.degree.no/2013/01/email-validation-finally-a-net-regular-expression-that-works/#comments</comments>
		<pubDate>Tue, 22 Jan 2013 22:55:32 +0000</pubDate>
		<dc:creator>Andreas</dc:creator>
				<category><![CDATA[Degree Blogg]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[email validation]]></category>
		<category><![CDATA[regular expression]]></category>

		<guid isPermaLink="false">http://blog.degree.no/2013/01/email-validation-finally-a-net-regular-expression-that-works/</guid>
		<description><![CDATA[Note: this is only relevant for .NET 3.5 and earlier. In .NET 4 the System.Net.Mail.MailAddress class includes validation and will throw an exception if instantiated with an invalid address. See comments below.&#160; Validating an email address sounds simple, and it really is! Until your fancy validator is released into the real world and people’s actual [...]]]></description>
				<content:encoded><![CDATA[<p align="justify"><strong><a href="http://blog.degree.no/wp-content/uploads/image90.png" rel="lightbox[2591]" title="image"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: right; padding-top: 0px; padding-left: 0px; margin: 0px 0px 4px 16px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" align="right" src="http://blog.degree.no/wp-content/uploads/image_thumb90.png" width="198" height="244" /></a>Note: this is only relevant for .NET 3.5 and earlier. In .NET 4 the System.Net.Mail.MailAddress class includes validation and will throw an exception if instantiated with an invalid address. See comments below.</strong>&#160;</p>
<p align="justify">Validating an email address sounds simple, and it really is! Until your fancy validator is released into the real world and people’s actual email addresses start pouring in, instead of the three email addresses you’ve been testing while developing: your work address, your Gmail address and an old Yahoo address you created in 2001. </p>
<p align="justify"><a href="mailto:chris-@somedomain.com">chris-@somedomain.com</a>     <br /><a href="mailto:!habla-hobla%wow@somedomain.com">!habla-hobla%wow@somedomain.com</a>     <br /><a href="mailto:!def!xyz%abc@example.com">!def!xyz%abc@example.com</a>     <br /><a href="mailto:joe_blow_@somedomain.com">joe_blow_@somedomain.com</a>     <br /><a href="mailto:love/hate=relationship@example.com">love/hate=relationship@example.com</a>     <br /><a href="mailto:$ilovemoney1234@example.com">$ilovemoney1234@example.com</a></p>
<p align="justify">They are, believe it or not, all valid according to the RFC spec. That doesn’t mean that you’ll be allowed to actually register them everywhere. Some (most?) email providers have their own rules that are much stricter than the specifications, simply because it makes no sense to allow all sorts of rubbish. </p>
<p align="justify">But if you’re writing a system allowing people to register using their email address, and you confirm their ownership of the given address by sending a confirmation email you really can’t be any stricter than the RFC and this is where the problem lies. I was also under the impression that “blah, how often would THAT become an issue?!”, but recently I got feedback from three different users within just a few weeks that they were unable to register. So I thought I’d better find a regular expression that actually works. </p>
<p align="justify">I’ve tried them all.. examples from Microsoft, Stack Overflow, random forums, cooked up my own and also converted a couple from other languages. It wasn’t until yesterday I stumbled across an old blog post by <a href="http://haacked.com/articles/AboutHaacked.aspx" target="_blank">Phil Haack</a> called <a href="http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx" target="_blank">I Knew How To Validate An Email Address Until I Read The RFC</a>. He did all the hard work (i.e. reading the #¤%&amp;”¤ RFC specs), and came up with an expression that so far seems to be working. So I thought I’d better save it here, because I know I will need this one again:</p>
<pre class="csharpcode"><span class="kwrd">string</span> pattern = <span class="str">@&quot;^(?!\.)(&quot;</span><span class="str">&quot;([^&quot;</span><span class="str">&quot;\r\\]|\\[&quot;</span><span class="str">&quot;\r\\])*&quot;</span><span class="str">&quot;|&quot;</span>
                + <span class="str">@&quot;([-a-z0-9!#$%&amp;'*+/=?^_`{|}~]|(?&lt;!\.)\.)*)(?&lt;!\.)&quot;</span>
                + <span class="str">@&quot;@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$&quot;</span>;
            
Regex regex = <span class="kwrd">new</span> Regex(pattern, RegexOptions.IgnoreCase);
<span class="kwrd">return</span> regex.IsMatch(emailAddress);</pre>
<p>&#160;</p>
<p>So thanks to Phil for his efforts! Let us know if anyone finds a flaw in this one as well…</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.degree.no/2013/01/email-validation-finally-a-net-regular-expression-that-works/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Why Programmers Work At Night</title>
		<link>http://blog.degree.no/2013/01/why-programmers-work-at-night/</link>
		<comments>http://blog.degree.no/2013/01/why-programmers-work-at-night/#comments</comments>
		<pubDate>Sat, 19 Jan 2013 03:29:07 +0000</pubDate>
		<dc:creator>Andreas</dc:creator>
				<category><![CDATA[Degree Blogg]]></category>

		<guid isPermaLink="false">http://blog.degree.no/2013/01/why-programmers-work-at-night/</guid>
		<description><![CDATA[My brother-in-law sent me a link to an article by Swizec Teller the other day. This article was so spot on I thought I’d share it here to allow even more programmers to get a bit of insight into their own brain and some understanding of their habits. So here goes (note that not a [...]]]></description>
				<content:encoded><![CDATA[<p>My brother-in-law sent me a link to an article by <a href="http://www.businessinsider.com/author/swizec-teller" target="_blank">Swizec Teller</a> the other day. This article was so spot on I thought I’d share it here to allow even more programmers to get a bit of insight into their own brain and some understanding of their habits.</p>
<p>So here goes (note that not a single word of the following text is mine):</p>
<p><strong><font size="4">Why Programmers Work At Night</font></strong></p>
<p>A popular saying goes that <a href="http://en.wikipedia.org/wiki/Programmer">programmers</a> are machines that turn caffeine into <a href="http://en.wikipedia.org/wiki/Source_code">code</a>.</p>
<p>And sure enough, ask a random programmer when they do their best work and there’s a high chance they will admit to a lot of late nights. Some earlier, some later. A popular trend is to get up at 4am and get some work done before the day’s craziness begins. Others like <em>going</em> to bed at 4am.</p>
<p>At the gist of all this is avoiding distractions. But you could just lock the door, what’s so special about the night?</p>
<p>I think it boils down to three things: the maker’s schedule, the sleepy brain and bright computer screens.</p>
<p><strong>The maker’s schedule</strong></p>
<p><a href="http://paulgraham.com/">Paul Graham</a> wrote about <a href="http://www.paulgraham.com/makersschedule.html">the maker’s schedule</a> in 2009 – basically that there are two types of schedules in this world (primarily?). The traditional manager’s schedule where your day is cut up into hours and a ten minute distraction costs you, at most, an hour’s worth of time.</p>
<p>On the other hand you have something PG calls the maker’s schedule – a schedule for those of us who produce stuff. Working on large abstract systems involves fitting the whole thing into your mind – somebody once likened this to constructing a house out of expensive <a href="http://en.wikipedia.org/wiki/Lead_glass">crystal glass</a>and as soon as someone distracts you, it all comes barreling down and shatters into a thousand pieces.</p>
<p>This is why programmers are so annoyed when you distract them.</p>
<p>Because of this huge mental investment, we simply can’t start working until we can expect a couple of hours without being distracted. It’s just not worth constructing the whole model in your head and then having it torn down half an hour later.</p>
<p>In fact, talking to a lot of founders you’ll find out they feel like they simply can’t get any work done during the day. The constant barrage of interruptions, important stuff to tend to and emails to answer simply don’t allow it. So they get most of their “work work” done during the night when everyone else is sleeping.</p>
<p><strong>The sleepy brain</strong></p>
<p><a href="http://static2.businessinsider.com/image/50f6d78fecad042b4800001e-960/ballmer_peak1.png" rel="lightbox[2587]" title="Why Programmers Work At Night"><img style="float: right; display: inline" border="0" alt="iamge" align="right" src="http://static2.businessinsider.com/image/50f6d78fecad042b4800001e-652-592/ballmer_peak1.png" width="400" /></a></p>
<p>But even programmers should be sleeping at night. We are not some race of super humans. Even programmers feel more alert during the day.</p>
<p>Why then do we perform our most mentally complex work work when the brain wants to sleep and we do simpler tasks when our brain is at its sharpest and brightest?</p>
<p>Because being tired makes us better coders.</p>
<p>Similar to the ballmer peak, being tired can make us focus better simply because when your brain is tired it <em>has</em> to focus! There isn’t enough left-over brainpower to afford losing concentration.</p>
<p>I seem to get the least work done right after drinking too much tea or having a poorly timed <a href="http://en.wikipedia.org/wiki/Energy_drink">energy drink</a>. Makes me hyperactive and one second I’m checking twitter, the next I’m looking at hacker news and I just seem to be buzzing all over the place..</p>
<p>You’d think I’d work better – so much energy, so much infinite overclocked brainpower. But instead I keep tripping over myself because I can’t focus for more than two seconds at a time.</p>
<p>Conversely, when I’m slightly tired, I just plomp my arse down and <em>code</em>. With a slightly tired brain I can code for hours and hours without even thinking about checking twitter or facebook. It’s like the internet stops existing.</p>
<p>I feel like this holds true for most programmers out there. We have too much brainpower for approximately 80 percent of the tasks we work on – face it, writing that one juicy algorithm, requires ten times as much code to produce an environment in which it can run. Even if you’re doing the most advanced machine learning (or something) imaginable, a lot of the work is simply cleaning up the data and presenting results in a lovely manner.</p>
<p>And when your brain isn’t working at full capacity it looks for something to do. Being tired makes you dumb enough that the task at hand is enough.</p>
<p><strong>Bright computer screens</strong></p>
<p>This one is pretty simple. Keep staring at a bright source of light in the evening and your <a href="http://en.wikipedia.org/wiki/Circadian_rhythm">sleep cycle</a> gets delayed. You forget to be tired until 3am. Then you wake up at 11am and when the evening rolls around you simply aren’t tired because hey, you’ve only been up since 11am!</p>
<p>Given enough iterations this can essentially drag you into a different timezone. What’s more interesting is that it doesn’t seem to keep rolling, once you get into that equilibrium of going to bed between 3am and 4am you tend to stay there.</p>
<p>Or maybe that’s just the <a href="http://en.wikipedia.org/wiki/Alarm_clock">alarm clocks</a> doing their thing because society tells us we’re dirty dirty slobs if we have breakfast at 2pm.</p>
<p><strong>Fin</strong></p>
<p>To conclude, programmers work at night because it doesn’t impose a time limit on when you have to stop working, which gives you a more relaxed approach, your brain doesn’t keep looking for distractions and a bright screen keeps you awake.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.degree.no/2013/01/why-programmers-work-at-night/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
