If you find yourself opening Twitter every five minutes (instead of working), you might find 1Focus useful.
First, it lets you define your activities - such as "work" or "studying". For each activity, you can define a list of blocked websites and a list of blocked apps. 1Focus will block access to all items on this list.
You can set a timer for an activity. If you're going to study for 2 hours, you can set a 2 hour timer and 1Focus will automatically block your distractions for that duration.
Another option is defining a schedule for an activity. You can set a schedule of 9AM-1PM for "work" every day, and your distractions will automatically be blocked for that time.
For avoiding distractions on your Mac, you have many options. There are simple apps like SelfControl, and complicated ones like RescueTime. 1Focus covers the sweet spot between ease of use and number of features.
$8.99 - App store