<?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>marthijn. &#187; Tutorials</title>
	<atom:link href="http://www.marthijnvandenheuvel.com/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marthijnvandenheuvel.com</link>
	<description></description>
	<lastBuildDate>Fri, 30 Dec 2011 13:03:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Map Traktor&#8217;s Beat Phase Monitor to your Reloop Digital Jockey 2</title>
		<link>http://www.marthijnvandenheuvel.com/2010/10/16/map-traktors-beat-phase-monitor-to-your-reloop-digital-jockey-2/</link>
		<comments>http://www.marthijnvandenheuvel.com/2010/10/16/map-traktors-beat-phase-monitor-to-your-reloop-digital-jockey-2/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 22:01:45 +0000</pubDate>
		<dc:creator>Marthijn</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Digital Jockey 2]]></category>
		<category><![CDATA[Midi mapping]]></category>
		<category><![CDATA[Reloop]]></category>
		<category><![CDATA[Traktor]]></category>

		<guid isPermaLink="false">http://www.marthijnvandenheuvel.com/?p=273</guid>
		<description><![CDATA[How to map Traktor's Beat Phase Monitor to a LED on the Reloop Digital Jockey 2]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.youtube.com/watch?v=ma7urvruR_Y" target="_blank">this video on YouTube</a> you can see the LED of the Load A and Load B button blink on the Beat Phase Monitor of Traktor. In this post I&#8217;ll describe how to add this functionality to your Reloop Digital Jockey 2 mapping in Traktor.</p>
<p><a href="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/10/r_dj2int.png" rel="lightbox[273]"><img class="aligncenter size-medium wp-image-274" title="Digital Jockey 2" src="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/10/r_dj2int-300x225.png" alt="" width="300" height="225" /></a><span id="more-273"></span>In Traktor open the Controller Manager (in the Preferences window). Now press the Add Out.. button and choose Output â†’ Beat Phase Monitor. For deck A modify the following settings:</p>
<ul>
<li>Note: Ch01.Note.G0</li>
<li>Type of controller: LED</li>
<li>Modifier Conditions are all empty</li>
<li>Interaction mode: Output</li>
<li>Assignment: Deck A</li>
<li>Controller range min: 0</li>
<li>Controller range max: 0.5</li>
<li>Midi range min: 0</li>
<li>Midi range max: 127</li>
<li>Both Blend and Invert are off</li>
</ul>
<p>Repeat this step for deck B, but now change Assignment to Deck B and Note to Ch01.Note.G5.</p>
<p><a href="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/10/traktor_beatphasemonitor.png" rel="lightbox[273]"><img class="aligncenter size-medium wp-image-275" title="Beat Phase Monitor mapping" src="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/10/traktor_beatphasemonitor-270x300.png" alt="" width="270" height="300" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marthijnvandenheuvel.com/2010/10/16/map-traktors-beat-phase-monitor-to-your-reloop-digital-jockey-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to stop Traktor from editing ID3 tags</title>
		<link>http://www.marthijnvandenheuvel.com/2010/10/11/how-to-stop-traktor-from-editing-id3-tags/</link>
		<comments>http://www.marthijnvandenheuvel.com/2010/10/11/how-to-stop-traktor-from-editing-id3-tags/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 22:01:45 +0000</pubDate>
		<dc:creator>Marthijn</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[ID3 Tags]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[Traktor]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://www.marthijnvandenheuvel.com/?p=266</guid>
		<description><![CDATA[How to run Traktor as a different user so it has no permission to modify music files.]]></description>
			<content:encoded><![CDATA[<p>A few days ago I was trying a demo version of <a href="http://www.native-instruments.com/#/en/products/dj/traktor-pro/" target="_blank">Traktor Pro</a>. When playing some tracks I discovered the ID3 tags were missing when viewing the files in Windows Explorer. According to <a href="http://www.native-instruments.com/forum/showthread.php?t=119173" target="_blank">this topic</a> Traktor changes the ID3 tags from version 2.3 to version 2.4 which can&#8217;t be read by Windows 7, so it&#8217;s not really a bug but rather annoying. In this post I&#8217;ll describe how to run Traktor as a different user in Windows 7 so it has no permissions to modify files any more. This solution is mentioned in <a href="http://www.native-instruments.com/forum/showthread.php?t=115804" target="_blank">this topic</a>.</p>
<p><span id="more-266"></span>The first thing to do is create a new user.Â  Go to Start and click with the right mouse button on Computer and choose Manage from the submenu. In the left column choose Local Users and Groups and open the Users folder. Now create a new user (Action â†’ New User or right mouse button â†’ New User):</p>
<p><a href="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/10/traktor_adduser.png" rel="lightbox[266]"><img class="aligncenter size-medium wp-image-267" title="Add user" src="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/10/traktor_adduser-300x298.png" alt="" width="300" height="298" /></a></p>
<p>Click Create and close the window. The next thing to do is change the permission of your music folder:</p>
<ol>
<li>Open Properties of your music folder</li>
<li>Open the Security tab and press the Edit button</li>
<li>In the Permissions window, choose Add</li>
<li>Enter the name of your Traktor user and press OK</li>
<li>Make sure the Traktor user is selected and in the permissions list check Deny for the Write permission</li>
</ol>
<p><a href="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/10/traktor_permissions.png" rel="lightbox[266]"><img class="aligncenter size-medium wp-image-268" title="Folder permissions" src="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/10/traktor_permissions-248x300.png" alt="" width="248" height="300" /></a></p>
<p>The final step is running Traktor as the newly created user. To do so go to Start and navigate to the Traktor shortcut. Now hold Shift and right click on the shortcut. Choose Run as different user and enter the Trakor user credentials. Since you start Traktor using a different user you need to reconfigure the application, but Traktor has no permission to modify your files any more.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marthijnvandenheuvel.com/2010/10/11/how-to-stop-traktor-from-editing-id3-tags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting started with LaTeX and BibTeX in LEd</title>
		<link>http://www.marthijnvandenheuvel.com/2010/10/05/getting-started-with-latex-and-bibtex-in-led/</link>
		<comments>http://www.marthijnvandenheuvel.com/2010/10/05/getting-started-with-latex-and-bibtex-in-led/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 14:56:50 +0000</pubDate>
		<dc:creator>Marthijn</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[LaTeX]]></category>

		<guid isPermaLink="false">http://www.marthijnvandenheuvel.com/?p=252</guid>
		<description><![CDATA[A simple tutorial about LaTeX and BibTeX in the editor LEd.]]></description>
			<content:encoded><![CDATA[<p>Recently I started writing a simple paper in <a href="http://en.wikipedia.org/wiki/LaTeX" target="_blank">LaTeX</a>. Since I was only used to editors like Word and OpenOffice writing in LaTeX was completely different. In this post I&#8217;ll describe how to get started with LaTeX and <a href="http://www.bibtex.org/" target="_blank">BibTeX</a> in a simple and free LaTeX editor for Windows called <a href="http://www.latexeditor.org/" target="_blank">LEd</a>. First of all, download LEd <a href="http://www.latexeditor.org/download_main.html" target="_blank">here</a> and install it on your system. Make sure you install <a href="http://miktex.org/" target="_blank">MiKTeX</a>, a Windows implementation of <a href="http://en.wikipedia.org/wiki/TeX" target="_blank">Tex</a>, as well if you not already have it.</p>
<p><span id="more-252"></span>Now startup LEd. In order to create a new paper go to File â†’ New and on the Template tab choose Paper. In the file tree, open your .tex file. You will see something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #E02020; ">\</span><span style="color: #800000;">documentclass</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">article</span><span style="color: #E02020; ">}</span>
&nbsp;
<span style="color: #E02020; ">\</span><span style="color: #800000;">title</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">...</span><span style="color: #E02020; ">}</span>
<span style="color: #E02020; ">\</span><span style="color: #800000;">author</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">...</span><span style="color: #E02020; ">}</span>
<span style="color: #E02020; ">\</span><span style="color: #800000;">date</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">...</span><span style="color: #E02020; ">}</span>
&nbsp;
<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">document</span></span><span style="color: #E02020; ">}</span>
<span style="color: #E02020; ">\</span><span style="color: #800000;">maketitle</span>
&nbsp;
<span style="color: #E02020; ">\</span><span style="color: #800000;">section</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">...</span><span style="color: #E02020; ">}</span>
&nbsp;
<span style="color: #E02020; ">\</span><span style="color: #800000;">section</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">...</span><span style="color: #E02020; ">}</span>
&nbsp;
<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">document</span></span><span style="color: #E02020; ">}</span></pre></div></div>

<p>You can change the dots for anything you like and add text under the \section tags:</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #E02020; ">\</span><span style="color: #800000;">section</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">Introduction</span><span style="color: #E02020; ">}</span>
Lorem ipsum dolor sit amet...</pre></div></div>

<p>Now it&#8217;s time to compile the LaTeX document; press the green arrow button in the toolbar or F9. Press the blue arrow or F7 to create a PDF file (the file is stored in the same folder as your .tex file):</p>
<p><a href="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/10/latex_testpaper.png" rel="lightbox[252]"><img class="aligncenter size-medium wp-image-254" title="Test paper" src="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/10/latex_testpaper-231x300.png" alt="" width="231" height="300" /></a></p>
<p>In scientific papers it&#8217;s quite common to refer to other papers. In order to manage this we use BibTeX. First create a .bib file adding a new file to the project: File â†’ New and choose &#8220;Bibliography file in BibTeX format&#8221;. Name the file for example mybib and make sure to add it to the right project. Add the following example text to your .bib file:</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;">@article<span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">miles09,
 author = {Richard Miles</span><span style="color: #E02020; ">}</span>,
 title = <span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">Who is John Doe?</span><span style="color: #E02020; ">}</span>,
 year = <span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">2009</span><span style="color: #E02020; ">}</span>,
 journal = <span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">The Unknown Magazine</span><span style="color: #E02020; ">}</span>,
 volume = <span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">1</span><span style="color: #E02020; ">}</span>,
 number = <span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">1</span><span style="color: #E02020; ">}</span>,
 pages = <span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">20--42</span><span style="color: #E02020; ">}</span>
<span style="color: #E02020; ">}</span></pre></div></div>

<p>In your .tex file, add the following commands before the \end{document} tag to enable the bibliography:</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\bibliographystyle</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">plain</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\bibliography</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">mybib</span><span style="color: #E02020; ">}</span></pre></div></div>

<p>Now if you want to cite something simply type \cite and a window will popup containing all the entries in your bibliography:</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. <span style="color: #E02020; ">\</span><span style="color: #800000;">cite</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">miles09</span><span style="color: #E02020; ">}</span></pre></div></div>

<p>Compile the bibliography file by pressing the blue book icon or F6. Then compile your LaTeX file and create a PDF. As you can see the bibliography is included in your document:</p>
<p><a href="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/10/latex_testpaperbib.png" rel="lightbox[252]"><img class="aligncenter size-medium wp-image-255" title="Test paper bibliography" src="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/10/latex_testpaperbib-231x300.png" alt="" width="231" height="300" /></a></p>
<p>That&#8217;s all for now, for more information about the BibTeX format see <a href="http://www.bibtex.org/Format/" target="_blank">this</a> page. Enjoy LaTeX!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marthijnvandenheuvel.com/2010/10/05/getting-started-with-latex-and-bibtex-in-led/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CodeIgniter simple CRUD improved</title>
		<link>http://www.marthijnvandenheuvel.com/2010/06/27/codeigniter-simple-crud-improved/</link>
		<comments>http://www.marthijnvandenheuvel.com/2010/06/27/codeigniter-simple-crud-improved/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 12:38:56 +0000</pubDate>
		<dc:creator>Marthijn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[CRUD]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Table]]></category>

		<guid isPermaLink="false">http://www.marthijnvandenheuvel.com/?p=208</guid>
		<description><![CDATA[Add sorting in a simple CRUD with CodeIgniter.]]></description>
			<content:encoded><![CDATA[<p>Currently I&#8217;m developing a web application in PHP using the <a href="http://codeigniter.com/" target="_blank">CodeIgniter</a> framework. Since I needed some admin functionality such as create, read, update and delete records (CRUD) I searched for CodeIgniter libraries. I came across <a href="http://henrihnr.wordpress.com/2009/04/26/simple-crud-application/" target="_blank">this post</a> by <a href="http://henrihnr.wordpress.com/" target="_blank">Henri</a>. His solution is very simple and easy to understand and implement. In this post I&#8217;ll describe how to improve his solution so it&#8217;s possible to sort columns. I start with the files Henri provided in his post.</p>
<p>In order to enable sorting I first modify the get_paged_list function of the PersonModel class:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_paged_list<span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order_column</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order_type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$order_column</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$order_type</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">order_by</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">order_by</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$order_column</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order_type</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tbl_person</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span><span style="color: #339933;">,</span> <span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span id="more-208"></span></p>
<p>The index function of the person controller must be modified as well. I changed the following parts:</p>
<ul>
<li>Function parameters</li>
<li>Get ordering from URI</li>
<li>Call to model</li>
<li>Table header</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order_column</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'id'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order_type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// checks</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$order_column</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$order_column</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'id'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$order_type</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$order_type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'asc'</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//TODO: check for valid column</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// load data</span>
	<span style="color: #000088;">$persons</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">personModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_paged_list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">limit</span><span style="color: #339933;">,</span> <span style="color: #000088;">$offset</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order_column</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order_type</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">result</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// generate pagination</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pagination'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'base_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> site_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'person/index/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'total_rows'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">personModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">count_all</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'per_page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">limit</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'uri_segment'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pagination</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pagination'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pagination</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create_links</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// generate table data</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'table'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_empty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;nbsp;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$new_order</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$order_type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'asc'</span> ? <span style="color: #0000ff;">'desc'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_heading</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'No'</span><span style="color: #339933;">,</span>
		anchor<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'person/index/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$offset</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/name/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$new_order</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		anchor<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'person/index/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$offset</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/gender/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$new_order</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Gender'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		anchor<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'person/index/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$offset</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/dob/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$new_order</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Date of Birth (dd-mm-yyyy)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'Actions'</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$offset</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$persons</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$person</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_row</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">++</span><span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #000088;">$person</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">,</span> <span style="color: #990000;">strtoupper</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$person</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">gender</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #0000ff;">'M'</span>? <span style="color: #0000ff;">'Male'</span><span style="color: #339933;">:</span><span style="color: #0000ff;">'Female'</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d-m-Y'</span><span style="color: #339933;">,</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$person</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dob</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			anchor<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'person/view/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$person</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'view'</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'view'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span>
			anchor<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'person/update/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$person</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'update'</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'update'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span>
			anchor<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'person/delete/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$person</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'delete'</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'delete'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'onclick'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;return confirm('Are you sure want to delete this person?')&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'table'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">generate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// load view</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'personList'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><i>Updated June 29th 2010 thanks to Stephen.</i><br/><br />
The only problem now is pagination doesn&#8217;t work any more. As far as I know there is no solution to pass the ordering parameter to CodeIgniter&#8217;s pagination class. I think the best solution is to implement your own pagination class. Maybe I&#8217;ll discuss that in another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marthijnvandenheuvel.com/2010/06/27/codeigniter-simple-crud-improved/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using NUnit in Visual Studio 2010</title>
		<link>http://www.marthijnvandenheuvel.com/2010/06/09/using-nunit-in-visual-studio-2010/</link>
		<comments>http://www.marthijnvandenheuvel.com/2010/06/09/using-nunit-in-visual-studio-2010/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 12:13:10 +0000</pubDate>
		<dc:creator>Marthijn</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[NUnit]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.marthijnvandenheuvel.com/?p=196</guid>
		<description><![CDATA[How to use NUnit in Visual Studio 2010.]]></description>
			<content:encoded><![CDATA[<p>Like in older versions of <a href="http://www.microsoft.com/visualstudio" target="_blank">Visual Studio</a> it is possible to use <a href="http://www.nunit.org" target="_blank">NUnit</a> as an external tool in the new 2010 version. By creating a toolbar as well it is very easy to run your test suite. The usual way to add an external command is by clicking the menu Tools -&gt; External Tools. However, by default this menu item is not visible. To enable this menu item go to Tools -&gt; Settings -&gt; Expert Settings.</p>
<p><a href="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/06/vs2010.png" rel="lightbox[196]"><img class="aligncenter size-full wp-image-197" title="Visual Studio 2010" src="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/06/vs2010.png" alt="Visual Studio 2010" width="214" height="32" /></a></p>
<p><span id="more-196"></span></p>
<p>The first step is download and install the latest version of NUnit since older versions are not compatible with .NET 4. NUnit version 2.5.5 can be downloaded <a href="http://www.nunit.org/?p=download" target="_blank">here</a>.</p>
<p>Now go to Tools -&gt; External Tools:</p>
<p><a href="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/06/vs2010_exttools.png" rel="lightbox[196]"><img class="aligncenter size-full wp-image-198" title="Visual Studio 2010 External Tools" src="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/06/vs2010_exttools.png" alt="Visual Studio 2010 External Tools" width="493" height="481" /></a></p>
<p>I think this screen shot explains itself very well. Now its possible to add this external command to a tool bar. To do so go to View -&gt; Toolbars -&gt; Customize:</p>
<p><a href="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/06/vs2010_customize.png" rel="lightbox[196]"><img class="aligncenter size-full wp-image-200" title="Visual Studio 2010 Customize Toolbars" src="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/06/vs2010_customize.png" alt="Visual Studio 2010 Customize Toolbars" width="465" height="509" /></a></p>
<p>Press the New button and enter a name. Now open the Commands tab and add the external command (usually External Command 1 when you don&#8217;t have any other external commands) to the toolbar:</p>
<p style="text-align: center;"><a href="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/06/vs2010_customize2.png" rel="lightbox[196]"><img class="aligncenter size-full wp-image-202" title="Visual Studio 2010 Commands" src="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/06/vs2010_customize2.png" alt="Visual Studio 2010 Toolbars" width="801" height="529" /></a></p>
<p style="text-align: left;">When clicking the NUnit button in the new toolbar the NUnit GUI starts and loads your test suite.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marthijnvandenheuvel.com/2010/06/09/using-nunit-in-visual-studio-2010/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Unit testing in Watir</title>
		<link>http://www.marthijnvandenheuvel.com/2010/04/14/unit-testing-in-watir/</link>
		<comments>http://www.marthijnvandenheuvel.com/2010/04/14/unit-testing-in-watir/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 15:17:12 +0000</pubDate>
		<dc:creator>Marthijn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Watir]]></category>

		<guid isPermaLink="false">http://www.marthijnvandenheuvel.com/?p=149</guid>
		<description><![CDATA[Write a simple unit test in Watir]]></description>
			<content:encoded><![CDATA[<p><a href="http://watir.com/" target="_blank">Watir</a> is an open-source Ruby library for automating web browsers. Combined with unit testing for Ruby it is a really powerful tool to test websites and webapplications. In this post I explain how to write a test for a simple website.</p>
<div id="attachment_150" class="wp-caption aligncenter" style="width: 120px"><a href="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/04/watir.png" rel="lightbox[149]"><img class="size-full wp-image-150" title="Watir" src="http://www.marthijnvandenheuvel.com/wp-content/uploads/2010/04/watir.png" alt="Watir" width="110" height="103" /></a><p class="wp-caption-text">Watir</p></div>
<p><span id="more-149"></span></p>
<p>First download and install <a href="http://www.ruby-lang.org/en/downloads/" target="_blank">Ruby</a>. If you are familiar with <a href="http://www.eclipse.org/" target="_blank">Eclipse</a>, <a href="http://www.aptana.com/" target="_blank">Aptana</a> is a nice web development plugin (see <a href="http://osdir.com/ml/RubyonRailsTalk/2009-08/msg02136.html" target="_blank">this simple installation tutorial</a>). If you don&#8217;t know how to use Ruby, <a href="http://www.basvandijk.eu/" target="_blank">Bas</a> has a <a href="http://www.basvandijk.eu/2010/03/28/getting-started-with-ruby/" target="_blank">nice article</a> about getting started with Ruby.</p>
<p>The second step is <a href="http://watir.com/installation/" target="_blank">install Watir</a>. You can try <a href="http://watir.com/examples/" target="_blank">these examples</a> to see what Watir does.</p>
<h2>Testing a simple website</h2>
<p>For one of my school projects I had to write a simple test for one of the function of this <a href="http://www.calcenstein.com/" target="_blank">online calculator</a>. In this tutorial we will test the <a href="http://www.calcenstein.com/calc/0416.php" target="_blank">GCF and LCM function</a>. Start with creating a new Ruby script containing the right requirements and a test case class:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'watir'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'test/unit'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> TC_LCM_GCD <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#CC00FF; font-weight:bold;"><span style="color:#6666ff; font-weight:bold;">Test::Unit::TestCase</span></span>
 <span style="color:#9966CC; font-weight:bold;">def</span> test_lcm_gcd
  <span style="color:#008000; font-style:italic;"># ...</span>
 <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>In order to let Watir start a new browser add the following to the test_lcm_gcd function:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">Watir::Browser</span>.<span style="color:#9900CC;">default</span> = <span style="color:#996600;">&quot;ie&quot;</span>
b = <span style="color:#6666ff; font-weight:bold;">Watir::Browser</span>.<span style="color:#9900CC;">start</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;http://www.calcenstein.com/calc/0416.php&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;"># GCF and LCM</span></pre></div></div>

<p>If you want to use Firefox for testing, change &#8220;ie&#8221; to &#8220;firefox&#8221; and don&#8217;t forget to install the <a href="http://watir.com/installation/" target="_blank">plugin</a>. The second line starts a new browser window.</p>
<p>Our goal is to let Watir insert two values (the &#8216;First Value&#8217; and &#8216;Second Value&#8217; input field), and then press the &#8216;Solve&#8217; button. In order to do so we need to know the name or id (or value in some cases) of the input fields and the &#8216;Solve&#8217; button. Instead of looking at the source I can recommend to use the <a href="https://addons.mozilla.org/nl/firefox/addon/1843" target="_blank">Firebug</a> add-on for Firefox, and use the inspect function. The &#8216;First Value&#8217; input is named &#8216;a&#8217;, and the &#8216;Second Value&#8217; input is named &#8216;b&#8217;. We want to set &#8216;a&#8217; to 30 and &#8216;b&#8217; to 45:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">b.<span style="color:#9900CC;">text_field</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#996600;">&quot;a&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">set</span> <span style="color:#996600;">&quot;30&quot;</span>
b.<span style="color:#9900CC;">text_field</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#996600;">&quot;b&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">set</span> <span style="color:#996600;">&quot;45&quot;</span></pre></div></div>

<p>When these values are set, Watir must press the &#8216;Solve&#8217; button. It appears this button doesn&#8217;t have a name or id, so get it by value and execute the click action:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">b.<span style="color:#9900CC;">button</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:value</span>, <span style="color:#996600;">&quot;Solve&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">click</span></pre></div></div>

<p>Now the click action is executed and the result is printed in the other two input fields (named &#8216;lcmA&#8217; and &#8216;gcdA&#8217;). Like in all other test cases, the result must be verified. The correct result is LCM = 90 and GCF = 15, so use assertions to check the values:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">assert<span style="color:#006600; font-weight:bold;">&#40;</span>b.<span style="color:#9900CC;">text_field</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#996600;">&quot;lcmA&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">value</span> == <span style="color:#996600;">&quot;90&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
assert<span style="color:#006600; font-weight:bold;">&#40;</span>b.<span style="color:#9900CC;">text_field</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#996600;">&quot;gcdA&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">value</span> == <span style="color:#996600;">&quot;15&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>This simple test case is now complete. The test output should be something like this:</p>
<pre>Loaded suite My_test_suite
Started
.
Finished in 5.579 seconds.

1 tests, 2 assertions, 0 failures, 0 errors</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.marthijnvandenheuvel.com/2010/04/14/unit-testing-in-watir/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to create a chroot ssh user in Ubuntu</title>
		<link>http://www.marthijnvandenheuvel.com/2010/03/10/how-to-create-a-chroot-ssh-user-in-ubuntu/</link>
		<comments>http://www.marthijnvandenheuvel.com/2010/03/10/how-to-create-a-chroot-ssh-user-in-ubuntu/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 13:12:43 +0000</pubDate>
		<dc:creator>Marthijn</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[chroot]]></category>
		<category><![CDATA[Jailkit]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.marthijnvandenheuvel.com/?p=79</guid>
		<description><![CDATA[Create a chroot in Ubuntu using Jailkit.]]></description>
			<content:encoded><![CDATA[<p>On my server I want to create accounts that can do SSH in a <a href="http://en.wikipedia.org/wiki/Chroot" target="_blank">chroot</a> environment. On the internet I searched for tools and I found <a href="http://olivier.sessink.nl/jailkit/" target="_blank">Jailkit</a>. In this post I will tell how I installed Jailkit on Ubuntu server 9.10, created a jail and how users are added to the jail. Note that most commands in this tutorial should be executed as su or sudo.</p>
<h3>Jailkit installation</h3>
<p>First I installed Jailkit by using the following commands:</p>
<pre># cd /tmp
# wget http://olivier.sessink.nl/jailkit/jailkit-2.11.tar.gz
# tar -zxvf jailkit-2.11.tar.gz
# cd jailkit-2.11
# ./configure
# make
# make install</pre>
<p><span id="more-79"></span></p>
<h3>Setting up the jail</h3>
<p>Now it&#8217;s time to set up the jail directory. Jailed users will see this directory as the root directory of the server. I chose to use /home/jail:</p>
<pre># mkdir /home/jail
# chown root:root /home/jail</pre>
<p>By using the jk_init command you can set up the jail. In this tutorial the basicshell, netutils, ssh and limited shell are installed:</p>
<pre># jk_init -v /home/jail basicshell
# jk_init -v /home/jail netutils
# jk_init -v /home/jail ssh
# jk_init -v /home/jail jk_lsh</pre>
<h3>Add a user</h3>
<p>Add a new user with a home directory and bash shell, and don&#8217;t forget to change the password:</p>
<pre># useradd -d /home/testuser -m testuser -s /bin/bash
# passwd testuser</pre>
<p>Now it&#8217;s time to jail this user, use the following command:</p>
<pre># jk_jailuser -m -j /home/jail testuser</pre>
<p>Your /etc/passwd should contain something like this now:</p>
<pre>testuser:x:1003:1004::/home/jail/./home/testuser:/usr/sbin/jk_chrootsh</pre>
<h3>Enable bash</h3>
<p>By using jk_cp the bash libraries are be copied to the jail:</p>
<pre># jk_cp -v -f /home/jail /bin/bash</pre>
<p>Now edit the /home/jail/etc/passwd file and make sure it contains something like this:</p>
<pre>testuser:x:1003:1004::/home/testuser:/bin/bash</pre>
<p>Also make sure the group exists in /home/jail/etc/group:</p>
<pre>testuser:x:1004:</pre>
<p>Now try to login with testuser. Look for errors in /var/log/auth.log.</p>
<h3>Maintenance</h3>
<p>By using jk_update updates on the real system can be updated in the jail. A dry-run will show what&#8217;s going on:</p>
<pre># jk_update -j /home/jail -d</pre>
<p>Without the -d argument the real update is performed. More maintenance operations can be found <a href="http://olivier.sessink.nl/jailkit/howtos_chroot_shell.html" target="_blank">here</a>.</p>
<h3>Troubleshooting</h3>
<p>Make sure the jailed user has a home directory in /home/jail/home. If not create one:</p>
<pre># mkdir -p /home/jail/home/testuser
# chown testuser:testuser /home/jail/home/testuser</pre>
<h3>References</h3>
<ul>
<li><a href="http://ubuntuforums.org/showthread.php?t=248724" target="_blank">How to chroot ssh user using Jailkit</a></li>
<li><a href="http://olivier.sessink.nl/jailkit/howtos_ssh_only.html" target="_blank">Jailkit howto &#8211; ssh only shell in a chroot</a></li>
<li><a href="http://olivier.sessink.nl/jailkit/howtos_chroot_shell.html" target="_blank">Jailkit howto &#8211; creating a regular shell in a chroot jail</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.marthijnvandenheuvel.com/2010/03/10/how-to-create-a-chroot-ssh-user-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

