<?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>georgeharito.com</title>
	<atom:link href="http://georgeharito.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://georgeharito.com</link>
	<description>A few miscellaneous ramblings of a BMW-loving, Amiga-nostalgic, Mac-using PHP developer from Australia</description>
	<lastBuildDate>Sun, 06 Mar 2011 08:50:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Retro Apple //e</title>
		<link>http://georgeharito.com/2011/03/retro-apple-e/</link>
		<comments>http://georgeharito.com/2011/03/retro-apple-e/#comments</comments>
		<pubDate>Sun, 06 Mar 2011 08:50:35 +0000</pubDate>
		<dc:creator>georgeharito</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Retro]]></category>

		<guid isPermaLink="false">http://georgeharito.com/?p=141</guid>
		<description><![CDATA[This weekend, the opportunity to receive an old Apple //e had passed my way and I took it eagerly with both hands. The guy who had it before me (one of my dad&#8217;s work mates) didn&#8217;t know much about it, but was about to throw it away or sell it, so I made sure I [...]]]></description>
			<content:encoded><![CDATA[<p>This weekend, the opportunity to receive an old Apple //e had passed my way and I took it eagerly with both hands. The guy who had it before me (one of my dad&#8217;s work mates) didn&#8217;t know much about it, but was about to throw it away or sell it, so I made sure I snapped it up real quick. As we got it home, I had a good look around it and it seems to be an Apple //e Platinum with monitor and disk drive. Unfortunately, the other end of the cable for the disk drive has been cut, so I can&#8217;t use any floppies until I either get a new cable and do a transplant, or get a new drive overall.<br />
<span id="more-141"></span><br />
The case has had a bit of a tan (I might use the old <a href="http://retr0bright.wikispaces.com/" target="_blank">retr0bright</a> trick to try and recover that), but all the keys are present and the monitor works quite well. Opening up the case doesn&#8217;t reveal much – I had always read that Woz created the Apple ][ with the least number of chips possible, but you don't really appreciate it until you open the case of one. The disk controller card itself is a masterpiece of engineering. There is also a memory upgrade card (I think it's 64KB, not sure if there is another 64KB on board though?) and a serial card that definitely hasn't been designed with Woz's intentions.<br />

<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0488/' title='Apple //e'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0488-150x150.jpg" class="attachment-thumbnail" alt="Apple //e" title="Apple //e" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0490/' title='Platinum edition (silk-screened)'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0490-150x150.jpg" class="attachment-thumbnail" alt="Platinum edition (silk-screened)" title="Platinum edition (silk-screened)" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0492/' title='Full keyboard, a little bit of yellowing'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0492-150x150.jpg" class="attachment-thumbnail" alt="Full keyboard, a little bit of yellowing" title="Full keyboard, a little bit of yellowing" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0495/' title='Rear of the machine'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0495-150x150.jpg" class="attachment-thumbnail" alt="Rear of the machine" title="Rear of the machine" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0496/' title='Model panel on the back of the monitor'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0496-150x150.jpg" class="attachment-thumbnail" alt="Model panel on the back of the monitor" title="Model panel on the back of the monitor" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0520/' title='Model plaque underneath case'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0520-150x150.jpg" class="attachment-thumbnail" alt="Model plaque underneath case" title="Model plaque underneath case" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0499/' title='Booting up (no disk drive though)'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0499-150x150.jpg" class="attachment-thumbnail" alt="Booting up (no disk drive though)" title="Booting up (no disk drive though)" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0500/' title='Case opened'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0500-150x150.jpg" class="attachment-thumbnail" alt="Case opened" title="Case opened" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0502/' title='The Real McCoy'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0502-150x150.jpg" class="attachment-thumbnail" alt="The Real McCoy" title="The Real McCoy" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0508/' title='Revision B motherboard'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0508-150x150.jpg" class="attachment-thumbnail" alt="Revision B motherboard" title="Revision B motherboard" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0509/' title='Blinkenlight :)'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0509-150x150.jpg" class="attachment-thumbnail" alt="Blinkenlight :)" title="Blinkenlight :)" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0510/' title='Disk controller'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0510-150x150.jpg" class="attachment-thumbnail" alt="Disk controller" title="Disk controller" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0511/' title='Memory upgrade card'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0511-150x150.jpg" class="attachment-thumbnail" alt="Memory upgrade card" title="Memory upgrade card" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0512/' title='Serial card'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0512-150x150.jpg" class="attachment-thumbnail" alt="Serial card" title="Serial card" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0513/' title='Good ol&#039; 65C02 ;)'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0513-150x150.jpg" class="attachment-thumbnail" alt="Good ol&#039; 65C02 ;)" title="Good ol&#039; 65C02 ;)" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0514/' title='Diagnostics mode (disconnect keyboard and then boot up machine)'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0514-150x150.jpg" class="attachment-thumbnail" alt="Diagnostics mode (disconnect keyboard and then boot up machine)" title="Diagnostics mode (disconnect keyboard and then boot up machine)" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0516/' title='A bit of BASIC'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0516-150x150.jpg" class="attachment-thumbnail" alt="A bit of BASIC" title="A bit of BASIC" /></a>
<a href='http://georgeharito.com/2011/03/retro-apple-e/img_0517/' title='Old Apple vs New(er) Apple'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2011/03/IMG_0517-150x150.jpg" class="attachment-thumbnail" alt="Old Apple vs New(er) Apple" title="Old Apple vs New(er) Apple" /></a>
</p>
<p>I found a way to get into the BASIC interpreter, I&#8217;m sure this isn&#8217;t the &#8216;official&#8217; way of doing it, but by turning the machine off and then on again pretty quick (about 1 second delay) got me to a &#8216;]&#8217; prompt, where I could clear the screen and start writing some BASIC on it. You can see in some of the photos in the gallery above that I had typed some things in and it seems to work well.</p>
<p>It&#8217;s a real shame that the floppy drive has been molested like that, so I&#8217;m on the prowl for a new floppy drive and hopefully some software too. I still have heaps of reading up to do about the Apple //e (I had some experience with it in primary school and early high school, where I was writing LOGO with it), but a copy of Where in the World is Carmen Sandiego for the Apple II would be a great addition :)</p>
]]></content:encoded>
			<wfw:commentRss>http://georgeharito.com/2011/03/retro-apple-e/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP technique: Using arrays as function parameters</title>
		<link>http://georgeharito.com/2010/12/php-technique-using-arrays-as-function-parameters/</link>
		<comments>http://georgeharito.com/2010/12/php-technique-using-arrays-as-function-parameters/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 09:45:38 +0000</pubDate>
		<dc:creator>georgeharito</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://georgeharito.com/?p=127</guid>
		<description><![CDATA[I&#8217;ve decided to start a not-so-regular string of blog posts that explore PHP programming techniques that you may or may not know of. I am in no means a perfect PHP programmer, and I&#8217;m sure there are heaps of people that are, but this is I guess my way of contributing back to the community. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve decided to start a not-so-regular string of blog posts that explore PHP programming techniques that you may or may not know of. I am in no means a perfect PHP programmer, and I&#8217;m sure there are heaps of people that are, but this is I guess my way of contributing back to the community.</p>
<p>I&#8217;m going to start this not-so-regular string of PHP programming posts by commenting on a technique that is relatively new to me (I&#8217;ve known it for a couple of years now, but to be honest the opportunities to use this haven&#8217;t been that numerous), but improves programmer usability ie. it makes your life as a PHP programmer just that little bit easier. I call it &#8216;array parameters&#8217; for lack of a better term.<br />
<span id="more-127"></span><br />
Basically, it&#8217;s just using an array for your parameters in your custom functions, rather than declaring the order of values for your parameter in your function declaration. It&#8217;s also handy when trying to do nifty little things like default values for parameters, in which PHP has some shortcomings in.</p>
<p>It&#8217;s best to show this by example. Let&#8217;s say we have a function that sends an email out to a specific address.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sendMail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$toAddress</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fromAddress</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailMessage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailSubject</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// let's just imagine that all inputs have already been sanitized and are safe to use</span>
	<span style="color: #000088;">$emailHeaders</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$fromAddress</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$toAddress</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailSubject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailMessage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailHeaders</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This function can be called via the following simple one-liner:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$sendResult</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'to@example.com'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'from@example.com'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'This is a test email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Test email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Pretty simple, right? We have four parameters, all in a specific order. We can go one step further and specify some defaults:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sendMail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$toAddress</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fromAddress</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailMessage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailSubject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is the default subject&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// let's just imagine that all inputs have already been sanitized and are safe to use</span>
	<span style="color: #000088;">$emailHeaders</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$fromAddress</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$toAddress</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailSubject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailMessage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailHeaders</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>That way, we can do something like the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$sendResult</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'to@example.com'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'from@example.com'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'This is a test email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// omitted the $emailSubject parameter</span></pre></td></tr></table></div>

<p>&#8230; which will fire off an email with the subject line &#8220;This is a default subject&#8221;.</p>
<p>This is all well and good, and heaps of PHP code out there in the wild (and behind locked doors) are written in this way. So what&#8217;s the big deal?</p>
<p>Let&#8217;s imagine that there is a group of PHP developers working on a project. There is a central repository of some shared libraries, and developrs are free to create new functions and add them to the library. One developer has contributed the above sendMail function (let&#8217;s say that this developer had embellished a little and turned it into an easy to use HTML email function) and ordered the parameters the way that made most sense to them, but some other people don&#8217;t agree and figure that it should follow more closely the order of parameters that the built in PHP mail() function has. </p>
<p>A political shitfight occurs, some sort of consensus has been achieved and the guys that thought differently to the original programmer won; the parameter order gets changed to make life easier. But by that stage, there&#8217;s already a whole heap of code that uses the &#8220;old&#8221; version. So they figure they should make another function instead, called sendMail2()&#8230; can you see where I&#8217;m getting at here? Some more lateral thought is needed.</p>
<p>Not everyone has the capability of seeing 3 steps ahead, and many times people come back to functions that they have written in the past and adjust them. Add a new feature or two, or try to make things more &#8220;usable&#8221; when it comes to programming, breaking old code in the process. </p>
<p>Wouldn&#8217;t it be great if you could just write a function that takes some sort of special variable, where the order doesn&#8217;t matter? That if new functionality is added to the function, it can be done so easily, and without breaking old code?</p>
<p>That&#8217;s where array parameters comes in.</p>
<p>Let&#8217;s refactor our sendMail() function and use a keyed array as our sole parameter input, as so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sendMail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$emailHeaders</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'fromAddress'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'toAddress'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'emailSubject'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'emailMessage'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailHeaders</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// when we call our function, we can do it as so:</span>
<span style="color: #000088;">$sendResult</span> <span style="color: #339933;">=</span> sendMail<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'toAddress'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'to@example.com'</span><span style="color: #339933;">,</span> 
	<span style="color: #0000ff;">'fromAddress'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'from@example.com'</span><span style="color: #339933;">,</span> 
	<span style="color: #0000ff;">'emailSubject'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'This is a test email'</span><span style="color: #339933;">,</span> 
	<span style="color: #0000ff;">'emailMessage'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'This is the test email content right here'</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You can jumble around whatever keyed array elements you like, it doesn&#8217;t matter. You don&#8217;t need to remember which parameter comes first, as long as it&#8217;s in the array, it&#8217;ll get picked up.</p>
<p>What if some parameters are missing though? You should have some sort of default values for parameters (read array keys) that might not be in the parameter array when called.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sendMail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	<span style="color: #666666; font-style: italic;">// we can set the defaults here</span>
	<span style="color: #000088;">$defaults</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'toAddress'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> 
		<span style="color: #0000ff;">'fromAddress'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'default_from@example.com'</span><span style="color: #339933;">,</span> 
		<span style="color: #0000ff;">'emailSubject'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'No subject was defined, so here is a default one'</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$defaults</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// copy the $options array over the $defaults </span>
&nbsp;
	<span style="color: #000088;">$emailHeaders</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'fromAddress'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'toAddress'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'emailSubject'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'emailMessage'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$emailHeaders</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// You can now call sendMail() as such, if you like:</span>
<span style="color: #000088;">$sendResult</span> <span style="color: #339933;">=</span> sendMail<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'toAddress'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'to@example.com'</span><span style="color: #339933;">,</span> 
	<span style="color: #0000ff;">'emailMessage'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Here is a test email with some default parameters applied'</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The array_merge() function will overwrite the $defaults array with whatever has been input. You don&#8217;t need to declare everything as an input (I put the &#8216;toAddress&#8217; key in the defaults and set it to null to demonstrate that you can do this too if you feel more comfortable). The key &#8216;emailMessage&#8217; isn&#8217;t declared in the $defaults array, but it is appended to $options when it is merged with it. It works the other way too; if you add functionality to this function and require more parameters, you can add them to the $defaults array and use them as above, without breaking any old code.</p>
<p>So I hope some of you out there have found this PHP coding technique useful. By no means have I discovered or invented this myself; it&#8217;s used liberally throughout the CakePHP framework and I have been pretty exposed to that over the past few years. I&#8217;m sure many other projects out there use something similar, if not the same. It won&#8217;t fix old code that still relies on the old process of itemising each parameter in a function, but if you start right now with this technique, your team (and yourself) will thank you later for it.</p>
<p>I&#8217;d be glad to hear your thoughts, and yes I know the code snippets above aren&#8217;t styled properly, but I&#8217;ll leave that for another day.</p>
]]></content:encoded>
			<wfw:commentRss>http://georgeharito.com/2010/12/php-technique-using-arrays-as-function-parameters/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arduino!</title>
		<link>http://georgeharito.com/2010/10/arduino/</link>
		<comments>http://georgeharito.com/2010/10/arduino/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 02:02:52 +0000</pubDate>
		<dc:creator>georgeharito</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[arduino]]></category>

		<guid isPermaLink="false">http://georgeharito.com/?p=107</guid>
		<description><![CDATA[I had been meaning to get into some embedded development for a little while now, as I am slowly getting bored of PHP / web development and thought it would be nice to broaden my horizons a little. I failed Computer Systems Engineering back at uni (but repeated it and passed the second time around) [...]]]></description>
			<content:encoded><![CDATA[<p>I had been meaning to get into some embedded development for a little while now, as I am slowly getting bored of PHP / web development and thought it would be nice to broaden my horizons a little. I failed Computer Systems Engineering back at uni (but repeated it and passed the second time around) simply because I hated assembler &#8211; I didn&#8217;t see the point of having to worry about which accumulator has been primed, or moving values left right and centre, and I much preferred C++ as I focused more on the task at hand, and not trying to show the computer what to do with values and memory.<br />
<span id="more-107"></span></p>
<p>Anyway, I digress – following some people on Twitter such as <a href="http://twitter.com/interactmatter">Interactive Matter</a> and <a href="http://twitter.com/mightyohm">Jeff Keyzer</a> had exposed me to some interesting information about the <a href="http://www.arduino.cc">Arduino</a>. A quick tweet to Jeff and a recommendation was made for the new Arduino model coming out soon (at the time) – the <a href="http://arduino.cc/en/Main/ArduinoBoardUno">Arduino Uno</a>. I quickly found a distributor in Australia called (funnily enough) <a href="http://www.australianrobotics.com.au/">Australian Robotics</a> and a few days later I receive my very own Arduino Uno in my hot little hands.</p>
<p>I don&#8217;t have any other hardware or cabling available on hand, so I can&#8217;t do much with it for now. But a quick stop at Jaycar will solve that problem.</p>
<p>I took some unboxing pics (keeping up with the Apple tradition) but didn&#8217;t think of taking pics until after I opened it – so the sealing label on the Arduino box is a little tattered in the photos. As for the photos themselves, I took them on my iPhone so some might be a bit blurry, I apologise in advance.<br />

<a href='http://georgeharito.com/2010/10/arduino/photo-02/' title='Packaging box from Australian Robotics'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/10/photo-02-150x150.jpg" class="attachment-thumbnail" alt="Packaging box from Australian Robotics" title="Packaging box from Australian Robotics" /></a>
<a href='http://georgeharito.com/2010/10/arduino/photo-05/' title='Inside the box'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/10/photo-05-150x150.jpg" class="attachment-thumbnail" alt="Inside the box" title="Inside the box" /></a>
<a href='http://georgeharito.com/2010/10/arduino/photo-07/' title='Arduino packing box'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/10/photo-07-150x150.jpg" class="attachment-thumbnail" alt="Arduino packing box" title="Arduino packing box" /></a>
<a href='http://georgeharito.com/2010/10/arduino/photo-09/' title='Arduino packing box'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/10/photo-09-150x150.jpg" class="attachment-thumbnail" alt="Arduino packing box" title="Arduino packing box" /></a>
<a href='http://georgeharito.com/2010/10/arduino/photo-10/' title='Arduino packing box and documentation'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/10/photo-10-150x150.jpg" class="attachment-thumbnail" alt="Arduino packing box and documentation" title="Arduino packing box and documentation" /></a>
<a href='http://georgeharito.com/2010/10/arduino/photo-13/' title='Contents of the Arduino packing box'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/10/photo-13-150x150.jpg" class="attachment-thumbnail" alt="Contents of the Arduino packing box" title="Contents of the Arduino packing box" /></a>
<a href='http://georgeharito.com/2010/10/arduino/photo-14/' title='The Arduino Uno itself'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/10/photo-14-150x150.jpg" class="attachment-thumbnail" alt="The Arduino Uno itself" title="The Arduino Uno itself" /></a>
<a href='http://georgeharito.com/2010/10/arduino/photo-17/' title='She&#039;s pretty small.'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/10/photo-17-150x150.jpg" class="attachment-thumbnail" alt="She&#039;s pretty small." title="She&#039;s pretty small." /></a>
<a href='http://georgeharito.com/2010/10/arduino/photo-19/' title='The board size in comparison to a 50c coin'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/10/photo-19-150x150.jpg" class="attachment-thumbnail" alt="The board size in comparison to a 50c coin" title="The board size in comparison to a 50c coin" /></a>
<a href='http://georgeharito.com/2010/10/arduino/photo-21/' title='Board underside'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/10/photo-21-150x150.jpg" class="attachment-thumbnail" alt="Board underside" title="Board underside" /></a>
<a href='http://georgeharito.com/2010/10/arduino/photo-22/' title='Plugged in and turned on'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/10/photo-22-150x150.jpg" class="attachment-thumbnail" alt="Plugged in and turned on" title="Plugged in and turned on" /></a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://georgeharito.com/2010/10/arduino/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Proposal via iPhone app</title>
		<link>http://georgeharito.com/2010/03/proposal-via-iphone-app/</link>
		<comments>http://georgeharito.com/2010/03/proposal-via-iphone-app/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 09:28:39 +0000</pubDate>
		<dc:creator>georgeharito</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[proposal]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://georgeharito.com/?p=87</guid>
		<description><![CDATA[For those who know me quite well, they already know this, but for those who don&#8217;t, I&#8217;ll just come clean and say it. I proposed to my (then) girlfriend in November 2009 via iPhone app. Yes, I&#8217;m a nerd. Here&#8217;s how it happened. At Dogma, my current workplace, we would go out for Yum Cha [...]]]></description>
			<content:encoded><![CDATA[<p>For those who know me quite well, they already know this, but for those who don&#8217;t, I&#8217;ll just come clean and say it.</p>
<p>I <strong>proposed</strong> to my (then) girlfriend in November 2009 via iPhone app. <strong>Yes, I&#8217;m a nerd.</strong> Here&#8217;s how it happened.<br />
<span id="more-87"></span><br />
At <a href="http://www.dogma.com.au/">Dogma</a>, my current workplace, we would go out for Yum Cha every couple of months ago and just get drunk on Asahi and bloated from chocolate-filled sesame dumplings. During this state, we would have a good long chat with everyone else on the table and discuss what&#8217;s happening in everyone&#8217;s lives.</p>
<p>For some reason, my co-workers were <strong>always</strong> interested in when I&#8217;m going to propose to my girlfriend, usually I just buff the question off or try to divert conversation to someone / something else, but I was getting a bit tired of that and just <strong>blurted out that </strong><strong>I had no idea how to</strong>. My girlfriend wasn&#8217;t like any one else I had gone out with (one of the reasons why I wanted to propose), and I felt that it would be good to propose to her in a <strong>unique and interesting way</strong>. I definitely didn&#8217;t want to hide a ring in a cake or drop it in a champagne glass (that&#8217;s so <em>tacky</em>).</p>
<p>Due to the level of drunkedness, the ideas that my coworkers were coming up with were <strong>absolute gold</strong>. The best one was to create an <strong>iPhone app</strong>, and I jumped onto that idea straight away as I felt it was really &#8216;me&#8217;. I can&#8217;t remember who of my co-workers thought of it first, but whoever you are, <strong>thanks</strong>!</p>
<p>I had gone out onto the intarwebs a few weeks before that and bought an iPhone programming book – <a href="http://www.manning.com/callen/">iPhone in Action</a> by Christopher Allen and Shannon Appelcline. The book&#8217;s split in two, one section focuses on web programming and optimising for iPhone use, and the other half focuses on the iPhone app with CocoaTouch side of things. I had a flick through it and was <strong>pretty daunted</strong> with the Objective C syntax &#8212; it didn&#8217;t seem very C-like to me, and I was very comfortable with PHP.</p>
<p>Time went on and being busy with other things, this project fell by the wayside a little. Lo and behold, the year&#8217;s end was nearing and without an iPhone app (at this stage I was completely sold on the idea) I wasn&#8217;t going to pop the question. So I made some time in my schedule to sit down and try and nut out this Objective C thing. One of the tutorials was how to load a website in an application, and <strong>then I had a lightbulb moment</strong>.</p>
<p>If only if I could write the whole application as a <strong>website</strong>, store it locally within the application, and then get the app to load it up, then I could make the app behave like a native iPhone app, and the turn around could be much, much quicker. Yes, it&#8217;s the <strong>lazy way</strong> of completing the project, but time was against me (I had a vacation to go to with my girlfriend to Sydney coming up, and I wanted to be engaged before then), so I read into it and figured it all out.</p>
<p>So without any further ado, <strong>here&#8217;s some screenshots</strong> that you&#8217;d probably be interested in. The application is called <strong>iDo</strong>. I am aware that <strong>another app </strong>on the iPhone App Store is called iDo, but since I am not looking at selling this app, this shouldn&#8217;t be a problem.</p>

<a href='http://georgeharito.com/2010/03/proposal-via-iphone-app/ido_1/' title='iDo on the iPhone'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/03/ido_1-150x150.jpg" class="attachment-thumbnail" alt="iDo on the iPhone" title="iDo on the iPhone" /></a>
<a href='http://georgeharito.com/2010/03/proposal-via-iphone-app/ido_2/' title='iDo first screen'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/03/ido_2-150x150.jpg" class="attachment-thumbnail" alt="iDo first screen" title="iDo first screen" /></a>
<a href='http://georgeharito.com/2010/03/proposal-via-iphone-app/ido_3/' title='iDo Ring Selection Screen'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/03/ido_3-150x150.jpg" class="attachment-thumbnail" alt="iDo Ring Selection Screen" title="iDo Ring Selection Screen" /></a>
<a href='http://georgeharito.com/2010/03/proposal-via-iphone-app/ido_4/' title='iDo Ring Selection - highlighting'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/03/ido_4-150x150.jpg" class="attachment-thumbnail" alt="iDo Ring Selection - highlighting" title="iDo Ring Selection - highlighting" /></a>
<a href='http://georgeharito.com/2010/03/proposal-via-iphone-app/ido_5/' title='iDo Fireworks animated GIF'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2010/03/ido_5-150x150.jpg" class="attachment-thumbnail" alt="iDo Fireworks animated GIF" title="iDo Fireworks animated GIF" /></a>

<p>Just a run-down on what each screen does.</p>
<ul>
<li>The first screen shows off the icon that I edited for the application. I say <strong>edited</strong>, as it&#8217;s actually an image that I grabbed off the internet somewhere (it might be a free stock image, or it might not, I can&#8217;t remember). I&#8217;m guessing since I&#8217;m not using this application for any commercial gain what-so-ever, that I&#8217;m relatively safe using images such as this.</li>
<li>The second screen shows what my girlfriend would be first greeted with when launching the app. I have blurred out the meaty part of the message, as I&#8217;m a private person, and don&#8217;t feel comfortable showing the world what I wrote there; they are for two sets of eyes only, mine and hers. Note that I made it so that the &#8216;No&#8217; button cannot be selected &#8212;  you have no option but to click on &#8216;Yes&#8217; to proceed ;) <strong>Plus it&#8217;s really mushy.</strong></li>
<li>The third screen needs a bit of background story. Early on in our relationship, I wasn&#8217;t exactly made of money so as a joke I would always say that when I propose, it&#8217;ll be with a <strong>Burger Ring</strong>. Hence the Burger Ring in the top slot on this screen. My girlfriend some time ago had actually shown me what style of ring she wanted, when I was ready to propose, to make sure that I get her a ring that she likes (which I think is pretty important). The ring in the third slot is the example ring she showed me, I had to find it again to place it in this app. The ring in the middle is something that I came across when trying to find some gag ring I could put in there &#8212; it&#8217;s a <strong>Chupa-Chup ring</strong>.</li>
<li>The fourth screen shows the <strong>highlighting</strong> that happens when you tap and drag a ring from the left side to the hand. It glows white.</li>
<li>The fifth screen is a shot of the animated GIF that I found of fireworks after some rummaging through Google Images. It was luckily big enough to fill the iPhone screen.</li>
</ul>
<p>The <strong>techincal details</strong> of the app is as follows:</p>
<ul>
<li>The only Objective-C / CocoaTouch part of the whole application is the iDo shell &#8212; in the view files, there is just a UIWebView that gets populated with a local file (index.html). It&#8217;s index.html (and subsequent pages like page2.html, etc) that contains the &#8220;controller&#8221; (if you were to think of it as MVC).</li>
<li>There are other frivolous things in iDoAppDelegate.m that controls things like the colour of the status bar.</li>
<li>The HTML files were interesting &#8212; I found out via trial and error that it&#8217;s hard, nay, <strong>impossible</strong>, to link CSS files and to get them to load properly when the app was running. So all the CSS is <strong>embedded in the HTML files</strong>. &lt;img&gt; links etc were fine though.</li>
<li>I used <strong>iPhone-specific JavaScript</strong> to prevent moving the whole web view around when tapping and dragging (like what Safari does by default when loading a page) , and to handle the tap + drag of the rings from the left side to the right.</li>
<li>The highlighting of the hand is actually executed by two images, <strong>hand.png</strong> and <strong>hand_w.png</strong>. They get swapped in via some JS, just your basic document.getElementById(&#8216;hand&#8217;).src = &#8216;hand.png&#8217; kind of thing. There is some <strong>x-y coordinate range detection</strong> in there (again, in JS) to make sure that when dragging the ring, it&#8217;s over the hand before it highlights. This means that if you get a ring, and drag it over the hand, it will highlight, and if you don&#8217;t let the ring &#8220;go&#8221; and drag it back to the left side, <strong>the highlight disappears as it should</strong>. If you drop the ring successfully on the hand, location.href is populated with &#8216;page3.html&#8217; (ie. it loads up page3.html). This file just has an &lt;img&gt; tag that specifies the animated fireworks GIF.</li>
<li>The background images of the hearts (again, found it somewhere on Google Images so who knows what the copyright is like for this) is just loaded up as a background-image attribute value to the body selector.</li>
<li>The home page is actually just one big image not including the &#8216;Yes&#8217; button, which is a separate image that&#8217;s linked to page2.html. This is how I got the &#8216;No&#8217; button to not be selectable; <strong>it&#8217;s part of the background image.</strong></li>
</ul>
<p>So that&#8217;s about it. From start to finish, the whole project took me 4 nights to do, including testing on my iPhone and in Xcode&#8217;s simulator. I then bought an iPod Touch and installed it on there too (just the developer version, so it probably still has debug code in it too, making it run a little slower), wrapped it up as a gift and proposed to my girlfriend with it at a nice secluded spot on Port Melbourne beach.</p>
<p>By the way, she said <strong>yes</strong> :)</p>
]]></content:encoded>
			<wfw:commentRss>http://georgeharito.com/2010/03/proposal-via-iphone-app/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What ticks me off about OSX &amp; culture</title>
		<link>http://georgeharito.com/2009/09/what-ticks-me-off-about-osx-culture/</link>
		<comments>http://georgeharito.com/2009/09/what-ticks-me-off-about-osx-culture/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 06:26:54 +0000</pubDate>
		<dc:creator>georgeharito</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[culture]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://georgeharito.com/?p=72</guid>
		<description><![CDATA[This might come across as a angry little Mac fanboy venting, but I was wondering today what aspects of OSX and/or its culture that tick you off. We talk about what&#8217;s great about OSX all the time (and in my opinion, there are heaps of HUGE plusses), but I can easily come up with a [...]]]></description>
			<content:encoded><![CDATA[<p>This might come across as a angry little Mac fanboy venting, but I was wondering today what aspects of OSX and/or its culture that <strong>tick you off</strong>. We talk about what&#8217;s great about OSX all the time (and in my opinion, there are heaps of HUGE plusses), but I can easily come up with a few points myself:<br />
<span id="more-72"></span><br />
1) People referring to the Mac platform as <strong>all caps</strong> in writing (&#8220;I have a problem with my MAC&#8221;) &#8212; it&#8217;s Mac, einstein! Get it right.</p>
<p>2) Those <strong>Get a Mac ads</strong> &#8212; c&#8217;mon guys, enough with the baby music in the background and the &#8220;jibes&#8221; at MS. Each platform has its strengths and weaknesses</p>
<p>3) The flip-flopping of Apple that happens sometimes. One recent one is the removal, then re-addition of Firewire on the MacBook (now MacBook Pro) platform.</p>
<p>4) Apple taking its sweet time releasing updates to some software. Like Java updates to 1.6, for example.</p>
<p>5) Related to (3), but the gradual removal of features. Like using your iPhone as a drive (I used to do this all the time with my iPod)</p>
<p>6) Tech reporters, especially from the US, that <strong>rubbish an entire platform</strong> like the iPhone because it doesn&#8217;t have a feature like MMS in the US. Hey, there&#8217;s a place called <strong>the rest of the world</strong> that MMS and other features work fine, guys!</p>
<p>7) People who have used a Mac only once ever in their lives, which was in 1987, and will never, while their hearts are still beating, <strong>ever</strong> touch another Mac again, considering them some sort of Fisher-Price toy that couldn&#8217;t ever do any serious work, ever. <strong>Welcome to 2009</strong>, try a Mac before you spew out your bigotry. Related to this is how some people still think a Mac comes with a <strong>one-button mouse</strong> out of the box, which automatically makes the entire platform <strong>invalid and broken</strong>, in their eyes.</p>
<p>8) Mac fanboys who think they&#8217;re <strong>invincible</strong> and click on links, view attachments, visit dubious websites and think that they&#8217;ll never get into trouble with viruses or malware. That day will come, one day. <strong>And you&#8217;ll be screwed</strong>.</p>
<p>9) People who take advantage of the no serial number policy of Apple when it comes to OSX and just <strong>pirate the software</strong>. Snow Leopard is only forty freaking dollars &#8212; <strong>don&#8217;t be a tight arse.</strong></p>
<p>10) MS users who rubbish any major 10.x.0 OS X upgrade as just a <strong>service pack</strong>. Uh&#8230; no. They&#8217;re paid upgrades, and are worth as much IMO. Funnily enough, the &#8220;paid service pack&#8221; philosophy that they poo-pooh so often is perfectly acceptable when Microsoft do it for Windows Vista (version 6.0.6002) upgrades to Windows 7 (version 6.1.7600). Here&#8217;s the <a href="http://www.codinghorror.com/blog/archives/001290.html">proof of the version numbers</a>. <strong>Talk about double standards.</strong></p>
<p>What aspects of OSX, its culture, or its perceptions from outsiders <strong>tick you off?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://georgeharito.com/2009/09/what-ticks-me-off-about-osx-culture/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Combining PDF docs using Automator and Services in Snow Leopard 10.6</title>
		<link>http://georgeharito.com/2009/08/combining-pdf-docs-using-automator-and-services-in-snow-leopard/</link>
		<comments>http://georgeharito.com/2009/08/combining-pdf-docs-using-automator-and-services-in-snow-leopard/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 11:31:06 +0000</pubDate>
		<dc:creator>georgeharito</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Automator]]></category>
		<category><![CDATA[Snow Leopard]]></category>
		<category><![CDATA[10.6]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[services]]></category>

		<guid isPermaLink="false">http://georgeharito.com/?p=37</guid>
		<description><![CDATA[UPDATE (10/09/2009): A big thanks to Eric Weijers who pointed out in the comments below that the &#8220;Get Finder Items&#8221; action that I implemented in this workflow actually doubles up the pages that are in the resulting PDF. If you follow the instructions outlined in the post below, please make sure you don&#8217;t add the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE (10/09/2009)</strong>: A big thanks to Eric Weijers who pointed out in the comments below that the &#8220;Get Finder Items&#8221; action that I implemented in this workflow actually doubles up the pages that are in the resulting PDF. If you follow the instructions outlined in the post below, please make sure you <strong>don&#8217;t</strong> add the &#8220;Get Finder Items&#8221; action.</p>
<hr />
Before upgrading to Snow Leopard, I had made a few Automator actions that were saved as Finder plugins, and hence were accessible from Finder&#8217;s contextual popup window. However, after upgrading to Snow Leopard I found that these Finder plugins were gone (amongst other undesireable, but tolerable and fixable changes). After hearing about Services through the <a href="http://www.apple.com/au/macosx/refinements/">Apple Snow Leopard features page</a>, and podcasts such as <a href="http://twit.tv/mbw155">MacBreak Weekly</a>, I decided to retool the Automator action as a Service instead.<br />
<span id="more-37"></span></p>
<p>The cool thing about Services is that it&#8217;s been around for ages and no one really used them :) Actually the most cool thing I found about Services is that it&#8217;s <strong>targetable</strong>; you can pick between <strong>text services</strong> (normal text, URLs, addresses, phone numbers, dates or email addresses) or <strong>file services</strong> (files, folders, files and folders, documents, image files, PDF files, movie files, audio files or text files) and you can even <strong>target in which application</strong> the Service can be invoked.</p>
<p>To create a Service, open Automator in your /Applications folder and you will be greeted with the following requestor:</p>
<p><img src="http://georgeharito.com/wp-content/uploads/2009/08/1_choose_template.png" alt="Choose a workflow template" title="Choose a workflow template" width="556" height="517" class="size-full wp-image-38" /></p>
<p>Selecting the <strong>Service</strong> template will display a blank canvas on which to work from. Note that you can select the target that you need for your Service – for combining PDFs, I selected the drop down values to read &#8220;Service receives selected <strong>PDF files</strong> in <strong>any application</strong>&#8220;.</p>
<p><a href="http://georgeharito.com/wp-content/uploads/2009/08/2_pdf_workflows-1024x907.png" rel="wp-prettyPhoto[g37]"><img src="http://georgeharito.com/wp-content/uploads/2009/08/2_pdf_workflows-300x265.png" alt="PDF blank canvas" title="PDF blank canvas" width="300" height="265" class="aligncenter size-medium wp-image-39" /></a></p>
<p>The action that is central to the whole functionality of combining PDFs is, funnily enough, the <strong>Combine PDF Pages</strong> action. It is available under the &#8220;PDFs&#8221; menu in the Library. Drag it over to the blank canvas.</p>
<p><a href="http://georgeharito.com/wp-content/uploads/2009/08/3_combine_pdfs.png" rel="wp-prettyPhoto[g37]"><img src="http://georgeharito.com/wp-content/uploads/2009/08/3_combine_pdfs-300x265.png" alt="Combine PDFs" title="Combine PDFs" width="300" height="265" class="aligncenter size-medium wp-image-40" /></a></p>
<p>The thing that you would need to consider when using this action is what state should the files be when invoking it. Personally, I thought that I would most likely be selecting all the PDFs I want to combine and then invoke the command (either through the Services menu option in the Apple menu, or through the contextual menu). </p>
<p>So to make this work, you need to add the <strong>Get Selected Finder Items</strong> action – this is available via the <strong>Files &#038; Folders</strong> menu in the Library. Drag it to the canvas, <strong>above</strong> the Combine PDF Pages action.</p>
<p><a href="http://georgeharito.com/wp-content/uploads/2009/08/4_get_selected_finder.png" rel="wp-prettyPhoto[g37]"><img src="http://georgeharito.com/wp-content/uploads/2009/08/4_get_selected_finder-300x265.png" alt="Get Selected Finder Items" title="Get Selected Finder Items" width="300" height="265" class="aligncenter size-medium wp-image-41" /></a></p>
<p>I like to have some ability to interact with the Automator action, so I have ticked the <strong>Show this action when the workflow runs</strong> checkbox under <strong>Options</strong>.</p>
<p>If you were to run the Automator action right now (select some sample PDFs in Finder and then hit the <strong>Run</strong> button at the top right corner), you will find in the <strong>Result</strong> pane for the Combine PDF Pages action a brand new spankin&#8217; PDF file, but named with some random characters and at a location that&#8217;s not readily accessible (it&#8217;s actually in an OS X temporary folder). This is where you will need to add some more Automator actions to move the file to a more accessible location. You can start by adding the <strong>Rename Finder Items</strong> action, found under Files &#038; Folders in the Library.</p>
<p><a href="http://georgeharito.com/wp-content/uploads/2009/08/6_rename_file.png" rel="wp-prettyPhoto[g37]"><img src="http://georgeharito.com/wp-content/uploads/2009/08/6_rename_file-300x265.png" alt="Rename File Automator" title="Rename File Automator" width="300" height="265" class="aligncenter size-medium wp-image-43" /></a></p>
<p>We want to change the basename only (the file name, not including the extension), so change the <strong>Add Date or Time</strong> drop down list to <strong>Name Single Item</strong>, and enable the <strong>Show this action when the workflow runs</strong> checkbox under Options to allow you to enter in a name when the Service will be invoked.</p>
<p>When dragging this action into the canvas,  you may come across a requestor asking if you want to add another action to copy the file instead. Since the file we want to move is already in a temporary location, and have no interest in keeping it in there, we should select <strong>Don&#8217;t Add</strong>.</p>
<p><img src="http://georgeharito.com/wp-content/uploads/2009/08/5_copy_files_requestor.png" alt="Copy Files Automator" title="Copy Files Automator" width="459" height="239" class="aligncenter size-full wp-image-42" /></p>
<p>Finally, you would want to move the resulting file out of the OS X temporary folder and into a location that&#8217;s accessible from the Finder. You will need to drag in the <strong>Move Finder Items</strong> action (available from the Files &#038; Folders menu in the Library), and turn on the <strong>Show this action when the workflow runs</strong> checkbox under Options.</p>
<p><a href="http://georgeharito.com/wp-content/uploads/2009/08/7_move_finder_items.png" rel="wp-prettyPhoto[g37]"><img src="http://georgeharito.com/wp-content/uploads/2009/08/7_move_finder_items-300x265.png" alt="Move Finder Items" title="Move Finder Items" width="300" height="265" class="aligncenter size-medium wp-image-44" /></a></p>
<p>You can test your workflow by selecting some files in Finder, and then hitting the <strong>Run</strong> button. You might get a requestor saying that the service cannot receive input while in Automator; just hit OK and continue the test. Once you are happy with the workflow, you can now save it as a Service. Hit the Save As function from the File menu, call it a name (I chose &#8220;Combine PDF documents&#8221;) and you&#8217;re done.</p>
<p>If you select a PDF or a group of PDF files and then right-clicking to invoke the context menu, you will find near the bottom of the menu your new service. It will also be available under the Services menu in the File menu. Note that the service is not exposed to the user if there is a file other than a PDF selected &#8212; this is directly controlled by the Services targetting as described above.</p>
<p>Congratulations, you&#8217;ve just created your own Snow Leopard Service!</p>
]]></content:encoded>
			<wfw:commentRss>http://georgeharito.com/2009/08/combining-pdf-docs-using-automator-and-services-in-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Pulling apart a Wallstreet G3 (and then putting it back together)</title>
		<link>http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/</link>
		<comments>http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 10:33:29 +0000</pubDate>
		<dc:creator>georgeharito</dc:creator>
				<category><![CDATA[Apple]]></category>

		<guid isPermaLink="false">http://georgeharito.com/?p=7</guid>
		<description><![CDATA[I had received an Apple PowerBook Wallstreet G3 some time ago that was looking a little sad. It had been an education machine, so it has had a bit of a rough life. Its external case has many scuffs and scratches, with some worn bits on the bottom where you can see the underlying metal, [...]]]></description>
			<content:encoded><![CDATA[<p>I had received an Apple PowerBook Wallstreet G3 some time ago that was looking a little sad. It had been an education machine, so it has had a bit of a rough life. Its external case has many scuffs and scratches, with some worn bits on the bottom where you can see the underlying metal, the PRAM battery was shot and the trackpad had been attacked with what I gathered was a sharp instrument of some sort, perhaps a drawing compass. Naturally, the laptop battery was dead and could only hold a couple of minutes&#8217; charge.</p>
<p><span id="more-7"></span></p>
<p>Over the following months, I had slowly collected the bits and pieces I needed to repair or replace the broken items and try to get the poor old Wallstreet as close as I can back to its original condition. I gave up looking for a great condition external case, as most if not all replaceable parts would be &#8220;reconditioned&#8221; or pulled from other second-hand laptops, which wouldn&#8217;t be in much better condition. I had however found another laptop battery (sold cheap &#8211; previous owner wasn&#8217;t sure of its condition, but it can hold at least 2 hours charge!), a replacement PRAM battery, replacement trackpad (both new), 256MB RAM (originally had only 32MB) and a CD-ROM drive that can be swapped out with the included floppy drive.</p>
<p>RAM is a cinch to upgrade &#8211; basically remove the keyboard and heat shields, and the RAM can be clicked into place without having to remove the CPU card at all. The PRAM battery needs access to the underside of the top cover / wrist rest, and since the trackpad which is also located here needed replacing, this worked out well as I could knock two birds with one stone.</p>
<p>I followed the disassembly steps from iFixit&#8217;s PowerBook G3 Wallstreet guide, which had told me while I was researching that I would need to remove the display to get further into the machine and replace the PRAM and trackpad. I found this daunting when reading about it at first, but when I got around to actually doing the transplants it was really easy. iFixit says that the difficulty level is &#8220;Difficult&#8221; but as long as you know what you&#8217;re doing and have some experience with computer disassembly and reassembly and know the basics about electronics and static electricity, it&#8217;s not very difficult at all. Reassembly / installation was, as they say in the Bentley Car Repair manuals, is the reverse of removal!</p>
<p>This was the first serious repair of a computer where I extensively used Blutack for the saving of screws and such. Can I say that this is an excellent idea (not wanting to gloat, but I did think of it myself &#8211; I&#8217;m sure I&#8217;m not the first to though), and with the different sized screws used in the Wallstreet, it was very handy as I didn&#8217;t need to write anything down or remember anything.</p>
<p>After the transplants, I put everything together but realised as I was installing back the keyboard that the CD cover / flap on the right side of the machine wasn&#8217;t aligned correctly &#8211; it had popped out between the upper and lower case. So I had to disassemble EVERYTHING again, pop it back in, and then reassemble everything again! Not to worry, it&#8217;s good to practice these things!</p>
<p>Anyway, here are the happy snaps I took. Once everything was put together, I pushed the power button and everything turned on and worked, flawlessly.</p>

<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_01/' title='Disassembly'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_01-150x150.jpg" class="attachment-thumbnail" alt="Keyboard removed" title="Disassembly" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_02/' title='Heat shield'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_02-150x150.jpg" class="attachment-thumbnail" alt="Used Blutack here to save the screws" title="Heat shield" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_03/' title='Heat shield removed'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_03-150x150.jpg" class="attachment-thumbnail" alt="At the back - PCMCIA slots, CPU card, hard drive. Nearer the front - Modem card, system ribbon cables" title="Heat shield removed" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_04/' title='Hard drive'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_04-150x150.jpg" class="attachment-thumbnail" alt="IBM 10GB IDE drive." title="Hard drive" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_05/' title='CPU Card'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_05-150x150.jpg" class="attachment-thumbnail" alt="233 MHz, spare Upper RAM slot (current system RAM on underside, next pic)" title="CPU Card" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_06/' title='Lower RAM slot'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_06-150x150.jpg" class="attachment-thumbnail" alt="Populated with the stock 32MB RAM." title="Lower RAM slot" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_07/' title='Display removed'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_07-150x150.jpg" class="attachment-thumbnail" alt="After disconnecting a few ribbon cables and removing a couple of screws, the display came off effortlessly." title="Display removed" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_08/' title='Headless Wallstreet'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_08-150x150.jpg" class="attachment-thumbnail" alt="Headless Wallstreet" title="Headless Wallstreet" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_09/' title='256MB RAM module'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_09-150x150.jpg" class="attachment-thumbnail" alt="For the upper RAM slot." title="256MB RAM module" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_10/' title='256MB RAM module from eBay.'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_10-150x150.jpg" class="attachment-thumbnail" alt="256MB RAM module from eBay." title="256MB RAM module from eBay." /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_11/' title='RAM installed.'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_11-150x150.jpg" class="attachment-thumbnail" alt="RAM installed." title="RAM installed." /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_12/' title='Bottom of lower case'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_12-150x150.jpg" class="attachment-thumbnail" alt="You can see all the scuffs and scratches. Worn patch around the latch area." title="Bottom of lower case" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_13/' title='Upper case removed.'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_13-150x150.jpg" class="attachment-thumbnail" alt="You can see the damage of the trackpad here." title="Upper case removed." /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_14/' title='Upper case underside'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_14-150x150.jpg" class="attachment-thumbnail" alt="Trackpad in the middle, PRAM battery in its holder." title="Upper case underside" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_15/' title='Inner lower case'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_15-150x150.jpg" class="attachment-thumbnail" alt="Wallstreet motherboards aren&#039;t that big." title="Inner lower case" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_16/' title='PRAM battery connector disconnected'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_16-150x150.jpg" class="attachment-thumbnail" alt="This was the fiddliest part of the whole process." title="PRAM battery connector disconnected" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_17/' title='New PRAM battery installed'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_17-150x150.jpg" class="attachment-thumbnail" alt="NewerTech battery installed. Make sure you thread the PRAM connection wire through the bracket first before slotting in the battery." title="New PRAM battery installed" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_18/' title='Old PRAM battery'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_18-150x150.jpg" class="attachment-thumbnail" alt="It&#039;s really just 6 tabbed cells, soldered together and wrapped in thin sticky paper." title="Old PRAM battery" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_19/' title='Trackpad underside'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_19-150x150.jpg" class="attachment-thumbnail" alt="Trackpad underside" title="Trackpad underside" /></a>
<a href='http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/wallstreet_20/' title='Old trackpad on the left, new on the right.'><img width="150" height="150" src="http://georgeharito.com/wp-content/uploads/2009/06/wallstreet_20-150x150.jpg" class="attachment-thumbnail" alt="Old trackpad on the left, new on the right." title="Old trackpad on the left, new on the right." /></a>

]]></content:encoded>
			<wfw:commentRss>http://georgeharito.com/2009/06/pulling-apart-a-wallstreet-g3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

