A Javascript debugging tip for Firebug (or “Stop using alert()!”)

Did you know that if you’ve got Firebug for Firefox installed, you can use it for debugging your own code? By calling

console.log("Here's a message!");

Firebug will print the message to it’s internal message log. Neat!

Firebug message console

Now, that’s all good. But let’s say you’re on a project that’s not using a Javascript preprocessor to minify and strip debugging code — which would be the best option. You want the benefits of debugging, but not having to constantly remove debugging code for deployment. If a user doesn’t have Firebug installed, they won’t have a console object. So obviously leaving your debug code in is going to cause an error.

Or will it?

Try adding this code before any of your other Javascript. It will set up a fake console so that if Firebug is not installed, there won’t be any errors.

if(!console || !console.log) {
var console = new Array();
console.log = function () {}
}

Bonus idea! If you combine the idea shown here, with my previous post about debugging Firefox extensions, you can see how to prevent extension debugging from getting in the way of your users.

if(!Firebug || !Firebug.Console || !Firebug.Console.log) {
var Firebug = new Array();
Firebug.Console = new Array();
Firebug.Console.log = function () {}
}

A message for rich people: “Spend your money!”

Buy American wine. Drink it on your American yacht. Read Forbes for instructions on how to spend your money. Eat American caviar. Stuff hundreds into tip jars when you go get coffee. Read the “Most Expensive” blog for ideas on how to support the economy. We’ve got to keep our economy going, and since you richies have over 70% of the wealth in this country, it’s time to pitch in. You people are always going on about how great firefighters were in NY on 9/11, here’s your chance to be a hero, and it’s easier than running into a burning building.

In case you’re wondering what the hell I’m going on about, I just finished reading The Great Crash. It’s an excellent book. One of the things mentioned is the unequal distribution of wealth in the 1920s. When the economy started going south, rich people stopped spending money on trivial shit. Unfortunately, “rich people spending money on trivial shit” was a portion of the economy.

Once again, we’ve got an unequal distribution of wealth. And an economic crisis. Although there are differences, ultimately, we need to get money moving through the economy.

So, if you’re feeling stressed about your 401K, perhaps you’d like a massage. Don’t forget to tip your masseuse, so they can go out to dinner and support another set of workers, who will in turn consume more goods and services. Aren’t spending multipliers awesome?

How to use Extension Developer’s Extension in Firefox 3

Here’s a tip for developing Firefox Extensions in FF3.

You might have heard of the Extension Developer’s Extension (EDE). EDE is an extension that provides useful settings and features for people who are writing their own extensions. For example, EDE makes it easy to activate Javascript debug settings, interactively debug Javascript, and a few other goodies.

My personal favorite feature is the “Extension Builder” — it that lets you install a development copy of the extension . That is, you can run an extension from your working copy/dev folder. Without EDE, you’d have to — uninstall an extension, restart Firefox, install, restart — every time you wanted to test a change. With it, you can just restart Firefox one time, and your dev extension is reloaded. When doing heavy development, I have personally saved over an hour per day from this one feature.

The sad part is that this feature does not work in FF3. The option is just grayed out. But, there’s a workaround. Load up FF2 with the same profile that you use for FF3. Use EDE to install the extension from disk like you normally would. Then, quit FF2, and launch FF3. Since the extension is tied to your profile, FF3 will load your extension from your dev folder, just like in FF2.

Win!

Divide and Conquer.

“Mr. Obama has, for at least brief moments, been forced offline. As he sat down with a small circle of advisers to prepare for debates with Senator John McCain, one rule was quickly established: No BlackBerrys. Mr. Axelrod ordered everyone to put their devices in the center of a table during work sessions. Mr. Obama, who was known to sneak a peek at his, was no exception.” [Source]

Obama’s own employee gives Obama order. Obama follows order.

I like this because it reminds me of an off-hand comment from the GTD thing. This comment has been making a lot of sense lately.

“It’s not about who’s on top; it’s about division of responsibility.”

Obama is a Renegade. No…he’s THE Renegade.

Recently I posted some ideas about the characteristics of codes, specifically the codes used to identify the President. Most of it was theorizing on my part.

“…this code has to be easily spoken via phone. No doubt, you’d like a certain about of uniqueness. Also, it should be something that could be understood when spoken over low-quality audio. You never know when those sat phones will get scratchy-sounding (‘I can’t hear you! I’m in a tunnel!’).”

I was very pleased to come across an article today that actually describes some of the codes used by the military, for identifying the President, Vice President, and their families. This was with respect to the new Secret Service code names being assigned for the Obama and Biden families. It turns out, speakability is a factor in their decision.

“The names are chosen to be easily pronounced and understood when agents use radio communications.

The code names have ‘nothing to do with security’ and more to do with ease in radio communication for those agents whispering into microphones up their sleeves.”

There’s a bit more info, along with a slightly funny story from Al Gore’s daughter.

When 19-year-old Karenna Gore’s father became vice-president in 1993 she had to choose her own name.

In 1997, she wrote: “Ever since four years ago, when I was put on the spot and told ‘two syllables’ and ‘It has to start with an s,’ I have been cringing in the back seat when identified as ‘Smurfette’.”

I find this additional “two syllable” requirement to be interesting. It makes sense, since it’s short, but still manages to provide a small amount of redundancy. [Edit: Chas points out that some of the names mentioned aren’t strictly two syllables, but I counter that if you slur them slightly, the names all have two “strong” sounding syllables — they’re not using “The Lotus Blossom”]

Also, the article mentions that the Obama family is being assigned names that begin with ‘R’ — Barack himself is “Renegade”. Karenna Gore said she was told it had to start with ‘S’. Bush and his wife have ‘T’. I think this might be so that the first sound of the word immediately identifies which family is being discussed. I think this is a clever trick.

And ultimately, it’s consistent. You don’t have agents using “Joe the VP”, “Mr Biden”, “The Vice Prez”, “Biden”, or any other possible name. There’s zero confusion. Day to day life is easy, and if they were ever put under stress, it’s one less thing they have to think about. They handle their thinking up front. Kind of like pre-processing data in a computer system. Good job, Secret Service.

“He’s not dead, he’s pining for the fjords”

Turns out that Monty Python’s Dead Parrot sketch wasn’t really groundbreaking. For it’s time, maybe. But it turns out that there’s a similar joke from the 4th century in Greece.

…a joke where a man complains that a slave he was sold had died.

“When he was with me, he never did any such thing!” is the reply.

I still love ’em, even if they were beat to the punch line by about 1500 years. Nudge nudge, wink wink, know what I mean?

Programming Visas, and effective regulation

I read an article on H-1B visas in the Harvard Business Review, and there was an interesting point made that I wanted to share.

Multinationals, desperate to fill technical positions, have been seeking alternatives to the use of H-1Bs. A solution that’s growing in popularity is intracompany transfer visas, which allow a firm to bring an unlimited number of foreign employees into the United States. But employees are eligible only after they have worked for the company for a year. So a multinational might, for example, assign a new hire to spend 12 months working in a country with looser immigration rules before bringing him or her to the United States.

The article then goes on to discuss how companies are also trying to simply avoid basing workers in the US at all. I suspect that — long term — this is not something we should want to encourage.

I thought this was interesting because it’s a clear demonstration of how companies will find a way around regulations, and how carefully regulation has to be designed so that is effective.

RSS Feed, side 2

New Point of Order: Ignore previous Point of Order.

You don’t need to update RSS anything. There’s a plugin that handles everything for WordPress forwarding to Feedburner.

I think the moral here is to ask Google before you do anything. [edit: Turns out I had an email in my inbox from Greg telling me that this plugin existed. So, new moral here: “ask Greg before you do anything.”]

Well, that’s nice.

If you’ve ever lost a cell phone, you know how much of a pain in the ass it can be. I’ve definitely lost and damaged phones. Just ask Dan.

I was looking at some papers from a credit card company I use, and realized that they will reimburse me if my phone is lost or stolen.

I wanted to point this out, because your credit card companies might offer this too.

One other thing, if you spend a lot on phones & service, you might be interested in the same card I have.They give you 10% back on phone-related stuff.