Stoping it at a code level isn't possible. What you can do, what I do with my own published works, search for long phrases from the work and see what hits. That will turn the copy cats up sooner or later. Incidently, Google does this themselves and SEO deranks sites that share large amounts of text with another site. So even if they do copy you, they won't beat you on search rankings. You'll also have legal recourse such as a DMCA takedown notice.
And no matter how narrow your writing, someone, somewhere will plagiarize it eventually. It's just the nature of the beast. If that isn't acceptable you'll need to keep it to yourself.