Some useful code that I wrote for future reference