<?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>dasz.at - Benutzbare Technologie &#187; CodeProject</title>
	<atom:link href="http://dasz.at/index.php/category/tech/codeproject/feed/" rel="self" type="application/rss+xml" />
	<link>http://dasz.at</link>
	<description>Benutzbare Technologie</description>
	<lastBuildDate>Wed, 07 Jul 2010 06:54:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Gendarme Integration for VS2008</title>
		<link>http://dasz.at/index.php/2010/01/gendarme-integration-for-vs2008/</link>
		<comments>http://dasz.at/index.php/2010/01/gendarme-integration-for-vs2008/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 20:33:42 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/?p=207</guid>
		<description><![CDATA[Ever since setting up our CruiseControl.NET server for our internal projects, I wanted to integrate a Gendarme run to catch all those nasty little things that slip through, like not checking arguments for null.
Now that I finally found some tuits to do it, the next problem became obvious: doing a quick commit often lead to [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since setting up our <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET">CruiseControl.NET</a> server for our internal projects, I wanted to integrate a <a href="http://www.mono-project.com/Gendarme">Gendarme</a> run to catch all those nasty little things that slip through, like not checking arguments for null.</p>
<p>Now that I finally found some tuits to do it, the next problem became obvious: doing a quick commit often lead to a quick build fail. Gendarme would have no use if it didn&#8217;t find anything, no? So the missing piece was integration into Visual Studio. Arthur hacked together a little XSLT+PowerShell and voila, Gendarme now runs on every build right from the studio and populates the &#8220;Error List&#8221; window with properly linked entries. Yay!</p>
<p>Read on for the details of the implementation. The complete source is downloadable at the end of the article.</p>
<p><span id="more-207"></span></p>
<p>First, the XSLT (&#8220;gendarme.xslt&#8221;), transforming Gendarme&#8217;s XML to properly formatted text.</p>
<pre class="brush: xml; ">

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;xsl:stylesheet
  xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;
  version=&quot;2.0&quot;&gt;
  &lt;xsl:output method=&quot;text&quot;/&gt;

  &lt;xsl:template match=&quot;/&quot;&gt;
    &lt;xsl:call-template name=&quot;rules&quot;&gt;
      &lt;xsl:with-param name=&quot;detailnodes&quot; select=&quot;//results/rule&quot;/&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template name=&quot;rules&quot;&gt;
    &lt;xsl:param name=&quot;detailnodes&quot;/&gt;
    &lt;xsl:for-each select=&quot;$detailnodes&quot;&gt;
      &lt;xsl:call-template name=&quot;defects&quot;&gt;
        &lt;xsl:with-param name=&quot;detailnodes&quot; select=&quot;target/defect&quot;/&gt;
      &lt;/xsl:call-template&gt;
    &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template name=&quot;defects&quot;&gt;
    &lt;xsl:param name=&quot;detailnodes&quot;/&gt;
    &lt;xsl:for-each select=&quot;$detailnodes&quot;&gt;
      &lt;xsl:value-of select=&quot;@Source&quot;/&gt;: error :[gendarme] &lt;xsl:value-of select=&quot;../../problem&quot;/&gt; Target: &lt;xsl:value-of select=&quot;../@Name&quot;/&gt;.
    &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;
</pre>
<p>Second, the powershell fragment to execute gendarme and transform the output (&#8220;gendarme.ps1&#8243;).</p>
<pre class="brush: php; ">

param($SolutionDir)

function Convert-WithXslt($xmlFilePath, $xsltFilePath, $outputFilePath)
{
    $xsltFilePath = resolve-path $xsltFilePath
    $xmlFilePath = resolve-path $xmlFilePath
    $outputFilePath = resolve-path $outputFilePath

    $xslt = new-object system.xml.xsl.xslcompiledtransform
    $xslt.load( $xsltFilePath )
    $xslt.Transform( $xmlFilePath, $outputFilePath )
}

if(-not $SolutionDir)
{
	$SolutionDir = &quot;.&quot;;
}

&quot;.&quot; &gt; $SolutionDir\bin\gendarme.txt
gendarme.exe -config $SolutionDir\gendarmerules.xml --xml $SolutionDir\bin\gendarme.xml $SolutionDir\bin\Debug\blahblah.exe
convert-withxslt $SolutionDir\bin\gendarme.xml $SolutionDir\gendarme.xslt $SolutionDir\bin\gendarme.txt
(get-content $SolutionDir\bin\gendarme.txt) -replace &#039;\(\D?(\d+)\)&#039;, &#039; ($1,1)&#039; | set-content $SolutionDir\bin\gendarme.txt
exit 0
</pre>
<p>Instead of <code>blahblah.exe</code>, put your own assemblies you want to check.</p>
<p>And last but not least, the post build step to actually run the whole thing.</p>
<p><code>powershell -command $(SolutionDir)gendarme.ps1 -SolutionDir:$(SolutionDir)<br />
type $(SolutionDir)bin\gendarme.txt<br />
</code></p>
<p>This can be added in your project properties on the &#8220;Build Events&#8221; tab, as &#8220;Post-build event command line&#8221;. In our project this is executed in one of the unit-test projects which has dependencies on all other projects and thus builds last.</p>
<p>Don&#8217;t forget to enable the <code>RemoteSigned</code> execution policy of the powershell; either by running</p>
<p><code>set-executionpolicy -executionPolicy RemoteSigned<br />
</code></p>
<p>from a Administrator&#8217;s shell or by adding one or both of the powershell.executionpolicy.reg and powershell.executionpolicy.wow6432.reg files to your registry.</p>
<p>You can find all files in <a href='http://dasz.at/wp-content/uploads/2010/01/gendarme-integration.zip'>this ZIP archive</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2010/01/gendarme-integration-for-vs2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL doesn&#8217;t (completely) support IEEE754 floating points</title>
		<link>http://dasz.at/index.php/2009/12/sql-and-ieee754-support-for-nan-infinity/</link>
		<comments>http://dasz.at/index.php/2009/12/sql-and-ieee754-support-for-nan-infinity/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 11:00:44 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2009/12/sql-and-ieee754-support-for-nan-infinity/</guid>
		<description><![CDATA[After looking for quite a while (it is unbelievable, no?) I have to accept that Microsoft&#8217;s SQL Server 2000, 2005 and 2008 do not fully support IEEE-754 floating point numbers. Specifically NaN (Not-a-Number) and +/- Infinity are not allowed. While the 2000 Server seemingly allows such values to be inserted, but breaks badly afterwards, the [...]]]></description>
			<content:encoded><![CDATA[<p>After looking for quite a while (it is unbelievable, no?) I have to accept that Microsoft&#8217;s SQL Server 2000, 2005 and 2008 do not fully support IEEE-754 floating point numbers. Specifically NaN (Not-a-Number) and +/- Infinity are not allowed. While the 2000 Server seemingly allows such values to be inserted, but breaks badly afterwards, the newer versions disallow inserting such values. Here is the <a href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=239674">MS Connect article requesting the feature</a>. There is also the documentation about <a href="http://msdn.microsoft.com/en-us/library/ms187912.aspx">float data</a> and a read-between-the-lines hint in the documentation for <a href="http://msdn.microsoft.com/en-us/library/ms172002.aspx">XPath numbers</a>. The article describing floats is very circumspect about this:</p>
<blockquote><p>The behavior of float and real <strong>follows</strong> the IEEE 754 specification on approximate numeric data types.</p></blockquote>
<p> [emphasis mine]</p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/ms172002.aspx">XPath article</a> states it clearly:</p>
<blockquote><p>However, float(53) is not exactly IEEE 754. For example, neither NaN (Not-a-Number) nor infinity is used.</p></blockquote>
<p>.</p>
<p>For completeness, here&#8217;s a little review about other DMBS&#8217; support for NaNs and Infinity:</p>
<ul>
<li>MySQL does what it always does if it encounters &#8220;strange&#8221; values: according to <a href="http://dev.mysql.com/doc/refman/5.5/en/numeric-types.html">this comment by Carl Fischer</a> (bottom of the page), MySQL transforms the special values quietly to zero when writing them into the table.</li>
<li><a href="http://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#new_ieee_floating_point_types">Oracle (starting at version 10g) supports all IEEE754 single and double precision values</a> and provides constants for NaN and Infinity in its SQL implementation. This is implemented using the BINARY_FLOAT and BINARY_DOUBLE data types.</li>
<li><a href="http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html#DATATYPE-FLOAT">PostgreSQL</a> uses the underlying system&#8217;s float representation and allows input of NaN and infinite values.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2009/12/sql-and-ieee754-support-for-nan-infinity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android development FAIL</title>
		<link>http://dasz.at/index.php/2009/10/android-development-fail/</link>
		<comments>http://dasz.at/index.php/2009/10/android-development-fail/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 15:25:43 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2009/10/android-development-fail/</guid>
		<description><![CDATA[After installing the Android 1.5r3 SDK and Eclipse 3.4 with the matching ADT plugin, I soon encountered this error message:
[2009-10-16 15:02:09 - ddms]Failed to reopen debug port for Selected Client to: 8700
[2009-10-16 15:02:09 - ddms]Address family not supported by protocol family: bind
java.net.SocketException: Address family not supported by protocol family: bind
	at sun.nio.ch.Net.bind(Native Method)
	at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
	at sun.nio.ch.ServerSocketAdaptor.bind(Unknown [...]]]></description>
			<content:encoded><![CDATA[<p>After installing the <a href="http://developer.android.com/sdk/1.5_r3/index.html">Android 1.5r3 SDK</a> and <a href="http://www.eclipse.org/downloads/packages/release/ganymede/sr2">Eclipse 3.4</a> with the matching ADT plugin, I soon encountered this error message:</p>
<blockquote><pre>[2009-10-16 15:02:09 - ddms]Failed to reopen debug port for Selected Client to: 8700
[2009-10-16 15:02:09 - ddms]Address family not supported by protocol family: bind
java.net.SocketException: Address family not supported by protocol family: bind
	at sun.nio.ch.Net.bind(Native Method)
	at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
	at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
	at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
	at com.android.ddmlib.MonitorThread.reopenDebugSelectedPort(Unknown Source)
	at com.android.ddmlib.MonitorThread.run(Unknown Source)

[2009-10-16 16:29:40 - ddms]Can't bind to local 8600 for debugger
[2009-10-16 16:30:14 - ddms]Can't bind to local 8601 for debugger
[2009-10-16 16:30:14 - ddms]Can't bind to local 8602 for debugger
[2009-10-16 16:30:15 - ddms]Can't bind to local 8603 for debugger
[2009-10-16 16:30:25 - ddms]Can't bind to local 8602 for debugger
[2009-10-16 16:30:25 - ddms]Can't bind to local 8606 for debugger
[2009-10-16 16:30:25 - ddms]Can't bind to local 8607 for debugger
[2009-10-16 16:30:25 - ddms]Can't bind to local 8610 for debugger</pre>
</blockquote>
<p>As it turns out, the debugger tries to connect to &#8220;localhost&#8221; which is resolved by Windows Vista via the Windows\System32\drivers\etc\hosts file, which contains the IPV6 address &#8220;::1&#8243;. Since <a href="http://groups.google.com/group/android-platform/browse_thread/thread/7e0e37705c8c3d71">Android&#8217;s IPv6 support is still under development</a>, none of the development tools can cope with it, resulting in above error messages.</p>
<p>Substituting the IPv4 127.0.0.1 as localhost address made it work fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2009/10/android-development-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Floating point adventures</title>
		<link>http://dasz.at/index.php/2009/10/floating-point-adventures/</link>
		<comments>http://dasz.at/index.php/2009/10/floating-point-adventures/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 11:27:21 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2009/10/floating-point-adventures/</guid>
		<description><![CDATA[Using == to compare floats and doubles is not only problematic when dealing with numerical precision, but also when dealing with NaNs: In C#, the equals-operator returns false when comparing NaNs. If NaNs shall compare equal (e.g. when suppressing PropertyChanged events, as I&#8217;m doing), use Double.CompareTo(double). The IComparable&#60;&#62; interface requires that A.CompareTo(A) always returns zero [...]]]></description>
			<content:encoded><![CDATA[<p>Using <code>==</code> to compare <code>float</code>s and <code>double</code>s is not only problematic when dealing with numerical precision, but also when dealing with <a href="http://msdn.microsoft.com/en-us/library/system.double.nan.aspx">NaN</a>s: In C#, the equals-operator returns false when comparing NaNs. If NaNs shall compare equal (e.g. when suppressing <code>PropertyChanged</code> events, as I&#8217;m doing), use <a href="http://msdn.microsoft.com/en-us/library/9cczk1sc.aspx">Double.CompareTo(double)</a>. The <code>IComparable&lt;&gt;</code> interface requires that <code>A.CompareTo(A)</code> always returns <code>zero</code> and therefore does correctly (for this case) work with NaNs and +/- infinity.</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2009/10/floating-point-adventures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Minor note on &#8216;dd&#8217; write performance</title>
		<link>http://dasz.at/index.php/2009/09/minor-note-on-dd-write-performance/</link>
		<comments>http://dasz.at/index.php/2009/09/minor-note-on-dd-write-performance/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 22:12:31 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Benchmarking]]></category>
		<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2009/09/minor-note-on-dd-write-performance/</guid>
		<description><![CDATA[Today I was cleaning out some old logical volumes. Since they resided on rented harddisks, I chose to overwrite them with zeroes to avoid leaving data tracks on someone else&#8217;s disks. The first thing that came to my mind was this:

dd if=/dev/zero of=/dev/vg/lv


Since I had ten logical volumes, I also ran ten instances of dd [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was cleaning out some old logical volumes. Since they resided on rented harddisks, I chose to overwrite them with zeroes to avoid leaving data tracks on someone else&#8217;s disks. The first thing that came to my mind was this:</p>
<pre>
dd if=/dev/zero of=/dev/vg/lv
</pre>
<p><span id="more-93"></span></p>
<p>Since I had ten logical volumes, I also ran ten instances of <a href="http://linux.die.net/man/1/dd">dd</a> in parallel. They were on a RAID and I was decommissioning the server, so I didn&#8217;t really care about performance. Speaking of which, I like to spy on running processes, call my a techno-voyeur if you want!</p>
<p>Anyways, <a href="http://linux.die.net/man/8/vmstat">vmstat</a> was telling me that the system was chugging along nicely, reading(sic!) and writing approximately 16MB/s each. Something was clearly wrong. Note the &#8220;bi&#8221; and &#8220;bo&#8221; columns, denoting kB/s read and written:</p>
<pre>
david@hetz:~$ vmstat 10
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
[...]
 0 12   6416 270676 1601220   9628    0    0 16628 16553 4481 7638  1 21 26 52
</pre>
<p>I had forgotten to specify the <a href="http://en.wikipedia.org/wiki/Block_%28data_storage%29">block</a> size which dd should use to make the transfer. And if the program is writing the zeroes one by one into the target file, the destination has to be read before it is modified, since the <a href="http://en.wikipedia.org/wiki/Linux_kernel">kernel</a> cannot (and should not!) guess that the rest of the block (which is all we&#8217;re talking about at this stage) will be overwritten too.</p>
<p>To test my hypotheses, I restarted the processes and told dd to use nice 1MB sized blocks. I had ten threads to keep the hardware busy, so that shouldn&#8217;t make any problems.</p>
<pre>
dd if=/dev/zero of=/dev/vg/lv bs=1M
</pre>
<p>Really, in this configuration, the system stabilized around a nice 55MB/s writes. The kernel was able to recognize that the 1MB sized writes would cover complete blocks and that their content would be overwritten. No need to load them beforehand:</p>
<pre>
david@hetz:~$ vmstat 10
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
[...]
 0 12   6416  16308 1749688   5312    0    0     0 55644  551 1576  0 23  1 76
</pre>
<p>While I was waiting for the last process to finish, I noticed that throughput had risen to 60MB/s:</p>
<pre>
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
[...]
 1  3   6416  15336 1750492   6088    0    0      4 62892  545  232  0 28 32 39
</pre>
<p>To summarize: having only one process running is ~10% faster than having ten processes running and using a non-trivial blocksize is more than three times faster than specifying none at all.</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2009/09/minor-note-on-dd-write-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
