A cabinet in the kitchen wouldn’t stay shut, so I glued a magnet to the door, and screwed a small wood screw into the frame. The most difficult part was disassembling the hard drive to get the rare earth magnet.
It works, but only just. With the door fully shut, the wood screw is a couple of millimeters farther than it should be from the magnet. Magnetic field strength being inversely proportional to the cube of the distance, a millimeter makes a difference.
Next time I’ll go to the hardware store and buy a magnetic cabinet latch. This design resulted from frustration, not planning. Still, it reuses rare earth materials; now I have two shiny disks from the hard drive; and I rediscovered the always-interesting Dan’s Data.