<?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>Daniele Demichelis &#187; Development</title>
	<atom:link href="http://www.danidemi.com/mainwww/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danidemi.com/mainwww</link>
	<description>There are 10 types of people in the world: Those who understand binary, and those who don&#039;t...</description>
	<lastBuildDate>Wed, 14 Apr 2010 08:14:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Assert statement in Objective C</title>
		<link>http://www.danidemi.com/mainwww/2010/03/assert-statement-in-objective-c/</link>
		<comments>http://www.danidemi.com/mainwww/2010/03/assert-statement-in-objective-c/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 15:40:40 +0000</pubDate>
		<dc:creator>danidemi</dc:creator>
				<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://www.danidemi.com/mainwww/?p=147</guid>
		<description><![CDATA[<p>Hi,
if you like to use assertions in your source code, but you miss this feature in ObjectiveC, give a look to this small class.
Assert.h</p>



#import &#60;Foundation/Foundation.h&#62;


@interface Assert : NSObject &#123;


&#125;


+&#40;void&#41;that:&#40;BOOL&#41;expr;


@end



<p>Assert.m</p>



#import &#34;Assert.h&#34;


@implementation Assert


+&#40;void&#41;that:&#40;BOOL&#41;expr&#123;


&#160;if &#40;!expr&#41; &#123;


&#160; &#91;NSException raise:@&#34;Failed assertion.&#34; format:@&#34;Failed assertion&#34;, nil&#93;;


&#160;&#125;


&#125;


@end



<p>As you can see, there&#8217;s only one static method that you can use wherever you want.
In this [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
if you like to use assertions in your source code, but you miss this feature in ObjectiveC, give a look to this small class.<br />
<b>Assert.h</b></p>
<div class="geshi no objc">
<ol>
<li class="li1">
<div class="de1"><span class="co2">#import &lt;Foundation/Foundation.h&gt;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">@interface</span> <span class="kw3">Assert</span> <span class="sy0">:</span> <span class="kw5">NSObject</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">+</span><span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>that<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>expr;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">@end</span></div>
</li>
</ol>
</div>
<p><b>Assert.m</b></p>
<div class="geshi no objc">
<ol>
<li class="li1">
<div class="de1"><span class="co2">#import &quot;Assert.h&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">@implementation</span> <span class="kw3">Assert</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">+</span><span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>that<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>expr<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span>expr<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#91;</span><span class="kw5">NSException</span> <span class="kw4">raise</span><span class="sy0">:</span>@<span class="st0">&quot;Failed assertion.&quot;</span> format<span class="sy0">:</span>@<span class="st0">&quot;Failed assertion&quot;</span>, <span class="kw2">nil</span><span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">@end</span></div>
</li>
</ol>
</div>
<p>As you can see, there&#8217;s only one static method that you can use wherever you want.<br />
In this snippet here&#8217;s an example how to use it.</p>
<div class="geshi no objc">
<ol>
<li class="li1">
<div class="de1"><span class="co2">#import &quot;Assert.h&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">-</span><span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>doSomething<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#91;</span><span class="kw3">Assert</span> that<span class="sy0">:</span><span class="br0">&#40;</span>&lt;your_assertion&gt;<span class="br0">&#41;</span><span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.danidemi.com/mainwww/2010/03/assert-statement-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby on CentOS</title>
		<link>http://www.danidemi.com/mainwww/2010/03/ruby-on-centos/</link>
		<comments>http://www.danidemi.com/mainwww/2010/03/ruby-on-centos/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 14:07:36 +0000</pubDate>
		<dc:creator>danidemi</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[operation]]></category>

		<guid isPermaLink="false">http://www.danidemi.com/mainwww/?p=121</guid>
		<description><![CDATA[Install a recent Ruby version in CentOS via Yum is almost impossible, since the packages are a little outdated. Maybe it is worth to give Enterprise Ruby a [...]]]></description>
			<content:encoded><![CDATA[<p>In these days I&#8217;m trying to install Ruby on Rails on our CentOS production server. What I really don&#8217;t like very much about CentOS are its pretty outdated packages installable via yum. This time proved to be the same&#8230; it&#8217;s seems that the Ruby available on CentOS via yum is a version released during 2006.<br />
In the first place I tried to compile Ruby from sources, but this proved a little too much messy for me. In the end I stumbled upon Ruby Enterprise Edition and I gave it a try.<br />
What I liked most about it was that it worked perfectly just out of the box and that all Ruby files go inside a single directory, so it&#8217;s pretty easy to move from a version to another even if not using yum.<br />
This is a brief tutorial about how to install Ruby Enterprise Edition on CentOS.</p>
<h1>Get rid of any Ruby previously installed</h1>
<p>First of all let&#8217;s remove any Ruby installation already present on our CentOS.<br />
We can ask Yum to give us a list of Ruby related packages currently installed.</p>
<div class="geshi no sh">
<ol>
<li class="li1">
<div class="de1">yum list | grep installed | grep ruby</div>
</li>
</ol>
</div>
<p>My server answered that way, but obviously yours can show other answers.</p>
<div class="geshi no shell">
<ol>
<li class="li1">
<div class="de1">ruby.i386 1.8.5-5.el5_3.7 installed
</div>
</li>
<li class="li1">
<div class="de1">ruby-devel.i386 1.8.5-5.el5_3.7 installed
</div>
</li>
<li class="li1">
<div class="de1">ruby-libs.i386 1.8.5-5.el5_3.7 installed
</div>
</li>
<li class="li1">
<div class="de1">ruby-mode.i386 1.8.5-5.el5_3.7 installed</div>
</li>
</ol>
</div>
<p>Time to gently ask to Yum to remove all those Ruby packages.</p>
<div class="geshi no shell">
<ol>
<li class="li1">
<div class="de1">yum erase ruby
</div>
</li>
<li class="li1">
<div class="de1">yum erase ruby-devel
</div>
</li>
<li class="li1">
<div class="de1">yum erase ruby-libs
</div>
</li>
<li class="li1">
<div class="de1">yum erase ruby-mode</div>
</li>
</ol>
</div>
<p>We can now start with the Enterprise Ruby installation.</p>
<h1>Download and install Enterprise Ruby</h1>
<p>There is really nothing deeply interesting here. Just download the sources, unpack them, compile them and set some useful links.</p>
<div class="geshi no shell">
<ol>
<li class="li1">
<div class="de1">mkdir -p ~/Temp/Sources
</div>
</li>
<li class="li1">
<div class="de1">cd ~/Temp/Sources
</div>
</li>
<li class="li1">
<div class="de1">wget http://rubyforge.org/frs/download.php/68719/ruby-enterprise-1.8.7-2010.01.tar.gz
</div>
</li>
<li class="li1">
<div class="de1">tar xzvf ruby-enterprise-1.8.7-2010.01.tar.gz
</div>
</li>
<li class="li1">
<div class="de1">./ruby-enterprise-1.8.7-2010.01/installer</div>
</li>
</ol>
</div>
<p>At the end we should have a working Ruby installation.<br />
Let&#8217;s create some useful link.</p>
<div class="geshi no shell">
<ol>
<li class="li1">
<div class="de1">ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/rake /usr/bin/rake
</div>
</li>
<li class="li1">
<div class="de1">ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/gem /usr/bin/gem
</div>
</li>
<li class="li1">
<div class="de1">ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/rails /usr/bin/rails
</div>
</li>
<li class="li1">
<div class="de1">ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/ruby /usr/bin/ruby
</div>
</li>
<li class="li1">
<div class="de1">ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/irb /usr/bin/irb</div>
</li>
</ol>
</div>
<h1>Worth reading</h1>
<p><a href="http://cristian.livadaru.net/2009/01/12/howto-installing-ruby-enterprise-edition-and-passenger-on-debian-etch/">Cristian Livadaru&#8217;s blog post about the topic.</a><br />
<a href="http://articles.slicehost.com/2009/4/7/centos-ruby-on-rails">Install the available Ruby via Yum</a><br />
<a href="http://www.rubyenterpriseedition.com/download.html">Enterprise Ruby download page</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danidemi.com/mainwww/2010/03/ruby-on-centos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Database testing with Mono and NUnit</title>
		<link>http://www.danidemi.com/mainwww/2010/03/database-testing-with-mono-and-nunit/</link>
		<comments>http://www.danidemi.com/mainwww/2010/03/database-testing-with-mono-and-nunit/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 16:03:37 +0000</pubDate>
		<dc:creator>danidemi</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[integration testing]]></category>

		<guid isPermaLink="false">http://www.danidemi.com/mainwww/?p=107</guid>
		<description><![CDATA[A class to set the database in a well know status before running an integration [...]]]></description>
			<content:encoded><![CDATA[<p>In these days I&#8217;m trying to rewrite an old application using Mono.<br />
I&#8217;m currently a newbie about Mono and the .Net world, but I happily noticed that the Mono environment come with a bundled interface to NUnit, so I can keep on writing tests as I&#8217;m slowly but steadily getting used to.<br />
After having put together a bunch of classes and relative and unit tests, it was time to write the first integration test. I needed to put the development database in a known state before running the test, so I came up with the following class, that I&#8217;d like to share with you.</p>
<div class="geshi no csharp">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">using</span> <span class="kw5">System</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> <span class="kw5">System</span>.<span class="me1">Collections</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> NUnit.<span class="me1">Framework</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> <span class="kw5">System</span>.<span class="me1">IO</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> <span class="kw5">System</span>.<span class="me1">Data</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> <span class="kw5">System</span>.<span class="me1">Data</span>.<span class="me1">SqlClient</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">namespace</span> TellItMailer<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">public</span> <span class="kw4">class</span> TestDbSetup<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">public</span> <span class="kw1">void</span> SetUpDbForTest<span class="br0">&#40;</span><span class="kw4">object</span> test<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw4">String</span> path <span class="sy0">=</span> test.<span class="me1">GetType</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">FullName</span> <span class="sy0">+</span> <span class="st0">&quot;.sql&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;path <span class="sy0">=</span> path.<span class="me1">Replace</span><span class="br0">&#40;</span><span class="kw1">this</span>.<span class="me1">GetType</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="kw1">Namespace</span> <span class="sy0">+</span> <span class="st0">&quot;.&quot;</span>, <span class="st0">&quot;&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;path <span class="sy0">=</span> <span class="st0">&quot;/home/danidemi/workspace/TellItMailer/Tests/&quot;</span> <span class="sy0">+</span> path;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="co1">//Read the script</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw4">String</span> script <span class="sy0">=</span> <span class="st0">&quot;&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">using</span> <span class="br0">&#40;</span>StreamReader sr <span class="sy0">=</span> File.<span class="me1">OpenText</span><span class="br0">&#40;</span>path<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw4">string</span> s <span class="sy0">=</span> <span class="st0">&quot;&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">while</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>s <span class="sy0">=</span> sr.<span class="me1">ReadLine</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">!=</span> <span class="kw1">null</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;script <span class="sy0">=</span> script <span class="sy0">+</span> s;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw4">string</span> connectionString <span class="sy0">=</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="st0">&quot;Server=192.168.75.128<span class="es0">\\</span>SQLEXPRESS;&quot;</span> <span class="sy0">+</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="st0">&quot;Database=TellIt_test;&quot;</span> <span class="sy0">+</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&quot;User ID=user;&quot;</span> <span class="sy0">+</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&quot;Password=password;&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IDbConnection dbcon;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">using</span><span class="br0">&#40;</span>dbcon <span class="sy0">=</span> <span class="kw3">new</span> SqlConnection<span class="br0">&#40;</span>connectionString<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; dbcon.<span class="me1">Open</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">using</span> <span class="br0">&#40;</span>IDbCommand dbcmd <span class="sy0">=</span> dbcon.<span class="me1">CreateCommand</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dbcmd.<span class="me1">CommandText</span> <span class="sy0">=</span> script;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;dbcmd.<span class="me1">ExecuteNonQuery</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>It&#8217;s quite useful. Essentially this class loads a SQL script file whose name is the same of the test class, and execute it.<br />
In this way you have for example a TestFeature.cs file alongside a TestFeature.sql file. Nice if your IDE shows files sorted alphabetically.<br />
I found that the best place to use the class is inside the SetUp marked method. In this way the SQL script is run before each test. Doing it in a local development environment is not so bad, since the scripts are executed at high speed.</p>
<p>So, this is an example of how a test that uses TestDbSetup looks like.</p>
<div class="geshi no csharp">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">using</span> <span class="kw5">System</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> NUnit.<span class="me1">Framework</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> log4net;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> log4net.<span class="me1">Config</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">namespace</span> TellItMailer <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#91;</span>TestFixture<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">public</span> <span class="kw4">class</span> IntegrationTest <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#91;</span>SetUp<span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">public</span> <span class="kw1">void</span> SetUp<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw3">new</span> TestDbSetup<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">SetUpDbForTest</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#91;</span>Test<span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">public</span> <span class="kw1">void</span> TestCase<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;BasicConfigurator.<span class="me1">Configure</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Pretty useful, IMHO.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danidemi.com/mainwww/2010/03/database-testing-with-mono-and-nunit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Obtain the root logger programmatically in log4net</title>
		<link>http://www.danidemi.com/mainwww/2010/03/obtain-the-root-logger-programmatically-in-log4net/</link>
		<comments>http://www.danidemi.com/mainwww/2010/03/obtain-the-root-logger-programmatically-in-log4net/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 11:15:35 +0000</pubDate>
		<dc:creator>danidemi</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.danidemi.com/mainwww/?p=113</guid>
		<description><![CDATA[<p>If you use log4net, you could have the need to configure the loggers programamtically. The problem arise when you want access to the root logger, since the documentation does not explain well how to obtain it.
So, here&#8217;s a snippet that show how to do it. Don&#8217;t forget to imort the log4net namespaces.</p>



using log4net;


using log4net.Core;


using log4net.Appender;


using [...]]]></description>
			<content:encoded><![CDATA[<p>If you use log4net, you could have the need to configure the loggers programamtically. The problem arise when you want access to the root logger, since the documentation does not explain well how to obtain it.<br />
So, here&#8217;s a snippet that show how to do it. Don&#8217;t forget to imort the log4net namespaces.</p>
<div class="geshi no csharp">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">using</span> log4net;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> log4net.<span class="me1">Core</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> log4net.<span class="me1">Appender</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> log4net.<span class="me1">Layout</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> log4net.<span class="me1">Repository</span>.<span class="me1">Hierarchy</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">using</span> log4net.<span class="me1">Config</span>;</div>
</li>
</ol>
</div>
<div class="geshi no csharp">
<ol>
<li class="li1">
<div class="de1">Hierarchy h <span class="sy0">=</span> <span class="br0">&#40;</span>Hierarchy<span class="br0">&#41;</span>log4net.<span class="me1">LogManager</span>.<span class="me1">GetRepository</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">Logger rootLogger <span class="sy0">=</span> h.<span class="me1">Root</span>;</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.danidemi.com/mainwww/2010/03/obtain-the-root-logger-programmatically-in-log4net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Good environment variable values during iPhone development</title>
		<link>http://www.danidemi.com/mainwww/2010/01/iphone_development_environment_variables/</link>
		<comments>http://www.danidemi.com/mainwww/2010/01/iphone_development_environment_variables/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 15:06:39 +0000</pubDate>
		<dc:creator>danidemi</dc:creator>
				<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.danidemi.com/mainwww/?p=94</guid>
		<description><![CDATA[<p>Directly from GHUnit, a small note about which environment variables to set while developing for the iPhone.</p>
Environment Variable:                 Default:  Set to:
NSDebugEnabled                  [...]]]></description>
			<content:encoded><![CDATA[<p>Directly from <a href="http://github.com/gabriel/gh-unit" target="_blank">GHUnit</a>, a small note about which environment variables to set while developing for the iPhone.</p>
<pre><code>Environment Variable:                 Default:  Set to:
NSDebugEnabled                           NO       YES
NSZombieEnabled                          NO       YES
NSDeallocateZombies                      NO       NO (or YES)
NSHangOnUncaughtException                NO       YES
NSAutoreleaseFreedObjectCheckEnabled     NO       YES
</code></pre>
<p>Actually, I keep forgetting them, so I hope this will be useful to me.</p>
<p>Here an example that shows how to set those environment variables.</p>
<div id="attachment_152" class="wp-caption aligncenter" style="width: 770px"><a href="http://www.danidemi.com/mainwww/wp-content/uploads/2010/03/variables.png"><img class="size-full wp-image-152" title="Setting iPhone development variables" src="http://www.danidemi.com/mainwww/wp-content/uploads/2010/03/variables.png" alt="" width="760" height="512" /></a><p class="wp-caption-text">Setting iPhone development variables in XCode</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.danidemi.com/mainwww/2010/01/iphone_development_environment_variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails ans SQLite3 on Ubuntu</title>
		<link>http://www.danidemi.com/mainwww/2009/12/rails-ans-sqlite3-on-ubuntu/</link>
		<comments>http://www.danidemi.com/mainwww/2009/12/rails-ans-sqlite3-on-ubuntu/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 10:06:37 +0000</pubDate>
		<dc:creator>danidemi</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.danidemi.com/mainwww/?p=90</guid>
		<description><![CDATA[<p>To configure a Rails application in order to use SQLite3 please follow the following steps:</p>
sudo apt-get install  sqlite3 swig libsqlite3-ruby libsqlite3-dev
 sudo gem install sqlite3-ruby
<p>Then create a Rails application as usual and update the environment.rb file in the following way</p>
Rails::Initializer.run do &#124;config&#124;
...
config.gem 'sqlite3-ruby', :lib =&#62; "sqlite3"
...
end
]]></description>
			<content:encoded><![CDATA[<p>To configure a Rails application in order to use SQLite3 please follow the following steps:</p>
<pre>sudo apt-get install  sqlite3 swig libsqlite3-ruby libsqlite3-dev
 sudo gem install sqlite3-ruby</pre>
<p>Then create a Rails application as usual and update the environment.rb file in the following way</p>
<pre>Rails::Initializer.run do |config|</pre>
<pre>...</pre>
<pre>config.gem 'sqlite3-ruby', :lib =&gt; "sqlite3"</pre>
<pre>...</pre>
<pre>end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.danidemi.com/mainwww/2009/12/rails-ans-sqlite3-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get rid of folder that should not be versioned</title>
		<link>http://www.danidemi.com/mainwww/2009/12/get-rid-of-folder-that-should-not-be-versioned/</link>
		<comments>http://www.danidemi.com/mainwww/2009/12/get-rid-of-folder-that-should-not-be-versioned/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 10:01:55 +0000</pubDate>
		<dc:creator>danidemi</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[revision control]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.danidemi.com/mainwww/?p=88</guid>
		<description><![CDATA[<p>If you work with subversion, for sure you had the problem to tell to subversion to ignore a folder inside your working copy. This happens for example if your IDE builds the sources in a folder inside your working copy. From the very first commit you&#8217;ll start noticing that subversion wants to add that &#8220;build&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>If you work with subversion, for sure you had the problem to tell to subversion to ignore a folder inside your working copy. This happens for example if your IDE builds the sources in a folder inside your working copy. From the very first commit you&#8217;ll start noticing that subversion wants to add that &#8220;build&#8221; folder to your repository. But, obviously, this is not a good practice.</p>
<p>So you can tell subversion to ignore a folder. Just move in the folder that contains the folder you want to be ignored by subversion and type the following command.</p>
<pre>svn propset svn:ignore &lt;dir_you_want_to_be_ignored&gt; .</pre>
<p>The &#8220;dot&#8221; at the end is important! It means you&#8217;re specifying which folders of the current folder you want to be ignored.</p>
<p>Please note that &lt;dir_you_want_to_be_ignored&gt; should be written without trailing slashes. So for example if you want the build directory not to be managed by subversion, type&#8230;</p>
<pre>svn propset svn:ignore build .</pre>
<p>And not&#8230;</p>
<pre>
<pre>svn propset svn:ignore build/ .</pre>
</pre>
<p>This is a quick tip. I always forget how to do it, so I wrote that little note.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danidemi.com/mainwww/2009/12/get-rid-of-folder-that-should-not-be-versioned/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone screen dimensions</title>
		<link>http://www.danidemi.com/mainwww/2009/11/iphone-screen-dimensions/</link>
		<comments>http://www.danidemi.com/mainwww/2009/11/iphone-screen-dimensions/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 16:31:30 +0000</pubDate>
		<dc:creator>danidemi</dc:creator>
				<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.danidemi.com/mainwww/?p=71</guid>
		<description><![CDATA[<p>This picture can be useful to those of you that develop graphics targeted to the iPhone platform. Here you see the dimensions in pixel of an iPhone windows in some of the most common configurations. Click on the image to enlarge it.</p>
<p></p>
]]></description>
			<content:encoded><![CDATA[<p>This picture can be useful to those of you that develop graphics targeted to the iPhone platform. Here you see the dimensions in pixel of an iPhone windows in some of the most common configurations. Click on the image to enlarge it.</p>
<p><a href="http://www.danidemi.com/mainwww/wp-content/uploads/2009/11/iphone-dimensions.png"><img class="aligncenter size-full wp-image-74" title="iphone dimensions" src="http://www.danidemi.com/mainwww/wp-content/uploads/2009/11/iphone-dimensions.png" alt="iphone dimensions" width="700" height="434" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danidemi.com/mainwww/2009/11/iphone-screen-dimensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chosing the number of decimal digits when printing a number with iPhone</title>
		<link>http://www.danidemi.com/mainwww/2009/11/chosing-the-number-of-decimal-digits-when-printing-a-number-with-iphone/</link>
		<comments>http://www.danidemi.com/mainwww/2009/11/chosing-the-number-of-decimal-digits-when-printing-a-number-with-iphone/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 11:39:59 +0000</pubDate>
		<dc:creator>danidemi</dc:creator>
				<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.danidemi.com/mainwww/?p=67</guid>
		<description><![CDATA[<p>This is a small snippet, useful whenever you want to convert a floating point number in a string with a fixed number of decimal digits.</p>
NSNumberFormatter *format = [NSNumberFormatter new];
 [format setMaximumFractionDigits:1];
 NSNumber *aNumber = [[NSNumber alloc ] initWithDouble:54.4235264];
 NSString label = [[NSString alloc] initWithFormat:@"The number is %@", [format stringForObjectValue:aNumber]];
 [distance release];
 [format release];
<p>Obviously the NSNumberFormatter [...]]]></description>
			<content:encoded><![CDATA[<p>This is a small snippet, useful whenever you want to convert a floating point number in a string with a fixed number of decimal digits.</p>
<pre>NSNumberFormatter *format = [NSNumberFormatter new];
 [format setMaximumFractionDigits:1];
 NSNumber *aNumber = [[NSNumber alloc ] initWithDouble:54.4235264];
 NSString label = [[NSString alloc] initWithFormat:@"The number is %@", [format stringForObjectValue:aNumber]];
 [distance release];
 [format release];</pre>
<p>Obviously the <a href="http://developer.apple.com/iphone/library/documentation/cocoa/reference/foundation/Classes/NSNumberFormatter_Class/Reference/Reference.html#//apple_ref/occ/cl/NSNumberFormatter" target="_blank">NSNumberFormatter</a> class offers plenty of other method you can use to customize the way your numbers should be rendered.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danidemi.com/mainwww/2009/11/chosing-the-number-of-decimal-digits-when-printing-a-number-with-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone: how to select a UITabBarItem programmatically</title>
		<link>http://www.danidemi.com/mainwww/2009/11/iphone-how-to-select-a-uitabbaritem-programmatically/</link>
		<comments>http://www.danidemi.com/mainwww/2009/11/iphone-how-to-select-a-uitabbaritem-programmatically/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 11:22:31 +0000</pubDate>
		<dc:creator>danidemi</dc:creator>
				<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIKit]]></category>

		<guid isPermaLink="false">http://www.danidemi.com/mainwww/?p=61</guid>
		<description><![CDATA[<p>I&#8217;m working to an iPhone application with a TabBar on the footer area. Among the others there are a &#8220;Home&#8221; button and an &#8220;Account&#8221; button. The first allows the user to see a view that gives an overview of the application. The latter shows the view that the user uses to manage his/her account.</p>
<p>If the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working to an iPhone application with a TabBar on the footer area. Among the others there are a &#8220;Home&#8221; button and an &#8220;Account&#8221; button. The first allows the user to see a view that gives an overview of the application. The latter shows the view that the user uses to manage his/her account.</p>
<p>If the user is not currently logged in, in the &#8220;Home&#8221; view a warning message is displayed. There is also a button that is supposed to show the &#8220;Account&#8221; view. In that way it&#8217;s more clear for the user that he/she should log in.</p>
<p>How can you accomplish that task ? That post shows you the way I followed.</p>
<p>The big idea is to retrieve the TabBarController from the &#8220;Home&#8221; controller, and programmatically change the current view. To do that, the &#8220;Home&#8221; controller should get a reference to the TabBarController. But you can easily set that dependency in Interface Builder. You only need to provide a suited IBOutlet to the Home controller.</p>
<p>That is the tree structure of the controllers and views, as built in the interface builder.</p>
<p><a href="http://www.danidemi.com/mainwww/wp-content/uploads/2009/11/iphone_change_tabbar_programmatically_0.png"><img class="aligncenter size-full wp-image-62" title="iphone_change_tabbar_programmatically_0" src="http://www.danidemi.com/mainwww/wp-content/uploads/2009/11/iphone_change_tabbar_programmatically_0.png" alt="iphone_change_tabbar_programmatically_0" width="405" height="366" /></a></p>
<p>So, that&#8217;s an excerpt of the HomeController showing you only what is really needed to reach our goal. The goToRegistrationPage method will execute programmatically the switch to the account page.</p>
<pre>@interface HomeViewController : UIViewController {
UITabBarController *mainTabBarController;
}
@property(nonatomic, retain) IBOutlet UITabBarController *mainTabBarController;
-(IBAction) goToRegistrationPage;</pre>
<p>Now, we only need to set in Interface Builder the link between the the IBOutlet we just created and the Tab Bar Controller. Here&#8217;s the result.</p>
<p><a href="http://www.danidemi.com/mainwww/wp-content/uploads/2009/11/iphone_change_tabbar_programmatically_1.png"><img class="aligncenter size-full wp-image-63" title="iphone_change_tabbar_programmatically_1" src="http://www.danidemi.com/mainwww/wp-content/uploads/2009/11/iphone_change_tabbar_programmatically_1.png" alt="iphone_change_tabbar_programmatically_1" width="282" height="156" /></a>As you can see the mainTabBarController outlet is linked to the Tab Bar Controller we want to manage programmatically. That&#8217;s not difficult at all. Let&#8217;s give a look to the goToRegistrationPage method.</p>
<pre>-(IBAction) goToRegistrationPage {
 mainTabBarController.selectedIndex=3;
}</pre>
<p>Quite easy, isn&#8217;t it ?</p>
<p>Now the user click on the button on the Home view and he/she get exactly the same result of touching the tab bar button in the footer.</p>
<p>Hope you can find it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danidemi.com/mainwww/2009/11/iphone-how-to-select-a-uitabbaritem-programmatically/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
