Back in 1987, at Amogla camp, when our electrician was wiring up a septic pump he used a flat switch, which had this cord on it with a plug and socket combination at the end. He wired the switch straight into the box, so he cut this part off. I figured this cord could be very useful for switching things on and off, and he let me have it.
I put a manual switch on the end of it, and this cord has proved to be very useful. I used it every time I built a new machine, to turn the motor on and off.
This remote switch is so handy that I figured I should make another like it, except I don't have another one of those cords with the funny plug/socket at the end. So I wired it up using standard house wiring electrical boxes. I used a wall socket, a light switch, two surface mount electrical boxes, and some old power cords for the wires.
This is how it's wired up. The power cord connects to the socket in the box, but with the "hot", side of the socket going to another box with the switch in it first. The ground leads are for safety, and are all connected together.
North American sockets are polarized, the larger slot is neutral (basically at "ground" voltage), the other slot is for "hot".
You can swap hot and neutral, or switch neutral instead of "hot" and everything will still work. Appliances don't rely on the polarity to be correct, but they are always wired so that the "hot" side is switched. For example, a lamp socket will always be wired so that the outside thread part is on neutral, and the center connection (deep in the socket) is the "hot" side and is switched, to minimize the chance of getting electrocuted when changing a light bulb.
Actually, "zapped" would be a better term than "electrocuted". "Electrocuted" implies fatal. With just 120 volts, it's highly unlikely (though not impossible) that it will kill you.
Here's the finished thing. I have the longer cord to the socket, so this is more like an extension cord.
You could just buy a switched power bar to achieve the same thing, but the switches on power bars are kind of annoying and not very good. You can also buy switched extension cords, but the switches on those also are also not very good.
And if the light switch on this were to fail, it's less than $2 to replace. That's the nice thing about regular house wiring components. They are not expensive.
This set-up, incidentally, is identical to the wiring on my 20" bandsaw, 16" bandsaw and 14" bandsaw.