What are the rules for re-using code? I'm publicly posting a document that used code verbatim from this link, and I don't know what kind of accreditation I am to give, let alone whether I am allowed to do this at all.
At present, the situation for the entire network is that all posts are subject to CC-BY-SA 3.0 as linked at the bottom of every page. That was brought in pretty early in the life of the network as a way of making sure people's contributions couldn't be taken without credit.
However, there's a problem with this for code as the license was never really meant for that use case (the license was meant for the 'text' of answers, and indeed the line between 'text' and 'code' is one of the problems with this entire thing). This has been discussed on the main meta site as the StackExchange staff are trying to 'fix' it. The situation is complicated as (particularly on StackOverflow) different users have different views on how they expect their code to be used and as licensing code is itself complex.
Here on TeX-sx we've tried to address this as the original poster of an answer can choose to 'dual license', saying 'as well as CC-BY-SA 3.0, you can also use my code under XXX'. We have a dedicated meta question on this. You can also post a comment on a question specifically asking about relicensing if that is necessary for you.
Note that in terms of copyright there is no transfer when you post to the site, so it remains with the author of material. Life gets a bit more complex when you start to look at stuff that is say modified in a answer from something in a question!