Like the OP, I'm using StayFocusd and I've used RescueTime in the past, and it's actually been very helpful for me. Right now I've given up Facebook and I'm tackling Reddit next. I don't have a solution for my phone, but it hasn't been a problem for me because I leave it charging across the room when I'm working. It's still difficult for me during evenings, but I'll probably try something similar for that soon.
I then started using the pomodoro technique, with strict no IM/FB/etc during pomodoros. A nice side benefit of disciplining myself to work in this way was to reduce the impulsive desire to check FB, and over time I noticed that my desire to go onto FB, even when it was "permitted", had been reduced. I don't have StayFocusd or any such plugins installed any longer.