When peeling, trimming, and chopping fresh fruits or vegetables, keep a plastic bag (such as a produce bag or a plastic grocery bag) on the counter by your cutting board. Peel vegetables over the bag rather than over the trash can (haven't we all dropped a half-peeled carrot into the garbage at least once?), and toss pits or other trimmings into the bag rather than walking back and forth to the trash can.
Particularly in warmer months, and particularly with fruit, I find it helpful to tie up the bag before dropping in the garbage. That way, it takes longer to stink up the trash can and makes the trimmings less alluring and accessible to pesky fruit flies.