The fastest way to buy Ink Cartridges and Toner Online

December 13th, 2011 No comments »

I am very happy to announce the launch of  fastsupplies.com.au – the fast, easy way to order Ink Cartridges and Toner online in Australia! A huge selection of genuine and compatible ink and toner, an easy to use website, and our next day delivery policy means buying print supplies online got a whole lot easier.

Extending Prototype’s Template class to allow default values

September 14th, 2011 No comments »

I’ve often wanted to extend Prototype’s Template class to allow setting default values for template fields if the user doesn’t pass them, so I wrote a simple wrapper class that does just that.

» Read more: Extending Prototype’s Template class to allow default values

Fit text string to cell in FPDF

May 19th, 2011 1 comment »

Something I really hate (and am not very good at thoroughly testing) is ensuring that a layout I’ve designed will nicely fit user data of any length. Of course you can easily wrap all text outputting on a webpage or a dynamically generated PDF in a truncate() method, however this crude method isn’t always sufficient.

Today, I was auto generating a PDF certificate (using the PHP PDF generation library: FPDF) and needed the company name and URL to fit nicely on the page. I used FPDF’s handy function GetStringWidth() to acheive a nice little solution to ensuring the string fit on one line of the PDF.

...
	$my_string = 'This is my variable length string!';
	$font_size = 14;
	$decrement_step = 0.1;
	$line_width = 160; // Line width (approx) in mm
...
	$pdf->SetFont('Verdana', 'B', $font_size);
	while($pdf->GetStringWidth($my_string) > $line_width) {
		$pdf->SetFontSize($font_size -= $decrement_step);
	}
	$pdf->Cell($line_width, 10, $my_string, 0, 1, 'C');
...

Win an iPad2

March 24th, 2011 No comments »

Service Central (where I work) is the best way to find a tradie, and we’ve helped thousands of Australians to find certified businesses for all sorts of work. We’re about to get our quarter of a millionth job posted and to celebrate we’re holding a competition to win an iPad2! Simply guess the date and time the 250,000th job will be posted and win. Also, if you refer a friend and they win the grand prize, you get one too. Enter the Competition Here.

Nagios return code of 255 is out of bounds for disk check

February 11th, 2011 No comments »

When trying to setup disk checks in nagios for a new VPS, I came across the error “(Return code of 255 is out of bounds)”. Searching around a few forums I wasn’t able to figure out why Nagios was giving me this error…

As it turns out it was quite a simple problem! Having never actually used the Nagios user account to SSH into the server for which I was trying to check the disk, when running the command ssh user@host /usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p / the ssh client was asking

The authenticity of host '[host]:22 ([xxx.xxx.xxx.xxx]:22)' can't be established.
RSA key fingerprint is xx:xx:xx.
Are you sure you want to continue connecting (yes/no)?

so the ssh command wasn’t able to return the result from the Nagios Disk Check plugin.

So simply logging in as the nagios user and connecting to the remote server via SSH and adding the remote host to the known hosts my nagios plugin worked fine!

Triple J Hottest 100 2010 Song Previews

January 3rd, 2011 1 comment »

Here’s a list of all songs that you can vote for in Triple J’s Hottest 100 for 2010.

It shows a YouTube preview of each song to help choose your own top 10.

http://www.paulferrett.com/triple-j-hottest-100/2010/

Pad a number with leading zeros in PHP

August 19th, 2010 1 comment »

Just a quick one to share a couple of ways to pad a number with leading zeros… I’ve seen a lot of really poor examples of how to do this so I thought I’d share the two ways I might add leading zeros to a number in PHP.
» Read more: Pad a number with leading zeros in PHP

Automatic backup all SVN repositories

June 26th, 2010 1 comment »

Here’s a shell script I use to automatically backup all of my subversion (svn) repositories. » Read more: Automatic backup all SVN repositories

Hosting ga.js locally (google analytics tracking code)

June 22nd, 2010 3 comments »

Hosting ga.js locally has two main benefits – fewer DNS lookups for the client’s browser (you could even combine it with your site’s java script to reduce HTTP reqs as well), and you might be able to get it to your users faster than Google can. Whilst the second point isn’t likely true for many, it is true for those of us serving most of our content in Australia.

Google recommends you don’t do this, but doesn’t say you can’t.
» Read more: Hosting ga.js locally (google analytics tracking code)

Compare Transport Routes with Transportle!

May 21st, 2010 No comments »

Transportle is a website myself and two friends made for the Victorian Government’s App My State competition.

It allows you to compare different transport routes in terms of not only time and money, but exercise value and environmental impact.

Check out out and let me know what you think! feedback@transportle.com