<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Code for Hire</title>
	<atom:link href="http://codeforhire.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeforhire.com</link>
	<description></description>
	<lastBuildDate>Tue, 23 Apr 2013 20:05:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='codeforhire.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Code for Hire</title>
		<link>http://codeforhire.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://codeforhire.com/osd.xml" title="Code for Hire" />
	<atom:link rel='hub' href='http://codeforhire.com/?pushpress=hub'/>
		<item>
		<title>Benchmarking Amazon micro instances</title>
		<link>http://codeforhire.com/2013/04/11/benchmarking-amazon-micro-instances/</link>
		<comments>http://codeforhire.com/2013/04/11/benchmarking-amazon-micro-instances/#comments</comments>
		<pubDate>Thu, 11 Apr 2013 20:03:16 +0000</pubDate>
		<dc:creator>Sampo N.</dc:creator>
				<category><![CDATA[Amazon AWS]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[micro instance]]></category>

		<guid isPermaLink="false">http://codeforhire.com/?p=185</guid>
		<description><![CDATA[Amazon t1.micro instances are the most affordable EC2 instance types.  Their distinctive feature is that while allowing short bursts of high CPU power (around double that of a m1.small instance), but very soon throttle the CPU usage significantly.  Therefore they are &#8230; <a href="http://codeforhire.com/2013/04/11/benchmarking-amazon-micro-instances/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=185&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Amazon t1.micro instances are the most affordable EC2 instance types.  Their distinctive feature is that while allowing short bursts of high CPU power (around double that of a m1.small instance), but very soon throttle the CPU usage significantly.  Therefore they are well suited for uses where there is low constant load, but periodic bursts of high activity, such as web servers for low-volume sites.</p>
<p>However, Amazon does not provide any specification on the exact method of throttling nor how long you can use full CPU utilization before the VM throttles.  I couldn&#8217;t find any info on this elsewhere, so I did some testing myself.</p>
<p>I wrote <a href="https://gist.github.com/plaa/5366129" target="_blank">a short program</a> that generates a desired amount of CPU load and measures the amount of CPU time it receives (in generic units).  I ran it on a 64-bit micro instance running Ubuntu Linux in the EU Ireland region for 10 minutes at varying CPU utilization, idling for 10 minutes between each test.  Below are graphs on the allotted CPU time for various load levels.</p>
<div id="attachment_193" class="wp-caption alignleft" style="width: 160px"><a href="http://codeforhire.files.wordpress.com/2013/04/load-100.png"><img class="size-thumbnail wp-image-193" alt="Micro instance 100% load" src="http://codeforhire.files.wordpress.com/2013/04/load-100.png?w=150&#038;h=112" width="150" height="112" /></a><p class="wp-caption-text">Micro instance 100% load</p></div>
<div id="attachment_192" class="wp-caption alignleft" style="width: 160px"><a href="http://codeforhire.files.wordpress.com/2013/04/load-75.png"><img class="size-thumbnail wp-image-192" alt="Micro instance 75% load" src="http://codeforhire.files.wordpress.com/2013/04/load-75.png?w=150&#038;h=112" width="150" height="112" /></a><p class="wp-caption-text">Micro instance 75% load</p></div>
<div id="attachment_191" class="wp-caption alignleft" style="width: 160px"><a href="http://codeforhire.files.wordpress.com/2013/04/load-50.png"><img class="size-thumbnail wp-image-191" alt="Micro instance 50% load" src="http://codeforhire.files.wordpress.com/2013/04/load-50.png?w=150&#038;h=112" width="150" height="112" /></a><p class="wp-caption-text">Micro instance 50% load</p></div>
<div id="attachment_190" class="wp-caption alignleft" style="width: 160px"><a href="http://codeforhire.files.wordpress.com/2013/04/load-25.png"><img class="size-thumbnail wp-image-190" alt="Micro instance 25% load" src="http://codeforhire.files.wordpress.com/2013/04/load-25.png?w=150&#038;h=112" width="150" height="112" /></a><p class="wp-caption-text">Micro instance 25% load</p></div>
<div id="attachment_189" class="wp-caption alignleft" style="width: 160px"><a href="http://codeforhire.files.wordpress.com/2013/04/load-20.png"><img class="size-thumbnail wp-image-189" alt="Micro instance 20% load" src="http://codeforhire.files.wordpress.com/2013/04/load-20.png?w=150&#038;h=112" width="150" height="112" /></a><p class="wp-caption-text">Micro instance 20% load</p></div>
<div id="attachment_188" class="wp-caption alignleft" style="width: 160px"><a href="http://codeforhire.files.wordpress.com/2013/04/load-15.png"><img class="size-thumbnail wp-image-188" alt="Micro instance 15% load" src="http://codeforhire.files.wordpress.com/2013/04/load-15.png?w=150&#038;h=112" width="150" height="112" /></a><p class="wp-caption-text">Micro instance 15% load</p></div>
<div id="attachment_186" class="wp-caption alignleft" style="width: 160px"><a href="http://codeforhire.files.wordpress.com/2013/04/load-10.png"><img class="size-thumbnail wp-image-186" alt="Micro instance 10% load" src="http://codeforhire.files.wordpress.com/2013/04/load-10.png?w=150&#038;h=112" width="150" height="112" /></a><p class="wp-caption-text">Micro instance 10% load</p></div>
<h2 style="clear:both;">Full load throttling</h2>
<p>One interesting question is how the throttling performs when the CPU is fully utilized, which may occur for example during a system upgrade.</p>
<p>In this case the throttling is rather binary; the VM either allows using the entire CPU, or throttles to about 11% of the full capacity.  You get about 10-13 seconds of full CPU power every 2-2.5 minutes, though this duty cycle varies somewhat.</p>
<h2>Constant load level</h2>
<div id="attachment_187" class="wp-caption alignright" style="width: 160px"><a href="http://codeforhire.files.wordpress.com/2013/04/load-10-15-20.png"><img class="size-thumbnail wp-image-187" alt="Micro instance 10% / 15% / 20% load" src="http://codeforhire.files.wordpress.com/2013/04/load-10-15-20.png?w=150&#038;h=112" width="150" height="112" /></a><p class="wp-caption-text">Micro instance 10% / 15% / 20% load</p></div>
<p>Another interesting matter is how much constant load you can provide a micro instance without it throttling.  This plot shows the results for 10%, 15% and 20% load levels.  From this it&#8217;s evident that the 20% load already throttles occasionally, but 15% load does not seem to have significant throttling.</p>
<p>Therefore if your micro instance web server&#8217;s load is going above 15%, you&#8217;re in a danger zone.  Once the throttling starts, response times will spike and requests may start piling up.</p>
<p>This limit is also evident when summing up the total CPU time obtained during the 10 minute tests.  From 20% load to 100% load the program got approximately the same amount of CPU time during the test, but for 10% and 15% it utilized less processing time than was available from the VM.</p>
<p>Another result of this is that if you have to do long processing on a micro instance, it&#8217;s approximately the same whether you hog up all the CPU you get, or slow down the processing yourself.</p>
<h2>Conclusions</h2>
<p>Micro instances are well suited for uses where there is little constant load.  A constant load level of 15% can be sustained indefinitely without CPU throttling.  However, it&#8217;s good to remember that if you&#8217;re constantly using all of your allotted CPU time, you may be throttled very quickly in CPU-intensive bursts.</p>
<p>During throttling, the available CPU is between 10-50% of the normal peak power.  The higher the load, the more aggressive the throttling.  With full load, you only get full power for about 10 seconds every 2 minutes, and 11% CPU time otherwise.</p>
<p>For long CPU-intensive tasks (lasting several minutes) it doesn&#8217;t matter whether you use all the CPU you get or regulate it, the task will take as long to finish anyhow.</p>
<p>Keep in mind, these are results for a single micro instance type in a single region.  Amazon doesn&#8217;t specify that the rules are the same everywhere.  They may even change according to the time of day and other region activity.  YMMV.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeforhire.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeforhire.wordpress.com/185/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=185&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeforhire.com/2013/04/11/benchmarking-amazon-micro-instances/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ac67d035cc08c4fe3a7ab9825f95b47a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samponiskanen</media:title>
		</media:content>

		<media:content url="http://codeforhire.files.wordpress.com/2013/04/load-100.png?w=150" medium="image">
			<media:title type="html">Micro instance 100% load</media:title>
		</media:content>

		<media:content url="http://codeforhire.files.wordpress.com/2013/04/load-75.png?w=150" medium="image">
			<media:title type="html">Micro instance 75% load</media:title>
		</media:content>

		<media:content url="http://codeforhire.files.wordpress.com/2013/04/load-50.png?w=150" medium="image">
			<media:title type="html">Micro instance 50% load</media:title>
		</media:content>

		<media:content url="http://codeforhire.files.wordpress.com/2013/04/load-25.png?w=150" medium="image">
			<media:title type="html">Micro instance 25% load</media:title>
		</media:content>

		<media:content url="http://codeforhire.files.wordpress.com/2013/04/load-20.png?w=150" medium="image">
			<media:title type="html">Micro instance 20% load</media:title>
		</media:content>

		<media:content url="http://codeforhire.files.wordpress.com/2013/04/load-15.png?w=150" medium="image">
			<media:title type="html">Micro instance 15% load</media:title>
		</media:content>

		<media:content url="http://codeforhire.files.wordpress.com/2013/04/load-10.png?w=150" medium="image">
			<media:title type="html">Micro instance 10% load</media:title>
		</media:content>

		<media:content url="http://codeforhire.files.wordpress.com/2013/04/load-10-15-20.png?w=150" medium="image">
			<media:title type="html">Micro instance 10% / 15% / 20% load</media:title>
		</media:content>
	</item>
		<item>
		<title>The Gimp is dead, long live the Gimp!</title>
		<link>http://codeforhire.com/2013/01/19/the-gimp-is-dead-long-live-the-gimp/</link>
		<comments>http://codeforhire.com/2013/01/19/the-gimp-is-dead-long-live-the-gimp/#comments</comments>
		<pubDate>Sat, 19 Jan 2013 17:15:58 +0000</pubDate>
		<dc:creator>Sampo N.</dc:creator>
				<category><![CDATA[Gimp]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[brushes]]></category>
		<category><![CDATA[Gimp 2.8]]></category>
		<category><![CDATA[saving]]></category>

		<guid isPermaLink="false">http://codeforhire.com/?p=168</guid>
		<description><![CDATA[I have been an avid user of the Gimp for well over a decade now. I started using it in the mid 90&#8242;s around version 0.60.  I was promoting it to my friends as a great image manipulation tool, and &#8230; <a href="http://codeforhire.com/2013/01/19/the-gimp-is-dead-long-live-the-gimp/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=168&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I have been an avid user of the Gimp for well over a decade now. I started using it in the mid 90&#8242;s around version 0.60.  I was promoting it to my friends as a great image manipulation tool, and recall laughing at PhotoShop that had only one level of undo at the time.</p>
<p>During that time Gimp evolved fast.  I anticipated every next release, and each one seemed to get closer to the functional level of PhotoShop.  Somewhere around version 1.2 &#8211; at least from my perspective &#8211; the only major deficiencies were lack of 16-bit color and CMYK support.</p>
<p>But then the development slowed down.  Major releases have been coming out every 1-3 years, but I haven&#8217;t noticed much change between them.  16-bit support and CMYK would be supported by GEGL, the do-it-all graphics library of the next-generation Gimp.  GEGL&#8217;s first release was in 2000, and Gimp has yet to see 16-bit support.</p>
<p>For many years now I have considered the Gimp to be at a dead end.  I have the utmost respect for the people who have worked &#8211; and still work &#8211; on it, and I use Gimp regularly.  But it seemed that to pull the next big thing into Gimp was too large an undertaking for a volunteer project.</p>
<h1>Gimp 2.8</h1>
<p>When I <a href="http://codeforhire.com/2013/01/19/switching-to-linux-mint/">upgraded to Linux Mint</a> and launched Gimp, I was in for a surprise.  After four years of development (think about it &#8211; that&#8217;s when Obama was first elected) Gimp 2.8 had been released.</p>
<p>My first reaction was that of disgust.  I couldn&#8217;t do anything in it.  Saving files was a pain, and even the standard brushes had been removed.  After cursing about it a while, I started looking around for a reason why these stupid changes had been made.</p>
<h3>Ctrl+E is the new Ctrl+S</h3>
<p>I came across the article <a href="http://libregraphicsworld.org/blog/entry/gimp-2.8-understanding-ui-changes">GIMP 2.8: understanding UI changes</a>.  I recommend every Gimp user reads it.  It explains the rationale the changes have been made, and even offers a simple &#8220;fix&#8221; to change the behavior to what it was earlier.  Even though I was looking for such a solution, after reading the article I decided to leave it as it was.</p>
<p>In Gimp 2.8 you essentially can have two &#8220;save files&#8221; at the same time, one XCF file and one export file (PNG, JPG, etc).  Ctrl+S saves the XCF file, Ctrl+E saves the export file.  Using Ctrl+Shift will prompt for the file (Save as, Export as).  Once you get used to this, it does save a lot of hassle.  You can independently save the original XCF and export a file to be used outside.  When you do changes, you don&#8217;t have to worry about remembering to save both the exported and original versions.</p>
<h3>Brush on the world</h3>
<p>The other thing I was missing was the 1px, 3px, 5px, etc. brushes from the old Gimp versions.  After creating several new brushes for the purpose, I found out that these have been changed to a &#8220;Size&#8221; parameter in the tool options.  Now all brushes are resizable from one place.</p>
<p>One gripe still is that the size control slider is very hard to use precisely with small brushes.  I often work with brushes below 10px in size, and controlling the size using a linear slider than goes up to 1000px is not very user-friendly.  However, according to the UI change article, the tool options are going to have an overhaul soon as well.</p>
<p>Gimp 2.8 also has a number of other nice changes, such as expressions in entry fields (how often have you whipped open a calculator to divide a size?  Now just type &#8220;1234/3&#8243;), layer groups, and single window mode with image tabs.</p>
<h1>The future</h1>
<p>Looking past 2.8, the Gimp core has <a href="http://jcornuz.wordpress.com/2012/06/02/the-day-goats-invaded-the-gimp/">finally been ported to use GEGL</a> by a hero effort of Øyvind Kolås and Mike Natterer.  This means that after waiting 15 years, Gimp 2.10 will finally have 16-bit color support.  Hooray!</p>
<p>The important question is, when will 2.10 be released?  Martin Nordholts has written about <a href="http://www.chromecode.com/2011/02/why-gimp-28-is-not-released-yet.html">the problems in Gimp development cycles</a>.  He states many of the problems that I have pondered and struggled with during <a href="http://openrocket.sourceforge.net/">OpenRocket</a> development.  Gimp 2.10 development will utilize more feature branches, which are merged to the master branch only once they&#8217;re ready, so as not to hinder the release of other features.  This will hopefully allow more regular feature releases and more motivation for new developers to jump in.</p>
<p>I have yet to explore many of the features in 2.8, but for the first time in a long time I have a heightened sense of excitement about Gimp.  There is finally clear and undeniable improvement happening.</p>
<p>Finally, I have to restate my admiration at the people who have made Gimp a reality, from its early stages and through its troublesome times.  A huge thanks to you all, and hoping for a great 2.10 development cycle.  I am rooting for you once again!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeforhire.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeforhire.wordpress.com/168/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=168&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeforhire.com/2013/01/19/the-gimp-is-dead-long-live-the-gimp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ac67d035cc08c4fe3a7ab9825f95b47a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samponiskanen</media:title>
		</media:content>
	</item>
		<item>
		<title>Switching to Linux Mint</title>
		<link>http://codeforhire.com/2013/01/19/switching-to-linux-mint/</link>
		<comments>http://codeforhire.com/2013/01/19/switching-to-linux-mint/#comments</comments>
		<pubDate>Sat, 19 Jan 2013 14:30:12 +0000</pubDate>
		<dc:creator>Sampo N.</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux Mint]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[ALSA]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[Cinnamon]]></category>
		<category><![CDATA[Full Disk Encryption]]></category>
		<category><![CDATA[Mate]]></category>
		<category><![CDATA[printer]]></category>
		<category><![CDATA[ThinkPad T430s]]></category>

		<guid isPermaLink="false">http://codeforhire.com/?p=107</guid>
		<description><![CDATA[This is a description of my migration from Ubuntu to Linux Mint 14.  As this was my work laptop, there are some additional requirements that need to be met by the system.  In particular, I review: Configurability and ease of &#8230; <a href="http://codeforhire.com/2013/01/19/switching-to-linux-mint/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=107&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This is a description of my migration from Ubuntu to Linux Mint 14.  As this was my work laptop, there are some additional requirements that need to be met by the system.  In particular, I review:</p>
<ul>
<li>Configurability and ease of use</li>
<li>Hardware support for a ThinkPad T430s</li>
<li>Printer and display configuration</li>
<li>Full disk encryption</li>
<li>Running Windows in VirtualBox</li>
</ul>
<p><span id="more-107"></span></p>
<h2>Background</h2>
<p>In the beginning there was Slackware<a href="#note1">*</a>.  And the spirit of Slackware was <tt style="font-size:smaller;background:#eee;">emacs Makefile; make; make install</tt>.  Then came Debian, with vast repositories of software waiting to be installed.  Finally, there was Ubuntu, which combined the vastness of the repositories with &#8220;it just works&#8221;.</p>
<p>At least a few years ago.  I was originally really impressed in Ubuntu at how things just magically worked.  For the first time, I could plug in a printer and seconds later print out a document.  Specifically, I&#8217;ve been using XUbuntu, as it was easier to configure to my taste.</p>
<p>But as years passed, Ubuntu became stagnant.  Versions came and went, and nothing turned to the better.  On the contrary, quite often a new release would break something in my system, and I started postponing upgrading.  Therefore I started looking for an alternative.</p>
<h2>Mate vs. Cinnamon</h2>
<p>Many sites recommended Linux Mint as an alternative to Ubuntu.  When I got a new work laptop, I decided to try Mint out.  The problem was:  Mate or Cinnamon?</p>
<p>Both versions are provided equally on the site, without any proper description of the differences.  I wasn&#8217;t able to find any proper reviews either.  Therefore I loaded both on USB sticks and tested them out.</p>
<p>I initially tested &#8211; and finally decided to use &#8211; Cinnamon.  Cinnamon provides a nice amount of eye candy out of the box, while Mate doesn&#8217;t sport much.  My laptop has ample power, so there&#8217;s no reason not to have a bit of eye candy when opening and closing windows.  I also liked the &#8220;hot corner&#8221; desktop switcher.  When you hit the upper-left corner with your mouse, you&#8217;re presented with a view of your workspaces to switch to.  The menu also seemed a bit nicer, but that&#8217;s purely a matter of preference.</p>
<p>Cinnamon also seemed to sport a touch more of &#8220;it just works&#8221;.  One particular case was that after pairing my phone via Bluetooth, the dialog had an option to create a network connection using it.  It worked immediately &#8211; or at least after I figured out I have to enable it on my phone as well.</p>
<p>Cinnamon also had the option of switching desktops using edge flipping with the mouse.  This is a feature I&#8217;ve used and loved since the mid-90&#8242;s, and it&#8217;s hard to live without it anymore.  I couldn&#8217;t find such an option in Mate.  The problem was that the edge flip delay was fixed at ~2 seconds, which is waaay to long for my taste &#8211; I want the flip to be instantaneous.  After asking around without answer, I checked out the source code and there it was, hard-coded.  I added the option for configuring the delay and issued <a href="https://github.com/linuxmint/Cinnamon/pull/1537">a pull request</a> &#8211; hopefully the next version will have it built-in.</p>
<p>The bottom line is, you&#8217;ll be fine with either.  Test both, and see which one seems to tickle your fancy more.</p>
<h2>Hardware support</h2>
<p>The out-of-the-box experience was amazing.  Everything was automatically configured and just worked.  Sounds were fine, Bluetooth was functioning, brightness and volume controls functioned with a nice OSD showing, even the play/forward/back buttons work in Banshee.  The network options also list the built-in GSM modem, and while I haven&#8217;t been able to test it for the lack of a SIM card, it looks promising.</p>
<p>In contrast, in XUbuntu, I haven&#8217;t even seen the Bluetooth icon for several years, let alone been able to pair something it with&#8230;</p>
<p>But my joy was a bit premature.  While audio worked out-of-the-box, it soon stopped functioning.  Music players worked fine, but no audio to the speakers.  However, if I plugged in earphones it played fine.  I tried fiddling with the sound configuration to no avail.</p>
<p>After googling around I found instructions on <a href="http://www.alsa-project.org/main/index.php/Help_To_Debug_Intel_HDA#.27model.27_parameter">a &#8216;model&#8217; parameter</a> needed for the sound driver on some systems.  The codec in my Thinkpad T430s is a Realtek ALC269VC, for which <a href="http://git.alsa-project.org/?p=alsa-kernel.git;a=blob;f=Documentation/sound/alsa/HD-Audio-Models.txt;hb=HEAD">six different model parameters</a> are listed.  After iterating a few times, I finally found that I needed to add the following line to /etc/modprobe.d/alsa-base.conf:</p>
<pre>options snd-hda-intel model=laptop-dmic</pre>
<p>So while everything looked good at first, some mojo was needed to fix the sound support after all.  I would have reported this to the ALSA team, but every link to their bug tracking system is dead.  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<h2>Displays and printers</h2>
<p>When you plug an external display to the laptop, it&#8217;s detected within a few seconds and the desktop is spanned across both displays by default.  Hitting Fn+F7 switches between the standard laptop-only, monitor-only, extended display and cloned display modes.  There is no dialog for selecting the mode like in XUbuntu, but it works.  Resolutions and orientation can easily be configured from the settings, but mostly it just works directly.</p>
<p>Adding printers is also delightful.  From clicking the &#8220;Add printer&#8221; button it takes a whole two clicks to add a network printer.  USB printers are even easier:  plug it in and wait a few seconds.  But&#8230;</p>
<p>When the printer works, everything is great.  When it doesn&#8217;t, the configuration utility in Linux Mint is useless.  You cannot configure anything in it.  However after some exploration I found out that the printer configuration utility for Ubuntu was also installed, it just wasn&#8217;t present in the menus.  You need to launch is separately with &#8220;<tt>system-config-printer</tt>&#8220;.  Time for <a href="http://community.linuxmint.com/tutorial/view/1200">another tutorial</a>.</p>
<h2>Full disk encryption</h2>
<p>Since this was my work machine, full disk encryption (FDE) was an important requirement.  The Linux Mint 14 installer unfortunately does not support FDE, though it does offer home-directory encryption.  However, a <em>newer version</em> of the installer <em>does</em> support FDE.  The development team just wasn&#8217;t satisfied with something in the new installer and it was dropped from the official release.</p>
<p>Thus, in order to get full disk encryption in Linux Mint 14, boot the desktop from a USB stick, then in a terminal run the following commands:</p>
<pre>$ sudo apt-get remove ubiquity
$ sudo apt-get update
$ sudo apt-get install ubiquity
$ sudo ubiquity</pre>
<p>This will upgrade the installer and then launch it, and you have the option for full disk encryption.</p>
<p><em>Note:  Originally I tried getting FDE to work following the <a href="http://community.linuxmint.com/tutorial/view/344">Full Disk Encryption easy HOWTO</a> instructions, but while I was able to complete all the steps, the system wouldn&#8217;t boot.  I wrote <a href="http://community.linuxmint.com/tutorial/view/1166">a new tutorial</a> on the subject.<br />
</em></p>
<h2>Running Windows 7 in VirtualBox</h2>
<p>As my work machine, I occasionally have the need to use Windows.  (If for nothing else, to see if a web design works in IE.)  Therefore I wanted to set up a virtual Windows image within Linux.</p>
<p>Before installing Linux, I made a VMware image of the default Windows installation using <a href="http://www.vmware.com/products/converter/overview.html">VMware vCenter Converter</a>.  However, I never needed it.  The preinstalled version contained a lot of junk software and drivers unnecessary in a virtualized environment, so I preferred to install Windows from scratch.</p>
<p>I preferred trying VirtualBox, as it&#8217;s open source.  I <a href="http://www.w7forums.com/official-windows-7-sp1-iso-image-downloads-t12325.html">downloaded the proper ISO image</a>, attached it to the new virtual image and booted it up.  Installation went smoothly, however the network connection didn&#8217;t work.  This was an issue with the version bundled with Linux Mint 14.  I upgraded to the latest version by adding</p>
<pre>deb http://download.virtualbox.org/virtualbox/debian precise contrib</pre>
<p>to the software sources and then using</p>
<pre>sudo apt-get install virtualbox-4.2=4.2.4-81684~Ubuntu~precise</pre>
<p>to force installation of the proper version.</p>
<p>After this the system worked fine and I was able to register the Windows copy using the license key provided with the laptop.  YMMV &#8211; take care when using your license key on an installation it wasn&#8217;t originally intended for.</p>
<p>I have had some problems with USB usage within the virtual system.  For example, when trying to install printer drivers in Windows, it did see the printer and try to install drivers (which Windows doesn&#8217;t support out-of-the-box), but when I manually tried to install the drivers, it couldn&#8217;t find the printer.  If USB usage from the virtual machine is important to you, I suggest to test it before committing to either VirtualBox or VMware.</p>
<h2>Final thoughts / gripes</h2>
<p>Linux Mint is an amazing distribution, which brings &#8220;it just works&#8221; to a new level and a very comfortable desktop to boot.  An interesting comparison is <a href="http://www.google.com/trends/explore#q=linux%20mint%2Cubuntu" target="_blank">Linux Mint vs. Ubuntu</a> in Google Trends.  While Ubuntu still trumps search volume 15-to-1 over Linux Mint, Ubuntu has been in decline for almost five years now, while Linux Mint is steadily gathering ground.</p>
<p>Nonetheless, there is still some polishing to do, some issues with hardware support and some gripes in the way:</p>
<ul>
<li>Full disk encryption was a bit of a pain to set up, but the good news is that it will probably be just a tick box away in the next installer.</li>
<li>Sound driver caused some headache before I could figure how to get it working.</li>
<li>The default printer setup doesn&#8217;t allow any configuration if the printer doesn&#8217;t work automatically.  You need to use a separate configuration utility for this purpose.</li>
<li>The VirtualBox version that comes with Linux Mint 14 is outdated.</li>
<li>While the Cinnamon desktop has excessive configurability in some areas, some places are minutely lacking.  In my case, configuring the workspace edge flip delay.</li>
</ul>
<div id="attachment_120" class="wp-caption aligncenter" style="width: 410px"><a href="http://codeforhire.com/2013/01/19/switching-to-linux-mint/cinnamon-config/" rel="attachment wp-att-120"><img class=" wp-image-120    " title="Cinnamon 'Effects' configuration dialog" alt="Cinnamon 'Effects' configuration dialog" src="http://codeforhire.files.wordpress.com/2012/12/cinnamon-config.png?w=400&#038;h=290" width="400" height="290" /></a><p class="wp-caption-text">Who needs this much configurability for window effects?</p></div>
<address id="note1">* I&#8217;m aware that there were distributions before Slackware, but that was the first one I used.</address>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeforhire.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeforhire.wordpress.com/107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=107&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeforhire.com/2013/01/19/switching-to-linux-mint/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ac67d035cc08c4fe3a7ab9825f95b47a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samponiskanen</media:title>
		</media:content>

		<media:content url="http://codeforhire.files.wordpress.com/2012/12/cinnamon-config.png?w=300" medium="image">
			<media:title type="html">Cinnamon &#039;Effects&#039; configuration dialog</media:title>
		</media:content>
	</item>
		<item>
		<title>No-nonsense ASCII chart</title>
		<link>http://codeforhire.com/2012/12/28/no-nonsense-ascii-chart/</link>
		<comments>http://codeforhire.com/2012/12/28/no-nonsense-ascii-chart/#comments</comments>
		<pubDate>Fri, 28 Dec 2012 19:49:09 +0000</pubDate>
		<dc:creator>Sampo N.</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[ASCII]]></category>

		<guid isPermaLink="false">http://codeforhire.com/?p=139</guid>
		<description><![CDATA[There are a lot of ASCII charts floating around the Internet.  However all of them seem to have a few fundamental problems:  They include the whole ASCII set in the chart and cram too much information of each char, making &#8230; <a href="http://codeforhire.com/2012/12/28/no-nonsense-ascii-chart/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=139&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>There are a lot of ASCII charts floating around the Internet.  However all of them seem to have a few fundamental problems:  They include the whole ASCII set in the chart and cram too much information of each char, making the chart illegible.  What I want is a clean, readable chart that I can glance at from a distance.</p>
<p>Therefore I made my own, the No-nonsense ASCII chart.  It features:</p>
<ul>
<li>the hex code and character, easily legible from two meters away</li>
<li>the decimal code, since this is occasionally needed</li>
<li>only the control characters I have ever heard about  (NUL excluded &#8211; everyone knows that anyway)</li>
<li>numbers and letters as a range, not individually printed out</li>
<li>no nonsense</li>
</ul>
<p>The chart is available in PDF and OpenDocument formats sized for A4 and Letter.  It&#8217;s licensed as <a title="Creative Commons Attribution 3.0 Unported License" href="http://creativecommons.org/licenses/by/3.0/deed.en_US" target="_blank">CC-BY</a>.  Customize as you will.</p>
<ul>
<li><a href="https://github.com/plaa/ASCII-chart/blob/master/ASCII%20chart%20(A4).pdf?raw=true">ASCII chart (A4).pdf</a></li>
<li><a href="https://github.com/plaa/ASCII-chart/blob/master/ASCII%20chart%20(A4).odt?raw=true">ASCII chart (A4).odt</a></li>
<li><a href="https://github.com/plaa/ASCII-chart/blob/master/ASCII%20chart%20(Letter).pdf?raw=true">ASCII chart (Letter).pdf</a></li>
<li><a href="https://github.com/plaa/ASCII-chart/blob/master/ASCII%20chart%20(Letter).odt?raw=true">ASCII chart (Letter).odt</a></li>
</ul>
<p>I recommend highlighting the most often used characters with a yellow highlighting pen (for web developers %, &amp;, ? and =).</p>
<p style="text-align:center;"><a href="https://github.com/plaa/ASCII-chart/blob/master/ASCII%20chart%20(A4).pdf?raw=true" rel="attachment wp-att-150"><img class="aligncenter  wp-image-150" alt="ASCII chart" src="http://codeforhire.files.wordpress.com/2012/12/ascii-chart1.png?w=596&#038;h=421" width="596" height="421" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeforhire.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeforhire.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=139&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeforhire.com/2012/12/28/no-nonsense-ascii-chart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ac67d035cc08c4fe3a7ab9825f95b47a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samponiskanen</media:title>
		</media:content>

		<media:content url="http://codeforhire.files.wordpress.com/2012/12/ascii-chart1.png" medium="image">
			<media:title type="html">ASCII chart</media:title>
		</media:content>
	</item>
		<item>
		<title>Android Torture</title>
		<link>http://codeforhire.com/2012/12/12/android-torture/</link>
		<comments>http://codeforhire.com/2012/12/12/android-torture/#comments</comments>
		<pubDate>Wed, 12 Dec 2012 04:13:12 +0000</pubDate>
		<dc:creator>Sampo N.</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[Samsung Galaxy S3]]></category>

		<guid isPermaLink="false">http://codeforhire.com/?p=84</guid>
		<description><![CDATA[Okay, this is my first rant post.  It&#8217;s 5:30 in the morning and I&#8217;m writing a blog post thanks to my new-and-shiny Samsung Galaxy S3. I was recently force-upgraded from my Nokia E7 because its USB-adapter broke off &#8211; again.  &#8230; <a href="http://codeforhire.com/2012/12/12/android-torture/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=84&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Okay, this is my first rant post.  It&#8217;s 5:30 in the morning and I&#8217;m writing a blog post thanks to my new-and-shiny Samsung Galaxy S3.</p>
<p>I was recently force-upgraded from my Nokia E7 because its USB-adapter broke off &#8211; again.  Long story short, I&#8217;m now adapting to life as a new Android user.</p>
<p>One of the most frustrating things immediately visible is how every application on the device believes it&#8217;s the center of the universe craving for attention.  Even though I haven&#8217;t installed many apps, my notification board is often crammed with stuff.  Right out of the box the phone had started beeping to the beat of incoming email, and it took me quite a while to figure out how to turn it off.</p>
<p>But tonight has been a nightmare.</p>
<p>At around 4 AM the phone bleeped.  I probably hardly stirred.  Then it bleeped again.  And again.  And again.  Slowly but surely it was wrenching me from sleep.</p>
<p>I tried ignoring it.  It was rare, maybe once every 5-10 minutes.  But each time I was just falling asleep, it bleeped again.  And again.  It was the electronic form of water torture.</p>
<p>Finally, after about an hour of futile resistance, I succumbed to the device&#8217;s will.  I opened it and found a Facebook notification.  I had just last evening installed the Facebook app, and figured it was causing the havoc &#8211; though I have only 1-2 friends abroad that should be awake at this hour.  I browsed through the app settings and turned notifications off, thinking I had slain the monster, and went back to sleep.  And then it bleeped again.</p>
<p>I recalled seeing some options for preventing notifications in the general settings, so I started scanning the menus.  I finally found the Blocking mode, turned it on, and configured it to block all notifications and the LED indicator.  For good measure I set the phone to vibration &#8211; I was afraid that muting it would mute the alarm I had set for the morning.  And then it vibrated.</p>
<p>At this point I was ready to drop the phone in a glass of water had it only fit in.</p>
<p>I was unsure was it a fluke.  As time passed I was starting to doubt myself that had I just dreamed it.  I turned sounds back on just in case there was some weird vibration alerts.  Time passed, and I was finally confident that the beast had been silenced and I tried frantically to get back to sleep.  <strong>And then it bleeped again.</strong></p>
<p>Had this been my trusty Nokia, I would have turned it off an hour ago, confident in the fact that it will wake me up even if it&#8217;s turned off.  Hell, a Nokia phone will sound the alarm <em>even if it has run out of battery during the night!</em>  That&#8217;s bloody engineering!</p>
<p>Now I&#8217;m up, sure that I won&#8217;t get any more sleep tonight and knowing it will be a long day ahead.  I&#8217;m already panicking about what will happen tomorrow night, will the torture ensue again.  Maybe I have to go buy an alarm clock&#8230;</p>
<p><strong>Post-mortem:</strong></p>
<ul>
<li>I still have no idea what caused the bleeping during the night.  My best guess is that something in the charger or charging logic got screwed up and it starting notifying of a full battery every 5-10 minutes.</li>
<li>I have had the phone multiple times emit varying beep noises, without any indication of what caused it.  It has a life of its own.</li>
<li>A timed blocking mode seems to prevent unnecessary beeping during the night time.</li>
<li>I verified that the Samsung will <em>not</em> wake you up if it&#8217;s turned off.  So much for conserving battery when you&#8217;re in a tight spot.  Similarly if you forget to plug the phone in when going to sleep and the battery runs out, you&#8217;re screwed.</li>
<li>I found out that it <em>will</em> sound the alarm even if the device is set to mute.  I&#8217;m torn on this one &#8211; it would have saved me a night&#8217;s sleep, but I&#8217;d really want a button that ensures the phone will stay quiet no matter what.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeforhire.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeforhire.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=84&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeforhire.com/2012/12/12/android-torture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ac67d035cc08c4fe3a7ab9825f95b47a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samponiskanen</media:title>
		</media:content>
	</item>
		<item>
		<title>Documenting Cucumber steps</title>
		<link>http://codeforhire.com/2012/12/08/documenting-cucumber-steps/</link>
		<comments>http://codeforhire.com/2012/12/08/documenting-cucumber-steps/#comments</comments>
		<pubDate>Sat, 08 Dec 2012 15:46:57 +0000</pubDate>
		<dc:creator>Sampo N.</dc:creator>
				<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[ATDD]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://codeforhire.com/?p=64</guid>
		<description><![CDATA[One of the great things in Cucumber testing is that as you go along, you start to accumulate ready step definitions, which makes writing new tests even faster.  Several times I&#8217;ve actually been surprised that a definition for a step &#8230; <a href="http://codeforhire.com/2012/12/08/documenting-cucumber-steps/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=64&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>One of the great things in Cucumber testing is that as you go along, you start to accumulate ready step definitions, which makes writing new tests even faster.  Several times I&#8217;ve actually been surprised that a definition for a step I wrote already existed and worked as I expected it to.</p>
<p>However, I noticed that developers in our project were also writing duplicate step definitions, because they didn&#8217;t know the definition already existed with a different name.  We defined some scenario writing guidelines and nomenclature to be used, which helped somewhat.  Still, in the mass of test code it was often hard to find whether the step you needed already existed.</p>
<p>Things like <a href="https://github.com/BBC-News/wally">Wally</a> and <a href="https://www.relishapp.com/">Relish</a> are great for converting the feature files into pretty documentation, but I couldn&#8217;t find anything similar for the step definitions themselves.  So I wrote my own:  <strong><a href="https://github.com/plaa/cuke-steps">cuke-steps</a></strong></p>
<p>The script parses the step definition files and generates a single page document containing all the step definitions it finds, in a pretty-printed fashion.  By clicking on any definition you can see the file and row number where the definition is and the code for the step.</p>
<p>Originally I wrote the script to create Confluence wiki markup.  We have a Jenkins job run every night that generates the documentation and pushes it into our wiki using the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Confluence+Publisher+Plugin">Confluence Publisher Plugin</a>.  I wrote a simple HTML outputter when publishing the script.  You can check out <a href="http://pastehtml.com/view/ckzm1o245.html" target="_blank">a sample output page</a> generated from Alister Scott&#8217;s <a href="https://github.com/alisterscott/wmf-custom-page-object">wmf-custom-page-object</a>.</p>
<p>There&#8217;s still some work to be done, like prettifying the HTML output, creating a gem out of it and making it link directly to a source repo.  Any updates are appreciated.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeforhire.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeforhire.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=64&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeforhire.com/2012/12/08/documenting-cucumber-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ac67d035cc08c4fe3a7ab9825f95b47a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samponiskanen</media:title>
		</media:content>
	</item>
		<item>
		<title>Dump World on failure</title>
		<link>http://codeforhire.com/2012/10/07/dump-world-on-failure/</link>
		<comments>http://codeforhire.com/2012/10/07/dump-world-on-failure/#comments</comments>
		<pubDate>Sun, 07 Oct 2012 15:45:58 +0000</pubDate>
		<dc:creator>Sampo N.</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[ATDD]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[debuging]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://codeforhire.com/?p=43</guid>
		<description><![CDATA[One of the most important aspects of test reports is that when something fails, you can easily debug what went wrong.  Splitting tests into logical, small tests that exercise a single functionality in the system goes a long way toward &#8230; <a href="http://codeforhire.com/2012/10/07/dump-world-on-failure/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=43&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>One of the most important aspects of test reports is that when something fails, you can easily debug what went wrong.  Splitting tests into logical, small tests that exercise a single functionality in the system goes a long way toward this goal.  Inevitably, you still occasionally get a weird failure where you have no idea what&#8217;s going wrong.</p>
<p>In such circumstances it&#8217;s vital to have sufficient information included in the test report to understand what happened — otherwise you&#8217;re stuck trying to do an autopsy without a corpse.  When running Cucumber tests, we have found that a dump of the World is often extremely useful information.</p>
<p>The following piece of code does just that.  Whenever a Cucumber scenario fails, it dumps the contents of the World to the console:</p>
<pre class="brush: ruby; title: ; notranslate">
After do |scenario|
  if scenario.failed?
    Kernel.puts &quot;Scenario failed, world contents:&quot;
    vars = self.instance_variables.select { |v| !v.to_s.include?(&quot;__&quot;) }
    vars.sort.each do |v|
      value = instance_variable_get(v)
      Kernel.puts &quot;    #{v}=#{value}&quot;
    end
  end
end
</pre>
<p>This iterates through the variables and writes them out one by one.  The <code>select</code> statement on line 4 filters out some Cucumber-specific variables stored in the World.</p>
<p>You can easily customize this to output elsewhere (we&#8217;ve found <code>Kernel.puts</code> to be the most reliable way to get the info out) or how to output certain data types.  For example, we use the <a href="https://github.com/archiloque/rest-client" target="_blank">rest_client</a> gem extensively, so we&#8217;ve customized the hook to detect the response object and to output <code>value.code</code>, <code>value.headers</code> and <code>value.body</code> in that case.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeforhire.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeforhire.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=43&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeforhire.com/2012/10/07/dump-world-on-failure/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ac67d035cc08c4fe3a7ab9825f95b47a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samponiskanen</media:title>
		</media:content>
	</item>
		<item>
		<title>API testing with Cucumber</title>
		<link>http://codeforhire.com/2012/09/24/api-testing-with-cucumber/</link>
		<comments>http://codeforhire.com/2012/09/24/api-testing-with-cucumber/#comments</comments>
		<pubDate>Mon, 24 Sep 2012 21:07:04 +0000</pubDate>
		<dc:creator>Sampo N.</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[ATDD]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[REST API]]></category>

		<guid isPermaLink="false">http://codeforhire.wordpress.com/?p=5</guid>
		<description><![CDATA[In our project we have a REST API using JSON that is used both internally by our mobile clients and offered externally to third parties.  Since we were consolidating all functional testing to Cucumber, it was natural to experiment what &#8230; <a href="http://codeforhire.com/2012/09/24/api-testing-with-cucumber/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=5&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In our project we have a REST API using JSON that is used both internally by our mobile clients and offered externally to third parties.  Since we were consolidating all functional testing to Cucumber, it was natural to experiment what would be the best way to test API&#8217;s in Cucumber.</p>
<p>The common first instinct is to write out the requests, payload and response expectations directly in the feature files.  After all, a major point of Cucumber and ATDD is specification by example.  The problem is that this results in very verbose descriptions that are hard to follow.</p>
<p>Consider the following example given in the <a href="https://github.com/collectiveidea/json_spec">json_spec</a> gem:</p>
<pre class="brush: plain; title: ; notranslate">
Feature: User API
  Scenario: Index action includes full user JSON
    Given the following user exists:
      | id | first_name | last_name |
      | 1  | Steve      | Richert   |
    And I visit &quot;/users/1.json&quot;
    And I keep the JSON response as &quot;USER_1&quot;
    When I visit &quot;/users.json&quot;
    Then the JSON response should be:
      &quot;&quot;&quot;
      [
        %{USER_1}
      ]
      &quot;&quot;&quot;
</pre>
<p>Consider that for a moment.  Do you understand what&#8217;s happening in this use case?  Next imagine giving this over to your business owner for a feature review.</p>
<p>One of the goals of Cucumber and specification by example is to provide a common language between developers and business. The above example contains so much detail that the intent of the use case is lost.  The code reminds me a lot of an example that Aslak Hellesøy gave of using the <a title="The training wheels came off" href="http://aslakhellesoy.com/post/11055981222/the-training-wheels-came-off"><code>web_steps.rb</code> &#8220;training wheels&#8221;</a> originally included in the <a href="https://github.com/cucumber/cucumber-rails">Cucumber-Rails</a> gem:</p>
<pre class="brush: plain; title: ; notranslate">
Scenario: Successful login
  Given a user &quot;Aslak&quot; with password &quot;xyz&quot;
  And I am on the login page
  And I fill in &quot;User name&quot; with &quot;Aslak&quot;
  And I fill in &quot;Password&quot; with &quot;xyz&quot;
  When I press &quot;Log in&quot;
  Then I should see &quot;Welcome, Aslak&quot;
</pre>
<p>This kind of detail should be abstracted out of the scenarios into higher-level steps and by use of <a href="http://watirmelon.com/2012/06/04/roll-your-own-page-objects/">page objects</a>.  Such refactoring makes the tests read better and much less brittle.</p>
<p>So if you don&#8217;t write explicit operations, what do you write?  Consider what a business owner would write as individual requirements.  Describe the intent of the API, not the explicit details.</p>
<p>I came up with a quite nice format in which to write the API tests.  As an example of registration:</p>
<pre class="brush: plain; title: ; notranslate">
Scenario:  Successful registration
   When I perform registration with the required parameters
   Then the request should be successful
    And I should receive a valid access token
</pre>
<p>This describes the essential functionality of the API, without any of the gory details.  The corresponding step definitions could be something like:</p>
<pre class="brush: ruby; title: ; notranslate">
When /^I perform registration with the required parameters$/ do
  # Populate request information
  @request_method = &quot;POST&quot;
  @request_url = &quot;/rest/register&quot;
  @request_body = {email: generateEmail, password: &quot;pass123&quot;,
      terms_accepted: true}
  @successful_response_code = 201
  @error_response_code_email_reserved = 409
end

Then /^the request should be successful$/ do
  # Perform the request and assert the response code
  @response = RestApi.call(@request_method, @request_url,
      body: @request_body, expect: @successful_response_code)
end

Then /^I should receive a valid access token$/ do
  # ... test that the token in @response is valid
end
</pre>
<p>The interesting part is that the actions (&#8220;When&#8221;) store fields to the World, and only the post-condition &#8220;Then the request should be successful&#8221; performs the request.  This allows adding more directives that modify the request, resulting in very natural language:</p>
<pre class="brush: plain; title: ; notranslate">
Scenario:  Failed registration; email address in use
   When I perform registration with the required parameters
    But the email address is already reserved
   Then the request should fail due to email reserved
</pre>
<p>Here the step definition for &#8220;But the email address is already reserved&#8221; would either register the email address in <code>@request_body.email</code> or set the email address to something that is known to be reserved.  The corresponding &#8220;should fail&#8221; step expects the response code in <code>@error_response_code_email_reserved</code>.</p>
<p>This approach also abstracts the setting up the request parameters.  When we needed to make a change to the mandatory registration parameters, there was only one method that needed to be changed.</p>
<p>This structure has been a great success in our project.  Very often I&#8217;ve noticed that after having the feature file defined, it takes only 5-10 minutes to implement the steps.  There&#8217;s a lot of step reuse, and often you only need to write the request setup step, and possibly some custom post-condition steps.</p>
<p>One caveat of this approach is that the exact methods, URLs and parameter names are not presented in the feature file, and thus it does not function as documentation on its own.  We have a separate API document, and we&#8217;ve been considering moving the corresponding parts to the free-text description area in the feature files.  This would not be executable specification, but I think it&#8217;s an acceptable compromise.  I feel it more important to keep the scenarios succinct and readable, and thus more maintainable.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeforhire.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeforhire.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeforhire.com&#038;blog=40197096&#038;post=5&#038;subd=codeforhire&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeforhire.com/2012/09/24/api-testing-with-cucumber/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ac67d035cc08c4fe3a7ab9825f95b47a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samponiskanen</media:title>
		</media:content>
	</item>
	</channel>
</rss>
