static RandomUsers(count:number): User[]{ let users:User[]=[]; for(let i=0;i<count; i++){ users.push(new User(i, _.sample(FIRST_NAMES), _.sample(LAST_NAMES))); } return users; }
const addUsers = (count, knex, date) => { count = parseInt(count) const rows = [] for (let i = 0; i < count; i++) { const channel = _.sample(channels) const id = _.uniqueId() const first_name = { key: 'first_name', value: generateName(), type: 'string' } const last_name = { key: 'last_name', value: generateName(), type: 'string' } const gender = { key: 'gender', value: Math.random() < vary(0.65, 0.35) ? 'male' : 'female', type: 'string' } const locale = { key: 'locale', value: _.sample(['en_US', 'fr_CA', 'en_CA']), type: 'string' } const timezone = { key: 'timezone', value: _.random(-6, 12, false), type: 'string' } const user = { user_id: id, channel: channel, attributes: JSON.stringify([first_name, last_name, gender, locale, timezone]), created_at: date } users.push(user) rows.push(user) } return knex.batchInsert('srv_channel_users', rows, 20).then(() => console.log('Added', count, 'users')) }
return times(4, () => { const device = sample (devices); const location = sample(locations); return { device: device, location: location, name : sample(['Cloud', 'Lamp', 'Bridge']), pin: sample(device.pins) }; });
const CONTACTS = COLORS.map((color, index) => { const title = `${sample(['Mr.', 'Mrs.', 'Ms.', 'Unknown'])} ${color} 🔥`; const key = sample(['name', 'profileName']) as string; const id = `+1202555${padStart(index.toString(), 4, '0')}`; const contact = { color, [key]: title, id, type: 'private', }; return parent.ConversationController.dangerouslyCreateAndAdd(contact); });
function enterScored(state: State) { const goalText = sample(goalWords); return state .setIn(['round', 'scored'], true) .setIn(['round', 'goalText'], goalText); }
"!typegame": enabler((command: Tennu.Command) => { var cache = typegameCache[command.channel] = typegameCache[command.channel] || { running: false }; if (typegameCache[command.channel].running) { return util.format("A game is still running! Name %s Pokémon with the type %s!", cache.cnt, cache.types.join("/")); } else { (runningCache[command.channel] = runningCache[command.channel] || []).push("typegame") var {type, cnt} = _.sample(Data.type_count_array); console.log(cnt); cache = typegameCache[command.channel] = { running: true, type: type, cnt: _.random(1, _.min([5, cnt])), max: cnt, userCount: {}, guessed: {}, types: [] }; for (var i = 0; type; type >>= 1, ++i) { if (type&1) cache.types.push(Data.type_list[i]); } return util.format("Name %s Pokémon with the type %s!", cache.cnt, cache.types.join("/") ); } }),
async getRandomKiller(): Promise<TKiller> { const killers = (await this.fetch()).killers; const killer = _.sample( killers.abilities ); return _.extend({}, killer, { addons: _.sampleSize( killers.addons[ killer.name.replace(/The\s/, '') ], 2 ) }); }
constructor(private readonly log: Logger, private readonly options: BasePathProxyServerOptions) { const ONE_GIGABYTE = 1024 * 1024 * 1024; options.httpConfig.maxPayload = new ByteSizeValue(ONE_GIGABYTE); if (!options.httpConfig.basePath) { options.httpConfig.basePath = `/${sample(alphabet, 3).join('')}`; } }
.then(pool => { if (pool.length === 0) return null; if (this.preferredTaskType) { const task = _.find(pool, t => t.templateType === this.preferredTaskType); if (task) return task; } return _.sample(pool); });
updateNextDirection() { let allDirections = [Phaser.LEFT, Phaser.RIGHT, Phaser.UP, Phaser.DOWN]; let possibleDirections = _.filter(allDirections, (direction) => { return direction !== this.currentDirection && direction !== this.opposites[this.currentDirection]; }); this.nextDirection = _.sample(possibleDirections); return this.nextDirection; }