url - Ruby on Rails - generating bit.ly style uuids -


I am trying to generate UUID in the same style as the bit.ly URL:

  http://bit.ly/aUekJP  

or people with the cloud:

  http://cl.ly/1hVU  

whichever is less

How can I do this? Now I am using UUID gem for Ruby, but I am not sure if it is possible to limit the length and get something like that. I am currently using:

  UUID.generate.split ("-") [0] = & gt; 

But I also want to know that it will be unique.

Any help would be greatly appreciated :)

There are two different things here Are confusing UUID is a universal unique identifier. It is very likely to be unique, even if millions of people are being created all over the world at the same time. It is usually displayed as a 36 digit string. You can not cut the first 8 letters and expect it to be unique.

Bitie, tinural et-al store links and generate a small code to represent that link. They do not rebuild the URL from the data that are visible in the data store and return the respective URLs. These are not UUIDs.

It is hard to give advice on what method you should use without knowing your application, although you can store whatever data you are pointing in with a numeric key in the store and

Edit

To avoid obvious typo problems such as' O '' '' 'L' etc., using Rebbus Basic 32 using 10 digits and 22 lowercase letters. After further investigation a

a 5 character base 32 string 33 million Can represent more than integers and can represent a string of 6 to 6 digits.


Comments