I have read several questions (1, 2, 3, 4) on how one should or could give attribution to SO. In some cases, attribution is expected for professional reasons. I'm going to focus on attribution for code (or mathematics proofs, which are similarly concise and verifiable intellectual contributions). There are two issues I am not clear on (NB: see update 2 below to clarify the relationship between these two issues):
Which link and author should one cite? When one has benefited from code, and it is presented in just one answer (or in a question), it seems attribution should be given to the relevant poster. If the results are drawn from multiple posts for the same question, it seems that one might just give attribution to Stack Overflow; this can be especially true when there are multiple edits, meaningless usernames, and so on.
What is the impact of the Creative Commons (CC BY-SA) license in regard to attribution and the release of code derived from SO posts? I have not found what it means to satisfy that requirement. It's a great idea, except that it seems it doesn't actually specify what is valid attribution. In fact, it seems to say that it must be done in a way specified by the licensor. Is the licensor StackExchange or the authors of posts? I can't possibly expect that each and every author will specify how they should be attributed, so is there some standard for SE's expected attribution?
---- Update 1: Jeff Atwood has listed some of the requirements for #2, though these appear to pertain only to online citations, rather than for more formal publications.
Update 2: As Robert Harvey has pointed out in his answer, attribution requirements appear fairly straightforward. However, I wasn't precise. This example citation uses just the author of the post, though the first part of my question is related to multi-author insights. If the code is presented by / derived from 3+ authors, it seems that one link to the question should suffice and the authorship could be "Smith, John et al.", and the URL is that of the question. Or should it reference all of the relevant links. That seems unwieldy and not very natural.
The second part of my question relates to the CC aspect. The contrast with the first is that the first part is about professional expectations and relates to multi-author results. The second part is about what does CC require. If it is less than professional expectations (i.e. Jeff & Co. set the standard), then resolving part 1 is adequate. If, however, full listing of each and every poster is expected, then that may exceed what typical citation practices, but it is perfectly permissible according to CC. I'm happy to oblige whichever standard is more stringent.
Critical point: Note that this only becomes interesting if there are multiple authors/editors/sources involved. For the single reference, I think both standard reference requirements and those stated by Jeff are in agreement. So, my apologies for being imprecise.
Update 3: Imagine this scenario: the OP plus answerers A1, A2, ..., An provide interesting insights that I use for code. If editors E1, E2, ..., Ek are also involved (e.g. in editing the OP's question or some of the answers), then what is appropriate per both standard citation rules and CC BY-SA? Further, if the OP doesn't contribute anything that I use, but there are a several answer posts that are useful, whom do I cite? Do I still cite the OP? They initiated and "edit" the Q&A by their selection of the official answer and the official question. I realize this may be uncharted territory, but I like to be ethical and rigorous, especially in regard to those whose efforts I value. (By the way, I'm not likely to cite myself. That could be recursion, which I hate.)