Making Campfire Work for Me (and More Like IRC)

One of the companies I work with has decided to use the 37signals line of products for internal project management and communication (which I think is great BTW). This means that I sit in a Campfire chat room for the working hours of my day, along with a handful of other developers. I started to run into a problem, though, when I didn’t need to be talking with others. It is difficult to tell when people are trying to talk to me. Campfire has, by default, two methods of notifying you of new messages: an unread messages counter (dock icon or browser tab), and optional sound ‘dings’. When I’m trying to work on something though that doesn’t involve chatting with others, all the while the chat room still active with other developers, it’s really distracting to hear constant ‘dings’ or have to repeatedly check new messages to see if they pertain to me.

The situation for me is similar to lurking on IRC channels. But IRC has been around much longer than Campfire, and IRC client developers are familiar with the problem. Thus, many IRC clients allow you to specify keywords, that, when present in other users messages trigger some form of notification, like a sound or Growl message. Well, this clearly is the feature I needed to solve my Campfire problem.

Greasemokey to the rescue! I stumbled across this userscript that allows you to set triggers for Growl notifications. Boy was that a welcome find. There were still some problems though. For one, I noticed that the chat window wouldn’t always detect that it had lost focus correctly, and as a result, I would miss some of my notices. Two, I wanted the same functionality for sound notifications. Three, it would be nice if at least some of it would work in Firefox, not just Fluid.

Thus, a new userscript was born: Campfire Notifications. As expected, it aims to solve the problems mentioned above. Growl notifications of course won’t work in Firefox. I’ve read, however, that Firefox 3 has added support for Growl. If I can get more information on that I may get it working in a future version.

On a related note, the guys at collectiveidea came up with an interesting way of writing Campfire plugins for things like post_commit VCS hooks. It’s called Tinder. Enjoy!

MySQL SELECT Entries Before NOW()

I’m in the business of making things faster. Using NOW() in a SQL query is something I’m going to complain about. Here’s a familiar scenario from the online publishing industry where future dating articles is a commonality:

You have a news site. You need to display only articles that have been published, and one of the criteria is that they need to have a publish_date before now. Easy, peasy, lemon squeezy.

SELECT author, title, body FROM articles WHERE publish_date <= NOW();

That works, right? Yeeeeah, it works, but it isn’t optimal. The problem is that MySQL can’t use the query cache on any query that has NOW() in it (or CURRENT_TIME() or any of these other functions for that matter). The solution I like to use is have PHP generate the timestamp. Even better is to have PHP round the timestamp, like so:

// Calculate time to nearest 15 minutes
$roundness = 60 * 15;
$rounded_now = (round(time() / $roundness) * $roundness);
$sql = "SELECT author, title, body FROM articles WHERE publish_date <= $rounded_now";

Of course, depending on how time sensitive your application is, you may need to change the code from rounding to 15 minutes to something like 5 minutes, or 1 minute. Hey, even rounding to 30 seconds would be better than using NOW() because you can use query cache!

SparkStats Widget Patch

Luc Betheder wrote a handy little widget for Sean McBride’s SparkStats plugin, which I recently started to use. I noticed, though, that whenever I made changes to my widgets the custom title I set for the Sparks plugin would get wiped out. So I fixed the problem in the plugin and thought I’d send the patch to Luc. Turns out, I can’t get in touch with him. You have to be registered on his blog to comment, but he has registrations turned off. Also, his email address was nowhere to be found. Hmm…slightly frustrating. I’m not giving up though, so here’s my patch (I’m also testing out the Google Syntax Highlighter):

--- sparks.php	2008-02-16 14:14:22.000000000 -0500
+++ sparks.php.mine	2008-02-16 14:14:58.000000000 -0500
@@ -63,13 +63,13 @@
 			// Clean up control form submission options
 			$newoptions['title'] = strip_tags(stripslashes($_POST['Sparks-title']));
 			$newoptions['text'] = strip_tags(stripslashes($_POST['Sparks-text']));
-		}

-		// If original widget options do not match control form
-		// submission options, update them.
-		if ( $options != $newoptions ) {
-			$options = $newoptions;
-			update_option('widget_Sparks', $options);
+			// If original widget options do not match control form
+			// submission options, update them.
+			if ( $options != $newoptions ) {
+				$options = $newoptions;
+				update_option('widget_Sparks', $options);
+			}
 		}

 		// Format options as valid HTML. Hey, why not.

Download the patch: SparkStats Widget Patch

FOWA & BarCamp Miami

Future of Web Apps (FOWA) Miami & BarCamp Miami are quickly approaching. I’m really looking forward to picking up tips on building better web apps, and meeting some smart people. I’m planning on giving a presentation at Barcamp, but I haven’t decided on what to talk about. I’m considering either “An Intro to Comet” or “Improving User Experience With JS Form Validation”, and I’m leaning more towards the former. Any suggestions?

I still have a lot to get done before the month’s end, including: launching the new and improved Statiksoft website, designing and printing affordable business cards, and, of course, writing my presentation. Add those things to the laundry list of other projects I’m trying to work on and it’s gonna be a busy month.

Also, BarCamp Orlando is slotted for early April, with two focused days! Kevin and I are gonna give a killer presentation on ExpressionEngine on the developer day. Be there.

Supporting the Community

The Orlando IT community has done a great job of promoting the upcoming BarCamp. The word is out, and over 170 people have registered for the event already. Like any community, though, to be successful some financial backing is needed. For this reason, we at both MindComet and Statiksoft have pledged our support and have signed on as sponsors. We’re excited to have BarCamp come to our home town, and we’re confident everyone’s going to take something useful away from it. You can too if you go, but you’ll have to register—space is limited. I look forward to seeing you there!

Next Page →