John Hawthorn

Work, work. Zug zug.

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.

#!/usr/bin/env ruby SiteList = %w{ } 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 << "\t#{site}" lines << "\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 = string.gsub!(/#{StartToken}.*#{EndToken}/m, '') 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.