Skip to content

Instantly share code, notes, and snippets.

@dillonforrest
Created February 14, 2014 16:28
Show Gist options
  • Save dillonforrest/9004208 to your computer and use it in GitHub Desktop.
Save dillonforrest/9004208 to your computer and use it in GitHub Desktop.
//////////////////////////////////////////////////
// data generation
//////////////////////////////////////////////////
var _ = require('underscore');
function genStaticData() {
var alphabet = 'abcdefghijklmnopqrstuvqxyz';
return _.range(69).map(function makePublisher() {
return {
site: genWord() + '.com',
status: genStatus(),
size: genSize(),
owner: genWord(),
guid: _.uniqueId(),
};
});
// utility fns
function genWord() {
return _.range( _.random(6) + 5 ).map(function randLetter() {
return randomNth(alphabet);
}).join('');
}
function genStatus() {
var statuses = ['inactive', 'live', 'none', 'prospecting'];
return randomNth(statuses);
}
function genSize() {
var sizes = ['small', 'medium', 'large'];
return randomNth(sizes);
}
function randomNth(array) {
return array[ _.random(array.length - 1) ];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment