(because I googled it, and on the first page of hits I couldn’t find any copy/pasteable source for this common problem, here’s an answer with (poor) public domain source code)
(because I googled it, and on the first page of hits I couldn’t find any copy/pasteable source for this common problem, here’s an answer with (poor) public domain source code)