Thursday, June 30, 2011

How to change the Gateway Metric on Windows 7

If there are multiple physical adapters present in the network, Windows 7 will always look at and compare the indices of gateway metric among the physical adapters and then pick the one with the lowest index to use. In order to override the default settings, you need to adjust the index of gateway metric for each physical adapter. The adapter assigned with the lowest index will always take precedence and used by Windows 7 automatically. For instance, if you want to use the wired connection when both wired and wireless are available in your network. You need to assign the lower gateway metric index to your LAN card so that you can ensure that your favorite adapter will be used by Windows 7 whenever it is available. In my previous post, I mentioned how to use route change command to adjust gateway metric index. In this post, I will present you an easy way to do it without going to the command prompt.

  • Open Network Connection from Network and Sharing Center. Or type ncpa.cpl in the search box at your Windows Explorer or Start menu.
  • Select your favorite connection, e.g., Local Area Connection and then right click to select Properties.
  • In the Networking tab, select the Internet protocol version, e.g., Internet Protocol Version 4 (TCP/IPv4).
  • And then click Properties button.
  • In protocol Properties dialog box, click Advanced....
  • Inside the Advanced TCP/IP Settings, at the IP Settings tab, click Add... of the Default gateways.
  • Uncheck the Automatic metic checkbox, and then enter your router IP (e.g. and assign your metric index. Click Add to insert the entry.

    Default Gateway Settings
  • Click all OK's to exit.

The changes will immediately take effect. If you check your route table after changes (using route print command), you'll find a new entry in the Persistent Routes.

Persistent Routes:
  Network Address          Netmask  Gateway Address  Metric

Regardless of the IP address obtained automatically or statically, changing gateway metric can be done via either route change command or network connection GUI (ncpa.cpl).

When you use route print to verify your settings, the metric indices usually will double the number you enter.

Use netsh int ip show config will show the exact settings you will find in the network connection properties.

I hope you'll find this information useful to you.

Wednesday, June 29, 2011

Forcing Windows 7 to use wired when available

For unknown reason, Windows 7 prefers using wireless connection over wired. In order to force Windows 7 to use the wired connection when available, you need to adjust the setting of gateway metric among network adapters. A lot of posts found online recommended to do it via via Network Connection (ncpa.cpl) by unchecking Automatic metric checkbox and manually setting Interface metric on each network adapter. Unfortunately, this only updates interface metric, not gateway metric. Thus, it won't have any effect on Windows 7 and the problem persists.

You can type the following command at the command prompt for the detail of your network adapter settings [see example]:

netsh int ip show config

Or type the following for the settings of the route table. In this command, the metric column is only for gateway metric. [see example]

route print

To change gateway metric, there are two options. First is to use route change command at the command prompt. For example,

route change mask metric 20 if 13


  • is the target network destination (IP address) found in route table.

  • mask is the subnet mask associated with the target network destination.

  • is the IP address of the gateway, my router.

  • metric 20 is setting gateway metric to 20. The network interface with a lower metric takes precedence. In this example, I am assigning 20 to my wired network card, which receives the lowest gateway metric. It enforces Windows 7 to use the wired whenever it is available. Also see KB299540.

  • if 13 means to apply the changes only to the network interface index equivalent to 13. In this example, 13 is my Intel(R) 82577LM Gigabit Network Connection that can be found in the Interface List section of route print.

There is no need to log out or reboot. The changes should take effect immediately.

The second option presented in my next post may be the preferable way, especially if you don't want to execute any command. Go and see my next how-to.

The meaning of metric numbers, see KB299540.
How to use Route Command.

Example of netsh int ip show config

Configuration for interface "Wireless Network Connection"
    DHCP enabled:                         Yes
    IP Address:                 
    Subnet Prefix:               (mask
    Default Gateway:            
Gateway Metric: 25 InterfaceMetric: 50
DNS servers configured through DHCP: ... ... Register with which suffix: Primary only WINS servers configured through DHCP: None Configuration for interface "Local Area Connection" DHCP enabled: No IP Address: Subnet Prefix: (mask Default Gateway:
Gateway Metric: 256 InterfaceMetric: 20
Statically Configured DNS Servers: ... Register with which suffix: Primary only Statically Configured WINS Servers: None ...

Example of route print

The column of Metric in the section of IPv4 Route Table is gateway metric.

Interface List
 13...5c 26 0a 23 40 d5 ......Intel(R) 82577LM Gigabit Network Connection
 14...00 24 d7 6c a6 fc ......Intel(R) Centrino(R) Ultimate-N 6300 AGN
 15...00 24 d7 6c a6 fd ......Microsoft Virtual WiFi Miniport Adapter
 10...5c ac 4c fd 7b 5e ......Bluetooth Device (Personal Area Network)
 16...00 50 56 c0 00 01 ......VMware Virtual Ethernet Adapter for VMnet1
 17...00 50 56 c0 00 08 ......VMware Virtual Ethernet Adapter for VMnet8
  1...........................Software Loopback Interface 1

IPv4 Route Table
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric 266 50 On-link 306 On-link 306 On-link 306 On-link 266 On-link 281 On-link 281 ... ... ... ... ...

Monday, June 20, 2011

How to attach CKEditor keyup event

My current version: CKEditor 3.6

  editor.document.on('keyup', function(evt){...});

I am trying to attach a keyup event to CKEditor. Unfortunately, it doesn't fire as soon as the setData() is being called.

It turns out that the editor.document is recreated every time setData() is called and thus all the events attached to the editor.document will be gone forever. Re-attaching the event to the editor.document is necessary. Luckily, setData() supports callback.

  editor.setData('set some data', function(evt) {
    editor.document.on('keyup', myKeyupEvent);

I don't understand why CKEditor won't support keyup event in editor.on. You can't do this:

err editor.on('keyup', function(evt){...});

But for keypress or keydown event, you can do this:

  editor.on('key', function(evt){...});

There isn't much details about the CKEditor event. Their API isn't helpful either. Reading through the event API, I still have no idea when I should be able to use editor.on to attach events and when I should use editor.document.on.

What I understand is that editor.on is good for custom events. You write your own event, hook it up and then fire it up yourself as needed. The events registered by editor.on will not be removed after setData() has been called. It means that there is no need to re-attach the event even though the editor.document is re-created.

For events registered by editor.document.on, they support all existing defined events as long as you provide a event handler for them. The drawback is that the event handler requires registration again after editor.document has been recreated.

Currently, I have no custom events to be defined; thus, I found editor.document.on more useful than editor.on. I can hook as many events I want without restrictions.

Wednesday, June 8, 2011

Posting an Ad to Craigslist now becomes more difficult or frustrated

I haven't posted and purchased anything from or to Craigslist for a very long time. On my mind, Craigslist was a great service for local people to get good deals. Unfortunately, a lot of innocent people got spammed; sadly stories happened one after another. A few years ago Craigslist started implementing posting verification by forcing people who post classified ads to the USA or Canada for phone verification. And each successful verified phone number is good for 90 days. To consumers, it is a good thing; it certainly eliminates a lot of spammers, especially the ones from oversea. However, this control along with others makes a lot legitimate posters (like marketers) extremely inconvenience. A lot of them look for and turn to other alternatives such as,, and etc. Sadly the alternatives traffic is still not as much as Craigslist.

I am not a marketer but sometimes I may have things for sale or giving away, like everyone else. The first service pops to my mind is Craigslist. I was trying to post an ad since yesterday morning without success. None of my phones could be verified.

First, I was trying to use magic jack phone number for verification. It turns out that Craigslist won't accept any VoIP phone. It means I cannot use Magic Jack for verification. Then I entered my cell phone number. Unfortunately, the page kept sayingYou are submitting telephone verification requests too rapidly. To prevent abuse, we require users to wait 5 minutes between requests, use no more than 3 telephone numbers in a 12 hour period, and not use any single phone number more than 3 times in a 12 hour period. Please wait and try again later.” At first, I believed in the error message. But after having waited for a few hours and then tried again, I concluded that something must have gone wrong. Reporting an error to Craigslist is no use. I received the same explanation that I could find in their phone authentication help page. What could I do? So I put this aside for the day and tried again in this morning. The same error message re-appeared. It was more than 12 hours waiting period. I cannot believe that I still received the same error. It implies that their phone verification service is not reliable. It could be why it frustrates a lot of marketers, besides other issues.

Craigslist phone verification process is even more difficult to follow than using a ATM card at an ATM machine when you're trying to remember your passcord. For ATM, at least I could try 3 times physically. For Craigslist phone verification service, the 3 times attempts are very easily to exceed without your knowledge.

You cannot refresh the page or use the same URL to another browser window/tab. If you do, it will count once because the page itself will remember your previous phone number. I am not talking about the browser cache. It is nothing related to it. Your URL is tied to your email address. When you enter a phone number, it will automatically tie it to that phone number as well. It is done in the craigslist backend server, not from the browser. Thus, if you have an issue on this, don't refresh, or cut-and-paste the URL to another browser to try again. You will quickly lose your two counts. Unfortunately, my issue is not related to this.

In order to resolve this issue, I decide to sign up an account with Craigslist. From there, it automatically detected a problem saying “There is already an account associated with this email address.” and offered me a chance to reset my password. I have never signed up an account with Craigslist, so I guess it could be a temporary account for non-registered user when I tried to post an ad. Obviously such a temporary account is required for their phone verification service. I followed the link to request password reset. Then I received an instant email for password reset. I finally have my password reset and registered an account with Craigslist.

Having an account with Craigslist doesn't mean I exempt for phone verification when I post an classified ad. To me, this password reset or the registration process cleared all errors including every single field of my phone number stored in their back-end server. From that onward, I could re-enter my cell phone number for verification to the page. Unfortunately, my request was expecting a text message / SMS from Craigslist but somehow Craigslist failed to deliver. When I went to check the sending code status, it indicated that “the call has been placed.” Call? I was requesting a text message, not a call! So I waited for another 5 or more minutes and then placed a request for a voice message instead of text. My cell phone rang as soon as I hit the "send the code!" button. My ad was finally posted.

This whole verification process with Craigslist negates my impression with them. I hope that Craigslist will improve this process. When the alternatives begin improving their traffic, people may leave Craigslist if this verification process is still a headache. Right now, Craigslist still holds a solid position in the market place.

Monday, June 6, 2011

Passed 70-515

As of today, I am certified for ASP.NET 4.0.

Learning from my previous experience, yesterday I drove to the test center and checked it out first. I don't understand why the same test center keeps moving from place to place! Every time I take an exam with them, they move. This time I ensure I know how to get there so everything was smooth. As usual, I was there an hour ahead and waiting outside for the time came.

There are 51 questions in total for 2.5 hours. I finished them about 1.75 hours. I am happy with my score. I could miss 1 or 2 questions. That's. My score is 970 out of 1000. The passing mark for this test is still at 700.

For some reason, I feel 4.0 is a lot easier than 3.5. But I am surprised to be tested by some jQuery questions. There were at least 4 questions in my test. Frankly, I don't find them related to ASP.NET. To me, it doesn't make any sense to have them in the test. jQuery is not mentioned in MS testing objective. Why am I being tested with jQuery syntax? Luckily I use jQuery and am able to answer them. Otherwise, it could be doomed. Besides MVC 2 and dynamic data stuff, I don't see any new stuff in the test. If you know 3.5 (including SP1) well and put some effort to learn more about MVC 2 and dynamic data, for sure you will be ready for the test.

Good luck to everyone who is preparing or going to take this test!