Last active
March 20, 2019 20:36
-
-
Save pbzona/793642744b684f60a4aa80edbdeba2a0 to your computer and use it in GitHub Desktop.
self.discipline()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
number_of_args = len(sys.argv) | |
f = open("/etc/hosts", "a+") | |
for i in range(number_of_args - 1): | |
f.write("127.0.0.1 %s\n" % sys.argv[i + 1]) | |
# To use: | |
# 1. Add this code to a file | |
# 2. Make executable: `chmod +x your-file-name` | |
# 3. Run as sudo and provide all sites you want to block | |
# as space separated arguments | |
# e.g. `sudo ./modify_hosts twitter.com facebook.com reddit.com` | |
# To disable: | |
# 1. Manually edit /etc/hosts and comment out the lines that include | |
# the hostnames you provided in the setup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment