Tech Thought

Tech tips, hints, and general musings. PHP, Perl, Mysql, Javascript, AJAX, JSON, Linux, Mac OSX

Entries for July, 2008

How-To: Create a mysql friendly date with php

This is really simple - and quite useful if you are trying to insert a date into mysql and you can’t use the “now()” mysql command (due to say a timezone difference):
$date = date(”Y-m-d G:i:s”);

Leave a Comment

How-To: Redirect all requests to maintenance page with mod_rewrite

A common requirement when performing maintenance on your website is to redirect all requests to a downtime message. This can be very easily achieve using mod_rewrite and a .htaccess file. Simply create an .htaccess file with the following commands:

RewriteEngine On 

RewriteRule !^site-down\.html$ /site-down.html [L]

This will redirect all requests to the site-down.html file. Once [...]

Leave a Comment

How-To: Embed high-resolution YouTube videos on your site

We had a YouTube video of our product embedded on our website, however it was pretty low-resolution. I wanted to make it display in higher quality, however still making use of YouTube’s servers.
After a little sniffing around, I discovered that you simply add a little bit extra to the embed parameters and it embeds [...]

Comments (1)

How-To: Install Subversion (SVN) 1.5 on Mac OS X

We use CVSDude.org to host all our subversion repositories.  They have recently upgraded to subversion 1.5.0 which is not compatible with 1.4.x clients.  Unfortunately the command line utility that is built into Mac OS X is only at version 1.4.4 on my MacBook Pro - so I needed a way to upgrade to version 1.5.
I’ve [...]

Leave a Comment

How-To: Removing trailing whitespace from a string with php

Need to remove the trailing whitespace characters from a string in php? chomp() is how you do it in Perl, however in PHP it’s just as easy. Simply use rtrim():

// $string = “|my string with trailing whitespace |”
$string = rtrim($string);

// $string = “|my string with trailing whitespace|”

It’s that easy! There is [...]

Leave a Comment

How-To: Check a Reverse DNS Record Lookup (PTR Record) and Solve Email Delivery Issues

More and more mail servers are starting to reject email if your outgoing mail server doesn’t have a reverse DNS record or PTR record. You can check if you have one by issuing the following command:

dig -x 127.0.0.1

Obviously, replace the 127.0.0.1 address with the relevant IP address of your mail server. You should [...]

Leave a Comment

Speeding up prototype.js and scritaculous

We use prototype.js and scriptaculous for a number of our sites and applications - they provide great foundations with which to build advanced javascript applications. However they can be fairly large and take a while to download.
As I’ve previously mentioned on this blog, you can get pre-shrunk versions of both prototype and scriptaculous which [...]

Leave a Comment

How-To Fix: Firefox 3 - Image cannot be displayed, because it contains errors

A number of people have reported problems viewing some images in Firefox 3, where they get the error:
<image> cannot be displayed, because it contains errors
Amazingly enough, there is a very simple fix to this problem - disable the Skype Add-On for Firefox.  This can cause this problem to occur, so disabling it often fixes the [...]

Leave a Comment

Optus announces iPhone 3G Pricing Plans

Optus has just announced iPhone plans including pre-paid and post-paid plans for those who registered on their iPhone site.
To summarise these:

$79 a month gets you an iPhone for free
Include 800MB of data per month.
Unlimited data usage in the first month applies.
Prepaid the phone costs $729 for 8GB and $849 for 16GB phone

These are pretty good, [...]

Leave a Comment