Returns a random statement from the database.
182784
def get_random(self):
        
        import random

        Statement = self.get_model('statement')

        session = self.Session()
        count = self.count()
        if count < 1:
            raise self.EmptyDatabaseException()

        random_index = random.randrange(0, count)
        random_statement = session.query(Statement)[random_index]

        statement = self.model_to_object(random_statement)

        session.close()
        return statement
1184479
def get_random(self, n, l=None):
        
        random_f = Fasta()
        if l:
            ids = self.ids[:]
            random.shuffle(ids)
            i = 0
            while (i < n) and (len(ids) > 0):
                seq_id = ids.pop()
                if (len(self[seq_id]) >= l):
                    start = random.randint(0, len(self[seq_id]) - l)
                    random_f["random%s" % (i + 1)] = self[seq_id][start:start+l]
                    i += 1
            if len(random_f) != n:
                sys.stderr.write("Not enough sequences of required length")
                return
            else:
                return random_f

        else:
            choice = random.sample(self.ids, n)
            for i in range(n):
                random_f[choice[i]] = self[choice[i]]
        return random_f
1009908
private String generateRandomSession() {
        final int length = 16;
        final SecureRandom r = new SecureRandom();
        final StringBuilder sb = new StringBuilder();
        while (sb.length() < length) {
            sb.append(Integer.toHexString(r.nextInt()));
        }
        return sb.toString().substring(0, length);
    }
527008
def get_random_user(self):
        
        c = self.db.cursor()
        c.execute('''SELECT username, password, fullname FROM users
                     WHERE rowid >= (abs(random()) % (SELECT max(rowid) FROM users))
                     LIMIT 1''')
        r = c.fetchone()
        return {"username": r[0], "password": r[1], "fullname": r[2]}
1114744
def random_letters(self, length=16):
        """"""
        return self.random_choices(
            getattr(string, 'letters', string.ascii_letters),
            length=length,
        )
494027
@Override
    public Statement createStatement() throws SQLException
    {
        checkClosed();
        try
        {
            return new JDBC4Statement(this);
        }
        catch(Exception x)
        {
            throw SQLError.get(x);
        }
    }
485626
def randomize(length=6, choices=None):
    """"""
    if type(choices) == str:
        choices = list(choices)
    choices = choices or ascii_lowercase
    return "".join(choice(choices) for _ in range(length))
537855
def generator(self, random, args):
        """"""
        if self.duplicates:
            max_count = [self.capacity // item[0] for item in self.items]
            return [random.randint(0, m) for m in max_count]
        else:
            return [random.choice([0, 1]) for _ in range(len(self.items))]
706643
protected synchronized Random getRandom() {
        if (this.random == null) {
            try {
                Class clazz = Class.forName(randomClass);
                this.random = (Random) clazz.newInstance();
                long seed = System.currentTimeMillis();
                char[] entropy = getEntropy().toCharArray();
                for (int i = 0; i < entropy.length; i++) {
                    long update = ((byte) entropy[i]) << ((i % 8) * 8);
                    seed ^= update;
                }
                this.random.setSeed(seed);
            } catch (Exception e) {
                this.random = new java.util.Random();
            }
        }
        return (this.random);
    }
792301
public static <T> /* @Nullable */ T random(final @NonNull Iterable<T> iterable) {
    return random(RANDOM, iterable);
  }
683468
def random(self):
        
        utc_now = datetime.datetime.utcnow()
        return self.valueFromString(utc_now.strftime(self.defaultFormat()))
1204522
def randomString(length, chrs=None):
    """"""
    if chrs is None:
        return getBytes(length)
    else:
        n = len(chrs)
        return ''.join([chrs[randrange(n)] for _ in xrange(length)])
404905
def generate_random_type(valid):
    
    type = choice(['int', 'str'])

    r = lambda: randrange(-1000000000, 1000000000)

    if type == 'int':
        return int,  (r() if valid else str(r()) for i in itertools.count())
    elif type == 'str':
        return str, (str(r()) if valid else r() for i in itertools.count())
    else:
        raise AssertionError('!')
291641
public function randomizeOrder(BaseStatement $statement){
		switch($this->driverName){
			case 'mysql':
			case 'pgsql':
				$random = 'RAND()';

			case 'sqlite':
			case 'sqlite2':
				$random = 'RANDOM()';

			case 'odbc':
				$random = 'Rnd(id)';

			case 'oci':
				$random = 'dbms_random.value';

			case 'mssql':
				$random = 'NEWID()';
		}
		$statement->order($random);
	}
463389
def random(self):
        
        minimum = self.minimum() or 0
        maximum = self.maximum() or 100
        return random.randint(minimum, maximum)
589221
def make_random(cls):
        """"""
        self = object.__new__(cls)
        self.rank = Rank.make_random()
        self.suit = Suit.make_random()
        return self
939842
def random_new(algo: int = RNG_CMWC) -> tcod.random.Random:
    
    return tcod.random.Random(algo)