Monday, May 30, 2005

GreaseMonkey is Cool

OK, so I mentioned earlier that Google was rewriting my search result URL's to be redirected through itself (and tracking my clicking habits in the process). Here is what the URL looks like when I searched for GreaseMonkey and tried to click the first link:

After doing a search on the web regarding this, it appears this only happens to certain locations at certain times. I tried this search on another PC in the house and it doesn't do it. So you may not see this when you search.

Now having discovered GreaseMonkey a month or so ago (and by the way BookBurro is just plain magic, check it out), I decided I would write my own script to take these URL's, pull out the address that comes after the q= part and before the & part and replace Google's link with the clean version.

After a bit of hacking around this is what I produced:

// ==UserScript==

// @name Google Link Fixer
// @author Doug Porter
// @namespace
// @description Cleans up google search result links that use a redirect through google.
// @include http://google.*/*
// @include*/*

// ==/UserScript==

(function() {
var aref = document.getElementsByTagName('a');
var href = '';
var id = '';
var beg = -1;
var end = -1;
var cleanUrl = '';

for (var i = 0; i < aref.length; i++)
href = aref[i].href;
id = aref[i].id;

if((id.indexOf('aw') < 0) && (href.indexOf('url?') > 0))

beg = href.indexOf('q=') + 2;
end = href.lastIndexOf('&');
cleanUrl = href.substring(beg, end);
aref[i].href = unescape(cleanUrl);

Crude, but works. What it does is get a list of all <a> tags. Then it walks this list looking for tags in which the id attribute does not contain 'aw' (these turned out to be adds) and where the href attribute contains 'url?' (which indicates a redirection).

Once it finds this it looks to pull out the string that falls between 'q=' and the last '&' character. Then it sets the href property of the current <a> to the cleaned version of the URL. It uses the unescape() function to make sure ? and = signs in the URL's don't get encoded.

Improvements to be made: Probably could be done more efficiently using XPath. Also very susceptible to breaking if Google changes their redirection and link format. One thing that would be nice would be to add some indication when a replacement had been done...(change the underline or coloring or something).

Well give it a try if you run into this problem and let me know how it goes, but keep in mind that this was a quick hack in a couple of minutes.

Got to find a place to store my script so I can provide it online, but I'll let you know when that happens. Till then enjoy.

Memorial Day

Today is Memorial Day. I hope you all get a chance to stop and remember all of our past and present members of the armed forces on this day.

I took advantage of the long weekend to head up to Birmingham, AL and also over to Atlanta, GA to visit some friends.

A great time was had by all, but I did end up feeling like I spent the whole weekend driving. I finally was able to try something out to make the trip a bit more enjoyable. Some of you may have seen or heard of For those that haven't, it is a site that holds mp3's of various technical talks and interviews. I downloaded and burned some to CD for the trip (since I don't currently have an iPod or car radio that plays mp3's). I have to say this helped make the drive much more pleasant. Plus I got to learn a little bit instead of just listen to radio stations come and go as I put miles on the road.

I listened to a talk by Thomas P.M. Barnett (a prolific blogger himself) which was a shortened version of one I had seen on TV. I listened to a 2 CD set of Steve Wozniac of Apple fame. I also listened to Wil Wheaton, Bruce Schneier, the great Paul Graham, and Jonathan Schwartz.

It actually makes me want to take a couple of more road trips to get to have time to listen to more interviews and talks like this.

Something I just noticed as I was creating this entry was that as I did Google searches and right clicked to copy a link, the link is no longer the pure link text. It now contains a link to Google that then redirects to the link returned in the search. Is the something new or did I just notice it finally? Don't really want to redirect everything through Google, so looks like I'll have to write a quick GreaseMonkey script to pull those out.

Monday, May 23, 2005

Starting a Mobile, AL .NET Users Group

So through correspondence with a friend I was connected with a local group that wanted to start a .NET user group in the Mobile area....again. Now there was a group a couple of years ago that got together when .NET was first hitting the scene and had meetings about once a month. Unfortunately like happens many times, people lost interest after awhile and after about a year it ended.

Our Microsoft contact Joe Healy, the south-eastern US technical evangelist for .NET, scheduled a conference call for 6:00pm this evening to gauge interest and go about organizing a user group. There were about 15 people that I saw on the conference call e-mail list that were interested in such a group.

So as I dialed into the call at 6:00pm expecting to be greeted by many happy .NET user voices eager to come together and learn as a group, I only found one voice. That was Joe Healy's. So there we were, Joe and myself talking about starting a local user group.

He begins by asking if I'm the main organizer of this group. Now I'm very eager to keep my skills fresh, and any learning is good learning, but I had to let him know a couple of things. For one, as most of you know from reading here, by day I am a Java, Oracle, PowerBuilder guy. I play in the .NET world some on the side, but not my main area of experience these days. Second, I was not the main organizer, but am more than happy to take the initiative. But, I have to admit I don't think he was too excited to here that someone that works mainly on competing platforms and technology would be trying to rally the troops.

After about 10 minutes we were joined by a local consultant who was eager to get involved. Good to have at least one other person, and it helped make us not look so bad by not having any participants at all. So here is the plan so far.

1) Get a website set up for the user group (have it listed on once set up)

2) Get a calendar of events and set a first meeting (Joe will be in town around August 25 and offered to be the first speaker, so probably some time around then)

3) Find some place that will allow us to use their space for meetings. I will check with the University of South Alabama Department of CIS to see if they will offer up a classroom once a month (or once a quarter depending on interest). It would be a good opportunity for the students to get involved if we met on campus. If that does not work out, I could check with my old/new employer (Oh, did I not tell you where I'm working again these days :-) )

4) Get the word out to the local technology companies and get some involvement commitments.

5) Of course get an RSS feed setup to keep users aware of what is going on and give us a way to have conversations. Right Scoble?

I think this is a great opportunity for learning and networking in general, so even though it isn't my full time technology, I will try to be as involved as I can. Plus since I'm not teaching these days, this will give me something to do in that vein....

Tuesday, May 10, 2005

Alternative to all_objects in Oracle 9i and Up to generate rows

As Oracle guru Tom Kyte says of his daily Oracle experiences, I have learned something new about Oracle today. This trick works in Oracle databases 9i and up (like a fine wine this one will actually get better as you move to newer versions).

From a fantastic post on entitled Can there be an infinite DUAL? I found a great alternative to using all_objects to generate X number of rows in a table.

Oftentimes, say for a Pivot Table, we will want to generate a table with X number of rows which we will Cartesian Product with some other table. To do this using all_objects (or some other table that is guaranteed to have a sufficiently large number of rows) it would look like this:

select rownum rn
from all_objects
where rownum < 10;


9 rows selected

Now using a cool trick with 9i and up we can produce the same thing like so:

select l
from (select level l
from dual connect by level < 10


9 rows selected

Why do we care if the results are the same? The consitent gets for the second approach are much lower and they scale fantastically. Guru Kyte says that this will be even faster in 10g thanks to something called FAST DUAL. If you don't believe me try it for 10,000 rows and check out the trace for both approaches.

Very cool stuff. Also did you know that Tom Kyte is blogging now at Very interesting to see a different side of this technology wizard.

Monday, May 09, 2005

Papers, I must see your Papers...

It appears that the battle has all but been lost regarding a National ID card in the United States. Through a tacked on bit of legislation to a military appropriations bill that is considered "must have" the Federal government is mandating the REAL ID program. This will require the States to standardize driver's licenses with all kinds of wonderful bits of identifiable information and have it read via some electronic means (magnetic stripe, RFID, you make the call). Yeah, sounds like a National ID card to me. And if burying this legislation in an unrelated spending bill that is seen as a must for passage wasn't a good indication that something slimy was going on, then check this out. The legislation doesn't go into effect until 3 years after passage. In war I believe they call those landmines, or in terrorism terms I think this would be a sleeper cell.

Unfortunately the media discovered this a bit too late (funny how things get overlooked when they are buried deep in spending bills with 3 year lags on taking effect) and it has already passed the House and the Senate will vote tomorrow (Tuesday May 10, 2005).

For what it is worth, please write your elected officials and tell them that you oppose any such legislation dictating a National ID card, and that research has shown repeatedly that such legislation will not make us a safer, just further erode our personal privacy and freedom (sounds like an ongoing theme these days). You can write them through or as always through Congress.Org. Of course the way the erosion of privacy and freedom is going in DC you will probably get audited and put on a watch list for expressing your opinion.

Security guru Bruce Schneier has posted on this and has some great links on the subject. Goodbye freedom and democracy, hello communism, eh comrade.... And the saddest part is we elected these officials to protect us and look out for our best interests (I know statements like these will keep you rolling on the floor laughing for hours).