How do you stop reading the internet when you need to work?
there: use virtual desktops (or spaces or whatever it's called on mac os).  put your web browser in one workspace, your e-mail/im client in another, and your coding environment in another.  work in only the coding workspace with no other apps showing.  if you're working on a web app, open a new browser window, hide your bookmarks bar, and drag it to your coding workspace.use things like growl notifications to alert you of instant messages and new e-mails.  that way you can remain in your coding window and quickly glance at what that little chime was just for.  if it's an important message, switch and take care of it (or don't).  if not, ignore it.  this way you aren't forced to switch workspaces and interrupt your work every time something comes in that you hope might be more fun than your current problem at hand.