I have seen several answers that I would like to add to a set of handouts or a departmentally generated text. 1) How do I get permission, or is it granted automatically by the nature of this site? 2) How do I give credit, especially if the author uses a pseudonym? 2a) Is there a way to notify an author you would like to contact them offsite without giving others (the general population) your direct contact info?
The license is set out in the "legal" link to be found in the footer of every page. It's a Creative Commons Attribution Share Alike license. I believe that the Creative Commons people feel that crediting a pseudonym covers the attribution requirement, and it is at least conceivable that a pseudonymous author may not want their real identity associated with the content.
You can attempt to contact individual authors on the site, or you can look in their profile for other contact information. You can assume that users who don't put contact info in their profiles probably don't want to be bothered. In my case you could work out my real contact info from a little digging, but I don't want to be pestered; so, please, only contact me directly for issues of import.
The re-use of all the user-provided content on this site is permitted and encouraged. If you found the answers here helpful and you want to share them with your students, then by all means do so! We only ask that you attribute the content appropriately.
More technically, the legal conditions for reuse are spelled out on the footer of every page on the site:
The specific requirements of attribution are given in the second link. Specifically, and quoting from there, you must:
Visually indicate that the content is from Stack Overflow or the Stack Exchange network in some way. It doesn't have to be obnoxious, a discreet text blurb is fine; and
Show the author names for every question and answer.
In addition, if you publish this content online, you must:
Hyperlink directly to the original question on the source site (e.g.,
Hyperlink each author name directly back to their user profile page on the source site (e.g.,
Ideally you should include the URLs also in printed content. For more details see section 3 (Subscriber Content) of the Stack Exchange Terms of Service, which is available under
legal on the footer of every page on the site.
There is an additional requirement from the CC BY-SA license, which is a bit fuzzier:
Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
This means that if you remix the content or you edit parts of it, you must do so in a way which makes that evident and which enables your audience to find the author's original version.
Regarding pseudonyms, if a user's profile allows you to personally identify them, then it is indeed nice to provide both the name they publish under and their Stack Exchange pseudonym when giving credit. If the user has not provided their name, then it is perfectly OK to simply attribute the pseudonym: the user contributed the content in the understanding that it was available to all under CC BY-SA with attribution set to the pseudonym.
If you nevertheless want to attribute someone personally, it is OK to attempt to contact them as long as you don't do so too often. The first port of call is checking whether the user is available over at the h bar, our chatroom. If they are not, a short and polite comment under the answer you want to re-use is acceptable. As D. McKee mentioned, doing minor detective work to find the real-life identity of users is generally OK, but please use a good deal of caution and do not pester users off-site!