<?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>Olivier Garcia Is Yet Another Linux Nerd &#187; english</title>
	<atom:link href="http://yet.another.linux-nerd.com/tag/english/feed/" rel="self" type="application/rss+xml" />
	<link>http://yet.another.linux-nerd.com</link>
	<description>m/few grams of( code)? peotry in a world of brute( force&#124;s)/</description>
	<lastBuildDate>Tue, 06 Jul 2010 18:13:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>The iBuildings Test Driven Challenge</title>
		<link>http://yet.another.linux-nerd.com/2010/07/02/ibuildings-test-driven-challenge/</link>
		<comments>http://yet.another.linux-nerd.com/2010/07/02/ibuildings-test-driven-challenge/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 10:00:14 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[Ego]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Opensource]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[contest]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[ibuildings]]></category>
		<category><![CDATA[obfuscation]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://yet.another.linux-nerd.com/?p=55</guid>
		<description><![CDATA[<p>For those who do not know <a href="http://www.ibuildings.com">iBuildings</a>, it is a company based in the Netherlands, England and Italy, which provides consulting services around PHP since 1999. During the last months, they organized contests consisting in writing PHP code with a specific goal. The last contest (ended 30th June 2010) was about creating the smallest class that has to pass tests from a provided PHPUnit file but after a few days, they divided the contest in two categories : one for a class with the lowest amount of lines while being respectful of good practices, and another one for class with the lowest amount of bytes.</p>

<p>I sent entries for both categories, and I'll describe the assumptions I made and the tricks I used for my files.</p>

<a href="http://yet.another.linux-nerd.com/?p=55">Read more...</a>]]></description>
			<content:encoded><![CDATA[<p><span class="drop">F</span>or those who do not know <a href="http://www.ibuildings.com">iBuildings</a>, it is a company based in the Netherlands, England and Italy, which provides consulting services around PHP since 1999. During the last months, they organized contests consisting in writing PHP code with a specific goal. The last contest (ended 30th June 2010) was about creating the smallest class that has to pass tests from a provided PHPUnit file but after a few days, they divided the contest in two categories : one for a class with the lowest amount of lines while being respectful of good practices, and another one for class with the lowest amount of bytes.</p>
<p>I sent entries for both categories, and I&#8217;ll describe the assumptions I made and the tricks I used for my files.</p>
<h2>Version without optimization</h2>
<p>The first thing was to get a class satisfying the various PHP tests provided. If you&#8217;re unfamiliar with the contest, you may look at the <a href="http://pastie.org/1027822">PHPUnit file</a>, with its seven tests for the seven expected functions. The five first functions are quite easy to guess as they are based on : addition, multiplication, square, factorial and the famous <a href="http://en.wikipedia.org/wiki/Fibonacci_number">Fibonnaci numbers</a>. The last two expected functions are a combination of previous ones, and since guessing in a second what the combinations are is not that straightforward, the use of a graph inside a spreadsheet can help (well, it did help me).</p>
<pre class="brush: php;">&lt;?php
class NumberCruncher {

    public function OperationA($v) {
        return $v + 4;
    }

    public function OperationB($v) {
        return $v * 3;
    }

    public function OperationC($v) {
        return $v * $v / 2;
    }

    public function OperationD($v) {
        return $v &gt; 1 ? $v * $this-&gt;OperationD($v - 1) : 1;
    }

    public function OperationE($v) {
        return $v&gt;1?$this-&gt;OperationE($v-1)+$this-&gt;OperationE($v-2):$v;
    }

    public function OperationF($v) {
        return $this-&gt;OperationC($this-&gt;OperationB($v));
    }

    public function OperationG($v) {
        return $this-&gt;OperationD($v) - $this-&gt;OperationE($v);
    }
}</pre>
<h2>Fewer lines</h2>
<p>With several times <span style="font-family: monospace;">public function </span> in it, and the according closing braces, there&#8217;s a way to reduce the number of lines since all functions are called with one argument and are returning a function on that argument.</p>
<p>The use of <a href="http://php.net/eval">eval()</a> is something I try to avoid in my code, but its use here will allow us to significantly reduce the number of lines. The trick is to use the function <a href="http://php.net/manual/en/language.oop5.overloading.php">__call()</a> to intercept calls to functions that have not been declared in the class and return an evaluation of what the functions would have contained.</p>
<p>Of course, since it&#8217;s a contest about having the smallest file, I assume that keeping empty lines or lines with only braces, parenthesis or <span style="font-family: monospace;">array(</span> is no option (requiring participants to <a href="http://pear.php.net/package/PHP_CodeSniffer/">use a particular naming/formating convention</a> such as <a href="http://framework.zend.com/manual/en/coding-standard.html">Zend Framework</a> or a custom one might be allowed to have a fixed list of good practices to follow removing any doubt). I also decide to pay a bit of readability by removing the $v variable. The latest enhancements enable us to gain a few more lines, but it is not possible to go further without deface the class.  That leads us to final version  with 13 lines, displayed below.</p>
<pre class="brush: php;">&lt;?php
class NumberCruncher {
    function __call($name, $argument) {
        $functions = array('A' =&gt; 'return $argument[0]+4;',
            'B' =&gt; 'return $argument[0]*3;',
            'C' =&gt; 'return $argument[0]*$argument[0]/2;',
            'D' =&gt; 'return $argument[0]&gt;1?$argument[0]*$this-&gt;D($argument[0]-1):1;',
            'E' =&gt; 'return $argument[0]&gt;1?$this-&gt;OperationE($argument[0]-1)+$this-&gt;OperationE($argument[0]-2):$argument[0];',
            'F' =&gt; 'return $argument[0]*$argument[0]*4.5;',
            'G' =&gt; 'return $this-&gt;D($argument[0])-$this-&gt;E($argument[0]);');
        return eval($functions[substr($name, -1)]);
    }
}</pre>
<h2>Fewer bytes</h2>
<p>I took that class as a basis for my entry of the second contest, but I wasn&#8217;t be limitated by good practices anymore.</p>
<h3>Use short tags</h3>
<p>Line 1: This is not recommended as part of normal development, but it is still not removed from PHP 5.3, so 3 bytes are taken out.</p>
<h3>Shorten variable names</h3>
<p>Lines 3-11: Clear and fully written variable names are not mandatory, so we can use $n and $v instead</p>
<h3>Create array with an implied indexes</h3>
<p>Lines 4-10:  Since the last letter of the function name was used to fetch the function content, it implies we have to write all index. They can be removed them if we access the array using an integer index, but we will have use the <a href="http://php.net/ord">ord()</a> function and remove to the result 65, the number for &#8216;A&#8217; in the ascii table. Using the last character has a nice side effect : if the use of composite functions is an obligation, we can do it using function name one character.</p>
<pre class="brush: php;">
//Before
$functions = array('A' =&gt; 'return 1;', 'B' =&gt; 'return 2;');
return eval($functions[substr($name, -1)]);

//Now
$functions = array('return 1;','return 2;');
return eval($functions[ord(substr($name, -1))-65]);
</pre>
<h3>Remove redundant array items separator</h3>
<p>Lines 4-10: Every array element is separated by &#8216;,&#8217; 6 times in total in the array. We can use instead the <a href="http://php.net/explode">explode()</a> function and a character not present in the array to gain some more bytes.</p>
<pre class="brush: php;">
//Before
array('formulaA', 'formulaB', 'formulaC', 'formulaD', 'formulaE');

//Now
explode(' ', 'formulaA formulaB formulaC formulaD formulaE');
</pre>
<h3>Find a shorter version of formulas</h3>
<p>Lines 4-10: The only rewriting that I could find was the Fibonacci sequence and only for the data used in the test : when argument exceeds 10, it won&#8217;t work anymore. I again used a chart to help get my form, copying the values from the Fibonacci sequence.</p>
<pre class="brush: php;">
// Before
$v &gt; 1 ? $this-&gt;OperationE($v-1) + $this-&gt;OperationE($v-2) : $v;

// Now
$v &gt; 0 ? ceil(exp($v / 2 - 1)) : 0;
</pre>
<h3>Remove redoundant strings</h3>
<p>Lines 4-10: All strings starts with &#8216;return $&#8217;, that can be moved in the <a href="http://php.net/eval">eval()</a> at line 11.</p>
<pre class="brush: php;">eval('return $' . $functions[substr($name, -1)]);</pre>
<h3>Do not use composite functions unless required</h3>
<pre class="brush: php;">
// Before
return $this-&gt;OperationC($this-&gt;OperationB($v));

// Now
return $v*$v*4.5;
</pre>
<h3>Remove unnecessary formatting</h3>
<p>All that remains to do is the removal of formating, carriage returns and unnecessary spaces before all &#8216;$&#8217;.</p>
<h2>Final entry</h2>
<p>The previously given tips give a 225 bytes long class</p>
<pre class="brush: php; light: true;">
&lt;?class NumberCruncher{function __call($n,$v){$b=explode(' ','v+4 v*3 v*$v/2 v&gt;1?$v*$this-&gt;D($v-1):1 v&gt;0?ceil(exp($v/2-1)):0 v*$v*4.5 this-&gt;D($v)-$this-&gt;E($v)');$v=$v[0];return eval('return$'.$b[ord(substr($n,-1))-65].';');}}
</pre>
<p>I have not yet had the opportunity to interact with other participants or to see examples of codes, so I do not know now if there were many other strategies to implement. I will try to post if I can get comparative quotes from other candidates. In the meantime, one thing is certain, the results will be published by iBuildings July 15. Go to this moment!</p>
]]></content:encoded>
			<wfw:commentRss>http://yet.another.linux-nerd.com/2010/07/02/ibuildings-test-driven-challenge/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Noticeable french &amp; english words used in IT</title>
		<link>http://yet.another.linux-nerd.com/2009/09/06/noticeable-french-english-words-used-in-it/</link>
		<comments>http://yet.another.linux-nerd.com/2009/09/06/noticeable-french-english-words-used-in-it/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 14:35:50 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[french]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[translation]]></category>

		<guid isPermaLink="false">http://yet.another.linux-nerd.com/?p=40</guid>
		<description><![CDATA[<p>I'm working on a project for deploying J2EE and PHP applications
and it requires communication with customers in both english and french. This work
is part of a traditional IT documentation but I had some trouble
translating certain expressions especially those inspired from Public
buildings and works sector (they're typical to France) so I'm going to
list them in this post, so other people can use them or suggest better
translations.</p>

<table border="0">
<tr>
<td width="50%">Environment or stage</td>
<td>Environnement</td>
</tr>
<tr>
<td>Deployment</td>
<td>Déploiement</td>
</tr>
<tr>
<td>Development</td>
<td>Développement</td>
</tr>
<tr>
<td>Quality assurance (QA)</td>
<td>Test</td>
</tr>
<tr>
<td>User acceptance, sometimes UAT for User Acceptence Testing</td>
<td>Recette</td>
</tr>
<tr>
<td>Staging</td>
<td>Pré-production</td>
</tr>
<tr>
<td>Production / Live</td>
<td>Production</td>
</tr>
<tr>
<td>Onlining</td>
<td>Déploiement en production</td>
</tr>
</table>

<br/>

<table><tr>
<td width="50%">Product owner or contracting owner</td>
<td><abbr title="Maîtrise d'ouvrage">MOA</abbr> for <strong>M</strong>aîtrise d'<strong>o</strong>uvr<strong>a</strong>ge</td>
</tr>
<tr>
<td>Project management or project owner</td>
<td><abbr title="Maîtrise d'œuvre">MOE</abbr> for <strong>M</strong>aîtrise d'<strong>oe</strong>uvre</td>
</tr>
<tr>
<td>Production execution or implementation team</td>
<td><abbr title="Mise en œuvre">MEO</abbr> for <strong>M</strong>ise <strong>e</strong>n <strong>o</strong>euvre</td>
</tr>
</table>

<br/>

<table><tr>
<td width="50%">Scope statement or Specification</td>
<td>Cahier des charges</td>
</tr>
<tr>
<td>Steering Committee</td>
<td>Comite de pilotage (CoPil)</td>
</tr>
<tr>
<td>Works council</td>
<td>Comité d'entreprise</td>
</tr>
</table>]]></description>
			<content:encoded><![CDATA[<p><span class="drop">I</span>&#8217;m working on a project for deploying J2EE and PHP applications<br />
and it requires communication with customers in both english and french. This work<br />
is part of a traditional IT documentation but I had some trouble<br />
translating certain expressions especially those inspired from Public<br />
buildings and works sector (they&#8217;re typical to France) so I&#8217;m going to<br />
list them in this post, so other people can use them or suggest better<br />
translations.</p>
<table border="0">
<tr>
<td width="50%">Environment or stage</td>
<td>Environnement</td>
</tr>
<tr>
<td>Deployment</td>
<td>Déploiement</td>
</tr>
<tr>
<td>Development</td>
<td>Développement</td>
</tr>
<tr>
<td>Quality assurance (QA)</td>
<td>Test</td>
</tr>
<tr>
<td>User acceptance, sometimes UAT for User Acceptence Testing</td>
<td>Recette</td>
</tr>
<tr>
<td>Staging</td>
<td>Pré-production</td>
</tr>
<tr>
<td>Production / Live</td>
<td>Production</td>
</tr>
<tr>
<td>Onlining</td>
<td>Déploiement en production</td>
</tr>
</table>
<p><br/></p>
<table>
<tr>
<td width="50%">Product owner or contracting owner</td>
<td><abbr title="Maîtrise d'ouvrage">MOA</abbr> for <strong>M</strong>aîtrise d&#8217;<strong>o</strong>uvr<strong>a</strong>ge</td>
</tr>
<tr>
<td>Project management or project owner</td>
<td><abbr title="Maîtrise d'œuvre">MOE</abbr> for <strong>M</strong>aîtrise d&#8217;<strong>oe</strong>uvre</td>
</tr>
<tr>
<td>Production execution or implementation team</td>
<td><abbr title="Mise en œuvre">MEO</abbr> for <strong>M</strong>ise <strong>e</strong>n <strong>o</strong>euvre</td>
</tr>
</table>
<p><br/></p>
<table>
<tr>
<td width="50%">Scope statement or Specification</td>
<td>Cahier des charges</td>
</tr>
<tr>
<td>Steering Committee</td>
<td>Comite de pilotage (CoPil)</td>
</tr>
<tr>
<td>Works council</td>
<td>Comité d&#8217;entreprise</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://yet.another.linux-nerd.com/2009/09/06/noticeable-french-english-words-used-in-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
