Matt's Blog

Archive for the ‘Sites’ Category

Twitter Bot: Magic 8 Ball

Tuesday, April 22nd, 2008

On the Weekend, Gary Jones from BlueFur (Twitter: bluefur) came up with the idea of a Twitter robot that would act as a Magic 8 Ball. He asked me if I wanted to help make it, I accepted, and development began.

What we came up with was a small script that would automatically reply with a Magic 8 Ball-type answer when it was “replied” to. To use it, all you have to do is write a “tweet” replying to magic_8ball with a yes or no question. Which would look like this “@magic_8ball <yes or no question>”.

This little “Twitter Bot” uses the Twitter API to receive the replies to it, and then send out replies with a randomly selected answer. We quickly found out that the Twitter API is quite restrictive. As outlined in Gary’s post, Twitter only allows 70 authenticated API requests an hour, which not only inconveniences developers while testing their Apps, but also users using Twitter Apps. Also, Twitter restricts API calls for replies and such to the latest 20, which can create quite a few problems.

We’ve decided to make this application Open Source, so that other developers looking to develop with the Twitter API can hopefully learn from our code. Feel feel to use, modify, hack and learn from this code to create your own Twitter Applications. The code is release under the GNU General Public License version 3 (or, at your option, any later version). You can get the code here (or in txt format here).

If you have any questions about the code, feel free to let me know.

I’m on Twitter under mattfreedman, feel free to follow me.

Speed Up Your Blog Using ZLIB

Monday, April 7th, 2008

With the release of WordPress 2.5, there is no longer an option to enable GZIP compression. This option was axed for the reason that it’s better to enable compression on the server, rather than through WordPress. GZIP is basically a compression “tool” that compresses files before sending them to the browser, if the browser states that it can handle GZIP compression. All modern browsers support GZIP compression, and send the appropriate header to the server to tell it that it can handle compression.

However, there is another compression library that is generally preferred over GZIP, called ZLIB. It’s essentially the same as GZIP, and is initiated by the same gzip header that browsers send.

We’ll be using ZLIB to speed up your blog. We’re using ZLIB because using GZIP causing TinyMCE (in WordPress) to be double compressed, and to stop working properly, using ZLIB works around the issue. Also, since ZLIB is preferred, we might as well use it.

Before enabling ZLIB compression, you’ll want to check with your host to ensure that PHP has been compiled with ZLIB support. I can confirm that BlueFur has it enabled on most (if not all) of their servers.

Now that you’ve made sure that your host can support ZLIB compression, let’s actually enable it. First of all, open your blog’s root .htaccess file. Then, you’ll want to add the following line to the file, above the WordPress code (# BEGIN WordPress):

php_flag zlib.output_compression On

Save the file, and reupload it. You should now notice improved speed in the execution time of your blog. On my blog, page execution has, on average, been reduced by 50%. However, your results may vary.

It’s important to note that, if you’re currently using any other compression or caching systems, you cannot use this in conjunction with them; you’ll have to choose between them or ZLIB compression.

This compression method will also work on any fairly dynamic site, it’s not limited to blogs.

New Gmail Feature, Colourised Labels

Monday, December 3rd, 2007

GmailIt looks like Gmail has another new feature. I just logged into my Gmail account (after having to force-close my browser, after it stopped responding), and I noticed something different about the Labels panel in the sidebar. On the right side of the panel, were these little rounded-corner squares on each line of a Label.

Label Panel

Upon hovering over the little square, it changes to a green, downward-facing arrow.

Square Hover

When you click on the little square, a little box appears beside the square you click on, showing 24 little boxes that contains a different colour and a letter “a” with a similar colour. Under those little squares, is 2 links, “Remove color” and “Edit name”.

Colour Picker

So, what does all this mean? Well, you can know colourise your labels! Once you choose a colour, the little square beside the label name becomes that colour, and when viewing a email that’s labeled, the label name beside the subject will have the background colour of that label’s colour. Also, when in your Inbox, the label name in front of the subject will also be colourised.

Colourised Label

Colourised Label Beside Email Subject

Inbox Colourised Label

On the Labels page under Settings, the labels are not represented by their colour.

Gmail has called this new feature “colored labels”, and has added it to the what’s new page.

I think Colourised (or Coloured, w/e) Labels is an excellent idea. It’ll help you determine what Label an email is under quicker, because you can just memorise the association of labels and their colour, instead of actually reading the label name. Seems like a pretty sweet feature to me!

Gmail Now Has 5 GigaBytes of Storage

Saturday, November 17th, 2007

GmailSometime yesterday or today, Gmail passed the 5 GigaBytes of storage mark. My original estimation was wrong, because Gmail slowed the counter back down, therefore invalidating my calculations. This means that Gmail now, once again, offers more storage than Windows Live Hotmail down. As of writing, Gmail has 5020 MBs of storage. It looks like the counter may have been sped up a bit again, too. Sweet!

Heh, I remember back in 2004 when I was using Hotmail and had 2 MBs of storage. But, now I have the awesome Gmail, and my more than 5 GBs of storage! :)

Track Searches With Google Analytics

Saturday, November 3rd, 2007

Google AnalyticsGoogle has rolled out a new feature in Google Analytics. You are now able to track searches that have been made on your site. This means that if your site, blog or forums has built-in search, you’ll be able to get some statistics for it.

I think that this new feature will be quite helpful to many people. You’ll be able to see what people are search for and possibly adjust things accordingly. You’ll also be able to see any refined searches by the same visitor, which will help you in seeing how effective your site, blog or forums search is.

How the tracking works is that you tell Google Analytics what URL parameter your search uses, and it’ll start to track all the searches on your site. If you already have Analytics tracking your site, no additional code is required. Just a note, Site Search tracking is not enabled by default. Also, it’s currently only available for English Analytics accounts, but Google says that it should be more widely available soon.

Here’s how you enable it, and configure it to work with WordPress.

  1. Login to Google Analytics
  2. Under “Website Profiles“, find the site you want to enable Site Search tracking on, and click the “Edit” link corresponding to it
  3. On the Profile Settings page, click the edit link for “Main Website Profile Information
  4. Find the section called “Site Search
  5. Click the radio button “Do Track Site Search
  6. In the input box that pops up, enter in “s
  7. Decide whether or not you want Analytics to strip out the parameter stuff when displaying it to you. I chose for it to not to.
  8. Leave the question “Do you use categories for site search?” as no
  9. Click Save Changes

There you have it. Google Analytics will start tracking any searches made on your site right away. This is assuming that WordPress is still using the default format of “?s=search+term” for searching. If someone searches in a specific category in your site, it should show up in Google Analytics as “/category/cat-name/?s=search+term” (assuming that’s have your permalinks are setup).

To see your Site Search reports, go to the Reports of the site you enabled this on, click on “Content” in the sidebar, then click on “Site Search” under the Content menu.

Enjoy your Site Tracking (oh, and try not to become mesmerised in the reports 😛 )!