<?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></title>
	<atom:link href="http://blog.gemmapeter.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.gemmapeter.co.uk</link>
	<description>Gem&#039;s ponderings on PHP programming and other stuff</description>
	<lastBuildDate>Sat, 25 Jul 2009 19:24:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mock PHP 5 exam</title>
		<link>http://blog.gemmapeter.co.uk/2009/07/25/mock-php-5-exam/</link>
		<comments>http://blog.gemmapeter.co.uk/2009/07/25/mock-php-5-exam/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 19:24:11 +0000</pubDate>
		<dc:creator>Gem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.gemmapeter.co.uk/?p=224</guid>
		<description><![CDATA[I have been considering going for the Zend PHP 5 certification and bought myself some Zend PHP 5 Practice Exams to see what I need to study up on.
Here is one of the questions I came across.

Which of the following functions are part of PHP's internal Iterator interface?

Answers: (choose 5)
    rewind()
  [...]]]></description>
			<content:encoded><![CDATA[<p>I have been considering going for the Zend PHP 5 certification and bought myself some <a href="http://shop.zend.com/en/php-certification/zend-php-certification-online-practice-testing.html">Zend PHP 5 Practice Exams</a> to see what I need to study up on.</p>
<p>Here is one of the questions I came across.</p>
<pre>
Which of the following functions are part of PHP's internal Iterator interface?

Answers: (choose 5)
    rewind()
    valid()
    next()
    key()
    current()
</pre>
<p>Maybe they had problems passing candidates that couldn&#8217;t count to five.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gemmapeter.co.uk/2009/07/25/mock-php-5-exam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How do I unit test this?</title>
		<link>http://blog.gemmapeter.co.uk/2009/02/20/how-do-i-unit-test-this/</link>
		<comments>http://blog.gemmapeter.co.uk/2009/02/20/how-do-i-unit-test-this/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 17:25:43 +0000</pubDate>
		<dc:creator>Gem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.gemmapeter.co.uk/?p=200</guid>
		<description><![CDATA[Came across a tricky bug a few weeks ago whilst working on some extremely fragile code.
This was the code:

settings.php

$mail_settings = array&#40;
    'server' =&#62; 'mail.example.com',
    'port' =&#62; 25
&#41;;


index.php

function send_email&#40;$recipient, $message&#41;
&#123;
    include_once&#40;'settings.php'&#41;;
    $foo = new MailSender&#40;$mail_settings&#41;;
    $foo-&#62;send&#40;$message, $recipient&#41;; //this was line number [...]]]></description>
			<content:encoded><![CDATA[<p>Came across a tricky bug a few weeks ago whilst working on some extremely fragile code.</p>
<p>This was the code:</p>
<hr />
<p>settings.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$mail_settings</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'server'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'mail.example.com'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'port'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">25</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<hr />
<p>index.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> send_email<span style="color: #009900;">&#40;</span><span style="color: #000088;">$recipient</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'settings.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MailSender<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mail_settings</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$foo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #339933;">,</span> <span style="color: #000088;">$recipient</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//this was line number in the error message</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
send_email<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin@example.com'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Admin message'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
send_email<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user@example.com'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'User message'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<hr />
<p>The tricky part was debugging it, it threw an error on the second call of the send_email function. That&#8217;s odd it ran fine the first time and the only thing I could see that had changed was the input to the function, surely that must be the problem? I commented out the second function call error went away, commented it back in and the error was back. This fitted with my hypothesis that the input on the second one was causing the error. But after looking inside the MailSender class I couldn&#8217;t see any reason why the function would error there.</p>
<p>I called Kev to give the problem a fresh set of eyes because sometimes when you are working on things like this you end up not being able to see the thing you&#8217;re looking for if you stare at the code for too long.</p>
<p>We took apart the function. We created a new file and replaced each function call with the code which was inside the function and were surprised when it worked perfectly. We were confused as to how the exact same code when placed inside a function would have any different effect.</p>
<p>After looking in the wrong places for a while we finally decided to re-examine our assumptions about what the commenting out was telling us. It wasn&#8217;t telling us that the problem is in how we were calling the function the second time around, it was the fact that we were calling the function twice.</p>
<p>After realising that it was obvious what was causing the error.</p>
<ul>
<li>Mailsender needs $mail_settings to work</li>
<li>variables from settings.php were included with an include once</li>
<li>include once will not include a file that has already been included</li>
<li>the second function call will not have access to variables from settings.php since they are a) out of scope from first function call b) won&#8217;t be included again due to the include once</li>
</ul>
<p>After changing the include_once to an include the function worked as expected.</p>
<p>This made me think of some questions. How would I unit test this? Should I create a unit test that runs each function n times? How could I ensure that the test wouldn&#8217;t fail at n+1 times? How can I be sure my test will be accurate without running the function an infinite amount of times?</p>
<p>Of course the real solution would be to remove the hidden dependencies caused by creating variables in an included file but to do that to this particular inherited project would require a complete rewrite.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gemmapeter.co.uk/2009/02/20/how-do-i-unit-test-this/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tomb Raider: Underworld First Impressions</title>
		<link>http://blog.gemmapeter.co.uk/2008/11/22/tomb-raider-underworld-first-impressions/</link>
		<comments>http://blog.gemmapeter.co.uk/2008/11/22/tomb-raider-underworld-first-impressions/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 19:24:50 +0000</pubDate>
		<dc:creator>Gem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.gemmapeter.co.uk/?p=185</guid>
		<description><![CDATA[Yesterday I bought myself the latest instalment of the Tomb Raider series for the Wii.
I spent a while playing it then I came across got stuck in the Level Puppet No Longer in the last room with the ceiling ring where I couldn&#8217;t progress in the game because the switch to open the door had [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I bought myself the latest instalment of the Tomb Raider series for the Wii.</p>
<p>I spent a while playing it then I came across got stuck in the Level Puppet No Longer in the last room with the ceiling ring where I couldn&#8217;t progress in the game because the switch to open the door had vanished  (see forum posts <a href="http://forums.eidosgames.com/showthread.php?t=82944">here</a> and <a href="http://www.tombraiderforums.com/showthread.php?p=3241042">here</a>).</p>
<p>I restarted the game and treked back to that point. This time the switch was there and I was able to complete the level.</p>
<p>Later on in the Mexico level I came across another similar bug. One of the switches needed to operate the giant cogs in the floor was missing, instead only a yellow cuboid floated in mid air where it should have been. Fortunately I had a save at the beginning of the level and when I reloaded and got to that point again the switch was there.</p>
<p>Also later there was a bit by where you stop the Archimedes screw from moving the blue glowing liquid into the pool in the main chamber. The column that you&#8217;re supposed to shoot down, initially it did not allow me to shoot it, I could aim and fire at it but it had no effect and I couldn&#8217;t get the red crosshairs on it as is normally the case with shootable objects.</p>
<p>In conclusion BUGGIEST. TOMB RAIDER. EVAR. I hope I don&#8217;t run into any more.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gemmapeter.co.uk/2008/11/22/tomb-raider-underworld-first-impressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lego Games</title>
		<link>http://blog.gemmapeter.co.uk/2008/06/09/lego-games/</link>
		<comments>http://blog.gemmapeter.co.uk/2008/06/09/lego-games/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 12:40:17 +0000</pubDate>
		<dc:creator>Gem</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.gemmapeter.co.uk/?p=174</guid>
		<description><![CDATA[I&#8217;ve completed two games to 100% this weekend, Lego Star Wars II and Lego Indiana Jones.
For Lego Star Wars II all I had to do was to complete the Super Story modes on each film which basically means playing through the entire of the story mode again except you get timed. I was under the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve completed two games to 100% this weekend, Lego Star Wars II and Lego Indiana Jones.</p>
<p>For Lego Star Wars II all I had to do was to complete the Super Story modes on each film which basically means playing through the entire of the story mode again except you get timed. I was under the impression that because the best time was defaulted to 1 hour that if you took longer you wouldn&#8217;t get the associated golden brick. This meant that I was restarting the Super Story mode if I felt I took too long on a level. I finally decided to play it all the way through to see what times I was currently getting and then found out that the under 1 hour completion time wasn&#8217;t mandatory. So off I went to get the last golden brick in Return of the Jedi which allowed me to complete the spigot outside the cantina which spews studs so I could finally afford the multiplier extras in the shop.</p>
<p>This Friday I got a copy of Lego Indiana Jones for the Wii. It is very fun and I spent the whole weekend playing it finally completing it at 100% on Sunday evening. It&#8217;s a fun game and like the Star Wars II Lego game you play through the original three films collecting characters, minikits and posting parcels (which unlock the extras).</p>
<p>Unlike the Lego Star Wars in the Indiana Jones Game I found it much easier to get the treasure multipliers. There was also a sub quest that unlocked Han Solo which involved finding Star Wars characters hidden in the levels. Here&#8217;s where I found 4 of the 5 characters (can&#8217;t remember the last one)</p>
<ul>
<li>Princess Leia I found in a detention cell in the Temple of Doom (ladder down a cliff face, metal barrier to blow up, nazi needed for guard)</li>
<li>Chewbacca &#8211; desert city in Raiders of the Lost Arc, door is behind where you find the vehicle which you use to smash the gate near the end of the level (door opened by academic, need short person)</li>
<li>C3PO in the first level of Raiders of the Lost Arc next to a minikit.</li>
<li>Luke Skywalker &#8211; found hanging by feet in snowy cave down a cliff face in &#8216;Into the Mountains&#8217;</li>
</ul>
<p>Also if you are on the level battle on the bridge the minikit detector will make it appear that there are two minikits beyond the gate just before the end of the level. I think what it&#8217;s actually showing are the two minikits hidden in the very beginning of the level, one requires you blow up a metal fence, the other requires you outrun the water.</p>
<p>I liked it better than Lego Star Wars II because you only needed to get the &#8220;True Adventurer&#8221; (like the Star Wars &#8220;True Jedi&#8221;) once per level rather than once in story mode and once in free play. I also liked that there wasn&#8217;t a Super Story Mode which had to be completed for 100%.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gemmapeter.co.uk/2008/06/09/lego-games/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A double standard for adult content</title>
		<link>http://blog.gemmapeter.co.uk/2008/04/29/a-double-standard-for-adult-content/</link>
		<comments>http://blog.gemmapeter.co.uk/2008/04/29/a-double-standard-for-adult-content/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 17:00:30 +0000</pubDate>
		<dc:creator>Gem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.gemmapeter.co.uk/?p=170</guid>
		<description><![CDATA[This is my opinion on the topic of a bill outlawing the possession of &#8220;extreme pornography&#8221; which is set to become law next week. Here&#8217;s the BBC article
Why does porn get a different set of standards? It&#8217;s perfectly legal to show non-pornographic films which contain &#8220;an act which threatens or appears to threaten a person&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>This is my opinion on the topic of a bill outlawing the possession of &#8220;extreme pornography&#8221; which is set to become law next week. <a href="http://news.bbc.co.uk/1/hi/magazine/7364475.stm">Here&#8217;s the BBC article</a></p>
<p>Why does porn get a different set of standards? It&#8217;s perfectly legal to show non-pornographic films which contain &#8220;an act which threatens or appears to threaten a person&#8217;s life&#8221;. In fact in many non-pornographic films we see people seriously assaulted or killed yet no-one applies the same standard to these. If adults can tell the difference between fiction and reality in other films why single out films of a pornographic nature for this harsher treatment?</p>
<p>For once my comment spam on this might actually be on topic.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gemmapeter.co.uk/2008/04/29/a-double-standard-for-adult-content/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
