Retrieve The Latest Twitter Trends

Here’s a simple and short tutorial on how to retrieve Twitter trends. We will be using PHP and Twitter’s API to retrieve the latest trends. You can publish the trends on your website, blog or any application you are working on. So, let’s get started.

Twitter has made trends available to anyone via API calls. The url of the API is: Trends is also available in XML, but we will use JSON in this example.

To retrieve the string of data, we will use a PHP command called file_get_contents. We will suppress errors by placing an @ sign in front of file_get_contents. We will assign the string to a variable called $contents. So this is what we have so far.

$contents = @file_get_contents("");

Next, we will check if we have the correct response from the http_header. We will check for the code “200”, meaning we have a valid response. We will use the PHP command called strpos to find the needle in the haystack. The needle in this case is “200.” We will look for it starting at position “0.” The format is going to be like this.

$contents = @file_get_contents("");
if (strpos($http_response_header[0], "200")) {
  echo "ok";
} else {
  echo "fail"

Ok, so we now have a JSON string assigned to the variable named $contents. We just need to decode it using the PHP command called “json_decode” and assign it to the $json array variable. Next, we will run a foreach contruct to echo each trend name.

$contents = @file_get_contents("");
if (strpos($http_response_header[0], "200")) {
  $json = json_decode($contents);
  foreach ($json->trends as $trend) {
        echo $trend->name;
} else {

So, there you have it. We now have the latest Twitter trends using PHP and Twitter’s API.

It’s Official No More Gimp in Ubuntu

The latest decision by the Ubuntu development team to exclude Gimp in future releases of Ubuntu was a bit of a head scratcher. I wondered why Gimp had to be taken out of future releases of Ubuntu.

Gimp is a powerful program for editing graphics that we all love. It offers everyone an alternative tool to Adobe’s Photoshop. It’s rich in features and capabilities. Although it not quite up to par with Photoshop, it certainly can hold its own.

Ubuntu developers explained the reasoning behind the removal. They said Gimp was too complicated, too intimidating to casual users. Too complicated? And Linux is not? Gimp developers seem to agree about leaving it out.

So, with no Gimp in Ubuntu’s future, users are encouraged to use F-Spot, a mono application I might add. And that may not even stick. Developers are already talking about replacing F-Spot with Shotwell or Gthumb.

The good news is it’s easy to install Gimp. It will probably be the first application I will install after installing Ubuntu. That’s if I’m still using Ubuntu.

Increase PHP File Upload Limit

If you have installed a LAMP server either on your Linux desktop or server, you are bound to run into this problem. The default PHP installation placed a 2MB limit on file uploads. I ran into this problem when I tried to import a XML file that was bigger than 2MB into a WordPress install. So, to increase the upload limit, I edited the PHP configuration file called PHP.INI.

In Ubuntu, the default location for PHP.INI is in the /etc/php5/apache2 directory. So, let’s open up the Terminal and edit the PHP.INI file:

$ sudo vi /etc/php5/apache2/php.ini

Look for this entry in the file.

upload_max_filesize = 2M

Increase the limit to 10MB or to any value you prefer.

upload_max_filesize = 10M

Save file and exit.

Next, you will need to restart the Apache server for your changes to take effect. From the Terminal type this command to restart your Apache web server:

$ sudo /etc/init.d/apache2 restart

That’s it. Have fun uploading large files!

Black Friday 2009 Sales

Are you looking for a great deal on Black Friday? Well, you’ve come to the right place. About two and a half years ago, I made a post about Frys Electronics running their own ads in the San Jose Mercury News. I just checked the link. The good news is the link still works. By the way, Frys publishes new ads everyday. So, I recommend that you check this link again on Thanksgiving Day.

In addition, I found a couple of websites that publishes Black Friday sales: check out this one and this one. Good luck with your hunt this Friday. I hope you find what you are looking for!

Upgrade Your Theme To Support WordPress 2.9

WordPress 2.9 is just around the corner. It will be here before we know it. There are a number of new features in WordPress 2.9. The inclusion of “post thumbnails” is first and foremost. It allow bloggers to upload thumbnail images associated with their posts. Theme designers and users have several choices as to what thumbnail image size to display, whether the default thumbnail size, medium, large or full, the original size uploaded.

Another feature that has made it to WordPress 2.9 is the addition of the trash feature for posts, pages and comments. It’s similar to the trash can feature found in Windows and Linux operating systems. It allow bloggers to recover posts, pages and comments that were previously deleted.

Also included with WordPress 2.9 is the addition of the basic image editing features in the Media Library. Users will be able to rotate, crop, flip and scale an image. This particular post focuses on what you need to do to get your theme supported in WordPress 2.9. I will show you how to make changes in your current theme to support the thumbnail images.

To activate thumbnail support, you need to add this line of code to functions.php.


Next, you need to edit your index.php and single.php pages or any page where you want the thumbnail images to be displayed. Add this line of code.

<?php the_post_thumbnail( 'post-thumbnail' ); ?>

For medium size:

<?php the_post_thumbnail( 'medium'); ?>

For large size:

<?php the_post_thumbnail( 'large'); ?>

For full image:

<?php the_post_thumbnail( 'full'); ?>

That’s it. Get a head start. Make your theme changes now.

Move a Gnome Window with the Alt Key

Remember the days when you were running Windows, when a window would go off the screen. You lost control of it. You can’t move it. You can’t minimize or maximize it. All because the title bar is off the screen. Well, this happened to me today in Gnome. In Gnome! Can you believe it! Well, it’s a simple fix really.

Just hold down the Alt key and use the mouse to grab/move any part of the window!

Install Google Chrome on Ubuntu 9.10

This post was written when Chrome was still not available for Linux. Chromium was the only option then. Now that Google Chrome is available, just go to Google’s website and download the browser directly.

Tired of Firefox? Do you want something a little bit more faster, maybe more stable? I seem to have issues with Firefox running on Ubuntu 9.10. I’m not sure what’s going on, but it has crashed several times. This article shows you how to install Google Chrome on Ubuntu 9.10.

Add to your sources list.

$ sudo gedit /etc/apt/sources.list
deb karmic main
deb-src karmic main

You may substitute jaunty, intrepid, hoary for other distributions.

Add the GPG keys.

sudo apt-key adv --recv-keys --keyserver

Run an update.

sudo apt-get update

Finally, install Google Chrome.

sudo apt-get install chromium-browser