Rub a thin layer of corn syrup around the rim of the glass then immediately roll it in the sugar, sprinkles, or whatever. For rims that aren't sweet use a thin layer of raw egg white and roll in salt crytals or pretzel crumbs.