<?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 by zzapper &#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>Wed, 18 Jan 2012 23:15:31 +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>CakePHP is a Piece of Cake!</title>
		<link>http://zzapper.co.uk/cakephp-is-a-piece-of-cake/</link>
		<comments>http://zzapper.co.uk/cakephp-is-a-piece-of-cake/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 20:28:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding Tips]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://zzapper.co.uk/?p=175</guid>
		<description><![CDATA[I&#8217;ve recently become aware of how behind the times my skills are , in particular if you write PHP you are expected to use a framework . I&#8217;ve chosen CakePHP and have installed it on my local Apache Server with a few permission hiccups. I&#8217;ve then completed the create a blog tutorial and it&#8217;s stunning [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently become aware of how behind the times my skills are , in particular if you write PHP you are expected to use a framework . I&#8217;ve chosen CakePHP and have installed it on my local Apache Server with a few permission hiccups. I&#8217;ve then completed the create a blog tutorial and it&#8217;s stunning how easy it is. It uses the MVC or Model-View-Controller system for development. To quote their documentation it <strong>CakePHP takes the monotony out of web development. We provide you with all the tools you need to get started coding what you really need to get done: the logic specific to your application. Instead of reinventing the wheel every time you sit down to a new project, check out a copy of CakePHP and get started with the real guts of your application</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://zzapper.co.uk/cakephp-is-a-piece-of-cake/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Remove Home in the Title of New Coppermine Gallery</title>
		<link>http://zzapper.co.uk/how-to-remove-home-in-the-title-of-new-coppermine-gallery/</link>
		<comments>http://zzapper.co.uk/how-to-remove-home-in-the-title-of-new-coppermine-gallery/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 15:44:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding Tips]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://zzapper.co.uk/?p=171</guid>
		<description><![CDATA[Edit include/themes.inc.php Find the function and modify as follows function theme_page_title($section) { global $CONFIG; $return = strip_tags(bb_decode($section)) . ' - ' . $CONFIG['gallery_name']; // original code $return = $CONFIG['gallery_name']; // Section removed return $return; } this change works for cpg1.5.x]]></description>
			<content:encoded><![CDATA[<p>Edit include/themes.inc.php</p>
<p>Find the function and modify as follows</p>
<p><code><br />
function theme_page_title($section)<br />
{<br />
    global $CONFIG;<br />
    $return = strip_tags(bb_decode($section)) . ' - ' . $CONFIG['gallery_name']; // original code<br />
    $return = $CONFIG['gallery_name']; // Section removed<br />
    return $return;<br />
}<br />
</code></p>
<p>this change works for cpg1.5.x </p>
]]></content:encoded>
			<wfw:commentRss>http://zzapper.co.uk/how-to-remove-home-in-the-title-of-new-coppermine-gallery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Perl for Complex Edits</title>
		<link>http://zzapper.co.uk/using-perl-for-complex-edits/</link>
		<comments>http://zzapper.co.uk/using-perl-for-complex-edits/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 08:45:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding Tips]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://zzapper.co.uk/?p=165</guid>
		<description><![CDATA[All I use Vim 99% of the time whenever I want to do a really complex multiple edit I tend to use Perl. So what&#8217;s the script doing ? It reads in one text file line by line and then operates on certain lines , and then writes out each line to an output file. [...]]]></description>
			<content:encoded><![CDATA[<p>All I use Vim 99% of the time whenever I want to do a really complex multiple edit I tend to use Perl.</p>
<p>So what&#8217;s the script doing ? It reads in one text file line by line and then operates on certain lines , and then writes out each line to an output file. You are only limited by your imagination as to what you do in the loop.</p>
<p>With a Perl script you can use Perl variables for counts, you can use a hash to store all the text and loop through it as often as required.<br />
<code><br />
#!/usr/local/bin/perl<br />
# pedit.pl<br />
# description : Use for complex edits on a single file, adapt as required<br />
# this trivial example is just incrementing a count<br />
# zzapper<br />
# v1.0<br />
if ($#ARGV >= 0) { $file = $ARGV[0]; }<br />
else<br />
{<br />
print "enter file:"; $file=<STDIN>;<br />
}<br />
chomp $file;<br />
open (R,"$file") or die ("could not open $file ($!)");<br />
$out = "c:/aaa/out.txt";<br />
$out = "$file.txt";<br />
$cnt=100;</p>
<p>open (W,">$out") or die ("could not open $out ($!)",__LINE__);<br />
{<br />
    for $l (<R>)<br />
    {<br />
       $l=~s/david1/david$cnt/gi;   # do what you want here<br />
       print W $l;<br />
       $cnt++;<br />
    }<br />
}<br />
close W; close R;<br />
print "\nOutput in cnt: $cnt :: $out\n";</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://zzapper.co.uk/using-perl-for-complex-edits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Common Programmer Mistakes</title>
		<link>http://zzapper.co.uk/common-programmer-mistakes/</link>
		<comments>http://zzapper.co.uk/common-programmer-mistakes/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 22:10:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding Tips]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[rollback]]></category>

		<guid isPermaLink="false">http://zzapper.co.uk/?p=119</guid>
		<description><![CDATA[I for my sins code in PHP,Perl,ColdFusion using database MySQL and also write JavaScript, XML and battle with CSS and Ajax etc. Often I&#8217;m working on these projects in parallel which gets kind of stressful. Anyway I let my standards slip recently and made the following mistakes and suffered for it. Not immediately taking my [...]]]></description>
			<content:encoded><![CDATA[<p>I for my sins code in PHP,Perl,ColdFusion using database MySQL  and also write JavaScript, XML and battle with CSS and Ajax etc. Often I&#8217;m working on these projects in parallel which gets kind of stressful. Anyway I let my standards slip recently and made the following mistakes and suffered for it.</p>
<ul>
<li>Not immediately taking my own <strong>backup </strong>of the files I was working so I could rollback at any time and as importantly prove whether my changes had or had not caused a regression or bug</li>
<li>Leaving <strong>test files</strong> lying about, so I later got confused as to which was the actual version</li>
<li>In Perl coded the <strong>catastrophic error </strong>$restart=0 if $cnt=1; (should be if $cnt==1)</li>
<li>Also in <strong>Perl </strong>had some problems due to not systematically initializing variables in a subroutine</li>
<li>To my credit have started to use  <strong>git </strong>for version control</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zzapper.co.uk/common-programmer-mistakes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>

