What counts as self-plagiarism?
Cite your online reference, just as you would cite some other online reference.  In neither case is it plagiarism, because you're citing it.  And in the case of your own online work, you can take credit for it as if it were not cited, as long as this work does not appear previously to when you published online.