Exclude Categories from Posts page

Some users would like to exclude certain categories from the posts page. This can be done with the following PHP snippet:

add_filter('pre_get_posts', 'excludeCat');
function excludeCat($query) {
      if ( $query->is_home ) {
            $query->set('cat', '-3,-5,-23');
      return $query;

Simply add your category IDs in there instead of the 3, 5 and 23 (examples) and keep the minuses in there.