First off, a word of caution. This technique will not work for areas larger than about a square inch. This is for small, unsightly imperfections that detract from an otherwise good looking carpet. Also, it is highly advisable to attempt to remove a stain with stain remover first before attempting this fix.
I recently helped a friend move into a new place and there were a couple of burn marks in the living room carpet which I fixed and have documented one such fix here. The supplies you will need are as follows:
1) Small piece of extra carpet that matches the area to be fixed. I was fortunate to have extra carpet available from installation. If you are ever installing new carpet, always keep some scarps! If you don't have this good fortune you can use a utility knife to remove small bit of carpet from a hidden location such as a corner inside the closet or something.
2) A utility knife
3) A pair of scissors
4) Carpet stain remover spray
5) A scrub brush. Note that the bristles on the brush MUST be plain white (or in other words, have no colored dyes). If you use a brush with a stripe of blue, green, or whatever colored bristles you are very likely to stain that area of the rug that you scrub as some of the dye.
6) Super glue (I have used super glue for my demonstration and have had no issues in my experience. However, a better alternative as suggested by Tisu Tinker would be to use a silicone or latex based adhesive which can be purchased at any good hardware store. As Tisu explains in the comment section, super glue dries hard and can leave crunchy bits on the carpet around the fix if you are not very careful in making sure to keep it only on the back side of the plug. Silicone and latex adhesives are more rubbery and forgiving in this manner. Another point he made is that some carpets contain synthetics which can be partially dissolved by the solvent in the super glue. I haven't experienced any issue of this sort with carpet but I have definitely see the effect when using super glue on plastic pieces. In summary, either be very careful in making sure that your super glue does not get on your carpet fibers or use a more forgiving silicone or latex adhesive. Thanks for the great feedback Tisu! It seems to me that hot glue may also be another reasonable adhesive to use. I will try using one of these on my next fix!)
7) Paper towels
Of course I take no responsibility for any damages you cause by using these instructions. However, the process is very simple as you will see and gives outstanding results in my experience. Let's get started!