Friday 20 April 2007

Fiddler Reverse Proxy Setup

The Fiddler documentation includes instructions on how to configure the tool as a reverse proxy (http://www.fiddlertool.com/Fiddler/help/reverseproxy.asp). Option #1 is only useful if you're setting up Fiddler as a local reverse proxy; if you want to use Fiddler from external clients, you need to go for Option #2.

The code snippet to be added to your custom rules file includes two string listerals: "webserver:8888" and "webserver:80". It's in important to note that "webserver" is not a variable name--it must be replaced with the name of your web server (i.e. MyServer, as in http://myserver). The other important thing is to add the code snippet to the OnBeforeRequest function and not the OnBeforeResponse function. You'll also probably want to allow remote clients to connet via Fiddler so make sure the Tools -> Fiddler Options... Allow remote clients to connect options is selected.

You can change the listen port from 8888 via Tools -> Fiddler Options... Listen Port if you want to use a port other than 8888.

If you implement both Option #1 and Option #2 you might end up with problems like an infinite loop.

The change may take a little while to come into effect so meanwhile, try restarting Fiddler, running an iisreset, or rebooting.

Tuesday 17 April 2007

How to determine if a page is in edit mode

SPContext.Current.FormContext.FormMode == SPControlMode.Edit

Alternatively, use an EditModePanel (the PageDisplayMode can be set for specific display modes).

Javascript Debugging in VS2005

See this link for a useful article on Javascript debugging with Visual Studio 2005. I managed to get it working using a basic page consisting of a single button with an OnClientClick attribute calling a simple inline function. I also played around with using the Javascript debugger; statement to break into the runtime document, which proved handy when attaching to the running server process instead of starting off via F5.

By the way, Firebug has a Javascript debugger and while it's pretty clunky, it might help get you out of a jam (Firebug is useful for so many other reasons as well).

http://blogs.msdn.com/webdevtools/archive/2007/03/08/jscript-debugging-in-visual-studio-2005.aspx

Thursday 12 April 2007

Determining the current variation

If you need to find out which variation a client has requested, this code might do the trick.

Start by getting the current VariationLabel; then compare its title against a known variation title.


VariationLabel currentVariation = PublishingWeb.GetPublishingWeb
(SPContext.Current.Web).Label;

if (currentVariation != null &&
currentVariation.Title.ToLowerInvariant () ==
"au")
{
//do something
}

Tuesday 3 April 2007

Saturday Shopping

I don't understand what went wrong with my parent's generation. They showed so much promise with their bombs, telecommunication, and political reform but they make out as though the race to the moon was only the first stage in the race of life: hussle, bussle--they can't get there fast enough no matter the price. In contrast, I believe our generation is now responsible for putting the humanity back into a world left devoid of everything but some elusive end goal.

Saturday grocery shopping, if you do it regularly, makes the Christmas rush seem like nothing out of ordinary. The shops are busy, the shelves are empty, and no one really wants to be there. I'm a happy Saturday shopper and I use each experience to test and develop my patience. Most times I make it through.

This Saturday seemed especially busy for whatever reason. It was the first cool weekend in a long while so my guess is families were out to stock up after a month of lying around sweating. Nevermind, I thought, I'm in no rush today so I'll just have to try extra hard to be patient and polite; "after you", "go ahead", smile and say "excuse me, thank you." With the narrow isles full of the overweight, carts, and mothers with strollers for triplets, there would be, I knew, a lot of standing around waiting.

At one point, momentarily frozen int time waiting for the isle to clear before I could move past the stacks of broken eggs and on towards the vegetarian sausages, my personal space suddenly vanished as a well-dressed, dark-haired woman well into middle-age squeezed up next to me and then bolted past into the gap only to stop in front of me. "Now that's pushing it, lady," I thought to myself. No "excuse me", no smile, only an in-grained push to get there sooner, get the job done, and trample anyone in the way.

"Have a taste of your own medicine, if you're going to be that way," I shouted at her in my mind as I plowed into the melay of shopping carts and unwashed Saturday shoppers. With her cart in the mix, the gap had narrowed significantly so I pushed forward, nosing my cart into what must have been the one piece of unoccupied real-estate in the entire store. I plowed her cart out of the way and then knocked it again for good measure before continuing on my way, a dazed mother glaring at me all the while. Yes, shame on me for my childish retaliation but let that be a lesson to the pushy woman.

I shuffled on in my sandy thongs not feeling any better for my actions--on reflection, feeling worse. Nevertheless, my calm depened as I resolve to kick back against the rush and hurry imposed on me by this boom-time generation. With all the man-made pressures built into our lives I'm finally beginning to understand why so many of me friends and classmates turned to cigarettes, booze, and pot over the years.

I always think back to my drives between Montreal and Ottawa as a university student returning home for a weekend or during the holidays. The old Grand Marquis I drove (a 5.0 litre V8) handled the drive at 140km/h quite happily but as the car moved ever closer to the scrap heap, exaust fumes seeping in through the salt-rusted holes in the floor meant the trip had to be completed at 90km/h in the slow lane. At either speed, the journey always took two hours.