Early morning running - Lessons learned

>> Wednesday, October 27, 2010

Today I decided to get a jump start to the day and get a run in before work. Since the Seattle marathon is a month away, I wanted to do a 10 mile run today.  So I set my alarm clock for 06:15, got woken up at 05:30 by my 4 year old son, by 6am I was ready to go.

Lessons learned:

1.  Eating a banana and a pack of gummy bears before the run I thought I would be safe to run right away, but even with a banana I think it's better to wait 1/2 hour.

2.  I played soccer 2 days before and had a knock on my quad, no big deal at all.  But after 5 miles every little injury is a big deal.

3.  There are a lot of old people going for walks at 6am.  Normally I get motivated seeing other runners or people being active.  Instead I felt myself saying "Ahh, that's a good life I could get used to...".  Not exactly motivating me to run faster.

4.  In the dark you need to be more careful.  I stepped into two little potholes before learning this one.  Another thing to be very aware of is that your watch is hard to read.  My pace was all over the place, it made me realize how much I rely on my watch to monitor pace.

5.  On the contrary, the sunrise in Seattle can be pretty awesome.  Kept my attention for the second half of the run.

Read more...

Capturing window "close" action

>> Friday, August 27, 2010

I was presented with the task of capturing the event in which one of our users would hit the close browser button (you know, that little 'x' on the top right).  The business wanted me to give a warning to the user that his information was still not saved yet.

  I remembered a solution I did a couple of years ago where I simply added a before unload event to my body and some simple Javascript:

     
This works great... in IE, not in Firefox or Chrome though.  The problem is that IE tracks the clientY mouse position and the other browsers don't, so a different solution was needed.  I got some snippets off of the web for tracking mouse position and came up with this cross-browser solution and it works great. First, add the following Javascript to your page:
    


    

Next, add the following form to your page, this simply stores the mouse coordinates, you could use the var values, but I liked having these to debug and see what's happening.
   

That's it! Now you can warn users using any browser that they still have unsaved work. You will still need to monitor whether the page is dirty, etc, but this allows you to at least capture the event.

Read more...

Backup sensitive file information using Amazon's S3 cloud

>> Monday, August 9, 2010

Everyone please answer the following questions honestly:

1. Do you store all your digital pictures on your home computer's hard drive, and do you have backups if the hard drive got corrupted?

Would your data be safe? Do you have duplicate media?

2. What if your entire house burned down? (hopefully this will never be the case!)

I have backups, and the HD backup sits about 2 feet from my computer, so I realized that if my house burned down, I could not retrieve my photos.

There are a few options, what I like to call "The Ghetto" backup, which would entail me giving my backup HD to a friend, but guess what? Then I lose access to that and it can easily be outdated.

There are some very good backup services, but they run $50 year, still good to have though.

I opted for Amazon's S3 cloud services, here is their pricing, considering I've got about 10 Gig of pictures, I'm only out about $20/year.

It's honestly pretty rudimentary, they don't really have a great interface, you are left using REST/SOAP calls for advanced handling. That is until I discovered the S3Fox Firefox plugin which makes things a breeze!

Now I have my pictures backed up, and another cool feature is that if I am away from my computer, I still have full access to all my original photos. See the screenshot below, real easy...

Read more...

Authentication sharing between diverse .Net apps

>> Saturday, July 24, 2010

I work at a company that has a .Net WebForms app on .Net 3.5. Pretty standard stuff, but from that we would like to link a .Net MVC app, and already be authenticated (We have WebForm authentication in the original Webforms app).

I thought this would be a pretty frequent scenario, but Google tells me otherwise, so I thought I would post on how to "git-r-done".

There are a few ways to do this, I chose a pretty simple, yet effective method. First off, copy your Authentication method section from your parent app into the child web.config. Exactly as is, no changes.

   
      
      
   
You will also need to share a machine key between the two applications, this is the insurance that the apps can share authentication. Simply add a MachineKey to your web config:


That's all there is to it, now you can simply link the child app from the parent app and authentication will be passed and not required again, pretty cool!

There is one more thing that is key. Web.config settings are inherited by default. The way around that is easy as well. Simply wrap your System.web section in the parent web.config with the location tag and the "inheritInChildApplications" attribute.

    
           ....
    
  

So there it is! I have a complete separate MVC app sharing authentication behind the scenes with a legacy webforms app, took a while to figure out these little trick so thought I would share.

Read more...

Lance Bullit and Windows 3.1

>> Friday, April 30, 2010

My parents visited recently and brought me a historic gem, a "movie" that I made with some friends 20 years ago. We got our teenage hands on a Hi-8 video camera and the rest is history.

The name of the movie is Lance Bullit, here it is:




Notables:

  • The word processor in the office scene is a predecessor to Word Perfect. It was freeware and I think I was running on a hacked copy of Windows 3.1
  • The sound of the fire in the car explosion scene is actually velcro
  • The bandages in the hospital scene is really TP
  • Dave plays two characters in the movie, and both have masks
  • 2 men jump through the door to assault Lance (that was purposely left in when editing), but Lance only refers to a "thug" *blooper
  • If you listen closely, you can hear Mike counting 3, 2, 1 in the office scene.
Enjoy!

Read more...

Viewing Powerpoint documents from Silverlight 3.0

>> Friday, March 19, 2010

I recently had a request to create a link to a User Guide for one of our products. "Great" I said, expecting an HTML page, or some text I could put into a Silverlight page.

What I got was a 10 page Powerpoint presentation with graphics. Silverlight 3 can't natively show a PPT file, so how could I do this?

First, I decided to create a "User Guide" hyperlink that would bring me out of Silverlight, and into an aspx page, here is the click event:

Uri SourceUri = new Uri(HtmlPage.Document.DocumentUri, Application.Current.Host.Source.ToString().Substring(0, Application.Current.Host.Source.ToString().IndexOf("ClientBin") - 1) + "/MSEUserGuide.aspx");
      HtmlPage.Window.Navigate(SourceUri, "_blank"); 
Next, I would use the ASP.net AJAX SlideShow control, Joe Stagner has a nice video tutorial on using the control that I found helpful.

This required a webservice with a list of images, but how to get the images from a PPT file?  Easy.  Open up the PPT file and choose "Save As" with your favourite image type.  I chose .gif and voila - 10 images nicely numbered from 1 to 10.  I then created a webservice to read in the images:
[WebMethod]
    public AjaxControlToolkit.Slide[] GetSlides()
    {
      List slides = new List();

      for (int i = 1; i <= 10; i++)
      {
        string fileName = string.Format("PowerPoint/Slide{0}.GIF", i.ToString());
        slides.Add(new AjaxControlToolkit.Slide(fileName, string.Format("Slide {0}", i.ToString()), string.Format("Slide {0}", i.ToString())));
      }

      return slides.ToArray();
    }
  }
Finally, here is the XAML code from my MSEUserGuide.aspx page (this is the newly created page I navigate to from the click even):
  


That's it! Seems like a complex way to show a simple PPT, but it was pretty quick to create and now you don't have to deal with the document any more which in my opinion is an advantage.

Alternatives to this would be to purchase a 3rd Party product to display the native PPT, or to wait for Silverlight 4 which I believe simplifies this.

Read more...

Meal preparation in the 21st century

>> Tuesday, February 23, 2010

Working at Microsoft, I'm seeing an interesting work culture/phenomenon that I've now adopted.

Rather than go out to lunch with folks (getting off campus would involve driving), apart from eating in the MS cafeteria, 80% of the folks here eat at their desk.

Remember the days when you actually prepared a meal from scratch?  Reheating that would be gourmet compared to what some of the folks eat here (myself included).  I actually saw one of my team workers eat 6 slices of white bread for lunch (nothing else - and yes, I counted 6 slices).

I think my favourite lazy observation has got to be the microwave dinners.  They are so easy to prepare, one of the instructions on my dinner said heat on high for 3 minutes, return, stir, then heat for another minute and let sit for one more minute.  Five minutes and you are all set!  Unless you do what a lazy programmer would do and heat on high for 5 minutes straight, burn your mouth, and complain that the prep instructions are too involved.

Welcome to the 21st century...

Read more...

  © Blogger templates Sunset by Ourblogtemplates.com 2008

Back to TOP