Basically you should only have to cut one side (one of the wires in the extension cord). Use a pocket knife or utility knife and split the two wires apart around the center of the cord over a 1' section, pick one of the two and cut it in the middle of the length seperated from the other wire, and feed it into the electrical box through a romex type knock out. (Little "D" shaped peices of metal with a slot cut in them that you just stick a screw driver in the slot and pry and twist and it should snap off.)
Depending on what you see on the back of the dimmer switch follow option A if brass screw terminals are seen and option B if 3 color coded wires are hanging out of the back of the dimmer.
(option A)Then the one wire you cut should be stripped and go on the two brass colored terminals. They may be marked supply and load or something similar. If they are the side of the cord going to the pronged plug is supply and the side with the female part of the plug is the load. Don't worry about the ground screw as what you are making is a plug in device instead of a fixed device, so the electrical code requiring the grounding of dimmer switches do not apply to your application.
(Option B)If you have wires hanging out of the back instead of screw terminals they should be color coded Black, Red, and Green. Tie the Black to the prong side wire and wire nut it together (Orange Wire nut) by screwing the wire nut down on the two wires twisted together. Then the female plug side goes to the red wire and again put a wire nut (Orange wire nut) on it. Then cut the green wire just so the factory stripped section is gone and try to put a wire nut on it, if a wire nut will not go on it just wrap it up in elecrical tape.
In the inside back of the box should be some sort of screw with a piece of metal that you screw the screw down and it clamps down on the wire and holds it in place. Use it!
Then mount the dimmer to the box using the screws on the top and bottom and put the face plate on.
Test it out on a lamp or something to make sure it is working correctly.
Hope this helps! I could be a lot clearer with pictures, but I don't have them.