Can you tell me in what context would you be using this? These kind of things are to be avoided in wordpress themes, which is why you’re getting the soft reject. Wordpress themes have a bunch of action, filter and function for this kind of reason, I guess it’s a wordpress policy if you need something, we’ll make a function for it. Reason why I personally don’t like WP, since it’s bloated to the core.
Why don’t you hook it to the wp_head action? You avoid having to manually include wp-config.php, you are sure to have access to get_categories function as well. I don’t see any reason why you would want to use this in a separate file.