They violate the attribution rule on
SO's CC-BY-SA. Question would be fine if they removed the first snippet or provided proper attribution
and tell that it's only for motivation. IIUC, the other snippet doesn't work correctly yet, though, so the whole thing might be off-topic either way.