Monday, November 30, 2009

Path from where a user control was loaded (ASCX)

Here is the code to retreive the path from where a user control (ASCX) was loaded.

protected string GetLoadDirectory()
{
    string controlPath = this.ResolveUrl(this.AppRelativeVirtualPath);
    if (string.IsNullOrEmpty(controlPath) == false)
    {
        int indexOfLastSlash = controlPath.LastIndexOf("/");
        controlPath = controlPath.Substring(0, indexOfLastSlash + 1);
    }
    return controlPath;
}

CSS box model

Two useful graphics that I found in my trolling about the box-model used in CSS

clip_image001

clip_image002

Thursday, November 19, 2009

Do math in your head

A nice little wiki with some short-cuts on how to perform some simple math calculations mentally.

howto.Wired.com

http://howto.wired.com/wiki/Do_Speedy_Math_in_Your_Head

Leaving yourself a message on Google Voice

Why? Well because you could leave a note to self and it will be automatically transcribed and available in your mailbox for searching, archiving, forwarding, etc.

Whats the problem now? When you call your Google Voice number from a registered cell number – you are automatically taken to the administrator's voice prompts menu. No way to leave yourself a message by default.

Workaround: Simple really. Go to Google Voice settings. Click on the Phones Tab. Click Edit on the cell phone number you use to forward calls to when your Google Voice number is called.

image

Click on “Show Advanced Settings” 

image

Set Voicemail Access to “No”. (by default this is set to Yes for mobile phones).

image

Now when you call your cell – you will be presented the same greeting that all callers are presented. You can leave a message to yourself. And if you want to access the administration menu – just press the * button. (This doesnt bother me too much – because I mainly use the website to access my voice mails).

Extra tip

You can also create a contact for yourself and setup the contact information so that when you call from that phone, you will be directly forwarded to your voicemail. I think this makes it a lot more quicker to get to the point where you can leave yourself a message (fewer rings).

Steps:

Click on contacts in the left bar. (If you dont have one for yourself, create it)
Select the contact.
Click on Edit Google Voice Settings
Under the heading “When this contact calls you:” click Edit.
Select the option “Send to Voicemail”

Free LIDAR training from ESRI

ESRI is offering its online LIDAR training for ArcGIS for free. Check it out at - http://training.esri.com/acb2000/showdetl.cfm?DID=6&Product_ID=945

The overview on page states:

This seminar introduces lidar in general, discusses how to manage lidar data using ArcGIS, and also addresses the needs of those who would like to know the benefits of using lidar data in ArcGIS.

Lidar datasets are massive and contain three-dimensional spatial information about features such as buildings, trees, power lines, etc. Lidar datasets are raw point cloud formats that are not easily interpreted. ArcGIS Spatial Analyst and ArcGIS 3D Analyst provide the functionality and tools you need to represent and extract feature information from lidar data.

The presenter will discuss:

  • Introduction to lidar
  • Understanding and interpreting lidar data using ArcGIS
  • Lidar applications and derived products using ArcGIS

Wednesday, November 18, 2009

ASP.Net, DNN and scroll position

In ASP.Net you can use the Page.MaintainScrollPositionPostBack to setup a page so that it remembers the scrolled location the user was at after a post-back has occurred. It is extremely useful on long pages that perform a post-back.

If you want the page to remember the scroll position you set the value to true, otherwise false.

But recently on a DotNetNuke page, we found that the scroll position was being remembered on a page, even though we were setting the Page.MaintainScrollPositionPostBack to false. We tried setting this value on the Page-Load event, as well as the event that was being fired after the post-back occurred – no luck – the page scrolled position was being remembered. The page we were working on had a multi-step Wizard control and it was really annoying when you moved from a long step to a short step, as the page wouldnt end up scrolling to the top.

After some digging we found that DNN had its own code to maintain the scroll position during post-backs. This scroll position is maintained using a hidden field called “ScrollTop”. DNN has javascript code that runs during a page load, that uses the ScrollTop value to set the windows scroll position. (I have no idea why DNN has this redundant functionality – when it is already present in Asp.Net via the MaintainScrollPositionPostBack property).

Anyways, we used JQuery to work around this issue. Basically, you perform a query to get the ScrollTop element and set its value to 0. This way, when DNN’s javascript code runs, it automatically scrolls to the top.

<script type="text/javascript" src="JQuery/js-jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
  jQuery.noConflict(); //needed to remove conflict of the alias $ that is already being used by DNN
  jQuery(document).ready(function() {
      jQuery("#ScrollTop").val(0);
  });
</script>

2009 Most-Livable Bargain Markets

According to MSN.com

1. Des Moines, Iowa
2. Buffalo-Niagara Falls, N.Y.
3. Oklahoma City
4. Scranton-Wilkes-Barre, Pa.
5. Minneapolis-St. Paul, Minn./Bloomington, Minn.-Wis.
6. Little Rock-North Little Rock, Ark.
7. Ogden-Clearfield, Utah
8. Columbia, S.C.
9. Houston-Sugar Land-Baytown, Texas
10. Columbus, Ohio

http://realestate.msn.com/slideshow.aspx?cp-documentid=22334217

Tuesday, November 17, 2009

Use Google Voice for all your voice-mail needs

I love Google Voice as it provides me with a copy of the voice mail and an email with a transcript of the voice mail. I really wanted to be able to use GoogleVoice for all my voice mail needs and today I figured out how to do this and now I dont have to miss important calls while I am in a meeting.

The technology used is called conditional call forwarding. Conditional, because when people call us and the number is either busy, unavailable or unanswered, we want the caller to be forwarded to Google Voice.

I have an AT&T cellphone and here is how I did it:

activate conditional call forwarding by dial the following number (replacing the xxxxxxxxxx with your GoogleVoice number)
*004*1xxxxxxxxxx#

To disable call forwarding dial
##004#

Information for other carriers: http://www.google.com/support/forum/p/voice/thread?tid=00a93855af6943b4&hl=en

Friday, November 13, 2009

Empty Design View for User Controls

Came across a bug in Visual Studio 2008, where the design view all of a sudden turned blank. I was working on a user web-control, when the design view turned blank.

Turns out the problem was because I had added a style element to the user control. Because the user-control (ascx) is embedded into a web-page (aspx) it does not have a head section. When the designer comes across a style or link tag, it infers and generates the head tag – so as to allow the designer to display the page just like any other web-page. But sometimes the designer does not know when to exit the head section and hence the entire contents of the user-control end up inside the head section and hence the white screen of death.

The easiest solution – wrap your contents in a <div> element. It signals to the web-designer to exit the head section and enter the body section of the page. Alternatively (move the head parts to the end of the ascx document) – I think this is very hacky and like the first work-around better.

For more info read the following post - http://blogs.msdn.com/webdevtools/archive/2008/04/27/workaround-empty-design-view-for-user-controls.aspx

Wednesday, November 11, 2009

Tuesday, November 10, 2009

Using Windows 7 theme desktop background on your Mac

I have a Windows 7 laptop and my wife has a Mac.

Microsoft has some beautiful wall-papers that they provide as part of their Windows 7 theme packs.

image

My wife wanted these for her laptop too. So instead of just copying the files over to her computer, I decided to try and figure out how to let her open up themes directly on her own Mac so that she could use them.

Here are the steps:

The Windows 7 theme packs are just zip files. Unfortunately, just renaming them and then trying to unzip them on a Mac does not work. Instead what you need is the StuffIt Expander tool: Download it from: http://www.apple.com/downloads/macosx/system_disk_utilities/stuffitexpander.html

Next go over to the Microsoft Personalization Gallery: http://windows.microsoft.com/en-us/windows/downloads/personalize and download a theme to your desktop.

Screen shot 2009-11-10 at 7.06.27 PM

Go to the Applications folder and open up StuffIt Expander.
Screen shot 2009-11-10 at 7.08.13 PM

Next drag the theme file on to the StuffIt Expander window.

Screen shot 2009-11-10 at 7.08.41 PM

This will extract the files from inside the theme file onto your desktop. Browse to the folder inside containing all the wall-papers for the theme. Copy the images over to your pictures folder (or where ever you keep all your wall paper images). Thats it. you are done!

Screen shot 2009-11-10 at 7.09.12 PM Screen shot 2009-11-10 at 7.09.31 PM

One of my favorite themes is the “Bing’s Best” theme. (The thumbnails in the first image in this post are from that theme).

Enjoy!

Monday, November 09, 2009

Windows 7 – Boot from VHD – Simple as pie instructions

Here is the simplest set of instructions for setting up Windows 7 to boot from VHD.

First of – why would you want to boot from VHD – because it gives you a experimental machine which is faster than running with VirtualPC but slower than running it natively. The reason I did it is so that I could test out Visual Studio 2010, without having to muck up my machine.

Having said that remember this important piece of information: Boot from VHD is only supported by the Ultimate and Enterprise editions of Windows 7. I learnt this the hard way and wasted at least an hour trying to setup a Win7 Starter boot from VHD machine.

Step 1: Create the VHD:

  1. Go to Start –> Right Click on My Computer –> Choose Manage. This will bring up the Computer Management Window
  2. Under the Storage node –> Select Disk Management.
  3. Right click and select Create VHD
  4. Set the location and choose dynamically expanding. Choose a size of at least 15GB. (I choose 20gb). Dont worry, because it is a dynamically expanding disk, it will use only what it needs.
    image
  5. You should now have a hard-disk appear in your disk-management window
    image
  6. Right click on the newly added disk and select initialize.
  7. Leave the default options and select OK.
    The disk will not report its status as being Online.
  8. Right click on the disk again and select “New Simple Volume”
  9. Select the defaults and keep clicking through.
    On the 3rd screen, note down the drive letter the volume will be assigned
    image 
  10. On the next screen, choose a name for your volume label. Also make sure that the FileSystem selected is NTFS
    image
  11. On the next screen select Finish.
    If everything went correctly you should see something like this: (The size will be different).
    image

Step 2: Use ImageX to Setup the Windows 7 on the VHD volume:

  1. First we need to download the Windows Automated Installation Toolkit (WAIK). Get it from the download center.
    Unfortunately its a big download (1.7GB) for a small file that we will end up using.
  2. Once you install the WAIK onto your computer, you can copy out ImageX.exe to a convenient folder (like c:\). (You will find ImageX.exe in the following folder - C:\Program Files\Windows AIK\Tools\x86)
  3. You will also need the Windows 7 installer DVD. On the DVD you will find the install.wim file in the sources folder.
  4. Run the following command:
    imagex /info "d:\sources\install.wim"
    This will output a whole lot of text to the screen, and will provide you with information regarding the available images in the install.wim file.
    Two parts are important – the image index and the “EditionID”. You want the image index that corresponds to the Enterprise edition or the Ultimate edition of Win7.
  5. Now to apply the selected image to the VHD drive. (Remember we selected drive G in 1.9 above).
    imagex /apply d:\sources\install.wim 1 g:\
    The process should take about 15 minutes to complete.
    In the above command the 1 represents the 1 image index we obtained in step 4 and we are applying it to drive g – which is the VHD drive we created.
  6. Now you can disconnect the drive.
    Right click on the disk and make it go offline.
    On the dialog – make sure that the option to delete the VHD file is not selected:
    image

Step 3: Add an entry into the boot menu:

  1. This step will provide you the option to select the VHD boot drive during startup.
  2. There are multiple bcdedit commands that need to be run:
    bcdedit /copy {current} /d "Win7 on VHD"
    returns a GUID after copying the current configuration. Copy the returned GUID for use in the next few steps.
  3. run the following command
    bcdedit /set {guid} device vhd=[C:]\test.vhd
    {guid} is the GUID returned previously. vhd= points to the VHD file. The square brackets [] are needed.
  4. run the following command
    bcdedit /set {guid} osdevice vhd=[C:]\test.vhd
  5. run this final command
    bcdedit /set {guid} detecthal on
    This turns on hardware abstraction layer detection.
  6. Now restart your computer.
    After restart, you should be shown a menu with “Win7 on VHD” as an option.
    The first time you run Windows on the VHD drive, it will step you through the setup process. Keep your Win7 registration key handy, as you will need it.

And you are done!

In case you run into a problem while setting up BCDEDIT, run the following command to delete the entry and then run through the above steps to resetup the entry.
bcdedit /delete {guid} /cleanup

Sunday, November 08, 2009

Ads – the Prized Possesion

Travelers Insurance – Prized Possesion – Ad with the dog.

The Song: Ray Lamontagne – Trouble.

Monday, November 02, 2009

Video Games – Real Time Racing

Real Time Racing is developing technology that will allow for video games that will allow you to race in real-time against actual race car drivers that are competing in an actual race. The technology is very cool and it uses LIDAR to generate maps of the race-tracks (which is how I came across the game).

Its was recently show-cased on the BBC’s Click program.

http://news.bbc.co.uk/2/hi/programmes/click_online/8334595.stm

Real Time Racing

Sunday, November 01, 2009

Google Wave – Bots List

Bots are robots that provide some sort of functionality within a Google Wave. You just drag and drop them just like any other contact onto your wave and you can begin using them. The one weird thing I have found is that there does not seem to be any way to find and add them from within Google Wave. So after a little Googling here are some of the useful ones I have found:

Preview Bug: If you copy and paste the email address into your add contact dialog, Google Wave might not enable the Submit button. If this happens, just delete one of the letters and retype them and it should enable the submit button.

Added 11/01/2009

blog-wave@appspot.com - Used to interact with blog-posts in Blogger. This is a very useful bot.
image 

wikifier@appspot.com - Used to interact with Wikipedia
image 

tweety-wave@appspot.com – Used to interact with Twitter. Add new tweets or search for tweets. Very cool

image

amazon-withwaves-com@appspot.com – Retrieves information from Amazon.com.

image