Github's ToS codify the inbound=outbound license principle: contributions to a repository can be assumed to be under the repository's license. However:
- The repository needs to have an obvious license.
- The user must have intended for their contributions to be included into the repository, for example by creating a pull request and/or uploading their changes under that license to their fork of the repository.
- This cannot apply retroactively: what is relevant is the license at the time the pull request was made, not the current license of the repository. If in doubt, check out the commit in question and inspect the tree for any license notices.
Whether issue comments are a contribution in this sense is more tricky, because an issue creator might not have intended to have their issues included under the repository licensed. I would argue that a repository license cannot extend to issues. To determine the license status of a code snippet, you would have to look at context. If it is intended as a contribution, then this may be fine. But in the general case you should assume that all rights are reserved.
There's also the question whether short code snippets are copyrightable at all: copyrightable works must meet some threshold of creativity to be eligible for protection. This threshold is not clear: there is no fixed number of lines before copyright starts to apply. Typo corrections, small fixes, modifications of existing code, and representations of facts can often indicate that these snippets are not copyrightable. For example, a minimal test case to reproduce some bug might not be a creative work but a fact, and therefore ineligible for copyright protection. But again: it's important to look at the context.