<?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>Vim, Cygwin, MySQL &#38; Zsh Tips &#187; Coding Tips</title>
	<atom:link href="http://zzapper.co.uk/category/coding-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://zzapper.co.uk</link>
	<description></description>
	<lastBuildDate>Tue, 13 Jul 2010 22:45:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Parsing HTML with preg_match</title>
		<link>http://zzapper.co.uk/parsing-html-with-preg_match/</link>
		<comments>http://zzapper.co.uk/parsing-html-with-preg_match/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 20:46:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding Tips]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://zzapper.co.uk/?p=97</guid>
		<description><![CDATA[preg_match_all(&#8216;#&#60;b>.+?&#60;/b>#i&#8217;, $html, $matches); // ? means non-greedy and is absolutely critical $match[1], $match[2] contain the results Non greedy stops the match gobbling everything between the first bold tag and the very last. I&#8217;ve never quite understood why greedy is the default behavior of RegExp (Regular Expressions) but I guess there&#8217;s a good reason for it. [...]]]></description>
			<content:encoded><![CDATA[<p>preg_match_all(&#8216;#&lt;b>.+?&lt;/b>#i&#8217;, $html, $matches);<br />
// ? means non-greedy and is absolutely critical</p>
<p>$match[1], $match[2] contain the results</p>
<p>Non greedy stops the match gobbling everything between the first bold tag and the very last. I&#8217;ve never quite understood why greedy is the default behavior of RegExp (Regular Expressions) but I guess there&#8217;s a good reason for it.</p>
<p>PHP also has the very useful <a href="http://www.php.net/manual/en/function.strip-tags.php">strip_tags</a> function.</p>
]]></content:encoded>
			<wfw:commentRss>http://zzapper.co.uk/parsing-html-with-preg_match/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Classic Programming Error: Variables inside a loop</title>
		<link>http://zzapper.co.uk/classic-programming-error-variables-inside-a-loop/</link>
		<comments>http://zzapper.co.uk/classic-programming-error-variables-inside-a-loop/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 22:23:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding Tips]]></category>

		<guid isPermaLink="false">http://zzapper.co.uk/?p=95</guid>
		<description><![CDATA[This for loop is OK foreach($cargo_data as $cid=&#62;$cargo_record) { $cargo_id=$cargo_data[$cid]['cargo_id']; $section=$cargo_data[$cid]['section']; &#8230; } But then later you add a condition cargo_id&#62;6 foreach($cargo_data as $cid=&#62;$cargo_record) { if ($cid&#62;6) {$cargo_id=$cargo_data[$cid]['cargo_id'];} $section=$cargo_data[$cid]['section']; &#8230; } Now the bug is that if $cid is less than 6 $cargo_id is not set and will likely inherit the value it was set [...]]]></description>
			<content:encoded><![CDATA[<p>This for loop is OK</p>
<p>foreach($cargo_data as $cid=&gt;$cargo_record)<br />
{<br />
$cargo_id=$cargo_data[$cid]['cargo_id'];<br />
$section=$cargo_data[$cid]['section'];<br />
&#8230;<br />
}</p>
<p>But then later you add a condition cargo_id&gt;6</p>
<p>foreach($cargo_data as $cid=&gt;$cargo_record)<br />
{<br />
if ($cid&gt;6) {$cargo_id=$cargo_data[$cid]['cargo_id'];}<br />
$section=$cargo_data[$cid]['section'];<br />
&#8230;<br />
}</p>
<p>Now the bug is that if $cid is less than 6 $cargo_id is not set and will likely inherit the value it was set to in the last loop this type of error may not be immediately noticeable but can cause chaos. In this simple example it is easy to see that their should be an else clause, however the real solution is to systematically  initialize all the variables at the beginning of the loop.</p>
]]></content:encoded>
			<wfw:commentRss>http://zzapper.co.uk/classic-programming-error-variables-inside-a-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Git for Document/Software Version Control</title>
		<link>http://zzapper.co.uk/using-git-for-documentsoftware-version-control/</link>
		<comments>http://zzapper.co.uk/using-git-for-documentsoftware-version-control/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 19:52:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding Tips]]></category>
		<category><![CDATA[cvs]]></category>
		<category><![CDATA[gitk]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://zzapper.co.uk/?p=77</guid>
		<description><![CDATA[I had been using my own ad-hoc system for years but recently started using CVS to maintain a history of my file and document changes. I was quite happy with CVS but everyone told me I should be using Git instead.  Git seems to be simpler and more intuitive. I can set up git for [...]]]></description>
			<content:encoded><![CDATA[<p>I had been using my own ad-hoc system for years but recently started using CVS to maintain a history of my file and document changes. I was quite happy with CVS but everyone told me I should be using Git instead.  Git seems to be simpler and more intuitive. I can set up git for a folder or project very quickly. You just need the following 5 commands to get going</p>
<p>git init       (set up git for the current directory)<br />
git add *.php   (add all your php files or whatever)<br />
git commit -m &#8220;first version&#8221;    (also need to commit all your existing php files)<br />
vi index.php (make a few changes)<br />
git commit -a -m &#8220;Added new date feature&#8221;   (do this periodically to maintain version control)<br />
<strong></strong></p>
<p><strong>gitk </strong>is a simple TK Gui which allows you to review you versions etc. I am delighted to have version control, all I have to do is remember to do a &gt; git commit -a -m &#8220;Added new date feature&#8221; every now and again (eg daily)</p>
]]></content:encoded>
			<wfw:commentRss>http://zzapper.co.uk/using-git-for-documentsoftware-version-control/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
