How to generate randomness on the blockchain: hacks and best practices