OK, a couple hours of googling and experimenting seems to have found the solution. Documenting it here for ...
stackoverflow.com