Code Monkey home page Code Monkey logo

host-blocker's Introduction

Host Blocker

A super simple script to uncomment entries in your hosts file.

Why?

I spend a lot of time editing domains from my hosts file: mostly to block sites that are distracting (facebook, youtube, reddit, etc). Occasionally however, I need to unblock a site (e.g., to look up a friend's contact info on Facebook) -- I do this by commenting out the line in the hosts file.

This script re-blocks domains by uncommenting existing entries.

There's no unblocking script -- if I want to unblock a distraction, I still have to do it manually.

Usage

sudo ./blocker.rb facebook.com

This will search your hosts file, find any commented line matching facebook.com or www.facebook.com, and uncomment that line. It will also print out a report of the number of lines blocked.

Note: on Ubuntu, the hosts file is at /etc/hosts, so you may need to edit that manually.

TODO

  1. Allow multiple domain name arguments to be passed
  2. Append mode: if a domain name isn't in the hosts file already, append to it.
  3. Auto detection of location of hosts file based on OS.

host-blocker's People

Contributors

sherwinyu avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.