<?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>Jeroen Smeets &#187; coding</title>
	<atom:link href="http://jeroensmeets.net/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeroensmeets.net</link>
	<description>technische dienst van &#039;t web</description>
	<lastBuildDate>Thu, 29 Mar 2012 19:36:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Setup Postfix to forward incoming email to PHP</title>
		<link>http://jeroensmeets.net/setup-postfix-to-forward-incoming-email-to-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setup-postfix-to-forward-incoming-email-to-php</link>
		<comments>http://jeroensmeets.net/setup-postfix-to-forward-incoming-email-to-php/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 13:40:20 +0000</pubDate>
		<dc:creator>Jeroen</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://jeroensmeets.net/?p=93</guid>
		<description><![CDATA[Setting this up took me a couple of minutes &#8212; finding the reason why it didn&#8217;t work a couple of hours. The question has hundreds of hits on Google, a simple answer hasn&#8217;t. Hope this helps someone somewhere you. Create script to parse incoming mail &#60;?php   $data = file_get_contents("php://stdin"); ?&#62; Add a new email address [...]]]></description>
			<content:encoded><![CDATA[<p>Setting this up took me a couple of minutes &#8212; finding the reason why it didn&#8217;t work a couple of hours. The question has hundreds of hits on Google, a simple answer hasn&#8217;t. Hope this helps <del datetime="2009-03-25T12:11:56+00:00">someone somewhere</del> you.</p>
<h3>Create script to parse incoming mail</h3>
<pre>&lt;?php
  $data = file_get_contents("php://stdin");
?&gt;</pre>
<h3>Add a new email address to Postfix configuration</h3>
<pre>sudo vi /etc/aliases</pre>
<p>and add the following line (everything on one line)</p>
<pre>email+to+redirect: "| php -q /home/user/full/path/to/your/new/script.php"</pre>
<p>Apply the changes to the aliases by running</p>
<pre>newaliases</pre>
<p>To make sure Postfix will pick up the newly added alias soon. If you&#8217;re in a hurry, do a</p>
<pre>/etc/init.d/postfix reload</pre>
<h3>Aaaaaah!</h3>
<p>One thing that took some time to figure out: my php script ran ok from the prompt, I had supplied it with test data and I saw all the expected data in my database. Yet, when I triggered the script by sending an email to the new address, Postfix bounced it right back at me, saying</p>
<pre>The e-mail system was unable to deliver the message,
but did not report a specific reason. Check the address and try again.
If it still fails, contact your system administrator.

&lt; xxx.yyy #5.0.0 X-Postfix; Command died with status 255:
   &quot;php -q /home/user/full/path/to/your/new/script.php&quot;&gt;</pre>
<p>In the end, the reason for this error is simple. It is Postfix telling me PHP stopped executing the script as it found an error. In my case, the error occured when the script ran as user Nobody. When tested from the prompt, I didn&#8217;t get the error, as the user had sufficient rights.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeroensmeets.net/setup-postfix-to-forward-incoming-email-to-php/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Programming Brain Teaser</title>
		<link>http://jeroensmeets.net/programming-brain-teaser/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=programming-brain-teaser</link>
		<comments>http://jeroensmeets.net/programming-brain-teaser/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 08:49:24 +0000</pubDate>
		<dc:creator>Jeroen</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://jeroensmeets.net/?p=29</guid>
		<description><![CDATA[Dustin Diaz told a programmer&#8217;s riddle &#8212; impossible to leave these things alone. So I wrote a solution. One thing bugs me: the itch that this could be done much, much easier. var arr = ['a', 'b', 'c', 'c', 'd','e', 'e', 'e', 'e', 'e', 'f', 'e', 'f', 'e', 'f', 'a', 'a', 'a', 'f', 'f', 'f']; [...]]]></description>
			<content:encoded><![CDATA[<p>Dustin Diaz told <a href="http://www.dustindiaz.com/programming-brain-teaser/">a programmer&#8217;s riddle</a> &#8212; impossible to leave these things alone. So I wrote a solution. One thing bugs me: the itch that this could be done much, much easier.</p>
<pre>var arr = ['a', 'b', 'c', 'c', 'd','e', 'e',
              'e', 'e', 'e', 'f', 'e', 'f', 'e',
              'f', 'a', 'a', 'a', 'f', 'f', 'f'];
var bingo = false;
// first two are never in a span
var result = arr[0] + ' ' + arr[1];
// old fashioned for to start at 3rd element
for (var i = 2; i &lt; arr.length; i++) {
  // is this the third in a row?
  if ((arr[i] == arr[i-1]) &amp;&amp; (arr[i] == arr[i-2])) {
    // start bookending them if that hasn't already been done
    if (!bingo) {
      result += ' &lt;span&gt;';
      bingo = true;
    }
  } else {
    if (bingo) {
      result += '&lt;/span&gt;';
      bingo = false;
    }
  }
  result += ' ' + arr[i];
}

// close last one?
if (bingo) {
  result += '&lt;/span&gt;';
}

// remove space after opening span tag
result = result.replace(/&lt;span&gt; /g, '&lt;span&gt;');
alert(result);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jeroensmeets.net/programming-brain-teaser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

