<?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>Naenius</title>
	<atom:link href="http://www.naenius.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.naenius.com</link>
	<description>“Development is a state of mind”</description>
	<lastBuildDate>Sat, 22 Oct 2011 22:17:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Outputting formatted XML using PHP</title>
		<link>http://www.naenius.com/2011/10/outputting-formatted-xml-using-php/</link>
		<comments>http://www.naenius.com/2011/10/outputting-formatted-xml-using-php/#comments</comments>
		<pubDate>Sat, 22 Oct 2011 22:14:11 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[prettify]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=364</guid>
		<description><![CDATA[For an interpreter it doesn&#8217;t matter how much whitespace there is in an XML document and often you find that machines strip it all out to reduce the amount of bandwidth used. Often at the receiving end you want to show the output in a log file or page and need it to be formatted [...]]]></description>
			<content:encoded><![CDATA[<p>For an interpreter it doesn&#8217;t matter how much whitespace there is in an XML document and often you find that machines strip it all out to reduce the amount of bandwidth used. Often at the receiving end you want to show the output in a log file or page and need it to be formatted so that it is easily readable by humans.</p>

<p><span id="more-364"></span>The following code snippet will format the XML for you:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000088;">$dom</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMDocument<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadXML</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">formatOutput</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$pretty_xml</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveXML</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<p>In this example the $xml variable is a plain-text XML string that needs to be &#8216;prettified&#8217;.</p>

<p>I hope this little snippet has helped you. It did for me!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2011/10/outputting-formatted-xml-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH Tunneling across multiple hosts in Linux</title>
		<link>http://www.naenius.com/2011/06/ssh-tunneling-across-multiple-hosts-in-linux/</link>
		<comments>http://www.naenius.com/2011/06/ssh-tunneling-across-multiple-hosts-in-linux/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 07:32:38 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[host]]></category>
		<category><![CDATA[jumphost]]></category>
		<category><![CDATA[multiple]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tunnel]]></category>
		<category><![CDATA[tunneling]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=477</guid>
		<description><![CDATA[Sometimes you need to communicate with a server (or other device) that is not directly accessible from your own computer. If you can reach this server via another server this is not an issue and can be solved by setting up a SSH Tunnel across your network. An example Let&#8217;s start with a example: Computer [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to communicate with a server (or other device) that is not directly accessible from your own computer. If you can reach this server via another server this is not an issue and can be solved by setting up a SSH Tunnel across your network.</p>

<p><strong>An example</strong></p>

<p>Let&#8217;s start with a example:</p>

<ul>
    <li>Computer A is where you are working.</li>
    <li>Server A is accessible by computer A.</li>
    <li>Server B has a administration web interface but its IP Address is completely shielded by a firewall; except for Server A.</li>
</ul>

<p>Thus the only way to reach the web interface on Server B from Computer A would be through Server A.</p>

<p><img class="aligncenter" title="Route from Computer A to Server B" src="http://yuml.me/diagram/class/[Computer A]-&gt;[Server A], [Server A]-&gt;[Server B]" alt="" width="635" height="69" /></p>

<p><strong>The solution</strong></p>

<p>You can solve this by setting up an SSH Tunnel which spans several server; the command for this is:</p>

<p><code lang="bash"> ssh -t -t -L[LOCAL_PORT]:localhost:[PORT_ON_A] [USER]@[SERVER_A] 'ssh -L[PORT_ON_A]:localhost:[PORT_ON_B] [USER]@[SERVER_B]'</code></p>

<p>Basically you are chaining a specific IP port to guide traffic from and to your PC.</p>

<p>The variables shown here represent:</p>

<ul>
    <li>LOCAL_PORT, the port on you local PC where you want to connect to in order to communicate with SERVER_B</li>
    <li>PORT_ON_A, the port on SERVER_A which is used to transfer your data across to SERVER_B (may be any port number but make sure it does not collide with other tunnels / uses)</li>
    <li>USER, your account name / login name on SERVER_A and/or SERVER_B</li>
    <li>SERVER_A, the hostname or IP address of your first jump point</li>
    <li>PORT_ON_B, the destination port to which you want to connect; in our example we wanted to connect to a web interface (port 80) thus we use the value 80 here</li>
    <li>SERVER_B, the hostname or IP address of your intended destination</li>
</ul>

<p>You might notice the use of a double -t argument in our command; this is not an error but is actually required in order to create the connection (without it your system might complain that it is unable to acquire a TTY; explaining the details of this would go beyond this blog posting)</p>

<p><strong>Our example command</strong></p>

<p>To complete this exercise I will show you the full command with which we could satisfy the requirement in our opening example:</p>

<p><code lang="bash">ssh -t -t -L8081:localhost:10000 mvriel@a.server.example.com 'ssh -L10000:localhost:80 mvriel@b.server.example.com'</code></p>

<p>See that we used port 8081 as local port? We did that to prevent collisions with services on our local machine. Were you to use (for example) port 80 it might produce unwanted results such as your local apache (if you have one) being unreachable.</p>

<p>Now all we need to do to visit the website on Server B would be to enter the following URL in your browser:</p>

<p><code>http://localhost:8081</code></p>

<p>That&#8217;s all there is to it. If anything is not clear, just leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2011/06/ssh-tunneling-across-multiple-hosts-in-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pre-commit hook in Git: Running PHPUnit</title>
		<link>http://www.naenius.com/2011/05/pre-commit-hook-in-git-running-phpunit/</link>
		<comments>http://www.naenius.com/2011/05/pre-commit-hook-in-git-running-phpunit/#comments</comments>
		<pubDate>Mon, 16 May 2011 20:30:52 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[gist]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpunit]]></category>
		<category><![CDATA[pre-commit]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=432</guid>
		<description><![CDATA[Pre-commit hooks in git are one of those things you hardly think about but can help you automate tasks and do last-minute checks. A good example of this is running unit tests before commits, to make sure nothing broke; or checking your files using PHP_CodeSniffer. With DocBlox I use them to run my unit tests [...]]]></description>
			<content:encoded><![CDATA[<p>Pre-commit hooks in git are one of those things you hardly think about but can help you automate tasks and do last-minute checks.
A good example of this is running unit tests before commits, to make sure nothing broke; or checking your files using PHP_CodeSniffer.</p>

<p>With <a href="http://www.docblox-project.org" title="DocBlox">DocBlox</a> I use them to run my unit tests as I personally believe these should be ran (and fixed!) before any commit.</p>

<p><span id="more-432"></span></p>

<blockquote>
  <p><em>Please note: contrary to Subversion pre-commit hooks are those used by Git installed locally. This is quite logical but makes it a little harder to enforce certain policies.</em></p>
</blockquote>

<h2>What is a hook in Git?</h2>

<p>Hooks in Git are, as with Subversion, command line scripts which are executed at a pre-determined moment. Because these are plain scripts they enable you to write the intended functionality in any programming language.</p>

<blockquote>
  <p><em>In this article we will be writing a pre-commit hook for use under Linux. Under Windows you will need to copy the code into a file different from your hook-file and invoke that using the following command:</em></p>

<pre><code>php -f &lt;name of file&gt;
</code></pre>
  
  <p><em>That will ensure execution under Windows.</em></p>
</blockquote>

<p>In this article we will only talk about the Pre-commit hook; though Git knows a total of <a href="http://www.kernel.org/pub/software/scm/git/docs/githooks.html" title="Git hooks">16 different hooks</a> at time of writing. All these hooks are used in the same way and should pose no challenge after reading this.</p>

<blockquote>
  <p><em>The Pre-commit hook is a script that runs before your commit is actually resolved; it is possible to abort the commit if an exit code other than 0 is provided. More on this later in this article.</em></p>
</blockquote>

<p>All client-side hooks (git actually has some server-side hooks as well) can be found in the <em>.git/hooks</em> folder of your project. During initialization of your repository has your folder been populated with example hooks; among which the pre-commit. These sample hooks are disabled and can be enabled by removing their <em>.sample</em> extension.</p>

<p>We will do no such thing; we intend to create a new file.</p>

<h2>Creating a new hook</h2>

<p>A hook in Git must:</p>

<ul>
<li>have the exact name as specified for the intended hook; which is in this case <code>pre-commit</code> (if you have no such file, create it now)</li>
<li><p>be executable; it is acceptable to set the permissions of a hook to 0&#215;777, which can be done using the following command</p>

<pre><code>chmod 777 .git/hooks/pre-commit
</code></pre></li>
</ul>

<p>After you have created the new file for your hook (you did do this by now, right?) we start by adding the first two and most important lines of code:</p>

<pre><code>#!/usr/bin/php
&lt;?php
</code></pre>

<p>That&#8217;s it! You do not need any more to start creating your own hook using PHP code.</p>

<h2>Making it useful: Adding automated unit tests</h2>

<p>Right. Now we need to add something useful. 
Let&#8217;s add the possibility for automated unit testing; which aborts the build when a test has failed!</p>

<p>The most basic form of this is:</p>

<pre><code>exec('phpunit', $output, $returnCode); // cwd is assumed here
if ($returnCode != 0) { echo implode(PHP_EOL, $output); }
die($returnCode);
</code></pre>

<p>This code executes <code>phpunit</code> and outputs the test results whenever a test has failed.
By returning phpUnit&#8217;s own error code we automatically return a non-zero value when the tests have failed. This then results in an aborted commit.</p>

<p>It is that simple.</p>

<h2>Full version</h2>

<p>To show you what is possible I have included my own pre-commit hook as a Gist:</p>

<div id="gist-975252" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="x">#!/usr/bin/php</span></div><div class='line' id='LC2'><span class="cp">&lt;?php</span></div><div class='line' id='LC3'><span class="k">echo</span> <span class="nx">PHP_EOL</span><span class="p">;</span></div><div class='line' id='LC4'><br /></div><div class='line' id='LC5'><span class="c1">// output a little introduction</span></div><div class='line' id='LC6'><span class="k">echo</span> <span class="s1">&#39;&gt;&gt; Starting unit tests&#39;</span> <span class="o">.</span> <span class="nx">PHP_EOL</span><span class="p">;</span></div><div class='line' id='LC7'><br /></div><div class='line' id='LC8'><span class="c1">// get the name for this project; probably the topmost folder name</span></div><div class='line' id='LC9'><span class="nv">$projectName</span> <span class="o">=</span> <span class="nb">basename</span><span class="p">(</span><span class="nb">getcwd</span><span class="p">());</span></div><div class='line' id='LC10'><br /></div><div class='line' id='LC11'><span class="c1">// execute unit tests (it is assumed that a phpunit.xml configuration is present </span></div><div class='line' id='LC12'><span class="c1">// in the root of the project)</span></div><div class='line' id='LC13'><span class="nb">exec</span><span class="p">(</span><span class="s1">&#39;phpunit&#39;</span><span class="p">,</span> <span class="nv">$output</span><span class="p">,</span> <span class="nv">$returnCode</span><span class="p">);</span> <span class="c1">// cwd is assumed here</span></div><div class='line' id='LC14'><br /></div><div class='line' id='LC15'><span class="c1">// if the build failed, output a summary and fail</span></div><div class='line' id='LC16'><span class="k">if</span> <span class="p">(</span><span class="nv">$returnCode</span> <span class="o">!==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC17'><br /></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// find the line with the summary; this might not be the last</span></div><div class='line' id='LC19'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">while</span> <span class="p">((</span><span class="nv">$minimalTestSummary</span> <span class="o">=</span> <span class="nb">array_pop</span><span class="p">(</span><span class="nv">$output</span><span class="p">))</span> <span class="o">!==</span> <span class="k">null</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nb">strpos</span><span class="p">(</span><span class="nv">$minimalTestSummary</span><span class="p">,</span> <span class="s1">&#39;Tests:&#39;</span><span class="p">)</span> <span class="o">!==</span> <span class="k">false</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC21'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">break</span><span class="p">;</span></div><div class='line' id='LC22'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC23'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC24'><br /></div><div class='line' id='LC25'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// output the status</span></div><div class='line' id='LC26'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">echo</span> <span class="s1">&#39;&gt;&gt; Test suite for &#39;</span> <span class="o">.</span> <span class="nv">$projectName</span> <span class="o">.</span> <span class="s1">&#39; failed:&#39;</span> <span class="o">.</span> <span class="nx">PHP_EOL</span><span class="p">;</span></div><div class='line' id='LC27'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">echo</span> <span class="nv">$minimalTestSummary</span><span class="p">;</span></div><div class='line' id='LC28'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">echo</span> <span class="nb">chr</span><span class="p">(</span><span class="mi">27</span><span class="p">)</span> <span class="o">.</span> <span class="s1">&#39;[0m&#39;</span> <span class="o">.</span> <span class="nx">PHP_EOL</span><span class="p">;</span> <span class="c1">// disable colors and add a line break</span></div><div class='line' id='LC29'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">echo</span> <span class="nx">PHP_EOL</span><span class="p">;</span></div><div class='line' id='LC30'><br /></div><div class='line' id='LC31'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// abort the commit</span></div><div class='line' id='LC32'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span></div><div class='line' id='LC33'><span class="p">}</span></div><div class='line' id='LC34'><br /></div><div class='line' id='LC35'><span class="k">echo</span> <span class="s1">&#39;&gt;&gt; All tests for &#39;</span> <span class="o">.</span> <span class="nv">$projectName</span> <span class="o">.</span> <span class="s1">&#39; passed.&#39;</span> <span class="o">.</span> <span class="nx">PHP_EOL</span><span class="p">;</span></div><div class='line' id='LC36'><span class="k">echo</span> <span class="nx">PHP_EOL</span><span class="p">;</span></div><div class='line' id='LC37'><span class="k">exit</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span></div><div class='line' id='LC38'><br /></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/975252/3001dfb9018d711d24bd65ee579af802d46515ba/pre-commit.php" style="float:right;">view raw</a>
            <a href="https://gist.github.com/975252#file_pre_commit.php" style="float:right;margin-right:10px;color:#666">pre-commit.php</a>
            <a href="https://gist.github.com/975252">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>


<h2>What is next?</h2>

<p>I intend to follow up on this post with another which will show you how to add support for PHP_CodeSniffer; which only checks the files that you have just committed.</p>

<p>See you back next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2011/05/pre-commit-hook-in-git-running-phpunit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple types of opening braces when matching pairs with the tokenizer/ext</title>
		<link>http://www.naenius.com/2011/02/multiple-types-of-opening-braces-when-matching-pairs-with-the-tokenizerext/</link>
		<comments>http://www.naenius.com/2011/02/multiple-types-of-opening-braces-when-matching-pairs-with-the-tokenizerext/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 20:37:20 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[braces]]></category>
		<category><![CDATA[DGA]]></category>
		<category><![CDATA[DocBlox]]></category>
		<category><![CDATA[matching]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tokenizer]]></category>
		<category><![CDATA[tokens]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=428</guid>
		<description><![CDATA[Whilst I was testing DocBlox on the Solar Framework I found a bug in the part of the application where I match the curly brace pairs of structures (like classes, functions, methods, etc). Every time a variable was imported in a string using the {$var} notation my algorithm thought that the function/method had ended at the [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst I was testing <a href="http://www.docblox-project.org">DocBlox</a> on the <a href="http://www.solarphp.com">Solar Framework</a> I found a bug in the part of the application where I match the curly brace pairs of structures (like classes, functions, methods, etc). Every time a variable was imported in a string using the {$var} notation my algorithm thought that the function/method had ended at the closing brace of that string.</p>

<p>To my surprise I found out that the issue was caused by the fact that the Tokenizer has three different tokens for recognizing an opening curly brace and only one for a closing curly brace.</p>

<p><span id="more-428"></span></p>

<p>Should you ever be in a position that you want to find curly brace pairs in your code you can test for the following:</p>

<ol>
    <li>a single &#8216;{&#8216; (thus without token type)</li>
    <li>an array whose first element (thus token type) is T_CURLY_OPEN (representing the sequence &#8216;{$&#8217;) or</li>
    <li>an array whose first element (thus token type) is T_DOLLAR_OPEN_CURLY_BRACES (representing the sequence &#8216;${&#8216;)</li>
    <li>a single &#8216;}&#8217;</li>
</ol>

<p>It took me quite some time to find out what went wrong here and I hope this blog post will help someone to find the answer to his problem.</p>

<p>Thank you for reading!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2011/02/multiple-types-of-opening-braces-when-matching-pairs-with-the-tokenizerext/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing: DocBlox</title>
		<link>http://www.naenius.com/2011/02/introducing-docblox/</link>
		<comments>http://www.naenius.com/2011/02/introducing-docblox/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 20:26:14 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[DGA]]></category>
		<category><![CDATA[DocBlox]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[phpDocumentor]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=365</guid>
		<description><![CDATA[Ever since I discovered phpDocumentor I have been fascinated by the idea of automatic Documentation Generation. Especially for large projects where an in-depth understanding of the code is a requirement. Unfortunately, the more I got to work with phpDocumentor the more issues surfaced with its performance, ease of use and above all: memory usage. Over [...]]]></description>
			<content:encoded><![CDATA[<p><em><a href="http://blog.naenius.com/wp-content/uploads/2011/01/logo.png" rel="lightbox[365]"><img class="alignright size-full wp-image-414" style="float: right; margin: 7px;" title="DocBlox Logo" src="http://blog.naenius.com/wp-content/uploads/2011/01/logo.png" alt="Logo" width="171" height="27" /></a>Ever since I discovered phpDocumentor I have been fascinated by the idea of automatic Documentation Generation. Especially for large projects where an in-depth understanding of the code is a requirement.</em></p>

<p>Unfortunately, the more I got to work with phpDocumentor the more issues surfaced with its performance, ease of use and above all: memory usage.</p>

<p>Over time I have encountered <em>at least</em> 1 project which could not be processed by phpDocumentor. This was unfortunate and thus I decided to try and contribute to the phpDocumentor project. After a pleasant introduction and solving a minor bug I attempted to solve, or at least decrease, the memory usage issues which were the main cause of my dissatisfaction.</p>

<p><span id="more-365"></span></p>

<p>Long story short: I gave up.
Although the application can work magic for some projects, I was unable to adapt the code base (which is reasonable old). The memory issues seemed to be partly due to the architecture of the application and the choices in the past. To change this would mean a rather large refactoring of the application.</p>

<p><strong>Enter DocBlox</strong></p>

<p>Right before or during the Dutch PHP Conference 2010 the issue had arisen again and this time I was determined on solving it. In the end I chose to build a new Documentation Generation Application (may I coin DGA?) for PHP for which I had the following spear points in mind:</p>

<ol>
    <li>Execution duration had to be as short as possible.</li>
    <li>Memory usage should at all times be within an acceptable range (less than 100mb).</li>
    <li>Focus on assisting Continuous Integration.</li>
    <li>Compatible with the latest PHP versions.</li>
    <li>Compatible with the basic phpDocumentor CLI arguments.</li>
    <li>Aid the user with Ajax enabled search and more.</li>
</ol>

<p>With these requirements written down in a small TODO file I started designing the new project (which at the time was still nameless).
After spending some hours designing, coding, prototyping, designing, coding and testing is now the time to reveal the fruits of my labour:<strong> DocBlox</strong></p>

<p><strong>State</strong></p>

<p>Currently DocBlox is still in an pre-release state (version 0.7.1) but is well underway to version 1.0. Even though I have marked this version as being pre-release, it is fully capable of parsing your source code and creating static HTML pages (PDF support is planned for the near future).</p>

<p><strong>Features</strong></p>

<p>DocBlox sports many features which help you reading the documentation hidden in your source code. Please take a look at <a href="https://github.com/mvriel/Docblox/wiki/Features">https://github.com/mvriel/Docblox/wiki/Features</a> for an overview!</p>

<p><strong>Conclusion and where to get it</strong></p>

<p>DocBlox is a new, versatile Documentation Generation Application (DGA) which enables large and / or PHP 5.3 projects to generate their documentation. It is compatible with many of the features that you are used to in other DGA&#8217;s.</p>

<p>You can get the source files from GitHub at: <a href="https://github.com/mvriel/Docblox">https://github.com/mvriel/Docblox</a>
Some documentation is also available at Github; but most is still under development. You can check the README, TODO and CHANGELOG in the project to see how to use the application and what is on the roadmap.</p>

<p>Try it and I hope you like it.</p>

<p>Either way, thank you and let me know!</p>

<div id="_mcePaste" style="position: absolute; left: -10000px; top: 586px; width: 1px; height: 1px; overflow: hidden;">91949</div>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2011/02/introducing-docblox/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Human readable memory usage in Linux per process</title>
		<link>http://www.naenius.com/2010/12/human-readable-memory-usage-in-linux-per-process/</link>
		<comments>http://www.naenius.com/2010/12/human-readable-memory-usage-in-linux-per-process/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 10:28:43 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[memory]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=387</guid>
		<description><![CDATA[I like to tune my VPS to use as little memory as possible. Not because I really want to; but because I just don&#8217;t have the money to spend on a 2+ GB RAM VPS and I would like to run Jira. In order to do this I keep a close eye on the processes [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: right; margin-left: 5px; margin-bottom: 5px;" title="Linux" src="http://farm4.static.flickr.com/3129/2910558393_f47213263b_s.jpg" alt="Linux" width="75" height="75" /><em>I like to tune my VPS to use as little memory as possible. Not because I really want to; but because I just don&#8217;t have the money to spend on a 2+ GB RAM VPS and I would like to run Jira. </em></p>

<p><em>In order to do this I keep a close eye on the processes running and how much memory each takes.
</em><span id="more-387"></span></p>

<p>For this I found (and tweaked) the following bash command (originally found <a href="http://www.linuxquestions.org/questions/programming-9/how-to-show-the-top-processes-eating-ram-in-human-readable-826216/">here</a>):</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-eo</span> <span style="color: #c20cb9; font-weight: bold;">size</span>,pid,user,<span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #660033;">--sort</span> <span style="color: #660033;">-size</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ hr=$1/1024 ; printf(&quot;%13.2f Mb &quot;,hr) } { for ( x=4 ; x&lt;=NF ; x++ ) { printf(&quot;%s &quot;,$x) } print &quot;&quot; }'</span></pre></div></div>


<p>This command will output every process and its memory usage in human readable (thus megabytes) format. For your convenience it is sorted by memory size descending (from highest to lowest).</p>

<p>An example of its use:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mvriel<span style="color: #000000; font-weight: bold;">@</span>naenius:~$ <span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-eo</span> <span style="color: #c20cb9; font-weight: bold;">size</span>,pid,user,<span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #660033;">--sort</span> <span style="color: #660033;">-size</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ hr=$1/1024 ; printf(&quot;%13.2f Mb &quot;,hr) } { for ( x=4 ; x&lt;=NF ; x++ ) { printf(&quot;%s &quot;,$x) } print &quot;&quot; }'</span>
<span style="color: #000000;">0.00</span> Mb COMMAND
<span style="color: #000000;">116.18</span> Mb <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>mysqld
<span style="color: #000000;">11.58</span> Mb <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2 <span style="color: #660033;">-k</span> start
<span style="color: #000000;">11.58</span> Mb <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2 <span style="color: #660033;">-k</span> start
<span style="color: #000000;">11.58</span> Mb <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2 <span style="color: #660033;">-k</span> start</pre></div></div>


<p>(I am sure I can tune the above to use less memory; this is merely an example)</p>

<p>I hope it will be as useful to you as it is to me,</p>

<p>Until next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2010/12/human-readable-memory-usage-in-linux-per-process/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Updated the design of this blog</title>
		<link>http://www.naenius.com/2010/12/updated-the-design-of-this-blog/</link>
		<comments>http://www.naenius.com/2010/12/updated-the-design-of-this-blog/#comments</comments>
		<pubDate>Sat, 11 Dec 2010 21:52:24 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=374</guid>
		<description><![CDATA[After less than 2 years I have finished my new WordPress template for this blog. The previous theme was clunky and lacked many of the features that WordPress has to offer. I hope to address these issues and enhance this site even more. To be honest: the graphic design was finished about a year ago [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.naenius.com/wp-content/uploads/2010/12/naenius_logo.png" rel="lightbox[374]"><img class="size-thumbnail wp-image-375" style="margin-right: 5px; margin-bottom: 5px; float: left;" title="naenius_logo" src="http://blog.naenius.com/wp-content/uploads/2010/12/naenius_logo-150x150.png" alt="Naenius logo" width="75" height="75" /></a>After less than 2 years I have finished my new WordPress template for this blog. The previous theme was clunky and lacked many of the features that WordPress has to offer. I hope to address these issues and enhance this site even more.
<em>To be honest: the graphic design was finished about a year ago but the conversion process took quite some time (life got in the way multiple times).</em></p>

<p><span id="more-374"></span>The theme is based on the previous but features some enhancements which the previous plainly lacked:</p>

<ul>
    <li>Search! (this was entirely missing from the previous theme, which was kind of &#8216;doh&#8217;)</li>
    <li>Improved commenting</li>
    <li>More detailed contact information on the front page</li>
    <li>Better paging</li>
    <li>Actually using the (more) breaks</li>
    <li>Fixed width to ensure a consistent experience and reduce the number of artifacts</li>
</ul>

<p>I hope that this will give me some more incentive to blog some more and document some of the things I have picked up here.
Please leave a comment whether you like the (new) design and/or what you find missing or non-intuitive!</p>

<p>Until next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2010/12/updated-the-design-of-this-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpStorm, a true delight to work with</title>
		<link>http://www.naenius.com/2010/05/phpstorm-a-true-delight-to-work-with/</link>
		<comments>http://www.naenius.com/2010/05/phpstorm-a-true-delight-to-work-with/#comments</comments>
		<pubDate>Sat, 01 May 2010 21:19:14 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[code completion]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[phpstorm]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=355</guid>
		<description><![CDATA[During my career as a PHP developer (hobbyist and professional) I have tried a multitude of IDEs and tools to write code in. Every IDE I have found thus far did great things but had their downsides. It is with phpStorm that I can send at least some of those problems to the past Let [...]]]></description>
			<content:encoded><![CDATA[<p>During my career as a PHP developer (hobbyist and professional) I have tried a multitude of IDEs and tools to write code in.
Every IDE I have found thus far did great things but had their downsides. It is with <a href="http://www.jetbrains.com/phpstorm/download/">phpStorm </a>that I can send at least some of those problems to the past</p>

<p><span id="more-355"></span>Let me start at the beginning.
Where I once started with Notepad, Notepad++, VI and alike; I later switched to <a href="http://www.eclipse.org/pdt">Eclipse</a> (with the PDT extension). This switch was great as it really increased my productivity by offering all these great things like code completion.</p>

<p>Alas, every good thing must have a downside.
Eclipse proved to be a sluggish memory hogging beast. The added features still made up for using it but as time went by I grew more and more frustrated with waiting for my code completion window to show (for example).
After some time I tried <a href="http://www.netbeans.org">Netbeans</a> (it was actually Stefan Koopmanschap who urged me to try it). This IDE offers the same amount of features for the same price as Eclipse PDT: free. Yet the big difference between the two IDEs is that Netbeans offers more speed and less memory usage.</p>

<p>Now, you might be wondering: fun and all, but what has this to do with <a href="http://www.jetbrains.com/phpstorm/download/">phpStorm</a>?</p>

<p>Well, it was only after a few months working with Netbeans that I read a tweet in my timeline by Kana (MissYeh) about a new kid on the block. You probably guessed it: phpStorm.
Even with the added improvements by Netbeans I was still unsure whether this was it. The memory footprint was lower than Eclipse but still high and I still had to wait for certain actions.</p>

<p>Having gotten that little push by MissYeh I decided to take a look at that new shiny IDE and found a true gem!
phpStorm offers so much more than Netbeans and Eclipse in terms of performance, memory but also functionality. Allow me to list some things:</p>

<ul>
    <li> Native git integration</li>
    <li> Method Usage search</li>
    <li>Being able to add types to variables in i.e. foreach loops</li>
    <li> more advanced docblock parsing and code interpretation</li>
    <li> the ability to view &#8216;blame&#8217; information in the IDE</li>
    <li> and much more</li>
</ul>

<p>It is truly wonderful!</p>

<p>But alas, as I have said before, nothing is all good. Currently the project is still in Beta and some bugs are to be encountered. Memory usage is great when starting the app but after a day&#8217;s work you really want to restart the IDE.
And something which might be akward compared to the other IDEs mentioned here: it is not for free.
Currently the application is offered for free as beta but once the full version comes out it will go commercial and a licence fee is required (though they state on their blogs that the prices are to be kept reasonable).</p>

<p><strong>Summary</strong></p>

<p>For me, phpStorm is despite its beta bugs a more complete and easier application to work with. The fact that it will not be free is regretful but I would gladly shelf out some money for a product like this. If you have not heard of it or tried it: I really recommend it!</p>

<p>Thank you for listening!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2010/05/phpstorm-a-true-delight-to-work-with/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>pman, a unix command line PHP Manual</title>
		<link>http://www.naenius.com/2010/01/pman-a-unix-command-line-php-manual/</link>
		<comments>http://www.naenius.com/2010/01/pman-a-unix-command-line-php-manual/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 17:07:26 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Lost in space]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=346</guid>
		<description><![CDATA[Yesterday I read a blog post by Hannes Magnusson titled Unix Manual pages for PHP functions. Unknowingly had Hannes done me a great favor by posting the exact instruction on installing pman, a commandline tool which acts as the unix man command. Every so often I am busy working and noticed how easy it would [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: left; margin-right: 20px;" class="alignright size-full wp-image-348" title="PHP" src="http://blog.naenius.com/wp-content/uploads/2010/01/php-med-trans-light.gif" alt="PHP Logo" width="95" height="51"  border="0"/>Yesterday I read a blog post by Hannes Magnusson titled <a href="http://bjori.blogspot.com/2010/01/unix-manual-pages-for-php-functions.html">Unix Manual pages for PHP functions</a>.</p>

<p>Unknowingly had Hannes done me a great favor by posting the exact instruction on installing <em>pman</em>, a commandline tool which acts as the unix <em>man</em> command. Every so often I am busy working and noticed how easy it would be to have such a Unix / Linux tool, unknowing that it already existed.</p>

<p><span id="more-346"></span>The installation as described on his blog (<a href="http://bjori.blogspot.com/2010/01/unix-manual-pages-for-php-functions.html">http://bjori.blogspot.com/2010/01/unix-manual-pages-for-php-functions.html</a>) is a cake walk and thus I had no trouble getting it to work.</p>

<p>With this blog post I wish to thank him for this post and remind myself where to get the instructions. For those people who expected the installation instruction here, sorry! You really should visit Hannes&#8217; blog for those.</p>

<p>Thank you for listening!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2010/01/pman-a-unix-command-line-php-manual/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The year of change</title>
		<link>http://www.naenius.com/2010/01/the-year-of-change/</link>
		<comments>http://www.naenius.com/2010/01/the-year-of-change/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 13:34:03 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=325</guid>
		<description><![CDATA[Photo is copyright of David Reece I usually do not make new year&#8217;s resolutions, but this year is going to be different. This year will be the year of change! In the past year I have done and experienced a lot of wonderful things but some things were left undone or have been given a [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; margin-left: 10px"><img src="http://farm3.static.flickr.com/2312/2328879637_c0d2e376ff.jpg" alt="" width="150" />
<small><a href="http://www.flickr.com/photos/spursfan_ace/2328879637/">Photo is copyright of David Reece</a></small></div>

<p><em>I usually do not make new year&#8217;s resolutions, but this year is going to be different. This year will be the year of change!</em></p>

<p>In the past year I have done and experienced a lot of wonderful things but some things were left undone or have been given a lower priority than all the other great things.</p>

<p>To compensate I have made a TO-DO list of things that I want to change or improve this year and which I want to share with you.</p>

<h2><span id="more-325"></span>Blog more, blog better</h2>

<p>This blog has multiple functions, but one of them is for me to remember and hopefully help other people in the process. Alas, the number of articles posted here are rather poor and they could use some company. Thus I intend to increase my blogging ratio with some topics which I find interesting.</p>

<p>I have never been a big writer and suffered from writer&#8217;s blocks quite often and this year I want to change that!</p>

<h2>Become a Zend Certified Engineer (ZCE)</h2>

<p>Although some people doubt whether being a ZCE actually shows your level of knowledge in PHP. It does show your perseverance to do something with your knowledge and how eager you are to attain it.</p>

<p>I have actually been working on becoming one for the past year on and off but never come around to actually do the exam.</p>

<h2>Keep up-to-date</h2>

<p>To my own embarrassment I have a rather large backlog of posts in my feed reader which I still need to read. By now I have added more blogs to my reader in the hopes of becoming acquainted with the latest and hottest developments in the PHP area.</p>

<p>By prioritizing my news better (PHP first then the rest) and spending a little more time I want to be involved more and more into the PHP community, learn and know what is going on.</p>

<h2>Finish or publicize one or more of my personal projects</h2>

<p>Personal projects are fun and highly educational. It gives me the ability to experiment with cutting edge techniques and APIs. The downside is that there are so many fun things to learn about and so little time, that they are never finished or published.</p>

<p>I have 2 personal projects in particular in which I want to spend significant effort to publish them; I believe they hold the potential to benefit a whole lot of people. And are fun to do ..</p>

<h2>Lose 10 kilograms</h2>

<p>One of the more sensitive areas but nonetheless one which I want to accomplish this year. Since I stopped smoking 3 years ago I managed to accumulate an unnecessary amount of extra kilograms. Nothing too unhealthy but nonetheless aesthetically unpleasant (at least to me).</p>

<p>Thus with the help of the gym and a lot of self-constraint (I pray that I find the strength) I should be able to do it.</p>

<h2>Conclusion</h2>

<p>There you have it, a small peak into my life and what I want to accomplish this year.
Aside from the things that are mentioned above I have some additional accomplishment that I want to achieve this year. But for now I am not going to tell you about them yet.
Perhaps that these will be revealed later this year.</p>

<p>I hope to accomplish everything mentioned so far by the end of this year and at least try to make a difference.</p>

<p>Thank you for listening.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2010/01/the-year-of-change/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Released a new version of sfPropelRowLevelAccessBehaviorPlugin</title>
		<link>http://www.naenius.com/2009/10/released-a-new-version-of-sfpropelrowlevelaccessbehaviorplugin/</link>
		<comments>http://www.naenius.com/2009/10/released-a-new-version-of-sfpropelrowlevelaccessbehaviorplugin/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 16:43:03 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Lost in space]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[rla]]></category>
		<category><![CDATA[row-level-access]]></category>
		<category><![CDATA[sfPropelRowLevelAccessBehaviorPlugin]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=316</guid>
		<description><![CDATA[After discovering a somewhat annoying bug had I removed the previous release of my plugin; I could not allow people to download and install a version of which I knew such a bug existed. Thus after some recoding and bug fixing I am proud to present version 1.1 of sfPropelRowLevelAccessBehaviorPlugin! You can find it in [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: left; margin-right: 10px;" src="http://www.symfony-project.org/downloads/logos/symfony.gif" alt="" width="150" />After discovering a somewhat annoying bug had I removed the previous release of my plugin; I could not allow people to download and install a version of which I knew such a bug existed.</p>

<p>Thus after some recoding and bug fixing I am proud to present version 1.1 of sfPropelRowLevelAccessBehaviorPlugin!</p>

<p>You can find it in the symfony plugin repository (<a href="http://www.symfony-project.org/plugins/sfPropelRowLevelAccessBehaviorPlugin">http://www.symfony-project.org/plugins/sfPropelRowLevelAccessBehaviorPlugin</a>) and install it with the symfony plugin:install command.</p>

<p>Please examine the README for details about implementing Row Level Access with this plugin and if you have any questions, please mail me.</p>

<p>Thank you for listening</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2009/10/released-a-new-version-of-sfpropelrowlevelaccessbehaviorplugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symfony plugin released!</title>
		<link>http://www.naenius.com/2009/10/symfony-plugin-released/</link>
		<comments>http://www.naenius.com/2009/10/symfony-plugin-released/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 20:29:44 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[acl]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[row-level-access]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=314</guid>
		<description><![CDATA[A few days ago I blogged about the lack of Row Level Access control in symfony. Although I still have too little time I was seduced to try and tackle this problem. The result is clear! A new plugin was born and it is available for all to enjoy at http://www.symfony-project.org/plugins/sfPropelRowLevelAccessBehaviorPlugin. It is very easy [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.symfony-project.org/downloads/logos/symfony.gif" width="150" style="float: right; margin-left: 10px;"/>A few days ago I blogged about the lack of Row Level Access control in symfony. Although I still have too little time I was seduced to try and tackle this problem.</p>

<p>The result is clear! A new plugin was born and it is available for all to enjoy at <a href="http://www.symfony-project.org/plugins/sfPropelRowLevelAccessBehaviorPlugin">http://www.symfony-project.org/plugins/sfPropelRowLevelAccessBehaviorPlugin</a>.</p>

<p>It is very easy to use, the details of which you can find on the plugin page and in the README file.</p>

<p>All that remains is to wish you heaps of fun coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2009/10/symfony-plugin-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Row level ACL on symfony</title>
		<link>http://www.naenius.com/2009/09/row-level-acl-on-symfony/</link>
		<comments>http://www.naenius.com/2009/09/row-level-acl-on-symfony/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 19:42:57 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[acl]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[row-level-access]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=306</guid>
		<description><![CDATA[Even though sfGuardPlugin is a great ACL plug-in; it unfortunately cannot handle Row Level Access. In most of my personal projects I require such a level of control and the solutions chosen always feel a bit ..hackish.. For those of you who do not know what Row Level Access is: Usually you grant access to [...]]]></description>
			<content:encoded><![CDATA[<dl class="wp-caption alignright" style="width: 268px;"> <dt class="wp-caption-dt"><a href="www.symfony-project.org" target="_blank"><img class="  alignright" style="border: 0pt none; float: left; margin-right: 20px;" title="symfony logo" src="http://www.symfony-project.org/downloads/logos/symfony.gif" alt="symfony logo" width="150" /></a></dt> </dl>

<p>Even though sfGuardPlugin is a great ACL plug-in; it unfortunately cannot handle Row Level Access. In most of my personal projects I require such a level of control and the solutions chosen always feel a bit ..hackish..</p>

<p><span id="more-306"></span></p>

<p>For those of you who do not know what Row Level Access is:
Usually you grant access to a part of your application based on User permissions, for example a module &#8216;Customer&#8217;. But what happens if you want to grant a particular User view rights on just one, or a few, of the customers listed in that table? That is where Row Level Access comes into play.</p>

<p>It would seem that CakePHP has some out of the box solutions (or at least, easily applied) but I have not yet come upon one for symfony. For your and my own reference is here a URL about a Row Level Access article with Cake: http://aidanlister.com/2009/05/implementing-row-level-access-control-in-cakephp/</p>

<p>I&#8217;d love to create a plug-in for this but I am somewhat limited on time ( I have more projects currently than I can finish in a reasonable amount of time) so I was hoping that maybe someone out there knows a plug-in which offers this functionality?</p>

<p>If you happen to read this post and know of one, please comment on this post where it is! Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2009/09/row-level-acl-on-symfony/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Symfony&#8217;s Lime in phpUnderControl</title>
		<link>http://www.naenius.com/2009/08/using-symfonys-lime-in-phpundercontrol/</link>
		<comments>http://www.naenius.com/2009/08/using-symfonys-lime-in-phpundercontrol/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 21:20:48 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[CI]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[lime]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpUnderControl]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=285</guid>
		<description><![CDATA[Do you know phpUnderControl? Do you know and use Lime? If you answered &#8216;Yes&#8217; to the questions above then you will likely have tried to integrate Lime into phpUnderControl. So have I.. What I discovered was that there are 3 ways in which this problem can be solved. Use Lime&#8217;s xUnit output mechanism, only available [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: right; margin-left: 10px;" src="http://www.symfony-project.org/downloads/logos/symfony.gif" alt="" width="150" /><em>Do you know phpUnderControl?
Do you know and use Lime? </em></p>

<p>If you answered &#8216;Yes&#8217; to the questions above then you will likely have tried to integrate Lime into phpUnderControl. So have I..</p>

<p>What I discovered was that there are 3 ways in which this problem can be solved.</p>

<ol>
    <li> Use Lime&#8217;s xUnit output mechanism, <span style="text-decoration: line-through;">only available in Symfony 1.3 and higher (or so I have been told)</span> available when Lime 2 is released (which is usable in symfony versions earlier than 1.3).</li>
    <li>Use Stefan Koopmanschap&#8217;s symfonyUnderControl plugin (<a href="http://www.leftontheweb.com/message/symfonyUnderControl_lime_integration_with_phpUnderControl">http://www.leftontheweb.com/message/symfonyUnderControl_lime_integration_with_phpUnderControl</a>), I only know for sure that it can be run in Symfony 1.2. Other versions of the framework might work as well.</li>
    <li>Or, and this is the subject of this post, directly use Lime from phpUnderControl</li>
</ol>

<p>The order above is (in my opinion) from best to less best, xUnit xml output is always preferred above the direct inclusion in phpUnderControl.
<span id="more-285"></span></p>

<h2>Why I post this method?</h2>

<p>There might be people who do not have the luxury of using the first two methods, for whatever reason. I have tried them because I want a light-weight solution until <span style="text-decoration: line-through;">1.3</span> Lime 2 hits the streets and the first option becomes available.</p>

<h2>What do I get?</h2>

<p>Funny that you should ask, or rather, that I asked it for you.</p>

<p>What we are going to do is add a new tab (page) to phpUnderControl where we show the output from Lime and add a task for it in CruiseControl. Whenever any test fails, the build fails and we will be able to view the information in our newly added tab.</p>

<h2>What do I have to do?</h2>

<p>Aside from creating unit tests you need to perform some actions before you will be able to use Lime. Luckily, I happen to know these steps and have written them down here. By the way: I do not intend to describe the process of adding a project to phpUnderControl, just adding the Lime checking to an existing project.</p>

<ol>
    <li>Create a directory lime in the build directory of your CruiseControl project (i.e. /opt/cruisecontrol/projects/myproject/build/lime/)</li>
    <li>Open the build.xml of the project in your favourite text editor (i.e. /opt/cruisecontrol/projects/myproject/build.xml)</li>
    <li>Append a new task (target) in the project element with the following content,


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">&nbsp;</pre></div></div>



This task will execute Lime and store the results in a lime subfolder in your build folder of your CruiseControl project.</li>
    <li>Add the target unit-test-lime to the depends attribute of your <em>build</em> target (i.e. &lt;target name=&#8221;build&#8221; depends=&#8221;checkout,clear-cache,php-codesniffer,unit-test-lime&#8221;/&gt;). It will now be used in the build cycle of phpUnderControl.</li>
    <li>To make sure the results are publicly available we need to move it to an artifacts folder (usually /opt/cruisecontrol/logs/myproject/). We can do this by adding a new artifactspublisher to the config.xml of cruisecontrol (in /opt/cruisecontrol/). In the list of publishers you can add a new line (preferably after the api publisher) which moves the output of lime to a new folder in the artifacts folder. i.e. &lt;artifactspublisher dir=&#8221;projects/${project.name}/build/lime&#8221; dest=&#8221;logs/${project.name}&#8221; subdirectory=&#8221;lime&#8221;/&gt;</li>
    <li>To add a tab (page) to phpUnderControl you need to modify one of the templates of CruiseControl, main.jsp in the /opt/cruisecontrol/webapps/cruisecontrol folder. Search for the &lt;%&#8211; phpUnderControl 8 &#8211;%&gt; text and add the following code:
<pre>    &lt;cruisecontrol:tab name="lime" label="Lime"&gt;
        &lt;cruisecontrol:artifactsLink&gt;
            &lt;iframe src="&lt;%=request.getContextPath() %&gt;/&lt; %= artifacts_url %&gt;/lime/lime.log" class="tab-content"&gt;
            &lt;/iframe&gt;
        &lt;/cruisecontrol:artifactsLink&gt;
    &lt;/cruisecontrol:tab&gt;

    &lt;%-- phpUnderControl 9 --%&gt;</pre>
This code will add a new link to the menu and show the results in an iframe, just like the phpdoc view!</li>
</ol>

<p>This is how you do it!
After the modifications show below and forcing a build, you have the results of your lime in phpUnderControl!</p>

<p>UPDATE: added some information from Bernhard in this post
UPDATE: fixed an error which was causing the snippets to become unavailable</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2009/08/using-symfonys-lime-in-phpundercontrol/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Changed theming to use Crossbrand</title>
		<link>http://www.naenius.com/2009/03/changed-theming-to-use-crossbrand/</link>
		<comments>http://www.naenius.com/2009/03/changed-theming-to-use-crossbrand/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 11:18:00 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[crossbrand]]></category>
		<category><![CDATA[maintenance]]></category>
		<category><![CDATA[site]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=274</guid>
		<description><![CDATA[I have not blogged in a while due to personal circumstances, like having started on a new job which keeps intensifying, but also because I was unsatisfied with the way my sites handle templating. Let me explain, I have a shared webhosting account and run multiple domains and subdomains. Some (actually most) of them require [...]]]></description>
			<content:encoded><![CDATA[<p><em>I have not blogged in a while due to personal circumstances, like having started on a new job which keeps intensifying, but also because I was unsatisfied with the way my sites handle templating.</em></p>

<p>Let me explain, I have a shared webhosting account and run multiple domains and subdomains. Some (actually most) of them require the same theme but have different theming mechanisms.</p>

<p>What I needed was a cross-(sub)domain branding solution!</p>

<p>Having looked around on the internet and coming to the conclusion there are none out of the box, I decided to build one myself.
Now, a month later (don&#8217;t have much spare time and more hobbies and interests <img src='http://blog.naenius.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) I can say, I am almost done!</p>

<p>This blog is now officially running on Crossbrand. I will release it to the community once I have ironed out the last glitches and finished documentation.</p>

<p>Check back regularly if you are interested!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2009/03/changed-theming-to-use-crossbrand/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A new design!</title>
		<link>http://www.naenius.com/2009/02/a-new-design/</link>
		<comments>http://www.naenius.com/2009/02/a-new-design/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 20:30:53 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Maintenance]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[naenius]]></category>
		<category><![CDATA[redesign]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=272</guid>
		<description><![CDATA[It was long overdue but I have finally managed to finish the new design for the Naenius.com website. My intention is to use this design in all subparts of this website, as well as the new parts I am concocting in my brain. With the implementation I did notice a few artifacts. For one, I [...]]]></description>
			<content:encoded><![CDATA[<p>It was long overdue but I have finally managed to finish the new design for the Naenius.com website. My intention is to use this design in all subparts of this website, as well as the new parts I am concocting in my brain.</p>

<p>With the implementation I did notice a few artifacts. For one, I did not implement a comments form. Actually I already knew about this but I was fed up with the old design and thus I decided to launch &#8216;prematurely&#8217;.
Aside from the above I noticed that the sidebar could use some additional styling. All bullets went missing in the design and this is not really my intent (specifically with the categories widget).</p>

<p>Aside from the things I mentioned above it has been a good launch! Now it is time to test this bird in Internet Explorer and hope all goes well <img src='http://blog.naenius.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

<p>If you would like to comment on this design, either wait until I have added the comments form or send me an e-mail!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2009/02/a-new-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Lotus Notes 8.5 on Kubuntu / Debian Linux KDE</title>
		<link>http://www.naenius.com/2009/02/installing-lotus-notes-85-on-kubuntu-debian-inux-kde/</link>
		<comments>http://www.naenius.com/2009/02/installing-lotus-notes-85-on-kubuntu-debian-inux-kde/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 22:54:18 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Lost in space]]></category>
		<category><![CDATA[IBM]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[Kubuntu]]></category>
		<category><![CDATA[Lotus Notes]]></category>
		<category><![CDATA[Open Beta]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=265</guid>
		<description><![CDATA[I have recently switched from employer in search of new opportunities, a new challenge and more tech-savy colleagues. After just 2 days I can say that I have found at least the latter two. Although I never expected to find a challenge in the mail system used, namely IBM Lotus Notes. After leaving my previous [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently switched from employer in search of new  opportunities, a new challenge and more tech-savy colleagues. After just 2 days I can say that I have found at least the latter two. Although I never expected to find a challenge in the mail system used, namely IBM Lotus Notes.</p>

<p>After leaving my previous employer I had hoped to leave my windows days behind for I was bound to the demonic Windows due to proprietary applications. I have adopted Kubuntu as my new Ambrosium.</p>

<p>Yet the funniest thing happened, I have to use Lotus Notus. Another windows only application by IBM.</p>

<p>As you can imagine I was mortally terrified when I learned no Linux client was there and no IMAP connection could be made (I have been told it is next to impossible with Notes). But then I found the <a href="http://www14.software.ibm.com/webapp/download/preconfig.jsp?id=2008-05-29+21%3A53%3A29.426610R&amp;S_TACT=104CBW71&amp;S_CMP=">IBM Lotus Notes 8.5 Open Beta 2 for Linux client</a>
(IBM Id needed but can be created for free during the process). This 460mb download is almost all that is needed to get it working.</p>

<p>Here are the steps that I have done to install Notes,</p>

<ol>
    <li>Download the application from the link given in the previous paragraph, choose the Debian package</li>
    <li>Untar the downloaded file <code lang="bash">tar -xvvf &lt;filename&gt;&lt;</code></li>
    <li>Install the notes debian package as root<code lang="bash">sudo dpkg -i ibm_lotus_notes-8.5.i586.deb</code></li>
    <li>In order to run the application it needs several Gnome packages. If you try to run the application but it won&#8217;t start, then you are missing some. To find out which, start the application from Konsole and it will display what it misses. The binary can be found in /opt/ibm/notes.
I missed the libgnomeprint2.2-0 and libgnomeprintui2.2-0 packages</li>
    <li>The installation has now created a folder lotus in your home folder as the user root. Since we will be starting the Lotus application with our own user we need to give it back from root to ourselves. Thus you execute <code lang="bash">chown -R &lt;youruser&gt;:&lt;youruser&gt; /home/&lt;youruser&gt;/lotus</code></li>
    <li>Run it and configure it just like you would do with the windows version</li>
</ol>

<p>After figuring out the steps above I was seriously relieved that I could stop reading my mail over a Remote Desktop connection and enjoy all that Kubuntu has to give to me.</p>

<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2009/02/installing-lotus-notes-85-on-kubuntu-debian-inux-kde/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>An introduction to Scrum</title>
		<link>http://www.naenius.com/2009/01/an-introduction-to-scrum/</link>
		<comments>http://www.naenius.com/2009/01/an-introduction-to-scrum/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 19:55:01 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Ken Schwaber]]></category>
		<category><![CDATA[QA]]></category>
		<category><![CDATA[Scrum]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=232</guid>
		<description><![CDATA[Whilst attempting to enrich my knowledge about Agile methodologies and Scrum in specific I found the site Learning Scrum. This site turned out to be a jewel and it contained a video of a Google Tech Talk by one of the Godfathers of Scrum, Ken Schwaber. In this talk he explains the history and purpose [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst attempting to enrich my knowledge about Agile methodologies and Scrum in specific I found the site <a href="http://www.learningscrum.com">Learning Scrum</a>. This site turned out to be a jewel and it contained a video of a Google Tech Talk by one of the Godfathers of Scrum, Ken Schwaber.
In this talk he explains the history and purpose of scrum as well as what usually happens when developers get into time shortage. On of my favourite quotes from the video is:
<em></em></p>

<p><em>By cutting quality we can produce more crap</em>.</p>

<p>How true&#8230;</p>

<p>Below is the embedded video as first seen through http://learningscrum.com/20080315/scrum-et-al-video/</p>

<p>If you like to know more, view this video. It is one well spend hour of your life!</p>

<p><object width="425" height="344" data="http://www.youtube.com/v/IyNPeTn8fpo&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/IyNPeTn8fpo&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2009/01/an-introduction-to-scrum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validating an e-mail address according to RFC 2822</title>
		<link>http://www.naenius.com/2009/01/validating-an-e-mail-address-according-to-rfc-2822/</link>
		<comments>http://www.naenius.com/2009/01/validating-an-e-mail-address-according-to-rfc-2822/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 10:30:33 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[2822]]></category>
		<category><![CDATA[e-mail]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[rfc]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=213</guid>
		<description><![CDATA[E-mail addresses are bitches! There, now that is said I can tell why. Should you ever have time on your hands you should read RFC 2822, it provides an interesting (though somewhat dull) background into e-mail messaging. Alas one can also see why it is so hard to validate an e-mail address, it is an [...]]]></description>
			<content:encoded><![CDATA[<p><em>E-mail addresses are bitches!
There, now that is said I can tell why.</em></p>

<p>Should you ever have time on your hands you should read <a title="RFC 2822" href="http://www.faqs.org/rfcs/rfc2822.html">RFC 2822</a>, it provides an interesting (though somewhat dull) background into e-mail messaging. Alas one can also see why it is so hard to validate an e-mail address, it is an extremely flexible format which is quite hard to check.</p>

<p><span id="more-213"></span></p>

<p>Fortunately I found a little gem on <a href="http://www.regular-expressions.info/email.html">http://www.regular-expressions.info/email.html</a> which is all about parsing E-mail addresses with regular expressions. For your (and my own) leasure I have prepared a snippet which you can copy paste right into your code.
One small note: this regexp is not fast! It is designed for accuracy, thus I&#8217;d advise so I would recommend to on a high traffic site to use the adaptations proposed on the website above.</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$regexp</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/^(?:[a-z0-9!#$%&amp;amp;'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;amp;'*+\/=?^_`{|}~-]+)*|<span style="color: #000099; font-weight: bold;">\&quot;</span>(?:[<span style="color: #660099; font-weight: bold;">\x01</span>-<span style="color: #660099; font-weight: bold;">\x08</span><span style="color: #660099; font-weight: bold;">\x0b</span><span style="color: #660099; font-weight: bold;">\x0c</span><span style="color: #660099; font-weight: bold;">\x0e</span>-<span style="color: #660099; font-weight: bold;">\x1f</span><span style="color: #660099; font-weight: bold;">\x21</span><span style="color: #660099; font-weight: bold;">\x23</span>-<span style="color: #660099; font-weight: bold;">\x5b</span><span style="color: #660099; font-weight: bold;">\x5d</span>-<span style="color: #660099; font-weight: bold;">\x7f</span>]|<span style="color: #000099; font-weight: bold;">\\</span>[<span style="color: #660099; font-weight: bold;">\x01</span>-<span style="color: #660099; font-weight: bold;">\x09</span><span style="color: #660099; font-weight: bold;">\x0b</span><span style="color: #660099; font-weight: bold;">\x0c</span><span style="color: #660099; font-weight: bold;">\x0e</span>-<span style="color: #660099; font-weight: bold;">\x7f</span>])*<span style="color: #000099; font-weight: bold;">\&quot;</span>)@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[<span style="color: #660099; font-weight: bold;">\x01</span>-<span style="color: #660099; font-weight: bold;">\x08</span><span style="color: #660099; font-weight: bold;">\x0b</span><span style="color: #660099; font-weight: bold;">\x0c</span><span style="color: #660099; font-weight: bold;">\x0e</span>-<span style="color: #660099; font-weight: bold;">\x1f</span><span style="color: #660099; font-weight: bold;">\x21</span>-<span style="color: #660099; font-weight: bold;">\x5a</span><span style="color: #660099; font-weight: bold;">\x53</span>-<span style="color: #660099; font-weight: bold;">\x7f</span>]|<span style="color: #000099; font-weight: bold;">\\</span>[<span style="color: #660099; font-weight: bold;">\x01</span>-<span style="color: #660099; font-weight: bold;">\x09</span><span style="color: #660099; font-weight: bold;">\x0b</span><span style="color: #660099; font-weight: bold;">\x0c</span><span style="color: #660099; font-weight: bold;">\x0e</span>-<span style="color: #660099; font-weight: bold;">\x7f</span>])+)\])$/&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$regexp</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mike.vanriel@naenius.com'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2009/01/validating-an-e-mail-address-according-to-rfc-2822/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating passwords in PHP</title>
		<link>http://www.naenius.com/2009/01/generating-passwords-in-php/</link>
		<comments>http://www.naenius.com/2009/01/generating-passwords-in-php/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 11:35:13 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=69</guid>
		<description><![CDATA[There are those things you encounter again and again and again. Generating passwords is one of those. My experience is that whenever an application needs to be created which deals with user account creation, it is best to let my application create a password for the user. Why? Simply, I am lazy. Good developers and [...]]]></description>
			<content:encoded><![CDATA[<p><em>There are those things you encounter again and again and again. Generating passwords is one of those. My experience is that whenever an application needs to be created which deals with user account creation, it is best to let my application create a password for the user.
</em></p>

<p>Why? Simply, I am lazy.</p>

<p>Good developers and users alike are and should be thus lazy that they should not want to think of a new password. All they need is to just generate one with a click and jot it down somewhere!
I have now encountered three or four separate applications which dealt with user creation and every time I have turned to <a href="http://www.google.com">Google</a> and find a method for generating passwords which I subsequently adapt for my own specific application.</p>

<p>To help myself and perhaps you (who probably came from the Google website as well) I have posted (one of) my password generating method(s). The code which I have used here is originally from someone else but I forgot to mention this in my source file. If you recognize this code as your own please comment it so I can give recognition where due. Thought I must comment that I have changed it quite a bit..</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * This method generates a random character value between the 33(!) and 126(~)
 * @return int
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> getRandomNum<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$rndNum</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// between 0 - 1000</span>
    <span style="color: #000088;">$rndNum</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rndNum</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">94</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">33</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// rndNum from 33 - 127</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$rndNum</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Check if a character value is a special / punctuation character, if so returns true
 * @param int $num
 * @return boolean
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> checkPunc<span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</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: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span><span style="color: #cc66cc;">33</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span><span style="color: #cc66cc;">47</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span><span style="color: #cc66cc;">58</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span><span style="color: #cc66cc;">64</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span><span style="color: #cc66cc;">91</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span><span style="color: #cc66cc;">96</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span><span style="color: #cc66cc;">123</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span><span style="color: #cc66cc;">126</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Generates a new password, if the length parameter equals false then
 * a random length is chosen between 5 and 15 characters long.
 * @param int|boolean $length
 * @param boolean $noPunctuation
 * @return string
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> generatePassword<span style="color: #009900;">&#40;</span><span style="color: #000088;">$length</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span> <span style="color: #000088;">$noPunctuation</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$length</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$length</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</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;">$i</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #000088;">$length</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$numI</span> <span style="color: #339933;">=</span> getRandomNum<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$noPunctuation</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> checkPunc<span style="color: #009900;">&#40;</span><span style="color: #000088;">$numI</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$numI</span> <span style="color: #339933;">=</span> getRandomNum<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$password</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numI</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$password</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<p><strong>Update 11-01-2009:</strong>
As it seems I had to implement a password generator in javascript today.
So I Googled one and found it on <a href="http://psacake.com/web/ei.asp">http://psacake.com/web/ei.asp</a>. This version funnily looks the same as the PHP version posted above, perhaps they share the same roots?
Anyhow, here it is:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> generatePassword<span style="color: #009900;">&#40;</span>length<span style="color: #339933;">,</span> punction<span style="color: #339933;">,</span> randomLength<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>parseInt<span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">appVersion</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Sorry this only works in 4.0 browsers&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>length<span style="color: #009900;">&#41;</span> length <span style="color: #339933;">=</span> <span style="color: #CC0000;">8</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> password <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>randomLength<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        length <span style="color: #339933;">=</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        length <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>length <span style="color: #339933;">*</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        length <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>length <span style="color: #339933;">%</span> <span style="color: #CC0000;">7</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">6</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> length<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        numI <span style="color: #339933;">=</span> getRandomNum<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>punction<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>checkPunc<span style="color: #009900;">&#40;</span>numI<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                numI <span style="color: #339933;">=</span> getRandomNum<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        password <span style="color: #339933;">=</span> password <span style="color: #339933;">+</span> String.<span style="color: #660066;">fromCharCode</span><span style="color: #009900;">&#40;</span>numI<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">return</span> password<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> getRandomNum<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// rndNum from 0 - 1000</span>
    rndNum <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// rndNum from 33 - 127</span>
    rndNum <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>rndNum <span style="color: #339933;">%</span> <span style="color: #CC0000;">94</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">33</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> rndNum<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> checkPunc<span style="color: #009900;">&#40;</span>num<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&gt;=</span><span style="color: #CC0000;">33</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">47</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&gt;=</span><span style="color: #CC0000;">58</span><span style="color: #009900;">&#41;</span>  <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">64</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&gt;=</span><span style="color: #CC0000;">91</span><span style="color: #009900;">&#41;</span>  <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">96</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&gt;=</span><span style="color: #CC0000;">123</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">126</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2009/01/generating-passwords-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My current affairs</title>
		<link>http://www.naenius.com/2009/01/my-current-affairs/</link>
		<comments>http://www.naenius.com/2009/01/my-current-affairs/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 19:11:10 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[affairs]]></category>
		<category><![CDATA[redesign]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.naenius.com/?p=54</guid>
		<description><![CDATA[I have neglected some of my contacts and social places. Although I would like to blaim my busy life for it, it is also a matter of just not making time for it. So to entertain myself and others, I can share that one of the things I am working on is a redesign of [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right">
<div id="attachment_55" class="wp-caption alignright" style="width: 160px"><a rel="attachment wp-att-55" href="http://www.naenius.com/2009/01/my-current-affairs/site-preview/"><img class="size-thumbnail wp-image-55" title="Design Teaser" src="http://blog.naenius.com/wp-content/uploads/2009/01/site-preview-150x150.png" alt="Teaser of the new Naenius design" width="150" height="150" /></a><p class="wp-caption-text">Teaser of the new Naenius design</p></div>
</div>

<p><em>I have neglected some of my contacts and social places. Although I would like to blaim my busy life for it, it is also a matter of just not making time for it.</em></p>

<p>So to entertain myself and others, I can share that one of the things I am working on is a redesign of my &#8216;brand&#8217; and website.
The logo was renewed during the last redesign and I will continue to use that. The things that needed improvement (IMHO) was that the colors could be lighter, causing a less depressing feeling and an additional reason was that I was in the mood for some graphical tinkering.</p>

<p>An additional benefit is that I am taking into account the twitter posts on my blog and make them less visible. Thus making actual posts more visible and dominant.</p>

<p>Unfortunately I have much to do and far too little time to get anything done (or so it seems these days). So all I can say is that it is underway but when it will exactly launch.. I do not know yet..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2009/01/my-current-affairs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving to a new host</title>
		<link>http://www.naenius.com/2008/12/moving-to-a-new-host/</link>
		<comments>http://www.naenius.com/2008/12/moving-to-a-new-host/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 14:58:33 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Maintenance]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[downtime]]></category>
		<category><![CDATA[maintenance]]></category>
		<category><![CDATA[moving]]></category>
		<category><![CDATA[webhost]]></category>

		<guid isPermaLink="false">http://www.naenius.nl/2008/12/moving-to-a-new-host/</guid>
		<description><![CDATA[What I want is not what I can get at my old host. Thus in order to do get what I want I have decided to move my domains to a new webhost. I have requested the move to be done monday the 22nd of december at 22.00 hours. I still need to get confirmation [...]]]></description>
			<content:encoded><![CDATA[<p>What I want is not what I can get at my old host. Thus in order to do get what I want I have decided to move my domains to a new webhost.</p>

<p>I have requested the move to be done monday the 22nd of december at 22.00 hours. I still need to get confirmation but am quite sure all will go ok.</p>

<p>During the move a notice will be placed informing you about the maintenance. This site will be unreachable in the meanwhile.</p>

<p>Now, let&#8217;s pray all goes well <img src='http://blog.naenius.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2008/12/moving-to-a-new-host/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spam has left the building &#8230; finally</title>
		<link>http://www.naenius.com/2008/12/spam-has-left-the-building-finally/</link>
		<comments>http://www.naenius.com/2008/12/spam-has-left-the-building-finally/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 19:58:26 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[akismet]]></category>
		<category><![CDATA[anti-spam]]></category>
		<category><![CDATA[missyeh]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://www.naenius.nl/?p=34</guid>
		<description><![CDATA[I have done it, on the 29th of November I finally activated Akismet and begun cleaning up spam which was still remaining on my blog. Today, I took the time and the liberty to remove the last spam comments AND write a new (perhaps for some quite uninteresting) blog post. When I started my blog [...]]]></description>
			<content:encoded><![CDATA[<p><em>I have done it, on the 29th of November I finally activated Akismet and begun cleaning up spam which was still remaining on my blog.</em></p>

<p>Today, I took the time and the liberty to remove the last spam comments AND write a new (perhaps for some quite uninteresting) blog post. When I started my blog I did not expect to be carpet bombed by this much spam but alas, even I had to undergo this torment. Due to the fact I found myself not interesting enough (yet?) to be spammed did I not bother to activate Akismet and forgot about it.
When spam issues arrived I tried several non-interesting and absolutely useless options until <a href="http://www.missyeh.nl">MissYeh</a> reminded me off Akismet. I still owe her..</p>

<p>Should anyone be reading this who is thinking about starting his own (WordPress) blog: <strong>install Akismet from day 1</strong>. It will save you a lot of headache and it will in the end save you a lot of time fixing your blog.</p>

<p>Again a big warm thanks to MissYeh for helping me remember Akismet and thank you to the creators of Akismet for doing such a fine job.</p>

<p>Until next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2008/12/spam-has-left-the-building-finally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spam part II</title>
		<link>http://www.naenius.com/2008/08/spam-part-ii/</link>
		<comments>http://www.naenius.com/2008/08/spam-part-ii/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 05:28:20 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[anti-spam]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://www.naenius.nl/?p=16</guid>
		<description><![CDATA[For some reason I seem to have become popular with the spam bots. Not quite the crowd I was hoping for It is not possible for me to keep deleting all spam until I have time to implement anti-spam measures. It is on my to-do list but other (more pressing) matters have priority. Should you [...]]]></description>
			<content:encoded><![CDATA[<p><em>For some reason I seem to have become popular with the spam bots. Not quite the crowd I was hoping for <img src='http://blog.naenius.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></p>

<p>It is not possible for me to keep deleting all spam until I have time to implement anti-spam measures. It is on my to-do list but other (more pressing) matters have priority. Should you have any good suggestions about anti-spam measures on WordPress, let me know!</p>

<p>So.. This blog ain&#8217;t dead or unmoderated, just temporarily overrun <img src='http://blog.naenius.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2008/08/spam-part-ii/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The first spam battle, I lost..</title>
		<link>http://www.naenius.com/2008/08/the-first-spam-battle-i-lost/</link>
		<comments>http://www.naenius.com/2008/08/the-first-spam-battle-i-lost/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 05:50:05 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[fail]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://www.naenius.nl/?p=15</guid>
		<description><![CDATA[I have had a spam run in the last couple of days and was forced to delete a couple of hundred spam messages. Despite the fact that I was reviewing every message if it was a valid comment or not (I unfortunately do not get many at the moment) it seems that I have overlooked [...]]]></description>
			<content:encoded><![CDATA[<p>I have had a spam run in the last couple of days and was forced to delete a couple of hundred spam messages.</p>

<p>Despite the fact that I was reviewing every message if it was a valid comment or not (I unfortunately do not get many at the moment) it seems that I have overlooked about 90% of the real comments.</p>

<p>FAIL!</p>

<p>I have now placed a small unobtrusive barrier which might temporarily slow the amount of spam and I must look into the spam issue. It is driving me bonkers..</p>

<p>I sympathize with every other blogger who ever had to deal with this..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2008/08/the-first-spam-battle-i-lost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPWomen Article contest has closed</title>
		<link>http://www.naenius.com/2008/08/phpwomen-article-contest-has-closed/</link>
		<comments>http://www.naenius.com/2008/08/phpwomen-article-contest-has-closed/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 18:32:00 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[contest]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpwomen]]></category>

		<guid isPermaLink="false">http://www.naenius.nl/?p=13</guid>
		<description><![CDATA[The PHPWomen contest has closed. As I had said earlier I have also participated in the contest. I restrained from posting the articles on my blog because it feels unfair to the community at PHPWomen. In hindsight it would have been convenient if I posted a new blog item whenever I posted a new article. [...]]]></description>
			<content:encoded><![CDATA[<p>The PHPWomen contest has closed. As I had said earlier I have also participated in the contest. I restrained from posting the articles on my blog because it feels unfair to the community at <a href="http://www.phpwomen.org" target="_blank">PHPWomen</a>.</p>

<p><img class="alignright" style="border: 0pt none ; margin: 5px; float: right;" src="http://www.phpwomen.org/wordpress/wp-content/themes/phpw/images/phpwomen-1-keyline.gif" alt="" width="260" height="65" />In hindsight it would have been convenient if I posted a new blog item whenever I posted a new article. But as with most good ideas, it came too late.</p>

<p>To compensate I will post the titles of the articles that I have written here with a deep link to the content, it is only fair that people actually visit the place where the contest was held IMHO.</p>

<p>So, without further delay, here they come:</p>

<ol>
    <li><a href="http://www.phpwomen.org/forum/index.php?t=msg&amp;th=475&amp;start=0" target="_blank">Love your class methods</a></li>
    <li><a href="http://www.phpwomen.org/forum/index.php?t=msg&amp;th=478&amp;start=0" target="_blank">Exceptions: errors on steroids</a></li>
    <li><a href="http://www.phpwomen.org/forum/index.php?t=msg&amp;th=490&amp;start=0" target="_blank">The art of docblogging</a></li>
</ol>

<p>I hope you enjoy the read and if you are there, say hello or share your wisdom on the forums!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2008/08/phpwomen-article-contest-has-closed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sometimes I temporarily get a life</title>
		<link>http://www.naenius.com/2008/07/sometimes-i-temporarily-get-a-life/</link>
		<comments>http://www.naenius.com/2008/07/sometimes-i-temporarily-get-a-life/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 20:25:17 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[ball]]></category>
		<category><![CDATA[dog]]></category>
		<category><![CDATA[fenna]]></category>
		<category><![CDATA[ijsselmeer]]></category>
		<category><![CDATA[lake]]></category>
		<category><![CDATA[walk]]></category>

		<guid isPermaLink="false">http://www.naenius.nl/?p=12</guid>
		<description><![CDATA[There are times when I do not touch a computer, it happens. I like to tabletop roleplay for example and I &#8216;own&#8217; a dog called Fenna who loves to be active. At these sort of times one might be tempted to say that I temporarily get a life. My wife suggested today to visit a [...]]]></description>
			<content:encoded><![CDATA[<p><em>There are times when I do not touch a computer, it happens. I like to tabletop roleplay for example and I &#8216;own&#8217; a dog called Fenna who loves to be active. At these sort of times one might be tempted to say that I temporarily get a life.</em></p>

<p>My wife suggested today to visit a little beachside at the <a href="http://maps.google.nl/?q=ijsselmeer" target="_blank">IJsselmeer</a>, which is a lake in the Netherlands, to allow Fenna to swim for a while. I thought this to be a good idea, given the heat and all, and off we went.<img class="alignright" style="border: 0pt none; margin: 5px; float: right;" src="http://www.naenius.com/images/deadball.png" alt="" width="300" height="200" /></p>

<p>We took two tennis balls with us to throw in the water (for some reason this is the only time balls are of any interest to Fenna?), which resulted in the utter abuse and molestation of one of those poor little balls. As is demonstrated by this picture.</p>

<p>We took this picture after Fenna had a very good time with the ball and she is currently still far too bouncy and happy happy joy joy.</p>

<p>We had pity on the other ball and kept it from her, perhaps next time it will fall victim to what seems a nice and friendly dog <img src='http://blog.naenius.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2008/07/sometimes-i-temporarily-get-a-life/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpWomen contest close to an end</title>
		<link>http://www.naenius.com/2008/07/phpwomen-contest-close-to-an-end/</link>
		<comments>http://www.naenius.com/2008/07/phpwomen-contest-close-to-an-end/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 20:28:22 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[contest]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpwomen]]></category>

		<guid isPermaLink="false">http://www.naenius.nl/?p=11</guid>
		<description><![CDATA[Tomorrow will be the last day to participate in the phpWomen contest at www.phpwomen.org. For those of you who do not know, phpWomen is a great initiative to bind the girls of the trade together in a sort of community or usergroup. It has received quite a bit of attention lately and in my opinion [...]]]></description>
			<content:encoded><![CDATA[<p><em>Tomorrow will be the last day to participate in the phpWomen contest at www.phpwomen.org.
For those of you who do not know, phpWomen is a great initiative to bind the girls of the trade together in a sort of community or usergroup.
It has received quite a bit of attention lately and in my opinion rightly so!</em></p>

<p>I have participated in the contest and am actually a bit ashamed that I have only blogged this late about it. I have been busy writing my own entries and reading that of others. I hope that authors will continue to write pieces on the forum. I know I will be there and talk as long as there is something to talk about!</p>

<p>phpWomen does allow men to post on their forum, so you do not have an excuse to pass by and say hello and even add some of your knowledge to the whole.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2008/07/phpwomen-contest-close-to-an-end/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kubuntu and a slow Eclipse</title>
		<link>http://www.naenius.com/2008/07/kubuntu-and-a-slow-eclipse/</link>
		<comments>http://www.naenius.com/2008/07/kubuntu-and-a-slow-eclipse/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 14:10:42 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Kubuntu]]></category>

		<guid isPermaLink="false">http://www.naenius.nl/?p=9</guid>
		<description><![CDATA[You know you want to do it, the move, from windows to Linux when developing locally. It works like a charm, except for Eclipse when you do not pay attention. One could wonder, why do you want to develop locally? Well, sometimes (twice a day) I travel by train. And sitting still is very hard [...]]]></description>
			<content:encoded><![CDATA[<p><em>You know you want to do it, the move, from windows to Linux when developing locally. It works like a charm, except for Eclipse when you do not pay attention.</em></p>

<p>One could wonder, why do you want to develop locally? Well, sometimes (twice a day) I travel by train. And sitting still is very hard for me (tend to get bored easily) and thus I wanted to be able to do some work in that time. When you do not have a 24&#215;7 UMTS high speed internet connection (or alike) you just have to do it sometimes.</p>

<p>This is where Linux plays an important part, in linux you can simulate your production environment as closely as possible to make deployments and or exchanges as painless as possible.
Unfortunately Eclipse tends to grind to a halt when you want to do anything more complicated then typing.
Fortunately, there is a fix!</p>

<p>First of all, install Eclipse (I advise the downloadable version with PDT included because the Aptitude version of Eclipse is one number behind (3.2) and PDT 1.x won&#8217;t run on it (hasn&#8217;t got WST 2.0.0 or higher).
When done, get the Java Sun 6 package from Aptitude with the following command:
<code>sudo apt-get install sun-java6-bin sun-java6-jdk sun-java6-jre</code>
Did it? Good!</p>

<p>Unfortunately Linux might not understand you actually want this to be your default JVM so you need to edit /etc/jvm and type the path where your JRE is installed at the top of the list (usually this is /usr/lib/jvm/java-6-sun
<code>sudo nano /etc/jvm</code>
In some case Eclipse does not dig it either (annoying, is it not?) and you can force Eclipse as well to use your new Sun JVM by placing the path in the /etc/eclipse/java_home file (or wherever your eclipse installation path is)
<code>sudo nano /etc/eclipse/java_home</code>
Last but not least: tell your linux version to use this JVM with the following command:
<code>sudo update-java-alternatives --set java-6-sun</code>
After this, your eclipse (and other Java applications) will work like never before!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2008/07/kubuntu-and-a-slow-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Errorhandling in PHP, now with Fatal Errors included</title>
		<link>http://www.naenius.com/2008/05/errorhandling-in-php-now-with-fatal-errors-included/</link>
		<comments>http://www.naenius.com/2008/05/errorhandling-in-php-now-with-fatal-errors-included/#comments</comments>
		<pubDate>Fri, 16 May 2008 06:18:11 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Error Handling]]></category>
		<category><![CDATA[Fatal Errors]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Singleton]]></category>

		<guid isPermaLink="false">http://www.naenius.nl/?p=8</guid>
		<description><![CDATA[Every once in a while you stumble upon a topic that you thought would have been completely covered. This I thought as well about PHP Errorhandling. Although resources are abundant about the topic, most of them cover Error handling without handling the Fatal Errors or with hacks for a solution. This last problem can easily [...]]]></description>
			<content:encoded><![CDATA[<p><em>Every once in a while you stumble upon a topic that you thought would have been completely covered. This I thought as well about PHP Errorhandling. Although resources are abundant about the topic, most of them cover Error handling without handling the Fatal Errors or with hacks for a solution.</em></p>

<p>This last problem can easily be solved as I wil explain in this post. We wil build an errorhandling class which starts trapping errors from the moment it comes into existance.</p>

<p>What comes first in such a task is to review what it must do, for this specific class we assume the following:</p>

<ul>
    <li>We run PHP 5.2.0 or higher, this is needed for our little trick</li>
    <li>The class must be a singleton</li>
    <li>It must trap all possible errors, including fatal errors</li>
    <li>Once trapped, we can do custom handling with them and then pass the error to the defaulthandler</li>
</ul>

<h2>The class skeleton</h2>

<p>Since we have stated as a requirement that our class should be a singleton, we will have to define the constructor as being private and create a getInstance method. The latter will instantiate the class the first time it is called.</p>

<p>Below is an example of how to do a singleton class skeleton:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> My_ErrorHandler <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> getInstance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    static <span style="color: #000088;">$Instance</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$Instance</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$Instance</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> My_ErrorHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$Instance</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<p>Although this post is not about Singletons in PHP I might as well explain a little about the code above.
In our new class we define the constructor as private, which effectively means that we can only instantiate this class from within and not from another class.</p>

<p><em>Protected would do as well and would perhaps be better because classes which extend this one can also call the constructor, but I leave this open to debate</em></p>

<p>And to round up we create a static method named getInstance (sounds logical?) which contains a static variable holding the instance. When this method is called we check whether the static variable contains our instance and if it does not, we instantiate is.
It really is that simple.</p>

<p><em>For the sake of completeness I must add that another way is to define our instance variable as a private static class variable instead of a method variable, this has the added advantage that other functions in the class could use it. I personally like to encapsulate it this way.</em></p>

<h2>Errorhandling as you know it</h2>

<p>Now that we have the basis for our errorhandling class, let&#8217;s create an error handling method as described in the <a href="http://nl.php.net/manual/en/function.set-error-handler.php" target="_blank">PHP Manual</a>. It is actually quite simple and I will quickly go over it.</p>

<p>All one has to do is define a method and register it to PHP with the set_error_handler call. A method needs to have 5 parameters:</p>

<ul>
    <li>An error level, this gives an integer corresponding to the E_ error constants fo PHP, i.e. E_WARNING</li>
    <li>A message, here we receive the text accompanying the error</li>
    <li>A file name, this is the file in which the error was triggered</li>
    <li>A line number, this is the line number where the error occurred</li>
    <li>An errorcontext, this is an array containing all the variables and their values in the scope where and when the error occurred</li>
</ul>

<p>Now we can choose, do we fully handle the error ourselves, including handling when to die the script or not?
This can be done by the return value of our method. If we return false, the default PHP error handler handles the error. And if you do not specify a return value PHP will believe you handled the complete error and continue executing where it was.
<em>I usually return false since I want to catch the errors and do something extra, like send it to the Syslog or sending an e-mail in some cases.</em></p>

<p>Example:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> error<span style="color: #009900;">&#40;</span><span style="color: #000088;">$level</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$line</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ctx</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;">error_reporting</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Do something here ...</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<p>You might have noticed that I check whether error_reporting is larger than zero. This is because of the at(@) operator. If we do not check this we end up handling the errors which were supposed to be silenced via the @ command.</p>

<p>To wrap this part up, we insert the set_error_handler call to the constructor of our class. This makes sure that once the class has been instantiated, we immediately start catching errors.
By the way, if you intend to send output to for example a Syslog, make sure you tell PHP to give plain text message instead of HTML typed.
Should you intend to use assert statements, add ASSERT_WARNING to your assert options.</p>

<p>Another example showing all of the above:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'html_errors'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">set_error_handler</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">assert_options</span> <span style="color: #009900;">&#40;</span>ASSERT_WARNING<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<h2>Catching the fatal error</h2>

<p>The above is all fun but well, it still does not catch the dreaded fatal error which let&#8217;s your application end up all white.
Well, this is what we are going to address now and is actually really simple once you know it (and you run PHP 5.2+, but you do that, right?)</p>

<p>With PHP 5.2.0 a new command was introduced, namely: <a href="http://nl.php.net/manual/en/function.error-get-last.php" target="_blank">error_get_last</a>.
This function returns the last error which has occurred in PHP. Although it might not sound exciting, try combining it with <a href="http://nl.php.net/manual/en/function.register-shutdown-function.php" target="_blank">register_shutdown_function</a>.</p>

<p>If you register a shutdown function which calls <a href="http://nl.php.net/manual/en/function.error-get-last.php" target="_blank">error_get_last</a> and checks if an error has occurred, it can call our previously defined error function with the given level, message, file and line. With this call we have automatically caught our fatal errors as well!</p>

<p>Let me show you:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> shutdown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #990000;">error_get_last</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$error</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>error<span style="color: #009900;">&#40;</span><span style="color: #000088;">$error</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$error</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$error</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$error</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'line'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<p>And we call the register function in our constructor as well:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// .. Things we have defined above ..</span>
  <span style="color: #990000;">register_shutdown_function</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'shutdown'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<h2>Conclusion</h2>

<p>This is all there is to it, if you call My_Errorhandler::getInstance() at the beginning of your script then all your custom error handling will automatically be invoked.
You can use the power of this function to pro-actively handle errors instead of waiting for users to report them to you. Just couple this with your Syslog or auto-mail the development department and you will know when things go bad.</p>

<p>I know I had fun writing this, I hope you have by implementing this!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2008/05/errorhandling-in-php-now-with-fatal-errors-included/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing LDAP</title>
		<link>http://www.naenius.com/2008/05/testing-ldap/</link>
		<comments>http://www.naenius.com/2008/05/testing-ldap/#comments</comments>
		<pubDate>Fri, 02 May 2008 20:09:25 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Apache DS]]></category>
		<category><![CDATA[LDAP]]></category>

		<guid isPermaLink="false">http://www.naenius.nl/?p=6</guid>
		<description><![CDATA[Since I tend to work quite a bit at home, for the company or just for myself, I need to work off the Business Intranet quite some times. This causes some problems when you are developing certain functionalities like a LDAP authentication mechanism in my new SOA Platform (I will blog about it in a [...]]]></description>
			<content:encoded><![CDATA[<p><em>Since I tend to work quite a bit at home, for the company or just for myself, I need to work off the Business Intranet quite some times.</em></p>

<p>This causes some problems when you are developing certain functionalities like a LDAP authentication mechanism in my new SOA Platform (I will blog about it in a later stadium). One of the problems is a lack of a LDAP server (how surprising).
Usually this should not cause any problems since most types of servers are found online and have portable versions suitable for Windows, the OS I am currently stuck with.</p>

<p><strong>However</strong>, LDAP is a different story. OpenLDAP, the most used implementation appears to be linux only and the windows port approximates ancient. Thus we had to look onwards for an alternative. After one and a half hours searching I found the Apache Directory Server (http://directory.apache.org/apacheds/1.5/index.html)
, which seemed a blessing at that time.
Currently I am toying with it and seeing what it can do, it looks like a good product but the learning curve is a bit steep since no GUIs are installed with the product. This has dampened my enthusiasm somewhat but I have just downloaded Apache DS Studio (based on Eclipse) and will see how it all works out..</p>

<p>In my next blog item more about this!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2008/05/testing-ldap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dutch PHP Business Seminar == excellent</title>
		<link>http://www.naenius.com/2008/04/dutch-php-business-seminar-excellent/</link>
		<comments>http://www.naenius.com/2008/04/dutch-php-business-seminar-excellent/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 13:56:03 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Seminar]]></category>
		<category><![CDATA[SOA]]></category>

		<guid isPermaLink="false">http://www.naenius.nl/?p=5</guid>
		<description><![CDATA[I like to learn, it might seem odd for some people but I just like it. There is never enough time to learn everything but attending a Seminar is surely one way to increase your learning efficiency. And so I did attend the Dutch PHP Business Seminar for the first time. It was offered by [...]]]></description>
			<content:encoded><![CDATA[<p><em>I like to learn, it might seem odd for some people but I just like it. There is never enough time to learn everything but attending a Seminar is surely one way to increase your learning efficiency.</em></p>

<p>And so I did attend the Dutch PHP Business Seminar for the first time. It was offered by iBuildings and Sogeti and covered SOA and Security in PHP. Both are topics in which cannot get enough attention!
Two tracks were available, Engineering and Management. In my role as developer and &#8216;representative&#8217; of my company I choose to attend the Engineering track.</p>

<h2>Opening</h2>

<p>First off, Ivo Jansch (CTO iBuildings, www.jansch.nl) opened the Seminar with a speech about the penetration of PHP into the Enterprise business&#8217;. Although technically it did not give insight into any subjects, I very much enjoyed the statistical and historical information which was given.
For example: <code><em>Did you know that of the top 10 visited sites in the Netherlands, 7 are running on PHP? And that 45% of the dutch domains use PHP to display their pages?</em></code>For me as trivia fanatic I love to hear about those facts, I believe I even bored some friends and collegues with those afterward.</p>

<div id="__ss_369255" style="width: 425px; text-align: left;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=php-in-the-enterprise-ivo-jansch-1208962226649498-8" /><embed type="application/x-shockwave-flash" width="425" height="355" src="http://static.slideshare.net/swf/ssplayer2.swf?doc=php-in-the-enterprise-ivo-jansch-1208962226649498-8" allowscriptaccess="always" allowfullscreen="true"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"><a href="http://www.slideshare.net/?src=embed"><img style="border:0px none;margin-bottom:-5px" src="http://static.slideshare.net/swf/logo_embd.png" alt="SlideShare" /></a> | <a title="View this slideshow on SlideShare" href="http://www.slideshare.net/phpseminar/php-in-the-enterprise-ivo-jansch">View</a> | <a href="http://www.slideshare.net/upload">Upload your own</a></div>
</div>

<p><img style="visibility:hidden;width:0px;height:0px;" src="http://counters.gigya.com/wildfire/CIMP/bT*xJmx*PTEyMDk1NjE4ODUzOTAmcHQ9MTIwOTU2MTg4ODUwMCZwPTEwMTkxJmQ9Jm49Jmc9Mg==.jpg" border="0" alt="" width="0" height="0" /></p>

<h2>Webservices in PHP</h2>

<p>After Ivo finished his talk it was time to start the Engineering Track. Here we were welcomed by Peter Verhage. Who gave an overview of Web services and which technologies are being used. Basically he named REST, SOAP and JSON as ways to accomplish interaction between the services and showed some source code. Although it usually is a matter of choice which way to go, every technology has it&#8217;s advantages. I do not intend to repeat his speech here, so i will just post the sheets from slideshare.</p>

<div id="__ss_369258" style="width: 425px; text-align: left;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=webservices-in-php-peter-verhage-1208962241260924-8" /><embed type="application/x-shockwave-flash" width="425" height="355" src="http://static.slideshare.net/swf/ssplayer2.swf?doc=webservices-in-php-peter-verhage-1208962241260924-8" allowscriptaccess="always" allowfullscreen="true"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"><a href="http://www.slideshare.net/?src=embed"><img style="border:0px none;margin-bottom:-5px" src="http://static.slideshare.net/swf/logo_embd.png" alt="SlideShare" /></a> | <a title="View this slideshow on SlideShare" href="http://www.slideshare.net/phpseminar/webservices-in-php-peter-verhage">View</a> | <a href="http://www.slideshare.net/upload">Upload your own</a></div>
</div>

<p><img style="visibility:hidden;width:0px;height:0px;" src="http://counters.gigya.com/wildfire/CIMP/bT*xJmx*PTEyMDk1NjIyODMyODEmcHQ9MTIwOTU2MjI4NDM3NSZwPTEwMTkxJmQ9Jm49Jmc9Mg==.jpg" border="0" alt="" width="0" height="0" /></p>

<h2>PHP Secure Application Development</h2>

<p>Robert van der Linde gave this rather impressive speech. What he told sounded like it should be common sense but you could not get the feeling &#8216;Am I doing enough about it?&#8217;. This rather distinct and at times uncomfortable feeling was amplified by the strong points given by Robert.
I could feel myself consciously implementing whitelisting on services, two days after this speech when I was working on a Webservices platform. Thus I can only conclude that it had made an impact on me.</p>

<div id="__ss_369259" style="width: 425px; text-align: left;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=php-secure-application-development-robert-van-der-linde-1208962204305158-8" /><embed type="application/x-shockwave-flash" width="425" height="355" src="http://static.slideshare.net/swf/ssplayer2.swf?doc=php-secure-application-development-robert-van-der-linde-1208962204305158-8" allowscriptaccess="always" allowfullscreen="true"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"><a href="http://www.slideshare.net/?src=embed"><img style="border:0px none;margin-bottom:-5px" src="http://static.slideshare.net/swf/logo_embd.png" alt="SlideShare" /></a> | <a title="View this slideshow on SlideShare" href="http://www.slideshare.net/phpseminar/php-secure-application-development-robert-van-der-linde">View</a> | <a href="http://www.slideshare.net/upload">Upload your own</a></div>
</div>

<p><img style="visibility:hidden;width:0px;height:0px;" src="http://counters.gigya.com/wildfire/CIMP/bT*xJmx*PTEyMDk1NjE4NzcxNDAmcHQ9MTIwOTU2MjgwNjMyOCZwPTEwMTkxJmQ9Jm49Jmc9Mg==.jpg" border="0" alt="" width="0" height="0" /></p>

<h2>Last but not least: the keynote</h2>

<p>The keynote was given by Cal Evans, a PHP Evangelist and Editor at Zend (if you know PHP you should know him). As last year his talk was amusing, insightful and at times disturbing (in a good way). He gave a speech about the changing role of the IT Specialist, that we change from &#8216;Gatekeepers&#8217; to &#8216;Gardeners&#8217;. Although I would like to rephrase the words as changing from &#8216;Secret Society Member&#8217; to &#8216;Caretaker&#8217;. And I could not shed the feeling that I had to agree that we need to be open to our users and give them a voice.
I think Cal told it best and should you wish to reread his comments about the seminar you can so do on <a href="http://blog.calevans.com/2008/04/24/amsterdam-wrap-up-the-directors-cut/" target="_blank">his blog</a>.</p>

<div id="__ss_369257" style="width: 425px; text-align: left;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=gardeners-not-gatekeepers-cal-evans-1208962256763966-9" /><embed type="application/x-shockwave-flash" width="425" height="355" src="http://static.slideshare.net/swf/ssplayer2.swf?doc=gardeners-not-gatekeepers-cal-evans-1208962256763966-9" allowscriptaccess="always" allowfullscreen="true"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"><a href="http://www.slideshare.net/?src=embed"><img style="border:0px none;margin-bottom:-5px" src="http://static.slideshare.net/swf/logo_embd.png" alt="SlideShare" /></a> | <a title="View this slideshow on SlideShare" href="http://www.slideshare.net/phpseminar/gardeners-not-gatekeepers-cal-evans">View</a> | <a href="http://www.slideshare.net/upload">Upload your own</a></div>
</div>

<p><img style="visibility:hidden;width:0px;height:0px;" src="http://counters.gigya.com/wildfire/CIMP/bT*xJmx*PTEyMDk1NjMzODkxNDAmcHQ9MTIwOTU2MzM5MDEyNSZwPTEwMTkxJmQ9Jm49Jmc9Mg==.jpg" border="0" alt="" width="0" height="0" /></p>

<h2>Conclusion</h2>

<p>At first my conclusion would be that this blog posting has become far too big, but I just had to write down my experiences of the Seminar and with them my thoughts and feelings about the talks which have been held.</p>

<p>All in all, I had a blast!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2008/04/dutch-php-business-seminar-excellent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My first talk</title>
		<link>http://www.naenius.com/2008/04/my-first-talk/</link>
		<comments>http://www.naenius.com/2008/04/my-first-talk/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 20:21:45 +0000</pubDate>
		<dc:creator>mvriel</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Intro]]></category>

		<guid isPermaLink="false">http://projects.dev.naenius.nl/wp/?p=4</guid>
		<description><![CDATA[I knew it when the hype begun.. I tried to postpone what I knew would be inevitable.. Alas, I could not resist or stay behind anymore.. I needed.. a blog From the moment blogging became popular, I thought that what I had to say was not important enough. At least not in my opinion. Time [...]]]></description>
			<content:encoded><![CDATA[<p><em>I knew it when the hype begun.. I tried to postpone what I knew would be inevitable.. Alas, I could not resist or stay behind anymore.. I needed.. a blog</em></p>

<p>From the moment blogging became popular, I thought that what I had to say was not important enough. At least not in my opinion. Time has gone by and I have come to see that I might have something valuable to say or at least to write. Though I could be mistaken, it is becoming wise to at least save my findings for my own benefit or of those around me.</p>

<p>My main passions in life are Development and Tabletop RPGs, one can expect most blog postings to be about this. Although I have the flaw of losing interest in posting on a blog or forum after some time I do intend to keep up this blog since it is also for my own sake.</p>

<p>Should you agree or disagree with anything I say, just leave a comment (no trolling please, this will be ignored and perhaps even removed). It <strong>will</strong> be read.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.naenius.com/2008/04/my-first-talk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

