Unique S/N Generator?

daniel mcfarland daniel.mcfarland at gmail.com
Mon Feb 7 18:55:21 UTC 2011


  This is ridiculous:

  apt-get install uuid
  ./uuid

  Done.

On Mon, Feb 7, 2011 at 9:19 AM, devicerandom <devicerandom at gmail.com> wrote:

> On 07/02/11 17:01, Amichai Rotman wrote:
>
>> Hello,
>>
>> I would like to hand out some Coupons to my customers granting the 2-3
>> hours free phone support as part of a marketing campaign.
>>
>> I am looking for a way to generate a unique S/N number / code
>> (preferably letters and numbers) for them to read back to me over the
>> phone, so I can verify it's authenticity and provide them the service.
>>
>> Is there a tool out there I can use?
>>
>
> With a bit of Python you can go anywhere. This code *should* generate 10000
> unique alphanumeric codes and save them to a text file (I haven't tested
> it).
>
>
> #!/usr/bin/env python
>
> import random
> a='1234567890abcdefghi' #we return permutations of this string
>
> a = list(a)
>
> codes=[]
>
> for i in range(10000): #we generate 10000 codes
>    code = ''.join(random.shuffle(a)))
>    if not (code in codes): #avoid duplicates -very improbable but cheap
>       codes.append(code)
>
> f = open('codes.txt','w')
> f.write('\n'.join(codes))
> f.close()
>
>
>
>  I'd like to set different ranges of codes for different target audiences.
>>
>
> This is easy -just include a unique character for each target audience in
> the initial string.
>
> http://docs.python.org/library/random.html can help.
>
> cheers,
> m.
>
> --
> http://devicerandom.org
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20110207/df087861/attachment.html>


More information about the ubuntu-users mailing list