Go Tutorials & Tips

How to install the Go programming language on your server or VPS?

Assuming you’ve logged in as root in Debian 5.0, to install the Go programming language by Google,

  1. Add these environmental variables for Go in .bash_profile:
    export GOROOT=$HOME/go
    export GOARCH=386  # for 32 bit architectures. Use GOARCH=amd64 for 64 bit architectures
    export GOOS=linux
    export GOBIN=$HOME/bin
  2. Install the Mercurial ‘hg’ command:
    aptitude install mercurial
  3. Fetch the sources of Go and put them at $GOROOT:
    hg clone -r release $GOROOT
  4. Fetch compilers and related utilities:
    aptitude install bison gcc libc6-dev ed make
  5. Create the directory $HOME/bin by:
    mkdir $HOME/bin

    and compile Go:

    cd $GOROOT/src
    make all

Done. You can now go about writing your first hello world program. If you haven’t got a server yet, I recommend Linode VPS and Rackspace Cloud.

Coupons and Promo Codes Hosting Tips & Deals

Rackspace Referral Discount

By Rackspace I mean the managed dedicated hosting service, not the cloud hosting. I’ve been talking a lot lately about Rackspace Cloud so I thought I’d make it clear. 😉

Check them out, they are pretty much the most expensive host you can find on the web. Their most basic server costs over $400 a month with 2TB monthly bandwidth. It’s by all means not a generous offer but it’s probably the most reliable and responsive platform you will ever need to know. They have the best uptime across the entire industry. A profitable online business deserves an uptime of 100%, because every minute of down time costs you money – no matter how solid and perfect your website is, it’s nothing when it’s down.

Rackspace provides the best support to its clients. They are not just a hosting provider, they are the all-around IT company who you can trust your entire IT infrastructure with. They take over everything from creating to optimizing, and monitoring to troubleshooting. When something goes wrong, chances are they have actively found and fixed it even before you know it. Many of the top players use Rackspace for their hosting needs. WHT, the Internet’s No.1 web hosting forum, has been with them for years. In a word, Rackspace is the kind of hosting you need when every second of your business counts.

5% Referral Discount for You

Anyway, as I’m a partner of Rackspace, I can earn or give 5% discount off any of their managed dedicated server packages. Shoot me a message about your intention to host with them, so I can get you the 5% discount and ask them to contact you. I’m currently not relying on this to make a living so, it’s better to pass along the favor than letting my partnership with them sitting in dust.

As per FTC requirement, I’m not making any money off this at all. 😉

Cloud Hosting

If you find their dedicated service a little more privileged than you can afford, their cloud hosting may be a better deal. Use this promo code for Rackspace Cloud to get a discount off their cloud hosting plans.

PHP Tips & Tutorials Regular Expression Tips & Tutorials

PHP: Subject String Length Limit of Regular Expression Matching Functions

Here’s a quick tip for those who have encountered this very same problem that all regular expression functions of PHP such as preg_match() and preg_replace() stop working when the input string (subject string to be searched or matched) is too long or large. If you believe your regular expressions should work but didn’t and the string to be searched is perhaps over 100kB in length, you have hit the match string length limit or PCRE’s backtracking limit set by configuration variable pcre.backtrack_limit.

To solve this issue and lift the length limit, to perhaps 10 times the original, you have to reset the default value of pcre.backtrack_limit in one of the following ways:

  1. If you are using cPanel, create a text file named php.ini and put it in the directory wherein you need to break the limit. Append this line in the file:
    pcre.backtrack_limit = 1000000
  2. If you operate your own dedicated / vps server, modify php.ini and put this line at the end of the file:
    pcre.backtrack_limit = 1000000
    Refer to this article to find out where your php.ini is.
  3. Use runtime configuration function ini_set() to set it at runtime:
    ini_set('pcre.backtrack_limit', 1000000)

This seems to be only affecting PHP 5.2.

Free PHP Classes & Library PHP Tips & Tutorials

A Simple PHP Contact Form Script

Update: Other than using the code outlined on this page, you may also want to download the Kavoir Contact Form script to be readily usable on your website.

It’s also a free one and a rather easy one too. You should be able to do it yourself. To create a working contact form, you need the front end and the back end. The front end presents the contact form to the website user and the back end accepts the data sent from the form by the user and take any necessary actions such as relaying the message to your email.

Visit for hosted free contact form solution.

Front end (HTML)

Simply copy this HTML form and paste it into your web pages where you want it to be, such as on the sidebar so a visitor can send you a contact message on any page.

<form action="/cf.php" method="post">
	<p><label for="input-email">Your Email: </label><br/><input type="text" name="email" id="input-email" size="40"/></p>
	<p><label for="input-message">Your Message: </label><br/><textarea type="text" name="message" id="input-message" rows="10" cols="40"></textarea></p>
	<p><button type="submit" name="submit">Send</button></p>

You may also want to style this form a little bit to make it look fancier. But make sure you don’t change any of the properties inside the tags such as action=”…” and name=”…”.

Back end (PHP)

Copy and paste these PHP code into a file named cf.php, change [email protected] to your own email address that you wish to receive the messages. Put the file at the root directory of your domain so that everyone can access it at


if (isset($_GET['success'])) {

	?><p><span style="color:green;">Message successfully sent.</span> Thank you!</p><?php

} else {

	if (!empty($_POST['email']) && !empty($_POST['message'])) {

		$to = '[email protected]'; // your email address, can be, etc.
		$subject = 'Contact from'; // change to your own domain name
		$message = $_POST['message']."\r\n\r\nSender IP: ".$_SERVER["REMOTE_ADDR"];
		$headers = 'From: '.$_POST['email']."\r\n".
					'Reply-To: '.$_POST['email']."\r\n";
		mail($to, $subject, $message, $headers);

		header("Location: /cf.php?success"); // redirects the sender to success page so he or she doesn't accidentally send multiple identical messages

	} else {

		?><p><span style="color:red;">Error detected.</span> Please make sure you have filled all fields. Press back button to go back.</p><?php




Should be functioning properly. Thus far this contact form script has been successfully tested on Rackspace Cloud, DreamHost and Linode.

There are a lot more that can be done to create a sophisticated contact form. For starters, you can implement a spam catcher and a file upload control that sends the user uploaded file as attachment to your email. You could also have on-page error detection but that’d need a lot more coding.