A View Inside My Head

Jason's Random Thoughts of Interest


CodeRush: The Refactor Key

Do a search, and you will find that there are a few IDE Productivity Tools available for Visual Studio. As far as feature sets go, you'll also find that there is quite a bit of overlap in what these tools offer.  So, deciding on one is largely a matter of personal preference. 

However, by not using an IDE Productivity Tool at all, you are doing yourself a great disservice.  No, really!  You are wasting a lot of time by manually doing things instead of allowing software do it for you.  Since time is money, and these tools are not very expensive, you will quickly make up for the cost of the program in time savings alone (I think within the first week, if not the first day).

The one tool that I stand behind is CodeRush by DevExpress. Some of the finest people in the industry work for Devexpress, and over the years, some of these folks have become quite good friends of mine.  The company has an outstanding commitment to supporting the developer community year after year, and you will surely find them sponsoring a developer event near you.  Aside from the goodwill, their product suite is outstanding, so I'm proud to continue to use and recommend their entire product line whenever I can.

Sidebar: Personally, I think that DX has a bit of a branding problem with their IDE Productivity Tools, because CodeRush includes another product called Refactor! Pro.  I would rather see them not offer Rafactor! Pro by itself, and only sell CodeRush with Refactor! Pro, since in my mind they are together one product (and I would never recommend Refactor! to someone without CodeRush).  As such, I often refer to features from Refactor! as belonging to CodeRush.  But, I digress.

Learning any new tool can be a bit daunting at first, and CodeRush is certainly no exception.  DevExpress has produced a collection of short tutorial videos to help new users come up to speed.  It should be noted, though, that some of these videos are likely useful to experienced users as well: with so much functionality packed into the product, I find that it's common for someone to master a number of features, be familiar with just as many if not more features, and yet be totally unaware of half of the things that the tool has to offer.

Since you have to start somewhere, the first feature that I recommend that someone master is mapping and using their Refactor key.  This is a shortcut key that will open a CodeRush "context menu" to show available refactorings for the code where the cursor is currently located. 

Personally, this is the feature that I probably use the most, so finding an appropriate key binding that is easy to hit yet does not interfere with my ability to type code or use Visual Studio key bindings was important.  The default is Ctrl-backtick ( ` ), but I landed on the just backtick key to save me from needing to hold Ctrl.  I've heard of a few people who have picked F1 as a way of defeating the annoying help system in VS2008 and earlier.  It's all a matter of personal preference, so choose something that works for you.

To set the Refactor key shortcut, open the Options from the DevExpress menu in Visual Studio.  In the tree on the left, open IDE and click on Shortcuts.  After admiring the entire collection of shortcuts that are available, locate the "Refactor!" section in the list.  One of the defined shortcuts will be mapped to the "Refactor" command, and by clicking on this, you can set your own key to bind it to on the right.

Refactor key binding is set in the Visual Studio Devexpress Menu, Options, IDE - Shortcuts - Refactor! group

Trivia: Notice the Alternate Bindings that also appear in the same section. Number Pad 0 is the one preferred by Mark Miller.  Dustin Campbell has two bindings mapped: the default Ctrl-`, as well as Number Pad INS.

Now that you have a Refactor key, try moving your cursor to different places in your code and pressing it. 

Refactor key pressed on a variable

You'll still have to learn about different refactorings that are available in the tool, but hopefully the Refactor key will become your preferred portal for accessing those refactorings (instead of using smart tags or the mouse to right-click on code).

Happy Coding!


Last week, I travelled to Philadelphia to work out of my company's office in Exton for a week.  Before leaving, I took my youngest daughter for a hike in the park, which was a two-fold treat for her: she got to spend time with Daddy, and as an extra bonus, she got to ride in Daddy's truck.  Being a two-seater, it is not often used unless I'm spending some 1-on-1 time with one of the kids.

After returning from out hike, I parked it on the street in front of the house.  It looked something like this picture that I took in 2003 right before buying it:

[Sorry, photo no longer available... But it was pretty sweet looking!]

Well, fast forward to very early Friday Morning.  I was sleeping in my hotel room, when my cellphone began to ring.  I think the alarm clock took quite a few swipes of my fist before I realized that it was not the loud noise that was bothering me.  I stumbled out of bed and picked up the phone, only to hear my wife tell a tale of firetrucks and flames and the entire neighborhood observing some bonfire that was taking place on the street in front of my house.

I had actually had a bad dream just a bit earlier, and was relieved to find out that it was only a dream.  I think part of me expected the same to happen in this case, but no such luck.  My truck - the one that I had just paid off a few months ago - was ablaze.

Now, the truck looks a little more like this:

Image Hosted by ImageShack.us

Image Hosted by ImageShack.us

Image Hosted by ImageShack.us

Notice if you will that there is no hood on the truck. It was a steel hood, and is nowhere to be found.  So, it was either removed by the firefighters and they took it with them, or it simply melted away.

The worst part now is that we have to wait until Monday (2 more days as I write this) for the insurance company to tow the shell away to their evaluation center...  once there, the lady told me, they would then make the determination as to whether it could be repaired or not.  I just giggled to myself. 

But, until then, there's a tarp-wrapped burned-out truck serving as a landmark for those trying to locate my house.  It's the one with the nose sitting on the asphalt.

UPDATE: The truck was hauled away shortly ago.  While speaking with the neighbors who came out to watch, I learned that another neighbor filmed it AND UPLOADED TO YOUTUBE!  Thanks, Andy!

Project Euler Comes to Azeroth

It seems that a lot of my friends are doing Project Euler (according to my High School math teacher, this is pronounced "Oiler").  For example, Bill Wagner has been posting C# solutions, Darrell Hawley has ventured into the Python realm, and Dustin Campbell has been working on F# versions.

I love numbers, and spent a good portion of one summer playing with primes and number fields just for fun (since then, I've discovered WoW, and that takes up all of my time that would otherwise be spent exercising my brain).  Project Euler is actually right up my alley, and while in Seattle, I joked with Dustin that I should post solutions using LUA, and use World of Warcraft as my testbed... 

Problem 1 is finished.  :-D


My no-frills WoW add-on is a simple ACE2 mod that includes AceConsole (for printing to the chat window in the lower left of the screenshot).  I won't bore you with the framework code, but will list my solutions as individual functions on my wiki (where it can grow without polluting my blog's RSS feed). 

As a taste, here's the Problem 1 solution written in LUA.  OnEnable() is my add-on's entry point, and it simply calls into the function Problem001(limit).

function ProjectEuler:OnEnable()

function ProjectEuler:Problem001(upperLimit)
   self:Print("Sum of all numbers less than " .. upperLimit .. " that are divisible by 3 or 5")

   local f = function(factor)
      local n = math.ceil(upperLimit / factor)
      return n * (n-1) * factor / 2

   local result = f(3) + f(5) - f(15)




This past Friday, I ended my 20+ year dependency on wearing glasses to see.  And while there's a lot of healing that remains as I write this, my vision is already better than with my old glasses.

Find a Facility and Get Evaluated

I started my adventure by selecting a LASIK center near me.  I was not necessarily interested in the lowest cost provider, but since I was using my Flexible Spending Account to pay for the procedure, I had a hard limit as to what I could afford.  The doctor that owns this particular business is from the Cleveland area, and comes to Toledo once a week to perform the procedure.  He comes well recommended, and has an impressive resume of experience.

The next step was to attend a free consultation.  Not everyone is a candidate for LASIK surgery, so pre-screening is required.  Aside from needing corneas that are thick enough to be reshaped, you also need to have a stable eye prescription.  There's no sense in performing surgery if your eyes are just going to change in a year or two! 

As you could have guessed, I "passed" this pre-screening, and was invited back for an official pre-operative examination (and to make a lump sum payment that covers the procedure itself, as well as all pre- and post-operative exams).  But first, I also had to decide what technologies I wanted to use.


You see, LASIK is sometimes referred to in endearing terms as the "Flap and Zap".  The surgeon cuts a thin flap of your outer cornea that resembles a contact lens, only it remains attached at the top.  The laser then reshapes the newly exposed layer of the cornea to correct your vision, and the flap is replaced.  By preserving your original outer cornea, the healing is extremely rapid, and the resulting vision is supposedly better than other types of refractive procedures.

 lasik1lasik2 lasik3

There are two ways that this flap can be created: by means of a specialized blade device, known as a microkeratome, or by a special type of laser.  As you can imagine, there's a price difference between the two.

Despite being used successfully millions of times since the inception of LASIK, the thought of the microkeratome scared the hell out of me.  With this, a contraption is placed precisely over your eye, and then an oscillating blade passes over the cornea, making a cut that results in a flap that is about the thickness of two human hairs. 


The more attractive (and more expensive, by about $500 per eye) method uses a femtosecond laser that scans across the flap area.  The beam is focused to just under the cornea, and is only active for one billionth of one millionth of a second per pulse.  Each pulse vaporizes a tiny portion of the cornea at the point of focus, causing a tiny bubble to form.  These bubbles start joining with adjacent bubbles, much like soap bubbles in the sink, until there is just one big bubble remaining.  In the end, the flap is freed from the cornea by lasering the outer ring.  Because IntraLase is the company that manufactures the FDA approved "laser microkeratome", this procedure is referred to as IntraLase.


The other pricing decision involved selecting either standard LASIK or custom wavefront LASIK.  Eyeglasses and contact lenses are able to correct certain vision problems, known as higher order aberrations, and they do this in a standard way.  People with the same prescription can actually share each other's spectacles and are then able to see just as well as when they wear their own.  With standard LASIK, the "generic" correction is made to your eyes, and the results would be the same as if you were wearing your glasses or contacts.

In my case, I had myopia (near-sighted) with astigmatism.  "Normal" people would see something like the flowers on the left, but I would see the blurry/doubled flowers on the right (only more blurry than these pictures):

2020 astig

However, there are other subtle deformities known as lower order aberrations that can make two people with the same prescription have different sight problems that are generally left uncorrected by glasses.  Custom wavefront LASIK takes a personalized mapping of your cornea, and as the name suggests, creates a custom reshaping just for you.  Again, it adds about $500 per eye over the standard (because the equipment manufacturer charges the facility more to use the custom mode, and this cost is simply passed onto the consumer).

In my case, I was able to afford the IntraLase and the custom wavefront, so that it what I ultimately decided on.


My pre-op exam was on Monday, March 3rd.  I knew that I would have to have my eyes dilated, so I took the day off of work.

When I first arrived, I was taken back to an examination room where my current prescription was determined ("better 1, 2"  "3, 4", etc).  It turned out that my prescription had changed in the past 7 years, and I was only seeing at about 20/40 with my glasses.  Who knew?!?!

Next, I was taken across the hallway and all of the same cornea measurements that were take during the consultation were repeated.  The computers produced identical results as before, so they had good numbers to program into the laser.

After that, it was time to watch a video to inform me of risks, sign paperwork, and wait for the eyedrops to work their magic and cause my irises to disappear.

When my eyes were fully dilated, I went into a different examination room and given a full optical exam by an ophthalmologist.  This involved repeating the "Better 1,2" test to ensure that her numbers matched the previous person's results, as well as an examination of my retina and whatever else they do as part of a full workup.

Then, it was done.  I was given a prescription for Valium and Zymar eye drops, as well as some eyelid cleansing pads (I had to disinfect my eyelids every evening leading up to the surgery), and sent home to sleep!  Awesome!

Operation Day!

I arrived on Friday, March 7 wearing a Red Gate T-Shirt (the alternative would have been a Developer Express shirt, but are you really interested in my choice of apparel?).  Right away, I was instructed to take the two Valium pills that I brought with me.  Then, I was taken back to a dimly-lighted waiting room with Lay-z-boy chairs and Men In Black II playing on a large television. 

My eyelids were sterilized with betadine, and surgical booties were placed over my shoes.  I also got an awesome hair net, and was not permitted to put my glasses back on.  So, there I sat, listening to the movie - because there's no way that I could see it. 

The operating room was separated from this waiting room by means of sliding glass doors.  They had a television placed facing the waiting room, presumably so that loved ones could watch the procedure taking place from the laser tracker point of view.  Despite my blindness, I could tell what was happening on this TV, and watched as the person ahead of me had the procedure done.  I had never taken Valium before, but my butterflies never went away.  I wonder how bad they would have been without the sedative!jQuery15206081989678969336_1341772668724!

Before I knew it, it was my turn!  I was led into the room, numbing drops were placed in my eyes, and then I was positioned on a bed (table?).  The IntraLase device was on my left, and the excimer laser was on my right, and by swinging the bed, my eyes were able to be placed under the appropriate devices.  I was handed a teddy bear with surgical scrubs (and a face mask) to hold onto.  How cute!

The surgeon covered my left eye with a pad of some sort, and then placed a ring over my right eye.  This device used suction to adhere to the whites of my eye, and served to hold open my eyelids and keep my eye from moving.  The pressure caused by the suction made my vision fade out, so I couldn't see anything.  Before I knew it, the laser tech was counting down how many seconds were left before the flap was complete.  Then they covered the right eye and repeated the procedure on the left.

With the flaps being cut, the suction devices were removed, and I was positioned under the excimer laser.  The surgeon carefully retracted the flaps, and I was staring up at a blurry orange light with a ring of LEDs surrounding it.  He taped my eyelids open, but essentially, I could look around if I wanted to (the computer scans your eye hundreds of times a second, and can track the laser precisely - still, I focused my gaze on the centermost blurry light).  There was zapping sounds as the laser started to vaporize my cornea in order to reshape it.  There was a smell, as you can imagine, and it reminded me of ozone and burning hair combined.  Again the laser technician was counting down the seconds until the laser was complete, and in the last 3 seconds, that blurry light that I had been staring at came into focus!

After both eyes were complete, the doctor placed what seemed to be 20 drops from a handful of different bottles into my eyes.  Then, I sat up.  The clock on the wall, which I could see, revealed that the entire procedure on both eyes took a little over 10 minutes.

My last stop was in the ophthalmologist office.  The eyechart revealed that I was about 20/80 or so with my brand new eyes.  The surgeon used the equipment to examine the positioning of the flaps, and said that everything turned out great.  The ophthalmologist gave me an assortment of drops and eye shields and sent me on my way to go home and sleep.


bugeyes At home, I took Tylenol every 4 hours for the discomfort (which would probably have been quite tolerable without taking anything, but I didn't want to chance it).  I also had to put medicated eyedrops in my eyes every 2 hours, and wear the eyeshields (and sunglasses, by my choosing) for a few days to keep me from accidentally rubbing my eyes.  I remained amazed at how quickly my vision sharpened up, and by Friday night, I was watching TV in my darkened bedroom.

On Saturday morning, while everyone else in Ohio was getting blasted by a blizzard, I drove myself in to the center so that the ophthalmologist could do a follow-up exam.  Everything was healing nicely, and my vision was 20/25 (!!!!). 

I continued to gaze at my surroundings, amazed by just how clear everything is (and getting crisper every day, it seems).  There are periods of time when my vision will blur up for a little bit, but this is chiefly attributed to the flap not being a perfect fit yet for the resurfaced cornea.  I have about another 1-3 months until everything is completely healed, and can expect my vision to get worse at times.  The LASIK center offers a lifetime guarantee, and will perform another touch-up surgery if my vision degrades beyond 20/40.


I can see clearly now, the rain is gone,
I can see all obstacles in my way
Gone are the dark clouds that had me blind
It's gonna be a bright (bright), bright (bright)
Sun-Shiny day

-Bob Marley   (correction) -Johnny Nash


As I was cleaning my glasses this morning, I felt the lens suddenly come away from the frames.  My immediate thought was that the screw popped out, which has happened before.  However, upon examination, the screw was intact, but the frame itself broke near the nose.


I scrambled to find any type of superglue that we had in the house, and managed to locate a bottle of acrylic nail glue.  It was futile to try to glue just the broken part, so I put a small bead of glue all around the plastic lens itself, and then assembled the lens into the broken frame.  There was much more surface area to hold everything together this way, but it's certainly not perfect, and I have spots of glue on my lens....  :-(

I guess that I could have went to a 1-hour optical store today and picked up a replacement pair... But, I've had something bigger in mind for a few years now: LASIK.

Last year, my oldest daughter had to have braces installed on her teeth, so that consumed a huge chunk of my FSA.  So far this year, there are no big medical expenses that have been identified, so I'm going to jump at this opportunity now while I have the chance and sufficient balance to pay for it.  My consultation appointment is in about 90 minutes, and I hope to be able to schedule the procedure for Monday morning when it is most convenient for Tina to drive me around.

I've been so dependent on glasses (and contacts for a while during High School) for 22 years.  It's gonna be weird to be "normal" again and not wandering around in a blurry world.