I wrote a little script to block websites which would destract me from work.
Inspired by get-shit-done and the Orc voices from Warcraft 2.
The script can be called as either workwork or readytowork to enable the block, and workcomplete to unblock the websites.
Warning: Contains a list of websites which will waste your time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
#!/usr/bin/env ruby SiteList = %w{ reddit.com news.ycombinator.com twitter.com plus.google.com slashdot.org cracked.com vimeo.com youtube.com digg.com } StartToken = '## workwork' EndToken = "## zugzug\n" HostsFile = '/etc/hosts' ConfigFile = '~/.workwork' def disabled_sites if File.exist?(ConfigFile) open(ConfigFile).read.split("\n") else SiteList end end def workwork lines = [] lines << StartToken disabled_sites.each do |site| lines << "127.0.0.1\t#{site}" lines << "127.0.0.1\twww.#{site}" end lines << EndToken open(HostsFile, 'a+') do |file| file.write lines.join("\n") end end def workcomplete open(HostsFile, 'r+') do |file| string = file.read string.gsub!(/#{StartToken}.*#{EndToken}/m, '') file.seek(0) file.truncate(0) file.write(string) end end # switch to root since we need to change /etc/hosts if ENV["USER"] != "root" exec("sudo #{ENV['_']} #{ARGV.join(' ')}") end case File.basename($0) when 'workwork' then when 'readytowork' then workwork when 'workcomplete' then workcomplete else puts "Unknown command" end |
Now I just need a script to remove executable permissions from minecraft.