Skip to content

Instantly share code, notes, and snippets.

@alexey-bass
Last active January 5, 2024 00:07

Revisions

  1. alexey-bass revised this gist Dec 9, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions random-id.js
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,9 @@ function randomString(length, chars) {
    }

    var dictionary = '';
    dictionary+= 'ABCDEFGHKLMNPQRTWXYZ'; // removed IJOUV
    dictionary+= 'abcdefghkpqrstwxyz'; // lmnouv
    dictionary+= '2346789'; // 10
    dictionary+= 'ABCDEFGHKLMNPQRTWXYZ'; // IJOSUV
    dictionary+= 'abcdefghkpqrstwxyz'; // ijlmnouv
    dictionary+= '2346789'; // 150
    dictionary+= '-_~';

    alert(randomString(10, dictionary));
  2. alexey-bass revised this gist Dec 9, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions random-id.js
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,9 @@ function randomString(length, chars) {
    }

    var dictionary = '';
    dictionary+= 'ABCDEFGHKLMNPQRTWXYZ';
    dictionary+= 'abcdefghkpqrstwxyz';
    dictionary+= '2346789';
    dictionary+= 'ABCDEFGHKLMNPQRTWXYZ'; // removed IJOUV
    dictionary+= 'abcdefghkpqrstwxyz'; // lmnouv
    dictionary+= '2346789'; // 10
    dictionary+= '-_~';

    alert(randomString(10, dictionary));
  3. alexey-bass revised this gist Dec 9, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions random-id.js
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,8 @@ function randomString(length, chars) {
    }

    var dictionary = '';
    dictionary+= 'ABCDEFGHJKLMNPQRTUVWXYZ';
    dictionary+= 'abcdefghijkmnpqrstuvwxyz';
    dictionary+= 'ABCDEFGHKLMNPQRTWXYZ';
    dictionary+= 'abcdefghkpqrstwxyz';
    dictionary+= '2346789';
    dictionary+= '-_~';

  4. alexey-bass created this gist Aug 11, 2013.
    15 changes: 15 additions & 0 deletions random-id.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    function randomString(length, chars) {
    var result = '';
    for (var i = length; i > 0; --i) {
    result += chars[Math.round(Math.random() * (chars.length - 1))];
    }
    return result;
    }

    var dictionary = '';
    dictionary+= 'ABCDEFGHJKLMNPQRTUVWXYZ';
    dictionary+= 'abcdefghijkmnpqrstuvwxyz';
    dictionary+= '2346789';
    dictionary+= '-_~';

    alert(randomString(10, dictionary));