<?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>Bobby Sciacchitano</title>
	<atom:link href="http://bobbysciacchitano.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bobbysciacchitano.com</link>
	<description>My World on the Internet</description>
	<lastBuildDate>Mon, 30 Jan 2012 04:25:08 +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>Autoloading 101</title>
		<link>http://bobbysciacchitano.com/2012/01/27/autoloading-101/</link>
		<comments>http://bobbysciacchitano.com/2012/01/27/autoloading-101/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 23:42:48 +0000</pubDate>
		<dc:creator>Bobby</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Autoload]]></category>
		<category><![CDATA[PHP 5.3]]></category>
		<category><![CDATA[SPL]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://bobbysciacchitano.com/?p=69</guid>
		<description><![CDATA[For some who are new to PHP 5 you may have heard about a PHP feature called SPL Autoload or Autoloading classes. Ordinarily, when you write a class your code may look something like this: &#60;?php require_once('../code/foo.php'); require_once('../code/baz.php'); class widget extends &#8230; <a href="http://bobbysciacchitano.com/2012/01/27/autoloading-101/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For some who are new to PHP 5 you may have heard about a PHP feature called <a title="PHP Manual Documentation" href="http://au2.php.net/manual/en/function.spl-autoload-register.php">SPL Autoload</a> or Autoloading classes.</p>
<p>Ordinarily, when you write a class your code may look something like this:</p>
<pre>&lt;?php

require_once('../code/foo.php');
require_once('../code/baz.php');

class widget extends foo
{
    public function event()
    {
        $baz = new baz();
    }
}</pre>
<p>Autoloading does away with the need to put require / include once to include class file by enabling you to attach a function that performs an action before a class is instantiated. SPL autoload works when you try to instantiate a class or use reflection on a class and only works when the class hasn&#8217;t already been loaded.</p>
<p><span id="more-69"></span></p>
<p><strong>Basic Autoloader</strong></p>
<p>This Autoload script looks at the name of the class, converts the class name into a path then includes the file. In this example, I&#8217;ve written my function so it will handle PHP 5.3 namespaced classes as well.</p>
<p>The Autoload function works on a couple of assumptions:</p>
<ol>
<li>There is only one class per file,</li>
<li>Your library directories are organised by a <a title="Zend Framework Naming Conventions" href="http://framework.zend.com/manual/en/coding-standard.naming-conventions.html">vendor structure</a></li>
</ol>
<p>This is a fairly high level implementation, there are a number of different approaches to class loading in PHP 5 however, this is my favourite because it&#8217;s the simplest.</p>
<pre>&lt;php

// Register autoloader
spl_autoload_register('loadGenericClass');

// Set base include paths
$paths = array();
$paths[] = "/PATH/TO/LIBRARY/";
$paths[] = "/PATH/TO/ANOTHER_LIBRARY/";
$paths[] = get_include_path();

set_include_path(implode(PATH_SEPARATOR, $paths));

// Autoloader
function loadGenericClass($class)
{
    $path = str_replace(array('_', '\\'), '/', $class) . '.php';

    @include_once($path);
}</pre>
<p><strong>Stepping through the code</strong></p>
<p>The first part registers a function that can be used to include a file. In this instance, the function is called <code>loadGenericClass</code>. Underneath, I&#8217;ve set up an array of paths to search through. We&#8217;re going to add these to the <a title="PHP Manual Documentation" href="http://au2.php.net/set_include_path">include path</a> since we want our autoload function to have complete access to our bespoke code and PEAR / PECL classes. In my example, my library files are in multiple locations which is I why I prefer to use an array over building a long string.</p>
<p>When PHP calls the <code>loadGenericClass</code> function it passes in the class name. In this instance, I&#8217;m performing a simple replace to look for underscores (_) and backticks (\) and replace them with a slash. The slash represents the path of the class file. For example <code>Vendor_Group_Class</code> is converted to <code>Vendor/Group/Class.php</code>.</p>
<p>We also look for backticks because in PHP 5.3 now has <a title="PHP Manual Documentation" href="http://au2.php.net/namespace">namespace support</a>. In this instance, the variable will be <code>\Vendor\Group\Class</code> which is converted to <code>Vendor/Group/Class.php</code>.</p>
<p>Finally, the file gets included into the script. This will use the include path to load the class file.</p>
<p>And there you have it. Class loading in PHP 5 without the need for include and require everywhere.</p>
]]></content:encoded>
			<wfw:commentRss>http://bobbysciacchitano.com/2012/01/27/autoloading-101/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Useful MySQL commands</title>
		<link>http://bobbysciacchitano.com/2012/01/19/useful-mysql-commands/</link>
		<comments>http://bobbysciacchitano.com/2012/01/19/useful-mysql-commands/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 01:00:48 +0000</pubDate>
		<dc:creator>Bobby</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://bobbysciacchitano.com/?p=41</guid>
		<description><![CDATA[I&#8217;m currently working on a project which requires me to use MySQL from the command line. This presents a number of interesting issues for a developer who prefers a GUI to perform management functions. I&#8217;ve started to compile a list &#8230; <a href="http://bobbysciacchitano.com/2012/01/19/useful-mysql-commands/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on a project which requires me to use MySQL from the command line. This presents a number of interesting issues for a developer who prefers a <a title="Sequel Pro" href="http://www.sequelpro.com/" target="_blank">GUI</a> to perform management functions.</p>
<p>I&#8217;ve started to compile a list of some of the more useful and maybe unknown MySQL commands.</p>
<p><span id="more-41"></span></p>
<pre>\! clear;</pre>
<p>Similar to the Linux clear command it gives you a shiny clean MySQL buffer for you to dirty up again.</p>
<pre>SHOW FULL PROCESSLIST;</pre>
<p>If you use the standard SHOW PROCESSLIST function, you&#8217;ll notice that the result in the info column is truncated which is unhelpful if there is a number of queries with similar syntax running. Adding FULL will return the full SQL query but will probably break the column layout which brings me to my next command:</p>
<pre>SHOW FULL PROCESSLIST \G;

SELECT * FROM table \G;</pre>
<p>Adding \G to the end of a query returns results in a &#8216;card view&#8217; layout which is useful if you have columns with large amounts of data.</p>
<pre>SHOW OPEN TABLES;</pre>
<p>If you&#8217;re working on a database which uses transactions and are trying to work out if a table is locked, or in use, this query will tell you.</p>
<pre>SHOW TABLE STATUS;</pre>
<p>This view will show you details related to the table including engine, how many rows in the table when it was created, updated and rows.</p>
<pre>SHOW CREATE TABLE `table_name`;</pre>
<p>This will dump the create script for the specified table name, useful if you don&#8217;t want to use MySQL dump to get the schema.</p>
]]></content:encoded>
			<wfw:commentRss>http://bobbysciacchitano.com/2012/01/19/useful-mysql-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On Resolutions</title>
		<link>http://bobbysciacchitano.com/2012/01/04/on-resolutions/</link>
		<comments>http://bobbysciacchitano.com/2012/01/04/on-resolutions/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 06:37:54 +0000</pubDate>
		<dc:creator>Bobby</dc:creator>
				<category><![CDATA[Housekeeping]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[people]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[resolutions]]></category>
		<category><![CDATA[social]]></category>

		<guid isPermaLink="false">http://bobbysciacchitano.com/?p=3</guid>
		<description><![CDATA[I&#8217;ve always been of the opinion that people put too much stock into New Year resolutions &#8211; simply because they eventually fall by the wayside. My only resolution has always been that the new year be better than the one &#8230; <a href="http://bobbysciacchitano.com/2012/01/04/on-resolutions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been of the opinion that people put too much stock into New Year resolutions &#8211; simply because they eventually fall by the wayside. My only resolution has always been that the new year be better than the one just gone.</p>
<p>When I was deciding whether to restart my blog, I considered if it would be a good idea to import the 2000 or so posts I accumulated in archive form from personal sites going back to 2003. Every year up until 2007, I&#8217;d do a post about what I want to achieve in the new year but then I realised the process was pointless: being the best you can be was more important. I also decided not to import the posts simply because they&#8217;re rubbish.</p>
<p>This year, I thought it&#8217;d be fun to write down some resolutions and see how they pan out.</p>
<p><span id="more-3"></span>Some of my favourite ones include:</p>
<ul>
<li>Attain my drivers licence</li>
<li>Learn how to play the guitar</li>
<li>Travel again, this time to Singapore, London and New York</li>
<li>Run 12K in just under 1h 5m</li>
<li>Deactivate my Facebook profile</li>
</ul>
<p>Whoa&#8230; What was the last one? <strong>Deactivate</strong> my Facebook profile. Actually, I just ticked that one off the list.</p>
<p>There were a number of reasons why I decided to do this. Firstly, it was eating a massive chunk of my 150mb monthly data access on Vodafone. I&#8217;m looking at getting off Vodafone when my contract runs out and I don&#8217;t want upgrade and be locked in for another 24 months.</p>
<p>The second and perhaps more important reason is because I felt that over the last two years the human element of interactions I had with others &#8211; friends, family and acquaintances had completely diminished. No one ever bothered to ring me to invite me to an event; it was simply put up on Facebook, if something exciting happened I&#8217;d read about it on the wall, if I wanted to chat to someone it&#8217;d be easier to open the chat window rather than make a phone call or meet face to face. I was just as bad. It made me really, really lazy.</p>
<p>In the end, I felt like I was beholden to Facebook for everything.</p>
<p>As a web developer and social media junkie, it&#8217;s the hardest thing to do but after all Facebook is only one conduit for interacting with others. This year I decided I was going to make my relationships more meaningful. It means others are going to have to make the same effort in return.</p>
<p>Roll on 2012.</p>
]]></content:encoded>
			<wfw:commentRss>http://bobbysciacchitano.com/2012/01/04/on-resolutions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

