So I wrote this gist after trying to figure out how to do it properly and I thought I'd post it here, should anyone need it.
https://gist.github.com/TheGuyDanish/e2ebdeab28753ad09e09
https://gist.github.com/TheGuyDanish/e2ebdeab28753ad09e09