Helper function that generates a random client ID
425054
function generateRandomClientId() {
    var length = 22;
    var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    var result = '';
    for (var i = length; i > 0; --i) {
        result += chars[Math.round(Math.random() * (chars.length - 1))];
    }
    return result;
}
216088
def _generate_ack_id(self, sid, namespace, callback):
        """"""
        namespace = namespace or '/'
        if sid not in self.callbacks:
            self.callbacks[sid] = {}
        if namespace not in self.callbacks[sid]:
            self.callbacks[sid][namespace] = {0: itertools.count(1)}
        id = six.next(self.callbacks[sid][namespace][0])
        self.callbacks[sid][namespace][id] = callback
        return id
533157
def random_connection(self):
        ''''''
        # While at the moment there's no need for this to be a context manager
        # per se, I would like to use that interface since I anticipate
        # adding some wrapping around it at some point.
        yield random.choice(
            [conn for conn in self.connections() if conn.alive()])
295990
def _uniqueid(n=30):
    
    return ''.join(random.SystemRandom().choice(
                   string.ascii_uppercase + string.ascii_lowercase)
                   for _ in range(n))
787526
function random (seed) {
  /**
   * Creates a subgenerator from the current one
   *
   * @param {string} key Key of the subgenerator
   * @param  {...number} params Parameters affecting the subgenerator's seed
   */

  function subgen (key, ...params) {
    return random(createSeed([...seed, keygen(key), ...params], seed.length))
  }

  /**
   * Retrieves a value from the random generator
   *
   * **Warning:** keys are cached indefinitely, keep them constant
   *
   * @param {string} key Key of the random value
   * @param  {...number} params Parameters affecting the value
   */

  function value (key, ...params) {
    return murmur([...seed, keygen(key), ...params])
  }

  return { seed, subgen, value, util }
}
160241
private static function generatePoolClientId()
    {
        $now = ceil(microtime(true) * 10000);
        if (class_exists('Reaction', false)) {
            $rand = \Reaction::$app->security->generateRandomString(8);
        } else {
            $rand = static::randomStr();
        }
        return static::getClientIdPrefix() . $now . $rand;
    }
319800
def random_id(length):
    """"""

    def char():
        """Generate single random char"""

        return random.choice(string.ascii_letters + string.digits)

    return "".join(char() for _ in range(length))
403203
def anonymous_name(id)
      name = "#{id}_#{Socket.gethostname}_#{Process.pid}_#{rand(1000000)}"
      name = name.gsub('.', '_')
      name = name.gsub('-', '_')
      name.gsub(':', '_')
    end
320871
def generate_minion_id():
    '''
    
    '''
    try:
        ret = salt.utils.stringutils.to_unicode(_generate_minion_id().first())
    except TypeError:
        ret = None
    return ret or 'localhost'
733776
def ping(self, timeout=0, **kwargs):
        """"""

        # http://stackoverflow.com/a/2257449/5006
        def rand_id(size=8, chars=string.ascii_uppercase + string.digits):
            return ''.join(random.choice(chars) for _ in range(size))

        payload = rand_id()
        self.ws.ping(payload)
        opcode, data = self.recv_raw(timeout, [websocket.ABNF.OPCODE_PONG], **kwargs)
        if data != payload:
            raise IOError("Pinged server but did not receive correct pong")
764062
def query_random(**kwargs):
        '''
        
        '''

        if 'limit' in kwargs:
            limit = kwargs['limit']
        elif 'num' in kwargs:
            limit = kwargs['num']
        else:
            limit = 10

        kind = kwargs.get('kind', None)

        if kind:
            rand_recs = TabPost.select().where(
                (TabPost.kind == kind) &
                (TabPost.valid == 1)
            ).order_by(
                peewee.fn.Random()
            ).limit(limit)
        else:
            rand_recs = TabPost.select().where(
                TabPost.valid == 1
            ).order_by(
                peewee.fn.Random()
            ).limit(limit)
        return rand_recs
1038117
function generateId () {
    var now = Date.now()
    if (now <= this.lastTime) {
      now = this.lastTime
      this.sequence += 1
    } else {
      this.lastTime = now
      this.sequence = 0
    }
    return now + ' ' + this.nodeId + ' ' + this.sequence
  }
822605
def random_filename(path=None):
    """"""
    filename = uuid4().hex
    if path is not None:
        filename = os.path.join(path, filename)
    return filename
407976
def generate_id(cls, prefix="pelix-"):
        
        if not prefix:
            # Normalize string
            prefix = ""
        else:
            # Truncate long prefixes
            prefix = prefix[:8]

        # Prepare the missing part
        nb_bytes = (23 - len(prefix)) // 2

        random_bytes = os.urandom(nb_bytes)
        if sys.version_info[0] >= 3:
            random_ints = [char for char in random_bytes]
        else:
            random_ints = [ord(char) for char in random_bytes]

        random_id = "".join("{0:02x}".format(value) for value in random_ints)
        return "{0}{1}".format(prefix, random_id)
113244
protected function generateId()
    {
        $len = 32; //32 bytes = 256 bits
        if (function_exists('random_bytes')) {
            $bytes = random_bytes($len);
        } elseif (function_exists('openssl_random_pseudo_bytes')) {
            $bytes = openssl_random_pseudo_bytes($len);
        } else {
            //Use a hash to force the length to the same as the other methods
            $bytes = hash('sha256', uniqid((string) mt_rand(), true), true);
        }

        //We don't care about messing up base64 format here, just want a random string
        return str_replace(['=', '+', '/'], '', base64_encode(hash('sha256', $bytes, true)));
    }
322096
function (instances) {
        var r = 10000000 * Math.random(); // todo: could be replaced with algo generating keys with numbers and
        // letters
        var key = '' + (r | r); // r|r = equivalent to Math.floor - but faster in old browsers
        while (instances[key]) {
            key += 'x';
        }
        return key;
    }
835477
def generate_random_id(size=6, chars=string.ascii_uppercase + string.digits):
    """"""
    return "".join(random.choice(chars) for x in range(size))