I just noticed that Discourse has a new feature "show copy button on codeblocks".
-
Hover with your mouse over the codebox, and the copy button will appear in the upper right corner of the codebox:
-
Click the copy button to copy the text of the codebox into your clipboard:
-
Paste text at desired destination