Playing by ear is truly an enviable skill. To be able to just hear something then play it yourself is almost like a super-power to many a musical layman. With enough time and practice I could probably develop such an ability too, but come on. I got too many ice cream and animal dating games to write about already.
So I rely on computers to do it for me. There are a variety of software applications on desktop computers that can take a song and at least attempt to break it down into its components, but they can be rather complicated and difficult to use. Now Casio has come out with an iOS app called Chordana Viewer that can reverse engineer songs right on your Apple device for piano or guitar.