Monthly Archives: July 2010

Quotes – Murphy’s Computers laws Part II

No matter how many resources you have, it is never enough.

Any cool program always requires more memory than you have.

When you finally buy enough memory, you will not have enough disk space.

Read more »

Quotes – Murphy’s Computers laws Part I

Any given program, when running, is obsolete.

Any given program costs more and takes longer each time it is run.

If a program is useful, it will have to be changed.

If a program is useless, it will have to be documented.

Read more »

PHP – Convert url to TinyURL

Sharing long urls by email or on social media sites is never a good idea, this is why most people are using urls shorteners such as biy.ly or Tinyurl.

This function takes a single parameter, an url, and will return a short url using the Tinyurl service.

function getTinyUrl($url)
{ return file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
}

Sample:

$my_url = getTinyUrl('http://www.whatever.you.want');
echo 'Short url: '.$my_url;

Sample usage within WordPress:

getTinyUrl(get_permalink($post->ID));