<?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/"
	>

<channel>
	<title>Anders Lundgren</title>
	<atom:link href="http://www.alundgren.se/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alundgren.se</link>
	<description>A piece of me</description>
	<pubDate>Tue, 25 Jan 2011 10:00:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Imagick resize filter comparison using PHP</title>
		<link>http://www.alundgren.se/2011/01/24/imagick-resize-filter-comparison-using-php/</link>
		<comments>http://www.alundgren.se/2011/01/24/imagick-resize-filter-comparison-using-php/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 18:18:40 +0000</pubDate>
		<dc:creator>Anders Lundgren</dc:creator>
		
		<category><![CDATA[Computers]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.alundgren.se/?p=107</guid>
		<description><![CDATA[For some time I've been using GD lib for generating thumbnails. The solution was never satisfying since you need different functions to output different image formats. For some reason the getimagesize() function stoped working so I decided it was time to rewrite the code, and this time Imagick caught my attention.]]></description>
			<content:encoded><![CDATA[<p>For some time I&#8217;ve been using GD lib for generating thumbnails. The solution was never satisfying since you need different functions to output different image formats. For some reason the getimagesize() function stoped working so I decided it was time to rewrite the code, and this time Imagick caught my attention.</p>
<p>Thanks to the Imagick PHP class the thumbnail generating process is really easy. You don&#8217;t have to do much, just pass the dimension of the thumbnail, what filter to use, blur factor and if it should try to use best-fit. Done! Except for one thing. There are 16 filters to choose from and the computation penalty varies. So which filter is the best one?</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-2901355957576730";
/* Alundgren.se 468x60, skapad 2009-06-10 */
google_ad_slot = "2882775280";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>For the tests I was using a JPEG photo with dimensions 2551 x 1701 (w x h) and 949 Kib in size. To test the filter I created thumbnails in the sizes 640, 200, 180, 130, 75 and 50 pixels in a square box model, that is the thumbnail must not be larger than a 50&#215;50 pixel box. To measure the time it takes for each filter to generate the thumbnails I was using the Linux shell time command:<br />
<code>$ time php resize.php image_Z.jpg</code></p>
<p>And here is the complete PHP script:</p>
<p><code>&lt;?php<br />
$filter = Imagick::FILTER_BOX;<br />
$i = new Imagick($argv[1]);<br />
$i-&gt;setImageOpacity(1.0);<br />
$h = $i-&gt;getImageHeight();<br />
$w = $i-&gt;getImageWidth();</code></p>
<p><code>echo "According to Imagick the image is ".$w."x".$h." pixels.\n";</code></p>
<p><code> </code></p>
<p><code>$sizes = array(</code></p>
<p style="padding-left: 30px;"><code><br />
'_F' =&gt; 640,<br />
'_E' =&gt; 200,<br />
'_D' =&gt; 180,<br />
'_C' =&gt; 130,<br />
'_B' =&gt; 75,<br />
'_A' =&gt; 50</code></p>
<p><code>);</code></p>
<p><code>foreach ($sizes as $label =&gt; $size) {</code></p>
<p style="padding-left: 30px;"><code><br />
echo "Resizing to ".$size."x".$size."... ";<br />
$i-&gt;resizeImage($size, $size, $filter, 1, true);<br />
$i-&gt;writeImage(str_replace('_Z', $label, $argv[1]));<br />
echo &#8220;Done\n&#8221;;</code></p>
<p><code>}</code></p>
<p><code> </code></p>
<p><code>?&gt;<br />
</code></p>
<p>Now I just ran the script for all the filters to measure the times. The times are the mean value of all runs. The size column is simply the size of the 640 pixel thumbnail.</p>
<table style="width: 90%;" border="0">
<tbody>
<tr>
<th>Filter</th>
<th>Real</th>
<th>User</th>
<th>Sys</th>
<th>Size</th>
</tr>
<tr>
<td>undefined</td>
<td><span style="color: #af1218;">1.273</span></td>
<td>0.645</td>
<td>0.110</td>
<td>179844</td>
</tr>
<tr>
<td>point</td>
<td>0.967</td>
<td>0.795</td>
<td>0.155</td>
<td><span style="color: #af1218;">202263</span></td>
</tr>
<tr>
<td>box</td>
<td>1.006</td>
<td>0.840</td>
<td>0.140</td>
<td>186783</td>
</tr>
<tr>
<td>triangle</td>
<td>1.155</td>
<td>0.935</td>
<td>0.155</td>
<td>178033</td>
</tr>
<tr>
<td>hermite</td>
<td>1.075</td>
<td>0.925</td>
<td>0.130</td>
<td>181151</td>
</tr>
<tr>
<td>hanning</td>
<td><span style="color: #af1218;">1.216</span></td>
<td>1.045</td>
<td>0.150</td>
<td>190509</td>
</tr>
<tr>
<td>hamming</td>
<td><span style="color: #af1218;">1.259</span></td>
<td>0.990</td>
<td>0.165</td>
<td><span style="color: #af1218;">191234</span></td>
</tr>
<tr>
<td>blackman</td>
<td>1.188</td>
<td>1.035</td>
<td>0.135</td>
<td>189332</td>
</tr>
<tr>
<td>gaussian</td>
<td>0.785</td>
<td>0.540</td>
<td>0.130</td>
<td><span style="color: #339966;">172981</span></td>
</tr>
<tr>
<td>quadratic</td>
<td><span style="color: #339966;">0.657</span></td>
<td>0.515</td>
<td>0.125</td>
<td><span style="color: #339966;">172130</span></td>
</tr>
<tr>
<td>cubic</td>
<td><span style="color: #339966;">0.769</span></td>
<td>0.605</td>
<td>0.150</td>
<td><span style="color: #339966;">167606</span></td>
</tr>
<tr>
<td>catrom</td>
<td><span style="color: #339966;">0.769</span></td>
<td>0.595</td>
<td>0.155</td>
<td>186291</td>
</tr>
<tr>
<td>mitchell</td>
<td>0.803</td>
<td>0.620</td>
<td>0.130</td>
<td>179844</td>
</tr>
<tr>
<td>lanczos</td>
<td>0.995</td>
<td>0.855</td>
<td>0.125</td>
<td><span style="color: #af1218;">190593</span></td>
</tr>
<tr>
<td>bessel</td>
<td>1.058</td>
<td>0.890</td>
<td>0.125</td>
<td>177809</td>
</tr>
<tr>
<td>sinc</td>
<td>1.178</td>
<td>1.000</td>
<td>0.135</td>
<td>189332</td>
</tr>
</tbody>
</table>
<p>Now, let&#8217;s picture that with a graph.</p>
<div id="attachment_120" class="wp-caption aligncenter" style="width: 501px"><a href="/wp-content/2011/01/imagick-filter-comparison-graph-1024x597.png"><img class="size-large wp-image-120  " title="Imagick filter comparison graph" src="http://www.alundgren.se/wp-content/2011/01/imagick-filter-comparison-graph-1024x597.png" alt="Imagick filter comparison graph" width="491" height="286" /></a><p class="wp-caption-text">Imagick filter comparison graph (click for larger image)</p></div>
<p>Take a look at the smaller thumbnail, less than 200 pixels. It&#8217;s here you&#8217;ll see the difference between the various filters. For my test image the Quadratic and Cubic filters generates a very blury thumbnail. I guess you have to test the filters for the type of images you will resize, in my case the Lanczos and Catrom filters generated about the same result. I decided to go with Catrom since it is faster.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alundgren.se/2011/01/24/imagick-resize-filter-comparison-using-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ffmpeg and h.264 in Debian Lenny</title>
		<link>http://www.alundgren.se/2010/06/10/ffmpeg-and-h264-in-debian-lenny/</link>
		<comments>http://www.alundgren.se/2010/06/10/ffmpeg-and-h264-in-debian-lenny/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 22:30:59 +0000</pubDate>
		<dc:creator>Anders Lundgren</dc:creator>
		
		<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://www.alundgren.se/?p=101</guid>
		<description><![CDATA[Ever tried to transcode into H.264 using ffmpeg in Debian Lenny just to end up with this message
Unknown encoder &#8216;libx264&#8242;
Here is how you solve the problem:

Download the debian-multimedia-keyring package
Install it dpkg -i debian-multimedia-keyring_2008.10.16_all.deb
Add the Debian Multimedia repository to your sources.list
Run apt-get update and apt-get upgrade
Install the libx264 and ffmpeg packages; apt-get install libx264 ffmpeg or [...]]]></description>
			<content:encoded><![CDATA[<p>Ever tried to transcode into H.264 using ffmpeg in Debian Lenny just to end up with this message</p>
<p>Unknown encoder &#8216;libx264&#8242;</p>
<p>Here is how you solve the problem:</p>
<ol>
<li>Download the <a href="http://www.debian-multimedia.org/pool/main/d/debian-multimedia-keyring/debian-multimedia-keyring_2008.10.16_all.deb">debian-multimedia-keyring</a> package</li>
<li>Install it <code>dpkg -i debian-multimedia-keyring_2008.10.16_all.deb</code></li>
<li>Add the <a href="http://debian-multimedia.org/">Debian Multimedia</a> repository to your sources.list</li>
<li>Run <code>apt-get update</code> and <code>apt-get upgrade</code></li>
<li>Install the libx264 and ffmpeg packages; <code>apt-get install libx264 ffmpeg</code> or <code>apt-get --reinstall install libx264 ffmpeg</code></li>
</ol>
<p>Good luck!</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-2901355957576730";
/* Alundgren.se 468x60, skapad 2009-06-10 */
google_ad_slot = "2882775280";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.alundgren.se/2010/06/10/ffmpeg-and-h264-in-debian-lenny/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JavaScript Date Format in Swedish</title>
		<link>http://www.alundgren.se/2010/03/10/javascript-date-format-in-swedish/</link>
		<comments>http://www.alundgren.se/2010/03/10/javascript-date-format-in-swedish/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 23:27:35 +0000</pubDate>
		<dc:creator>Anders Lundgren</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.alundgren.se/?p=97</guid>
		<description><![CDATA[Found myself &#8220;late-night-surfing&#8221; again, but this time I actually found something interesting. Steven Levithan has written an easy-to-use and easy-to-extend JavaScript date format function. So, to encourage his great work I publish the Swedish translation.

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör",
		"Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag"
	],
	monthNames: [
		"Jan", "Feb", "Mar", [...]]]></description>
			<content:encoded><![CDATA[<p>Found myself &#8220;late-night-surfing&#8221; again, but this time I actually found something interesting. Steven Levithan has written an easy-to-use and easy-to-extend JavaScript date format function. So, to encourage his great work I publish the Swedish translation.<br />
<code><br />
// Internationalization strings<br />
dateFormat.i18n = {<br />
	dayNames: [<br />
		"Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör",<br />
		"Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag"<br />
	],<br />
	monthNames: [<br />
		"Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec",<br />
		"Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"<br />
	]<br />
};<br />
</code></p>
<p>The complete code at its latest version can be found at Stevens blog, <a href="http://blog.stevenlevithan.com/archives/date-time-format">JavaScript Date Format</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alundgren.se/2010/03/10/javascript-date-format-in-swedish/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Configure pure-ftpd in Debian</title>
		<link>http://www.alundgren.se/2010/01/27/configure-pure-ftpd-in-debian/</link>
		<comments>http://www.alundgren.se/2010/01/27/configure-pure-ftpd-in-debian/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 18:25:59 +0000</pubDate>
		<dc:creator>Anders Lundgren</dc:creator>
		
		<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://www.alundgren.se/?p=87</guid>
		<description><![CDATA[Currently there is a lack of good documentation about how to configure pure-ftpd in Debian and Ubuntu. It&#8217;s easy to find information about the command-line flags for pure-ftpd but in Debian you are supposed to use files in the /etc/pure-ftpd/conf directory. Information about what filenames to use and what they should contain is hard to [...]]]></description>
			<content:encoded><![CDATA[<p>Currently there is a lack of good documentation about how to configure pure-ftpd in Debian and Ubuntu. It&#8217;s easy to find information about the command-line flags for pure-ftpd but in Debian you are supposed to use files in the /etc/pure-ftpd/conf directory. Information about what filenames to use and what they should contain is hard to find, so here is a list that translates the command-line flag to filenames.</p>
<p>Not all files requires a contents, it&#8217;s sufficient if you just &#8220;touch&#8221; it. See the <a href="http://download.pureftpd.org/pub/pure-ftpd/doc/README">pure-ftpd documentation</a> for details about the flag values.</p>
<p><!--adsense--></p>
<table style="border:1px solid #ccc;width:100%">
<tbody>
<tr>
<th>Flag</th>
<th>Filename</th>
<th>Value</th>
</tr>
<tr>
<td>-W</td>
<td>AllowAnonymousFXP</td>
<td></td>
</tr>
<tr>
<td>-z</td>
<td>AllowDotFiles</td>
<td></td>
</tr>
<tr>
<td>-w</td>
<td>AllowUserFXP</td>
<td></td>
</tr>
<tr>
<td>-O %s</td>
<td>AltLog</td>
<td>string</td>
</tr>
<tr>
<td>-t %s</td>
<td>AnonymousBandwidth</td>
<td>range</td>
</tr>
<tr>
<td>-M</td>
<td>AnonymousCanCreateDirs</td>
<td></td>
</tr>
<tr>
<td>-i</td>
<td>AnonymousCantUpload</td>
<td></td>
</tr>
<tr>
<td>-e</td>
<td>AnonymousOnly</td>
<td></td>
</tr>
<tr>
<td>-q %d:%d</td>
<td>AnonymousRatio</td>
<td>range</td>
</tr>
<tr>
<td>-s</td>
<td>AntiWarez</td>
<td></td>
</tr>
<tr>
<td>-r</td>
<td>AutoRename</td>
<td></td>
</tr>
<tr>
<td>-S %s</td>
<td>Bind</td>
<td>string</td>
</tr>
<tr>
<td>-b</td>
<td>BrokenClientsCompatibility</td>
<td></td>
</tr>
<tr>
<td>-o</td>
<td>CallUploadScript</td>
<td></td>
</tr>
<tr>
<td>-A</td>
<td>ChrootEveryone</td>
<td></td>
</tr>
<tr>
<td>-j</td>
<td>CreateHomeDir</td>
<td></td>
</tr>
<tr>
<td>-Z</td>
<td>CustomerProof</td>
<td></td>
</tr>
<tr>
<td>-B</td>
<td>Daemonize</td>
<td></td>
</tr>
<tr>
<td>-D</td>
<td>DisplayDotFiles</td>
<td></td>
</tr>
<tr>
<td>-H</td>
<td>DontResolve</td>
<td></td>
</tr>
<tr>
<td>-P %s</td>
<td>ForcePassiveIP</td>
<td>IP-number</td>
</tr>
<tr>
<td>-F %s</td>
<td>FortunesFile</td>
<td>string</td>
</tr>
<tr>
<td>-4</td>
<td>IPV4Only</td>
<td></td>
</tr>
<tr>
<td>-6</td>
<td>IPV6Only</td>
<td></td>
</tr>
<tr>
<td>-K</td>
<td>KeepAllFiles</td>
<td></td>
</tr>
<tr>
<td>-L %d:%d</td>
<td>LimitRecursion</td>
<td>range</td>
</tr>
<tr>
<td>-1</td>
<td>LogPID</td>
<td></td>
</tr>
<tr>
<td>-c %d</td>
<td>MaxClientsNumber</td>
<td></td>
</tr>
<tr>
<td>-C %d</td>
<td>MaxClientsPerIP</td>
<td>integer</td>
</tr>
<tr>
<td>-k %d</td>
<td>MaxDiskUsage</td>
<td>integer</td>
</tr>
<tr>
<td>-I %d</td>
<td>MaxIdleTime</td>
<td>integer</td>
</tr>
<tr>
<td>-m %d</td>
<td>MaxLoad</td>
<td>integer</td>
</tr>
<tr>
<td>-u %d</td>
<td>MinUID</td>
<td>integer</td>
</tr>
<tr>
<td>-N</td>
<td>NATmode</td>
<td></td>
</tr>
<tr>
<td>-E</td>
<td>NoAnonymous</td>
<td></td>
</tr>
<tr>
<td>-R</td>
<td>NoChmod</td>
<td></td>
</tr>
<tr>
<td>-G</td>
<td>NoRename</td>
<td></td>
</tr>
<tr>
<td>-0</td>
<td>NoTruncate</td>
<td></td>
</tr>
<tr>
<td>-p %d:%d</td>
<td>PassivePortRange</td>
<td>range</td>
</tr>
<tr>
<td>-y %d:%d</td>
<td>PerUserLimits</td>
<td>range</td>
</tr>
<tr>
<td>-X</td>
<td>ProhibitDotFilesRead</td>
<td></td>
</tr>
<tr>
<td>-x</td>
<td>ProhibitDotFilesWrite</td>
<td></td>
</tr>
<tr>
<td>-n %d:%d</td>
<td>Quota</td>
<td>range</td>
</tr>
<tr>
<td>-f %s</td>
<td>SyslogFacility</td>
<td>string</td>
</tr>
<tr>
<td>-Y %d</td>
<td>TLS</td>
<td>integer</td>
</tr>
<tr>
<td>-a %d</td>
<td>TrustedGID</td>
<td>integer</td>
</tr>
<tr>
<td>-V %s</td>
<td>TrustedIP</td>
<td>IP-number</td>
</tr>
<tr>
<td>-U %s:%s</td>
<td>Umask</td>
<td>file:dir</td>
</tr>
<tr>
<td>-T %s</td>
<td>UserBandwidth</td>
<td>range</td>
</tr>
<tr>
<td>-Q %d:%d</td>
<td>UserRatio</td>
<td>range</td>
</tr>
<tr>
<td>-d</td>
<td>VerboseLog</td>
<td></td>
</tr>
</tbody>
</table>
<p>There is a <a title="Config of pure-ftpd need to be simplified" href="https://bugs.launchpad.net/ubuntu/+source/pure-ftpd/+bug/477">bugreport</a> for this problem so hopefully it will be fixed in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alundgren.se/2010/01/27/configure-pure-ftpd-in-debian/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Smarty for e-mail templates</title>
		<link>http://www.alundgren.se/2009/11/29/smarty-for-e-mail-templates/</link>
		<comments>http://www.alundgren.se/2009/11/29/smarty-for-e-mail-templates/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 00:44:01 +0000</pubDate>
		<dc:creator>Anders Lundgren</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[mail]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Smarty]]></category>

		<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://www.alundgren.se/?p=69</guid>
		<description><![CDATA[As you&#8217;ve realized Smarty can be used to more than just site templates. You can set up templates for almost anything, for example e-mails. When you do this you have to decide on an approach, and I&#8217;ll cover three of them here.

Simple and straightforward
You can see this approach in the Smarty manual. The template simply [...]]]></description>
			<content:encoded><![CDATA[<p>As you&#8217;ve realized <a href="http://www.smarty.net/">Smarty</a> can be used to more than just site templates. You can set up templates for almost anything, for example e-mails. When you do this you have to decide on an approach, and I&#8217;ll cover three of them here.</p>
<p><!--adsense--></p>
<p><strong>Simple and straightforward</strong><br />
You can see this approach in the Smarty manual. The template simply states the message body, and if you have multiple bodies, say one in plain text and one in HTML, you can do like this.</p>
<p><em>mail.text.tpl</em>:<code><br />
Hi {$name},</code></p>
<p><code>You've got mail!<br />
</code></p>
<p><em>mail.html.tpl</em>:<code><br />
// HTML-header here<br />
&lt;body&gt;<br />
&lt;h1&gt;Hi {$name},&lt;/h1&gt;</code></p>
<p><code>&lt;p&gt;You've got mail!&lt;/p&gt;<br />
&lt;/body&gt;<br />
</code></p>
<p>Now you can simply fetch your two versions of the mail body and use them with your PHP code to send mails. The benefit here is that you keep a good abstraction, the person who makes the mail templates does not have to care about hos the mail is sent. A drawback is that you can&#8217;t store all information for this e-mail in one place; where do you store the subject?</p>
<p><strong>The advanced solution</strong><br />
The advanced solution creates just one template containing all data needed for the e-mail message. Your template could look like this:<br />
<em>gotmail.mail.tpl</em>:<code><br />
Date: {$mail.date|date_format:"%a, %d %b %Y %H:%M:%S %z"}<br />
From: "{$sender.name}" &lt;{$sender.email}&gt;<br />
To: "{$recipient.name}" &lt;{$recipient.email}&gt;<br />
Subject: New mail</code></p>
<p><code>Hi {$recipient.name},</code></p>
<p><code>You've got mail!<br />
</code></p>
<p>Here you just fetch the mail data and sends it. The benefit is that you store all data related to the e-mail at the same place. The drawbacks are that this method needs extra parsing to work with the built-in <a href="http://docs.php.net/manual/en/function.mail.php">PHP mail() function</a> and the abstraction is poor since the person creating the template now has to know how to enter all mail headers as well.</p>
<p><strong>Best of all?</strong><br />
In this version you get the benefits from the two previous versions, eleminating the drawbacks. Here we can store all information about the e-mail in the template and we can still use them when sending the e-mail using PHP. Consider this template:<br />
<em>gotmail.mail.tpl</em>:<code><br />
Hi {$name},</code></p>
<p><code>You've got mail!<br />
{assign var="subject" value="New mail"}<br />
</code></p>
<p>Now you can, as in the simple version, fetch the template to get the body text and then use the <a href="http://www.smarty.net/manual/en/api.get.template.vars.php">get_template_vars()</a> Smarty method to get the subject from the template. Just apply some more Smarty tweaking using the built-in <a href="http://www.smarty.net/manual/en/language.builtin.functions.php#language.function.capture">{capture}</a> function or simply <a href="http://www.smarty.net/manual/en/language.function.insert.php">{insert}</a> the templates from the first example to get a multi-body message in just one template file.</p>
<p><em>The code above should be considered as proof-of-concept or pseudo code, there are a few problems not solved in the examples above.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.alundgren.se/2009/11/29/smarty-for-e-mail-templates/feed/</wfw:commentRss>
		</item>
		<item>
		<title>DocBook for PHP, a tool you can&#8217;t afford to ignore</title>
		<link>http://www.alundgren.se/2009/11/27/docbook-a-tool-you-cant-afford-to-ignore/</link>
		<comments>http://www.alundgren.se/2009/11/27/docbook-a-tool-you-cant-afford-to-ignore/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 05:50:53 +0000</pubDate>
		<dc:creator>Anders Lundgren</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[DocBook]]></category>

		<category><![CDATA[documentation]]></category>

		<guid isPermaLink="false">http://www.alundgren.se/?p=60</guid>
		<description><![CDATA[You&#8217;ve heard it before but it&#8217;s worth mentioning again - you have to properly document you code! Programmers realized this back in the 1960s when the first industrial programming languages were defined, they came up with something called &#8220;comment lines&#8221;. For 27 years this was apparently considered enough, but in 1993 the first documentation generator [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve heard it before but it&#8217;s worth mentioning again - you have to properly document you code! Programmers realized this back in the 1960s when the first industrial programming languages were defined, they came up with something called &#8220;comment lines&#8221;. For 27 years this was apparently considered enough, but in 1993 the first documentation generator was created by Eric Artzt, called Autoduck. Two years later, in 1995, a more commonly known documentation generator was released by Sun Microsystems, called Javadoc. In the year 2000 a similar generator was created by Joshua Eichorn for PHP, called the phpDocumentor and it&#8217;s this documentation generator that is the reason why I&#8217;m writing this post.</p>
<p>I&#8217;ve been using phpDocumentor for quite some time now but only to parse my classes to get an overview. Now I&#8217;m building a framework. I soon realized that writing a tutorial for each class wasn&#8217;t what I wanted. It&#8217;s always good with examples but it doesn&#8217;t show how a bunch of classes work together to solve a larger problem. I want to collect all documentation in one place so it&#8217;s impractical to write tutorials stored in some other place. So, for the first time I decided I&#8217;d take a look at the possibility to use external documentation with phpDocumentor.</p>
<p><!--adsense--></p>
<p>DocBook <em>&#8220;provides a system for writing structured documents using SGML or XML&#8221;</em>, as stated in the <a href="http://www.docbook.org/tdg/en/html/ch00.html">preface in the DocBook documentation</a>. It&#8217;s used in development projects like <a href="http://www.php.net">PHP</a> and <a href="http://www.kde.org">KDE</a>. Although the <a href="http://pear.php.net/manual/en/developers.documentation.docbook.php">PEAR manual</a> states that DocBook should be used, nothing is said about the document type and no example is given. Instead, I found an short example in the <a href="http://manual.phpdoc.org/HTMLframesConverter/default/phpDocumentor/tutorial_phpDocumentor.quickstart.pkg.html#coding.tutorials">phpDocumentor quickstart document</a>. A more elementary example than that is hard to find, but if you combine that with the documentation about <a href="http://www.docbook.org/tdg/en/html/ch02.html#making-refentry">how you create a reference page</a> in the DocBook documentation you&#8217;ll understand what you are doing. You don&#8217;t have to use the &lt;refentry&gt; top-level element but it is recommended if your code may become part of PEAR.</p>
<p>Since the phpDocumentor parses the DocBook file you can use some of the phpDocumentor syntax in your external documentation. It&#8217;s mainly two tags that you&#8217;ll use in your external documentation, and that&#8217;s the {@id} and {@toc} tags. The {@link} may also be useful to link between documents. There&#8217;s no need for me to dig any deeper in this, you can read a great tutorial about <a href="http://manual.phpdoc.org/HTMLframesConverter/default/phpDocumentor/tutorial_tutorials.pkg.html">how to write tutorials for PHP</a> at the phpDocumentor site.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alundgren.se/2009/11/27/docbook-a-tool-you-cant-afford-to-ignore/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Evolution of religion</title>
		<link>http://www.alundgren.se/2009/01/11/evolution-of-religion/</link>
		<comments>http://www.alundgren.se/2009/01/11/evolution-of-religion/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 01:58:33 +0000</pubDate>
		<dc:creator>Anders Lundgren</dc:creator>
		
		<category><![CDATA[Philosophy]]></category>

		<category><![CDATA[Politics]]></category>

		<category><![CDATA[Religion]]></category>

		<guid isPermaLink="false">http://www.alundgren.se/2009/01/11/evolution-of-religion/</guid>
		<description><![CDATA[Since this can be a sensitive subject I guess I&#8217;ll start to say that this is a post of a more philosophic nature. Many religions contains wise formulations about common sense that&#8217;s being abused and used as a front to gain power at many levels. With that said - let&#8217;s go&#8230;
In the beginning the religion [...]]]></description>
			<content:encoded><![CDATA[<p>Since this can be a sensitive subject I guess I&#8217;ll start to say that this is a post of a more philosophic nature. Many religions contains wise formulations about common sense that&#8217;s being abused and used as a front to gain power at many levels. With that said - let&#8217;s go&#8230;</p>
<p>In the beginning the religion was used to explain things that couldn&#8217;t be described with the knowledge at that point. This kind of religion is often called <a href="http://en.wikipedia.org/wiki/Animism">animism</a> or <a href="http://en.wikipedia.org/wiki/Shamanism">shamanism</a> and reaches back to the <a href="http://en.wikipedia.org/wiki/Hunter-gatherer">hunter-gatherer</a>s, that&#8217;s more than 15,000 years ago. The two are very similar in that they both states that the world we live in have spirits, they differ in what role the spirits have though.</p>
<p>The religion then evolved into what&#8217;s called <a href="http://en.wikipedia.org/wiki/Polytheism">polytheism</a>. It means that you believe in multiple gods and you surely have heard of both the <a href="http://en.wikipedia.org/wiki/Roman_mythology">Roman mythology</a> and the <a href="http://en.wikipedia.org/wiki/Greek_mythology">Greek mythology</a>. Now the stories got a more human form but does not distinguish good from bad, both heroes and gods shows both good and bad sides. The mythologies developed when societies were founded and villages started to grow into cities. The human was no longer considered to be a part of nature but superior to it and thus the respect for animals, plants and natural forces decreased. When living in a society the need for rules and laws grows with the size of the society. As a result the religions we know as of today was formed containing rules for how to treat your neighbours.</p>
<p>During the time when, among others, <a href="http://en.wikipedia.org/wiki/Christianity">Christianity</a> was formed and documented or translated, politics and <a href="http://en.wikipedia.org/wiki/Rhetoric">rhetorics</a> had started to grow of importance with the <a href="http://en.wikipedia.org/wiki/Roman_Empire">Roman Empire</a>. These new religions was a perfect target for greedy people to influence and inflict the new documents with hidden messages or just state that a certain interpretation is the correct one. There are many examples of how this is abused and how it changes over time. I do not maintain that the &#8220;modern&#8221; religions was the first ones to be used to gain power, I&#8217;m stating that they resulted in an opportunity to spread the message to a larger crowd.</p>
<p>In my opinion it&#8217;s obvious that the opportunity to power exists since Christianity ended up as being centrally controlled by the <a href="http://en.wikipedia.org/wiki/Holy_See">Holy See</a>. A power that in many cases have lead to megalomania with disastrous, and sometimes amusing, results. A recent historic happening is the discovering of the <a href="http://en.wikipedia.org/wiki/Dead_Sea_scrolls">Dead Sea scrolls</a>, where you can get a good picture of the power that the Holy See can inflict.</p>
<p>Religious texts is often studied according to rhetorical principals that for reasons may not be used in modern law practice. This may, or may not, be a good thing, depends on the text and its message, but it&#8217;s something that you have to keep in mind when reading. After all, the purpose of the modern religions is to achieve compassion between people, a fantastic thing ruined by false interpretation of the word - call it &#8220;free will&#8221; if you like. I call it greed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alundgren.se/2009/01/11/evolution-of-religion/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Differences</title>
		<link>http://www.alundgren.se/2008/12/20/snc01006/</link>
		<comments>http://www.alundgren.se/2008/12/20/snc01006/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 20:36:58 +0000</pubDate>
		<dc:creator>Anders Lundgren</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Politics]]></category>

		<guid isPermaLink="false">http://www.alundgren.se/2008/12/20/snc01006/</guid>
		<description><![CDATA[It&#8217;s interesting how countries can have so different regulations. This for example would not be able to do in Sweden:

On the other hand there is a logical explanation. During the winter snow and ice will build up on the blades and can be thrown away as the wind increases. You don&#8217;t want to take a [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s interesting how countries can have so different regulations. This for example would not be able to do in Sweden:<br />
<a href="http://media.shozu.com/cache/portal/media/57db154/16777224"><img src="http://media.shozu.com/cache/portal/media/57db154/16777224_blog" /></a></p>
<p>On the other hand there is a logical explanation. During the winter snow and ice will build up on the blades and can be thrown away as the wind increases. You don&#8217;t want to take a hit&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alundgren.se/2008/12/20/snc01006/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Loneliness</title>
		<link>http://www.alundgren.se/2008/11/19/loneliness/</link>
		<comments>http://www.alundgren.se/2008/11/19/loneliness/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 14:51:32 +0000</pubDate>
		<dc:creator>Anders Lundgren</dc:creator>
		
		<category><![CDATA[Confusion]]></category>

		<guid isPermaLink="false">http://www.alundgren.se/2008/11/19/loneliness/</guid>
		<description><![CDATA[Even if I&#8217;ve spent the last couple of days among friends I can&#8217;t help it, I feel lonely. I&#8217;m sure (and I know) it&#8217;s due to the resent events. A lot has happened and not everything is easy to deal with. I guess that it&#8217;s because I can&#8217;t talk to anyone about it that I [...]]]></description>
			<content:encoded><![CDATA[<p>Even if I&#8217;ve spent the last couple of days among friends I can&#8217;t help it, I feel lonely. I&#8217;m sure (and I know) it&#8217;s due to the resent events. A lot has happened and not everything is easy to deal with. I guess that it&#8217;s because I can&#8217;t talk to anyone about it that I feel lonely and somewhat abandoned - even if I&#8217;m among friends.</p>
<p>I&#8217;ve got a lot on my mind and and a terrible schedule for the rest of the year. I don&#8217;t like my current situation. Not at all. I need a vacation but I do not know if it would do good since I really don&#8217;t have time, kind of a double bind.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alundgren.se/2008/11/19/loneliness/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rest in peace</title>
		<link>http://www.alundgren.se/2008/11/16/rest-in-peace/</link>
		<comments>http://www.alundgren.se/2008/11/16/rest-in-peace/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 22:47:25 +0000</pubDate>
		<dc:creator>Anders Lundgren</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.alundgren.se/2008/11/16/rest-in-peace/</guid>
		<description><![CDATA[Tonight I lost my grandfather.
During the last years my grandfather has struggled with the horrible Alzheimer disease. The disease does not just capture the victim in his or her body, but it also makes the next to kin watch a close one transform into someone unknown. In the case of my grandfather he was unable [...]]]></description>
			<content:encoded><![CDATA[<p>Tonight I lost my grandfather.</p>
<p>During the last years my grandfather has struggled with the horrible Alzheimer disease. The disease does not just capture the victim in his or her body, but it also makes the next to kin watch a close one transform into someone unknown. In the case of my grandfather he was unable to express himself, he couldn&#8217;t find the words. The thing that makes it so sad is that he was fully aware about this, and he often expressed his frustration about it. In his case he had to live and see his body degenerate.</p>
<p>He was always very happy when we, the grandchildren, came to visit. He also enjoyed my parents little Bichon Frisé called Bisse. Even if he did not manage to get the names right he almost always realized who we were.</p>
<p>For about one week ago he had a very good day when we visited. He was not depressed (depression is an effect of Alzheimers), he was joking and responded to the conversations around the table. At one moment he was unable to express his joy resulting in a long and hearty laugh. We all enjoyed the visit.</p>
<p>Shortly after he fell and broke his hand, most likely due to a cerebral haemorrhage or as a result of advancing Alzheimer, with the result that for three days he did not respond at all when talked to. When he finally woke up he was noticeable worse than before and he slurred when he talked. After another couple of days he went back into a sleepy state and again stopped responding when talked to. When asked he could squeeze your hand, but that was it. He never recovered and tonight he passed away.</p>
<p>Tonight my thoughts go to my mother that is abroad and can&#8217;t be here. It burdens me that your longed-for vacation had to end like this.</p>
<p>You will be missed Ingemar Åström.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alundgren.se/2008/11/16/rest-in-peace/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

