dmuth's blog

jQuery in Firebug: How and why?

There are a number of folks out there who use the Firebug extension for FireFox so they can debug webpages. Firebug also includes a Javascript console so you can execute arbitrary Javascript code against the current page.

If you're a fan of the jQuery library, there's a way you can use that in Firebug (first documented here):

var j = document.createElement("script");
j.onload = jsCallback;
j.src = "";

See the line j.onload = jsCallback;? That fires a function called "jsCallback()" after jQuery is successfully loaded.

"Why a fancy callback?"

As I learned the hard way, if I were to just put Javascript code following the jQuery code, it might get executed before jQuery is successfully loaded, leading to errors. While I could just re-run the code (as jQuery would already be loaded), I was looking for a better solution to the problem, and this is what I came up with.

"So what can I do this callback?"

I'm glad you asked. One way using jQuery in Firebug comes in quite handy is if you want to dissect another web page. For example, let's say you want to run a Google search, and extract the URLs in the search results. Here's how to do it:

* This is executed after jQuery is successfully loaded.
function jsCallback() {
    var e = jQuery("a.l");

    var output = "";
    e.each(function() {
        output += jQuery(this).attr("href") + "\n";



var j = document.createElement("script");
j.onload = jsCallback;
j.src = "";

"I could write $.get() calls to load Google's search results!"

Good luck with that. FireFox won't let you do that due to the same-origin policy.

"Well, how about if I get Google's search results in JSONP format?"

Um, good luck with that, too. You won't get very far without an HTTP referrer header, I'm afraid.

"So if I want to do this on an ad-hoc basis, I have to dissect the Google search results page?"

Yep, exactly.

Got any other tricks you find really useful to do with jQuery in Firebug? Let me know in the comments! 

Average: 2.3 (7 votes)
Your rating: None

Dial 1-800-GET-ZERG!

He just wants hugs.

We, the Zerg Swarm, believe that our special process, known as "infestation", can improve your life in numerous ways! Being a part of a group like the Zerg Swarm means that you're never lonely, and there will always be someone there for you. Your body will become more powerful than you have ever dreamed before; with our patented improvement system, you will be able to lift more, run faster, and eat nearly anything! Many sentient life-forms consider the Zerg look to be attractive:

"Wow, that's gorgeous", says Tserisa, a dragon who later opted for infestation. "Kinda handsome", says a clockwork gryphon.

Usually, when a being opts for "infestation", it is a permanent process. But we are prepared to offer, for a short time only, a free 30-day trial infestation! We will send a personal representative to guide you through the metamorphosis, and in adjusting to your new abilities. If at any time you are unsatisfied with the trial, the representative will either correct it or reverse the change.

Average: 5 (5 votes)
Your rating: None

Awesome Memorial Day weekend

I had a pretty awesome Memorial Day weekend last weekend. I went up to my parents' place for the first time since Christmas. They're fine, the cat is stupid fine, and the rest of my family is fine.

I've been wearing my knee braces whenever I walk around, just like my doctor told me to, and they've gotten much much better. I have an MRI scheduled for this coming Wednesday, so we can see what precisely is going on inside the knee. Still, I can walk for considerable distances and feel well enough to do my normal thing at Anthrocon at this point.

(PROTIP: Want to get the smell out of neoprene knee braces? Soak in 1 cup vinegar and 1 cup hot water for an hour. That kills the fungus.)

Speaking of Anthrocon, I spent yesterday working with registration laptops, giving funny looks to MSIE 8, and testing all of our badge printers. Everything still works, and I feel more confident about onsite registration this year (not that last year didn't go fine) because my code has remained largely unchanged since last year, and I made more documentation for troubleshooting purposes, should anything go wrong.

While visiting my parents, I took a trip to the old neighborhood where I grew up, walked around, and took many pictures. Once again, the UV filter on my camera did its job.

Shepherd Hills Golf Course

Driver Place Greens Drive Greens Drive

And here's the whole set, browseable in Flash:


Average: 3 (2 votes)
Your rating: None

What happened to

Nothing in particular, but seeing that I have worked in the software industry for about 11 years now, I figured it was time to get a more professional sounding domain name. It was getting increasingly more difficult to tell co-workers and colleagues that my website was at and keep a straight face. A domain name of sounds more professional, and doesn't tie the site to any one topic. (Unlike, which has a furry slant)

I'm still keeping the furry stuff, convention photos, etc. here. In fact, going to any URL on will cause the browser to be redirected to the exact same page on this site. For those of you who still have email addresses (yeah, both of you Sticking out tongue ), that won't change any time in the near future either.

Average: 2.8 (9 votes)
Your rating: None

Portal and Steam for the Mac

Folks might have heard that Steam is finally available for the Mac and that, for a limited time, Portal is available as a free download. Naturally, I made the most of it, and downloaded Portal on Friday evening, beating it just last night. Smiling

Downloading Portal was interesting, I had no idea that the game was on the order of 3 Gigs in size. It was a great way to test out my current Internet connection, which performed pretty well, as this graph shows:

Portal Network Usage

As for playing the game itself, someone asked me how Steam and Portal were on the Mac, out of concern that there might just be some emulation going on. This does not seem to be the case, judging by my CPU usage (gameplay began right after the download):

Portal CPU Usage on my Mac Mini

I'd say that my Mac Mini held its own just fine. Smiling

I'll probably be on Steam on occasion. If anyone wants to friend me there, feel free. My Steam ID is DmuthAtHome.

Average: 3.3 (4 votes)
Your rating: None

Some updates to the PA-Furry website

There has been some increased activity on Pennsylvania Furries website recently, so I decided it justified finally biting the bullet and upgrading the site from Drupal 4.7 to Drupal 6.16. That upgrade was fun and... interesting. But now that I have a much more recent version of Drupal installed, I've been able to add some features such as these:

- Event Calendar. Want to know when upcoming furmeets, gathers, etc. are? We now have a calendar that anyone may post events to.

- Buddy lists. Yes, they are what you think they are. Users can now have an actual "friends" list on this site. Go to any user's page and click the link towards the bottom to become their buddy. (Here's an example)

- Private messages. Just what the name implies. Users on the site can now send each other private messages. When you're logged into the site, just click the "Messages" link to get started.

- Searching. I reindexed the entire site (and set up crontabs to keep that happening) so now the search engine works again, and posts (and users) on this site are fully searchable.

- Tagging posts. All posts can now be tagged. Even posts made by others. Go ahead. Give it a try. There is also a tag cloud that lists the most popular tags on the site.

- User profiles that don't suck. All user profiles now have links to a number of social networks, along with support for forum signatures, private messaging, and buddy lists.

And the URL for the Pennsylvania Furries website?

Check it out, and let me know what you all think!

Average: 2.8 (4 votes)
Your rating: None

Anthrocon 2010 Commercial

So the user Jalterixnar on the Anthrocon forums was nice enough to create a commercial for Anthrocon 2010 and post it on YouTube:

That is amazingly cool, and the tool used to create it was at I've been playing with it on my own, and it's quite neat, as it allows different kinds of searches to be performed, as well as choosing different music.

I'm unclear whether this was just a "toy" that Google created, or whether they plan on using it to revolutionize the advertising industry, but it certainly is a great step in that direction.

Average: 3.3 (3 votes)
Your rating: None

Scheduling crontabs in Drupal

One of the neat things about the Drupal CMS is that it has a facility to schedule certain things to be run at regular intervals. For example: sending out subscription notifications or indexing posts for the search function. Those operations can take tens of seconds to complete, so you obviously don't want them executing in the middle of a page load.

The normal way to execute Drupal's crontabs is to load the script cron.php via the web interface. This is a terrible idea, since anyone with an Internet connection could cause your machine to run CPU intensive tasks at well, and bring the webserver to its knees.

An alternative way to run crontabs is with a third-party module called Poormanscron. It's a nice module, but the locking facility it has isn't so hot, and on more than one occasion I've had two cron runs execute in parallel, causing extra load on the machine. In especially bad (read: I/O bound) situations, multiple crontabs get "backed up" onto each other, and that creates huge load spikes and 60-second+ page loads until things calm down again.

There is yet a third way to run Drupal crontabs, and that's via the command line. It gives you maximum control over when and where crontabs run, and this is particularly important when you have multiple Drupal sites running. And I'm going to show you how to do it.

Step 1) Download Drush, the Drupal shell. It's a great little app for accessing your Drupal installation and performing common tasks from the command line. Install Drush (I usually put it in /usr/local/drush/, and make a symlink from /usr/local/bin/drush)

Step 2) Create a script in your home directory, and call it It should look something like this:

# Our main directory for holding websites

export DRUSH_OPTIONS="-q"
#export DRUSH_OPTIONS="-v" # Debugging

# Errors are fatal
set -e

cd $ROOT

# All of our drupal installations under $ROOT

# Loop through our sites to run crontabs on
for SITE in $SITES
   cd $SITE
   # Disable errors, since sometimes crontabs have issues.
   set +e
   drush $DRUSH_OPTIONS cron
   set -e
   cd ..

Be sure to season the $ROOT and $SITES variables to taste as per your specific installation.

If you run a chmod 755 on this script, you can execute it from the command line. However, you may run into file permission issues if the webserver is running as a different user than you (usually the case).

Step 3) Now you need to set up a crontab to run this script. My preferred way to do it is to create a file called /etc/cron.d/drupal-crontabs and place the following in it:

# Run all of our crontabs for Drupal once an hour

15 * * * *     www-data /path/to/

Make sure you are running these crontabs under the same user as your webserver.

That's it! If you want to see emailed notifications once an hour, just uncomment the line with the "-v" option for Drush. Otherwise, crontabs on all your sites will be run once an hour. Provided they do not take longer than hour to run, all of your search indexes and subscriptions will be kept up to date, and you will no longer have to worry about crontabs stomping over top of each other with Poormanscron. Enjoy!

Average: 1.8 (5 votes)
Your rating: None

The Cherry Blossom Festival

Last weekend I headed down to Washington, D.C. to visit November and see the Cherry Blossom Festival.

I don't have much else to say about the festival, because it was a bunch of cherry trees, really. Sticking out tongue We walked around for a bit and I took a ton of pictures:

Cherry Blossom Trees The Lincoln Memorial The Washington Monument

Cherry Blossom Trees Cherry Blossom Trees Cherry Blossom Trees

And here's the full slideshow:

Average: 2.6 (5 votes)
Your rating: None

Using Drupal's Advanced Forum and Author Pane modules on blog posts

Earlier today, I performed a major Drupal upgrade on another site that I run. Part of the upgrade involved me installing the Advanced Forum module to bring the forums a little more up to date with other sites that are out there.

Along the way, I learned something interesting: the Author Pane module does NOT display on blog posts.

It looked rather odd when comments on the blog posts had detailed user info, but the post itself did not. So I set out to fix that. I ended up commenting out the line print $picture; in node.tpl.php and instead adding in these lines:

$account = user_load($node->uid);
$template = "advf-author-pane";
$author_pane = theme('author_pane', $account, 
        advanced_forum_path_to_images(), $template);
print $author_pane;

The code is fairly straightforward. It loads user info on the author of the post, and the theme() function loads the author_pane template, passing in the user data.


Average: 2.5 (6 votes)
Your rating: None