I have used YOURLS. You could easily create a plug-in to extract urls from a question and call the yourls function. Here is a list of more open source shorteners.
With yourls you can make short urls on your own domain or subdomain, and it gives you some extra stats.
If you just want to make the url look shorter, like your example, that is simple php.