<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"
>

<channel>
	<title>NuBlog &#187; LAMP</title>
	<atom:link href="http://blog.nuit.dk/category/lamp/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nuit.dk</link>
	<description>Web technology, blogging, programming, Linux and IT project management</description>
	<lastBuildDate>Tue, 04 May 2010 08:35:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Testing: WP Super Cache</title>
		<link>http://blog.nuit.dk/2009/02/09/testing-wp-super-cache/</link>
		<comments>http://blog.nuit.dk/2009/02/09/testing-wp-super-cache/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 09:15:07 +0000</pubDate>
		<dc:creator>jul</dc:creator>
				<category><![CDATA[Geekyness]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.nuit.dk/?p=57</guid>
		<description><![CDATA[Seems like a very cool plugin to enhance the userexperience &#8211; performance wise, plus it seems to prepare Wordpress blogs for high traffic spikes.
Bug found: Links to posts from archives seems to cache PHP-code &#8211; not the resulting HTML. There&#8217;s gotta be a simple fix. Was a bit quick there. The bug is in my [...]]]></description>
			<content:encoded><![CDATA[<img style='float: left; margin-right: 10px; border: none;' src='http://www.gravatar.com/avatar.php?gravatar_id=21a11738f6a3b0696645fe12a6af6440&amp;default=http://use.perl.org/images/pix.gif' alt='No Gravatar' width=40 height=40/><p>Seems like a very <a title="WP Super Cache on author Donncha O Caoimh's blog" href="http://ocaoimh.ie/wp-super-cache/">cool plugin</a> to enhance the userexperience &#8211; performance wise, plus it seems to prepare Wordpress blogs for high traffic spikes.</p>
<p><span style="text-decoration: line-through;">Bug found: Links to posts from archives seems to cache PHP-code &#8211; not the resulting HTML. There&#8217;s gotta be a simple fix.</span> Was a bit quick there. The bug is in my theme &#8211; not in WP Super Cache.</p>
<p>Edit: Also &#8211; the issues may have to do with my host who seems to mess with their user database right now..</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nuit.dk/2009/02/09/testing-wp-super-cache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magpie RSS/Snoopy problem finally solved</title>
		<link>http://blog.nuit.dk/2007/11/05/magpie-rsssnoopy-problem-finally-solved/</link>
		<comments>http://blog.nuit.dk/2007/11/05/magpie-rsssnoopy-problem-finally-solved/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 09:10:07 +0000</pubDate>
		<dc:creator>jul</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://blog.nuit.dk/2007/11/05/magpie-rsssnoopy-problem-finally-solved/</guid>
		<description><![CDATA[MagpieRSS IS great &#8211; I like it a lot, and it almost does exactly what you need to aggregate RSS feeds from PHP. MagpieRSS has one achilles heel in Snoopy. MagpieRSS relies on Snoopy as the HTTP-client (browser-component) that fetches feeds from websites &#8211; be it RSS or Atom formatted &#8211; It fetches files from [...]]]></description>
			<content:encoded><![CDATA[<img style='float: left; margin-right: 10px; border: none;' src='http://www.gravatar.com/avatar.php?gravatar_id=21a11738f6a3b0696645fe12a6af6440&amp;default=http://use.perl.org/images/pix.gif' alt='No Gravatar' width=40 height=40/><p><a href="http://sourceforge.net/project/showfiles.php?group_id=55691">MagpieRSS</a> IS great &#8211; I like it a lot, and it almost does exactly what you need to aggregate RSS feeds from PHP. MagpieRSS has one achilles heel in <a href="http://sourceforge.net/projects/snoopy/">Snoopy</a>. MagpieRSS relies on Snoopy as the HTTP-client (browser-component) that fetches feeds from websites &#8211; be it RSS or Atom formatted &#8211; It fetches files from a webserver.</p>
<p>The latests Snoopy release was in 2005 (as was the latest MagpieRSS), which could indicate that the development community has abandoned the code. The problem with Snoopy is that it has low tolerance to the use of carriage-return and linefeed characters in the header of HTTP responses from webservers. For some requests that means certain files, though rich in content, appear empty if they are fetched using Snoopy.</p>
<p>At first I tried downloading the latest Snoopy release from Sourceforge. It seemed to do the trick for some feeds, but aparently not all. <a href="http://blog.adaniels.nl/?p=18" title="Arnold Daniels blog">Arnold Daniels came to my rescue</a>. He has devised a wrapper &#8211; on the &#8220;outside&#8221; it appears to be Snoopy &#8211; but on the inside PHP&#8217;s Curl library has taken the place of a lot of the original Snoopy code. Give his alternative library a spin if you are using MagpieRSS for anything the should be somewhat resistant to deviations from standards.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nuit.dk/2007/11/05/magpie-rsssnoopy-problem-finally-solved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point featurename="[55.69614575418864, 12.545013427734375]">55.69614575418864 12.545013427734375</georss:point>
	</item>
		<item>
		<title>Generate PDF files from PHP</title>
		<link>http://blog.nuit.dk/2007/09/12/generate-pdf-files-from-php/</link>
		<comments>http://blog.nuit.dk/2007/09/12/generate-pdf-files-from-php/#comments</comments>
		<pubDate>Wed, 12 Sep 2007 15:15:49 +0000</pubDate>
		<dc:creator>jul</dc:creator>
				<category><![CDATA[Geekyness]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.nuit.dk/2007/09/12/generate-pdf-files-from-php/</guid>
		<description><![CDATA[For a web project I needed to create invoices, to be downloaded or e-mailed to clients in PDF format. The platform is PHP and the documentation for this almost exclusively describe PDFLib for this purpose. I am sure PDFLib is fine, and the tutorials that come with the package looks really good.
But..
You pay for PDFLib [...]]]></description>
			<content:encoded><![CDATA[<img style='float: left; margin-right: 10px; border: none;' src='http://www.gravatar.com/avatar.php?gravatar_id=21a11738f6a3b0696645fe12a6af6440&amp;default=http://use.perl.org/images/pix.gif' alt='No Gravatar' width=40 height=40/><p>For a web project I needed to create invoices, to be downloaded or e-mailed to clients in PDF format. The platform is <a href="http://php.net/">PHP</a> and <a href="http://www.php.net/manual/en/ref.pdf.php" title="PHP Documentation: PDF Functions">the documentation</a> for this almost exclusively describe <a href="http://www.pdflib.com/products/pdflib-family/" title="PDFLib Product Family">PDFLib</a> for this purpose. I am sure PDFLib is fine, and the tutorials that come with the package looks really good.</p>
<p><strong>But..</strong></p>
<p>You pay for PDFLib &#8211; I don&#8217;t mind paying for software, you should pay for usable high-quality stuff, which I am sure PDFLib is. US$ 995 is a little steep though &#8211; compared to free. The FAQ however mentions a few free alternatives. Right now I am looking into <a href="http://www.fpdf.org/" title="FPDF website">FPDF</a> &#8211; which seem to do the trick.</p>
<p>Actually I found out that my previous ISP (invoicing their customers only by PDF invoices via E-mail) use FPDF. This tells me that FPDF is more than ready for production. I&#8217;ll let you know if I something disappoints me &#8211; although I would hate to bash a truly free initiative such as this one. Oh &#8211; and by the way it has another edge to PDFLib &#8211; It is written in PFP and does not need server reconfiguration to work. If you want a head start, there are quite an extensive list of <a href="http://www.fpdf.org/en/script/index.php" title="FPDF code examples">code examples</a> available.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nuit.dk/2007/09/12/generate-pdf-files-from-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point featurename="[55.6957164450209, 12.54413366317749]">55.6957164450209 12.54413366317749</georss:point>
	</item>
		<item>
		<title>MySQL query/indexing tip</title>
		<link>http://blog.nuit.dk/2007/08/31/mysql-queryindexing-tip/</link>
		<comments>http://blog.nuit.dk/2007/08/31/mysql-queryindexing-tip/#comments</comments>
		<pubDate>Fri, 31 Aug 2007 15:10:14 +0000</pubDate>
		<dc:creator>jul</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://blog.nuit.dk/2007/08/31/mysql-queryindexing-tip/</guid>
		<description><![CDATA[I originally learned about this MySQL shortcoming in the book High Performance MySQL, and luckily I remembered it for an issue that struck me today.
I have two tables &#8211; one containing blog-posts, and one containing a record for each tag on these posts. Now the requirement was to show a blog post AND to show [...]]]></description>
			<content:encoded><![CDATA[<img style='float: left; margin-right: 10px; border: none;' src='http://www.gravatar.com/avatar.php?gravatar_id=21a11738f6a3b0696645fe12a6af6440&amp;default=http://use.perl.org/images/pix.gif' alt='No Gravatar' width=40 height=40/><p>I originally learned about this MySQL shortcoming in the book <a href="http://www.amazon.com/High-Performance-MySQL-Jeremy-Zawodny/dp/0596003064/ref=pd_bbs_sr_1/104-8510121-9631906?ie=UTF8&amp;s=books&amp;qid=1188570640&amp;sr=8-1" title="Amazon.com High Performance MySQL">High Performance MySQL</a>, and luckily I remembered it for an issue that struck me today.</p>
<p>I have two tables &#8211; one containing blog-posts, and one containing a record for each tag on these posts. Now the requirement was to show a blog post AND to show the five latest related posts. Related posts in this scenario are other posts that share one or more tags with this post.</p>
<p>Now, it does not take one second to find a blog post, and it does not take one second to find tags related to it. And actually it does not even take a second to find a list of posts having a list of tags. The reason why all these requests take less than a second is because the tables have been supplied with efficient indexes &#8211; the table of blogposts has more than 3.5 million records and there are about 700.000 tags.</p>
<p>The problem was that when we tried to generate a list of related posts, the query took up to twelve seconds to run. It sucked and looked like this:</p>
<blockquote><p><code>SELECT distinctrow i.id, i.item_title, i.item_url<br />
FROM rss_items_master i<br />
INNER JOIN rss_item_tag t ON i.id=t.item_id<br />
WHERE t.item_tag IN (SELECT item_tag FROM rss_item_tag WHERE item_id=$itemid)<br />
AND t.item_id != $itemid<br />
ORDER BY i.item_date DESC<br />
LIMIT 5;</code></p></blockquote>
<p>In plain english we request a list of items that does not match the specific post, but they must have at least one tag that match one of the tags from the specific post. The nested SELECT-statement produce a list of tags to look for, and the outer SELECT statement pulls blog posts containing tags found in the nested SELECT. This does not perform, <em><strong>because only one index can be used per query</strong></em> &#8211; so either the index from the rss_item_tag table or from the rss_items_master table is ignored (i did not bother figuring out which one was ignored). To fix it, I split the SQL in two (PHP example):</p>
<blockquote><p><code>$sql_tags = "SELECT item_tag FROM rss_item_tag WHERE item_id=$itemid;";<br />
$arr_tags = query_array($sql_tags, $link);<br />
// $tag_o will be an array of tags from the original post.<br />
$tag_o = Array();<br />
foreach($arr_tags as $tag_i) {<br />
array_push($tag_o, mysql_real_escape_string($tag_i[0]));<br />
}<br />
$tags = implode("','", $tag_o);</code></p></blockquote>
<p>Now $tags contain a list og tags to look for &#8211; actually it contains exactly what the nested SELECT-part did in the slow query. Now these two queries will actually complete in less than a second:</p>
<blockquote><p><code>select distinctrow i.id, i.item_title, i.item_url<br />
from rss_items_master i inner join rss_item_tag t on i.id=t.item_id<br />
and t.item_tag in ('$tags')<br />
and t.item_id != $itemid<br />
order by i.item_date desc<br />
limit 5;</code></p></blockquote>
<p>So even though the SQL has been split in two, and even though we are passing a lot of information through variables that we have to build from the first query and added quite a lot of code &#8211; this outperforms the first single query by a factor larger than 10 &#8211; simply because it enables MySQL to use the indexes it should.</p>
<p>For more MySQL performance tips, check out <a href="http://mysqlperformanceblog.com/">MySQL Performance Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nuit.dk/2007/08/31/mysql-queryindexing-tip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point featurename="[55.90423859525798, 12.486348152160645]">55.90423859525798 12.486348152160645</georss:point>
	</item>
		<item>
		<title>Windows &#8216;amp tip</title>
		<link>http://blog.nuit.dk/2007/05/22/windows-amp-tip/</link>
		<comments>http://blog.nuit.dk/2007/05/22/windows-amp-tip/#comments</comments>
		<pubDate>Tue, 22 May 2007 18:07:09 +0000</pubDate>
		<dc:creator>jul</dc:creator>
				<category><![CDATA[Geekyness]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://blog.nuit.dk/2007/05/22/windows-amp-tip/</guid>
		<description><![CDATA[I was annoyed &#8211; but not anymore. I have been developing for Apache/MySQL on my laptop for a while, and in the beginning I would start the Apache and MySQL services automatically as I booted Windows. Recently I embarked to minimize the boot time of my Windows installation &#8211; and that included minimizing the services [...]]]></description>
			<content:encoded><![CDATA[<img style='float: left; margin-right: 10px; border: none;' src='http://www.gravatar.com/avatar.php?gravatar_id=21a11738f6a3b0696645fe12a6af6440&amp;default=http://use.perl.org/images/pix.gif' alt='No Gravatar' width=40 height=40/><p>I was annoyed &#8211; but not anymore. I have been developing for Apache/MySQL on my laptop for a while, and in the beginning I would start the Apache and MySQL services automatically as I booted Windows. Recently I embarked to minimize the boot time of my Windows installation &#8211; and that included minimizing the services starting automatically &#8211; including Apache and MySQL. To start these two services, I enabled the System Tray icons for the two services and when I wanted to start the services I would right click the MySQL monitor and choose &#8220;Start instance&#8221;, and then left-click the Apache icon and click &#8220;Start&#8221; in the submenu.</p>
<p>This seems fairly simple, but if you try to navigate icons in the System Tray before everything is done loading, you will know that right-clicking something may give long delays, sometimes sub-menues disapear and you don&#8217;t know if it was because of your click, which it did not respond to or if your click was actually registered. So the tip is simple and low tech &#8211; perform the same thing in a .bat file:</p>
<p>startamp.bat:</p>
<blockquote><p><code>net start mysql</code><br />
<code>net start apache2</code></p></blockquote>
<p>stopamp.bat:</p>
<blockquote><p><code>net stop apache2<br />
net stop mysql</code></p></blockquote>
<p>Put these on your desktop or quickstart menu..</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nuit.dk/2007/05/22/windows-amp-tip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point featurename="[55.90423859525798, 12.486348152160645]">55.90423859525798 12.486348152160645</georss:point>
	</item>
	</channel>
</rss>
