Skip to content

Instantly share code, notes, and snippets.

@comilab
Last active December 22, 2015 14:18
Show Gist options
  • Select an option

  • Save comilab/6484652 to your computer and use it in GitHub Desktop.

Select an option

Save comilab/6484652 to your computer and use it in GitHub Desktop.

Revisions

  1. comilab revised this gist Feb 28, 2014. 2 changed files with 33 additions and 33 deletions.
    33 changes: 33 additions & 0 deletions getRandomName.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    var getRandomName = function() {
    // ゥは使わない気がするので一旦外す
    var chars = 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンヴガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポァィェォッャュョー'.split(''),
    prefixes1 = 'ウクグツフブプヴ'.split(''),
    prefixes2 = 'ツフブプヴ'.split(''),
    prefixes3 = 'キシチニヒミリギジヂビピ'.split(''),
    length = Math.max(Math.floor(Math.random() * 9), 2),
    name = '';

    while (name.length < length) {
    var rand = Math.floor(Math.random() * chars.length),
    c = chars[rand];
    if (('ンァィゥェォッャュョー'.match(c) && !name.length)
    || ('ァィゥェォャュョ'.match(c) && (name.length + 2) == length)
    || ('ッ'.match(c) && (name.length + 1) == length)
    ) {
    continue;
    }
    if ('ィェォ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes1.length);
    name += prefixes1[rand] + c;
    } else if ('ァ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes2.length);
    name += prefixes2[rand] + c;
    } else if ('ャュョ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes3.length);
    name += prefixes3[rand] + c;
    } else {
    name += prev = c;
    }
    }
    return name;
    };
    33 changes: 0 additions & 33 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,33 +0,0 @@
    var getRandomName = function() {
    // ゥは使わない気がするので一旦外す
    var chars = 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンヴガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポァィェォッャュョー'.split(''),
    prefixes1 = 'ウクグツフブプヴ'.split(''),
    prefixes2 = 'ツフブプヴ'.split(''),
    prefixes3 = 'キシチニヒミリギジヂビピ'.split(''),
    length = Math.max(Math.floor(Math.random() * 9), 2),
    name = '';

    while (name.length < length) {
    var rand = Math.floor(Math.random() * chars.length),
    c = chars[rand];
    if (('ンァィゥェォッャュョー'.match(c) && !name.length)
    || ('ァィゥェォャュョ'.match(c) && (name.length + 2) == length)
    || ('ッ'.match(c) && (name.length + 1) == length)
    ) {
    continue;
    }
    if ('ィェォ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes1.length);
    name += prefixes1[rand] + c;
    } else if ('ァ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes2.length);
    name += prefixes2[rand] + c;
    } else if ('ャュョ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes3.length);
    name += prefixes3[rand] + c;
    } else {
    name += prev = c;
    }
    }
    return name;
    };
  2. comilab revised this gist Sep 30, 2013. 1 changed file with 31 additions and 27 deletions.
    58 changes: 31 additions & 27 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,33 @@
    var getRandomName = function() {
    // ゥは使わない気がするので一旦外す
    var chars = 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンヴガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポァィェォッャュョー'.split(''),
    prefixes1 = ['フ', 'ヴ'],
    prefixes2 = 'キシチニヒミリギジヂビピ'.split(''),
    length = Math.max(Math.floor(Math.random() * 9), 2),
    name = '';

    while (name.length < length) {
    var rand = Math.floor(Math.random() * chars.length),
    c = chars[rand];
    if (('ンァィゥェォッャュョー'.match(c) && !name.length)
    || ('ァィゥェォャュョ'.match(c) && (name.length + 2) == length)
    || ('ッ'.match(c) && (name.length + 1) == length)
    ) {
    continue;
    // ゥは使わない気がするので一旦外す
    var chars = 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンヴガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポァィェォッャュョー'.split(''),
    prefixes1 = 'ウクグツフブプヴ'.split(''),
    prefixes2 = 'ツフブプヴ'.split(''),
    prefixes3 = 'キシチニヒミリギジヂビピ'.split(''),
    length = Math.max(Math.floor(Math.random() * 9), 2),
    name = '';

    while (name.length < length) {
    var rand = Math.floor(Math.random() * chars.length),
    c = chars[rand];
    if (('ンァィゥェォッャュョー'.match(c) && !name.length)
    || ('ァィゥェォャュョ'.match(c) && (name.length + 2) == length)
    || ('ッ'.match(c) && (name.length + 1) == length)
    ) {
    continue;
    }
    if ('ィェォ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes1.length);
    name += prefixes1[rand] + c;
    } else if ('ァ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes2.length);
    name += prefixes2[rand] + c;
    } else if ('ャュョ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes3.length);
    name += prefixes3[rand] + c;
    } else {
    name += prev = c;
    }
    }
    if ('ァィゥェォ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes1.length);
    name += prefixes1[rand] + c;
    } else if ('ャュョ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes2.length);
    name += prefixes2[rand] + c;
    } else {
    name += prev = c;
    }
    }
    return name;
    };
    return name;
    };
  3. comilab created this gist Sep 8, 2013.
    29 changes: 29 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    var getRandomName = function() {
    // ゥは使わない気がするので一旦外す
    var chars = 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンヴガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポァィェォッャュョー'.split(''),
    prefixes1 = ['フ', 'ヴ'],
    prefixes2 = 'キシチニヒミリギジヂビピ'.split(''),
    length = Math.max(Math.floor(Math.random() * 9), 2),
    name = '';

    while (name.length < length) {
    var rand = Math.floor(Math.random() * chars.length),
    c = chars[rand];
    if (('ンァィゥェォッャュョー'.match(c) && !name.length)
    || ('ァィゥェォャュョ'.match(c) && (name.length + 2) == length)
    || ('ッ'.match(c) && (name.length + 1) == length)
    ) {
    continue;
    }
    if ('ァィゥェォ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes1.length);
    name += prefixes1[rand] + c;
    } else if ('ャュョ'.match(c)) {
    var rand = Math.floor(Math.random() * prefixes2.length);
    name += prefixes2[rand] + c;
    } else {
    name += prev = c;
    }
    }
    return name;
    };