Monday, July 10, 2006

Firefox: Create your own search plugin

Firefox comes bundled with a small search box where you can type in any query and you'll instantly search using the selected engine. There are several engines already in the list: Google, Yahoo, Answers.com... but what if your favourite site isn't listed there or isn't available through the Mozilla addons site?

That's where this trick comes in handy. You can easily add whatever search engine you wish to that list by following a few steps.

The Engine
First, find a site that you commonly execute a search on and then perform a test search with their engine. Some sites are easier to create plugins from than others, but for demonstration purposes, I've chosen the CBC website at http://www.cbc.ca. The format of their search queries is really long, but you'll be ready in case you find something more challenging.

Once I've typed in my term in their search box (I'm using "TEST" this time), and pressed Enter, I arrive at the results page with the address bar of my browser showing this:
http://search.cbc.ca/search?ie=&site=CBC&output=xml_no_dtd&
client=CBC&lr=&getfields=description&proxystylesheet=CBC&oe=&
amp;searchWeb=cbc&q=TEST
Ouch! In this case, the action parameter should be http://search.cbc.ca/search (everything before the question mark), but not in this case (see below). The only parameter you're truly worried about is q, which is clearly set as "TEST". All of the other parameters do serve a function, but let's shove them aside for the moment.

<search> tag
Search plugins rely on a source file (plain text). They are described by a tag that has the following attributes:
  • version - Describes the plug-in version, although for some strange reason it is set to the current Netscape release, which is now "7.1".
  • name - The name of your search plug-in
  • description - A simple description
  • method - The search method used, which is always "GET"
  • action - The URL of the search site. Usually, this is everything before the "?" in the test search, but some websites will go nuts when you try to execute a no term search, including CBC.ca. If you know an alternate search URL, use that instead, as I have in the text below.
Now that we have some information, we can start to create the markup that will form the basis of the plugin functionality. First, open a text editor and enter the following tag, which is based on what we've gathered so far.

<search
version="7.1"
name="CBC News"
description="Search CBC.ca"
method="GET"
action="http://www.cbc.ca/search"
>
</search>

Add the content
Now that we have our foot in the door, we can add some data to our search element. Each query has various parameters that we have to consider. The CBC search happens to have a ton of them, each separated with an ampersand (&). These constitute the "meat" of our plug-in and follow this format:
<input name="" value="">
Easy enough, right? For that special parameter that holds our search term, you have to replace the value attribute with the user attribute:
<input name="" user="">
Great, now we have the information we need to complete our plug-in. Fill in the details of the tag, like so:

<search
version="7.1"
name="CBC News"
description="Search CBC.ca"
method="GET"
action="http://www.cbc.ca/search"
>

<input name="ie" value="">
<input name="site" value="CBC">
<input name="output" value="xml_no_dtd">
<input name="client" value="CBC">
<input name="lr" value="">
<input name="getfields" value="description">
<input name="proxystylesheet" value="CBC">
<input name="oe" value="">
<input name="searchWeb" value="cbc">
<input name="q" user="">
<input name="sourceid" value="Mozilla-search">

</search>

You may be wondering what that tag at the bottom does. Well, it's there to inform the website admins that you're performing a search using your plug-in. Simple enough.

Save your text file in <firefoxpath>/searchplugins (commonly C:\Program Files\Mozilla Firefox\searchplugins) with any name and the extension .src.

Favourites Icon
Your plug-in will work if you restart Firefox, but we're not quite finished. Currently, there's no icon associated with your search, so it won't stand out if you make several of them. One trick to snag the icon is to go to the search site in question, and point to the favicon.ico icon. For CBC, it's at http://www.cbc.ca/favicon.ico. Download this file and convert it to .gif or .png, then save the new image in the searchplugins folder under the same name as your .src file. Now you have an icon for your search!

For more information about search plug-ins, consult the Mycroft Project.

Biking around Toronto cont'd

Although I have yet to try it out, it seems as though the newest change to the Martin-Goodman trail has been completed. Check it out.

Sunday, July 09, 2006

Biking around Toronto

It's that time of the year when you should... no, you must get out to enjoy the summer. What better way to do so than to ride through the trails and paths of Toronto on a bike?

One of the most valuable tools to exploring the city on two wheels is the Toronto Bike Map, which is available free at any Toronto civic centre and also most bike shops. You can also call the city to request a copy of it. For a few cycling tips and an online copy of the map, you can visit the City of Toronto Cycling page.

I urge you in your travels to check out the Martin-Goodman Trail that stretches across the waterfront, view the gardens along the hilly Humber Trail, and wind your way through the scenic Don Valley Trail. Catching a trip on the ferry across to Toronto Island is also a good bet, but be sure to avoid it during the spring when the eastern cottonwood (poplar) trees litter the island with their characteristic white fluff. It's like riding your bike through a summer snowstorm :).

One of my favourite trails (which I rarely get to see) begins above Eglinton West station next to Allan Road, starts east and then curves to the south. It's a long dirt trail flanked by two almost never-ending rows of mature maples and oaks, eventually leading through one of the largest and most peaceful cemetaries in the city, and deep into the heart of Toronto. If the far end of the trail hadn't been closed this year, you'd be able to follow it right down to the lakefront, and then continue east back up the Don Valley River. However, it's also a good starting point to exploring the downtown routes that grace many of Toronto's tourist attractions.


For those wishing to take a long trip along these trails, I have a few words of advice:
  1. Bring plenty of water and stay hydrated. The water fountains in any of Toronto's parks are, from my experience, damaged or unusable if they're not already broken.
  2. Bring a tire kit or a spare inner tube, and also the tools necessary to repair any leaks or tears. This includes an air pump.
  3. Wear loose clothing and bring sunscreen.
  4. Make sure you're fit enough to make it through the trails and back without killing yourself. There's nothing worse than getting downtown and being too exhausted to climb back up the tall hills to get home. If all else fails, bring enough for a TTC fare. You're allowed to take your bike on the buses, streetcars, or subways anytime outside of rush hour (7-10AM, 3-6PM if I recall correctly).
Good luck and happy riding.

Wednesday, July 05, 2006

Environment: Do you drink from your toilet?

I sure don't... nor do I know any people that do.

However, that's what the health crusaders at Brita would like you to believe you do every single day!

I'm sure you're picturing it right now. Now that was refreshing, wasn't it?

The fact is, our tap water is completely safe for consumption. Sure, those water molecules were probably in someone's toilet at one point, or inside someone's body, or perhaps flowing over the dirtiest sludge you've ever had the pleasure of encountering, but that applies to just about every other bunch of atoms out there. Simply put, unless there is something wrong with your plumbing, you're not about to get sick from the water flowing out of your tap. For the time being, Brita will probably stick to their tired marketing campaign for months to come, preying on those of us vulnerable to their FUD (Fear, Uncertainty, and Doubt).

On a similar note, this is the same argument that bottled water producers use on consumers all of the time. "Oh, just look at what happened in Walkterton. Your public water is too dangerous and full of nasty bacteria!". On the contrary, tap water is subject to even stricter health standards than bottled water ever was:
A regulation (O. Reg.169/03) under Ontario 's new Safe Drinking Water Act, 2002 sets numerical limits on contaminants in drinking water. Under this regulation, maximum levels of chemical, bacterial and radiological parameters are set for municipal drinking water supplies. All drinking water in Ontario must meet these standards. However, bottled water is not legally required to meet these same standards.
Source: Canadian Environmental Law Association (CELA)

Not only is the bottled water more costly than the gas in your car (several times more in some cases) but it's not even held to the same standards as tap water (which costs you pennies). In addition, tap water contains fluoride to help your teeth resist cavities and decay.

Even more revolting than the masses of consumers who are gullible enough to take bottled water marketer's claims at face value, is the fact that much of that bottled water comes from the exact same set of pipes that your tap water does!:
Some is cleaned by adding ozone. Some is passed through high-tech filters. And a quarter of all bottled water comes originally from a municipal water source -- a tap.
Source: CBC Marketplace

So, for all of the people who can't go anywhere without buying overpriced, overrated H2O, enjoy your $1 plastic bottle because it's the only special thing you're going to get.

Tuesday, July 04, 2006

Environment: Going nuclear

For those of us in Ontario, you may recall several Canadian Nuclear Association ads during the winter and spring of this year that essentially painted nuclear energy as the rosy solution to all of our power woes. The second I saw those ads, I knew that the Liberals, who had been struggling with their promise of eliminating coal-fired power from Ontario by 2007, were going to announce new nuclear facilities in the upcoming months. It was an attempt to cozy us up to the thought of clean, efficient power, and away from those nasty memories of Chernobyl. Lo and behold, just a few weeks ago the provincial government declared that they were the first in North America to invest in building new nuclear power plants in the last 30 years. I really can't say that I'm surprised.

The fact is, Ontario is a very power hungry place. With one of the largest commercial and urban centres in North America, we're bound to be tapping heavily into the grid to quench our insatiable thirst. Deviating from my previous views, I think nuclear is not only the best solution for us, but the only solution in our current situatuon.

Let's consider the alternatives. First, there's coal. It's cheap, it's plentiful, but it's a very dirty fossil fuel to burn. You can thank part of that smog you breathe in everyday to the coal power plants that surround us. We've used it for the past, oh, two centuries? Developing nations such as India or China practically eat it for breakfast and look how their air quality is. Personally, I think it's about time to give it a rest.

Second, we have 'green power', which no one wants. Yep, you heard me. Sure, we all talk like we want to have 100% of our power from renewable, green power, but when that power bill comes in and it's higher than it used to be, do you think people will continue supporting green energy? Not likely.

However, some citizen's attacks against green energy are, frankly, really stupid. I think the most amusing argument I've heard against wind or solar power is that "It's an eye-sore". Hello? As if smokestacks and summer haze aren't?

On the other hand, I think that clean, renewable energy is definitely within our grasp, but only if it's given the investment it deserves. Even aiming to have 5-10% of our power seems like such a hard thing for politicians to handle, that I wonder why they even bother. If you've seen the wind turbine in downtown Toronto, you'll have all of the proof you need to know that it's only a half-hearted effort. They must only turn it on when nobody's looking.

Third, you have hydro-electric [dams]. I don't really lump this in with green power since it's anything but green. To dam a river is to essentially kill any natural balance that it once had. Fish can't return to their natural spawning grounds, so they die. Anything that depends on the fish or the river's wildlife also vanishes. Land up stream from the dam is flooded, harmful chemicals or elements such as mercury accumulate and poison the water... the list goes on. Hydro-electric dams are a modern environmental disaster in themselves. Just look at the destruction reaped by China's new Three-Gorges Dam.

Last, you end up with nuclear. The accidents at Chernobyl and Three-Mile Island, although they are important lessons about what devastation nuclear energy can bring, both lie in the past. Advancements in both reactor design and safety have virtually eliminated the chance of such mistakes occurring in the future. Plus, nuclear plants are clean in that they don't contribute to the smog sitting over our urban centres and low lying areas. They're also far more efficient than coal, more centralized than wind, solar, or tidal power, and also less damaging to local ecosystems than the majority of our other energy sources.

I know many Ontarians have a bitter taste in their mouth from the frequent problems in our old nuclear plants - I was, and still am, one of those people. I'm hoping just as much as you are that the new plants will be efficiently run, reliable, and provide us with the energy that we desperately need and crave.