Hacker News new | past | comments | ask | show | jobs | submit login

Haha, that's how I like to write all my code now. Sometimes I'll write a function that generates a random id, and checks the database to make sure that it doesn't already exist. I always like to add a counter and throw an error (or just return some default value) if it gets up to 100 or so. It might not ever happen in this universe, but I like to imagine there's a parallel universe out there where I saved some server from going into an infinite loop.

I actually did this recently for a random phone number generator, using the phony Ruby library to validate numbers. It was just for some test fixtures, but it's nice to know that it will always fallback to a default test number in case something goes wrong and it runs out of attempts. Or I'm in some universe where my random number generator suddenly starts producing an endless stream of zero bits.

This is just a little 'tick'. I also find myself using 12px and 14px a lot more frequently than 13px.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: