Well, the thing thing that is happening when you scrub or scuff your feet on the carpet is you are stripping electrons off the carpet and building a negative static charge in your body. This static charge will discharge by emitting a tiny electrical spark when you reach out to touch something made of metal, such as a door knob. This is a mini-version of what happens during a thunderstorm, there is a separation of charges in the thunderclouds, and when the charge exceeds the gap potential between the bottom of the cloud and the ground, the charge is discharged to the ground in the form of lightning. The static charge built up in your body is much weaker, of course, but it makes for great entertainment when you sneak up on your friends and "zap" them. The charge is much easier to create on days when the relative humidity is low, as the water vapor in the air causes the charge to "bleed" away from your body, making it harder to store.