<?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>ModeWeb Blog</title>
	<atom:link href="http://www.modeweb.co.uk/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.modeweb.co.uk/blog</link>
	<description>Web Development Tech Blog</description>
	<lastBuildDate>Wed, 21 Mar 2012 15:08:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Nice one liner to restore a database</title>
		<link>http://www.modeweb.co.uk/blog/2012/03/nice-one-liner-to-restore-a-database/</link>
		<comments>http://www.modeweb.co.uk/blog/2012/03/nice-one-liner-to-restore-a-database/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 15:08:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[nix]]></category>

		<guid isPermaLink="false">http://www.modeweb.co.uk/blog/?p=172</guid>
		<description><![CDATA[
zcat `ls -t *.gz &#124; head -1` &#124; mysql -uroot -ppassword DB_NAME

The above runs a command ls -t to show files in a directory, order by modification time -t, it then just grabs the first one in the list head -1 i.e. the latest back up file. The output is then piped to mysql where [...]]]></description>
			<content:encoded><![CDATA[<pre>
zcat `ls -t *.gz | head -1` | mysql -uroot -ppassword DB_NAME
</pre>
<p>The above runs a command <code>ls -t</code> to show files in a directory, order by modification time <code>-t</code>, it then just grabs the first one in the list <code>head -1</code> i.e. the latest back up file. The output is then piped to mysql where the SQL is ran. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.modeweb.co.uk/blog/2012/03/nice-one-liner-to-restore-a-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript string filtering methods</title>
		<link>http://www.modeweb.co.uk/blog/2012/03/javascript-string-filtering-methods/</link>
		<comments>http://www.modeweb.co.uk/blog/2012/03/javascript-string-filtering-methods/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 10:20:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.modeweb.co.uk/blog/?p=164</guid>
		<description><![CDATA[Some maybe useful Javascript string manipulation and filtering methods:

// convert Characters
returnString = returnString.replace(/ö/g, 'o');
returnString = returnString.replace(/ç/g, 'c');
returnString = returnString.replace(/ş/g, 's');
returnString = returnString.replace(/ı/g, 'i');
returnString = returnString.replace(/ğ/g, 'g');
returnString = returnString.replace(/ü/g, 'u');

// if there are other invalid chars, convert them into blank spaces
returnString = returnString.replace(/[^a-z0-9\s-]/g, "");
// convert multiple spaces and hyphens into one space
returnString = returnString.replace(/[\s-]+/g, " ");
// [...]]]></description>
			<content:encoded><![CDATA[<p>Some maybe useful Javascript string manipulation and filtering methods:</p>
<pre>
// convert Characters
returnString = returnString.replace(/ö/g, 'o');
returnString = returnString.replace(/ç/g, 'c');
returnString = returnString.replace(/ş/g, 's');
returnString = returnString.replace(/ı/g, 'i');
returnString = returnString.replace(/ğ/g, 'g');
returnString = returnString.replace(/ü/g, 'u');

// if there are other invalid chars, convert them into blank spaces
returnString = returnString.replace(/[^a-z0-9\s-]/g, "");
// convert multiple spaces and hyphens into one space
returnString = returnString.replace(/[\s-]+/g, " ");
// trims current string
returnString = returnString.replace(/^\s+|\s+$/g,"");
// cuts string (if too long)
if(returnString.length > maxLength)
    returnString = returnString.substring(0,maxLength);
// add hyphens
returnString = returnString.replace(/\s/g, "-");
</pre>
<pre>
/**
  * Remove all characters that do not fit regex antipattern.
  *
  * @param string $string
  * @param string $antiPattern
  **/
function stripInvalidStringChars($string, $antiPattern) {
    return preg_replace('/ {2,}/',' ',preg_replace($antiPattern, '', $string));
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.modeweb.co.uk/blog/2012/03/javascript-string-filtering-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Validate an array of integers in one go</title>
		<link>http://www.modeweb.co.uk/blog/2012/03/php-validate-an-array-of-integers-in-one-go/</link>
		<comments>http://www.modeweb.co.uk/blog/2012/03/php-validate-an-array-of-integers-in-one-go/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 13:19:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.modeweb.co.uk/blog/?p=160</guid>
		<description><![CDATA[Here&#8217;s a nice way to make sure an array of integer values contains elements that are greater than zero.

$array = array(123,32,321,3442,342);
$r = array_filter($array, create_function('$val', 'return (int)$val;'));
if(count($array) != count($r)) {
&#160;&#160;echo 'not valid';
}else {
&#160;&#160;echo 'valid';
}

]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a nice way to make sure an array of integer values contains elements that are greater than zero.</p>
<pre>
$array = array(123,32,321,3442,342);
$r = array_filter($array, create_function('$val', 'return (int)$val;'));
if(count($array) != count($r)) {
&nbsp;&nbsp;echo 'not valid';
}else {
&nbsp;&nbsp;echo 'valid';
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.modeweb.co.uk/blog/2012/03/php-validate-an-array-of-integers-in-one-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Count Rows For Pagination</title>
		<link>http://www.modeweb.co.uk/blog/2011/12/mysql-count-rows-for-pagination/</link>
		<comments>http://www.modeweb.co.uk/blog/2011/12/mysql-count-rows-for-pagination/#comments</comments>
		<pubDate>Sun, 25 Dec 2011 21:36:46 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.modeweb.co.uk/blog/2011/12/mysql-count-rows-for-pagination/</guid>
		<description><![CDATA[The following SQL snippet shows a neat way to do queries when implementing paged results.
I have tested the snippet on MySQL 5 only.

SELECT SQL_COUNT ROWS *, tableName.id, tableName.someCol
FROM tableName
LIMIT 0,25;



SELECT SELECT FOUND_ROWS();

For example, say the above table tableName has a total of 100 rows, running the above queries one after another would first return a [...]]]></description>
			<content:encoded><![CDATA[<p>The following SQL snippet shows a neat way to do queries when implementing paged results.</p>
<p>I have tested the snippet on MySQL 5 only.</p>
<pre>
SELECT SQL_COUNT ROWS *, tableName.id, tableName.someCol
FROM tableName
LIMIT 0,25;
</pre>
<p><span id="more-147"></span></p>
<pre>
SELECT SELECT FOUND_ROWS();
</pre>
<p>For example, say the above table <code>tableName</code> has a total of 100 rows, running the above queries one after another would first return a result set of 25 rows, then the second query would return 100, the total number of rows.</p>
<p>It may be interesting also to see if there is a performance difference between a   3 or a 2 query approach, as the MySQL manual only shows running the <code>SQL_COUNT_ROWS *</code> statement on it&#8217;s own, unlike with columns as I have done here.</p>
<p>My hunch is that 2 queries would be faster but maybe not for tables with millions of rows?</p>
<p>
<a href="http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows">http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.modeweb.co.uk/blog/2011/12/mysql-count-rows-for-pagination/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Boolean Rules</title>
		<link>http://www.modeweb.co.uk/blog/2011/12/php-boolean-rules/</link>
		<comments>http://www.modeweb.co.uk/blog/2011/12/php-boolean-rules/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 19:46:03 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.modeweb.co.uk/blog/?p=93</guid>
		<description><![CDATA[When converting to boolean, the following values are considered FALSE:

the boolean FALSE itself
the integer 0 (zero)
the float 0.0 (zero)
the empty string, and the string &#8220;0&#8243;
an array with zero elements
an object with zero member variables (PHP 4 only)
the special type NULL (including unset variables)
SimpleXML objects created from empty tags

Every other value is considered TRUE (including any [...]]]></description>
			<content:encoded><![CDATA[<p>When converting to boolean, the following values are considered FALSE:</p>
<ul>
<li>the boolean FALSE itself</li>
<li>the integer 0 (zero)</li>
<li>the float 0.0 (zero)</li>
<li>the empty string, and the string &#8220;0&#8243;</li>
<li>an array with zero elements</li>
<li>an object with zero member variables (PHP 4 only)</li>
<li>the special type NULL (including unset variables)</li>
<li>SimpleXML objects created from empty tags</li>
</ul>
<p>Every other value is considered TRUE (including any resource).</p>
<p><a href="http://php.net/manual/en/language.types.boolean.php">More information here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.modeweb.co.uk/blog/2011/12/php-boolean-rules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

