Sugru is waterproof, heat- and cold-resistant, durable, flexible, shock-resistant, and electrically insulating up to 24 volts. It bonds to glass, ceramic, wood, metal, and most plastics. It can also bond to walls and safely hold 4.4 pounds.
Promising review: "This is the greatest product EVER — it lives up to all hype. I used it to repair the bands on several IRREPLACEABLE glass rings. Not only is it rubbery enough to make a comfortable fit and sticky enough to bond to glass, but its many colors made matching a breeze! I’ve already used it to repair broken earbuds, place nearly invisible hooks everywhere so chargers don’t get tangled up in my iRobot vacuum, and even used it to make hanging loops on jars so I could put my collection of completely random tillandsia gardens on the wall! I couldn’t recommend more highly." —Fawn Force
Get an eight-pack from Amazon for $15.97+ (available in seven colors).