Skip to content

Instantly share code, notes, and snippets.

@ksundong
Created June 16, 2020 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksundong/15fd366c2826e5c3621311dedd6c713a to your computer and use it in GitHub Desktop.
Save ksundong/15fd366c2826e5c3621311dedd6c713a to your computer and use it in GitHub Desktop.
이름과 랭크 돈 등을 자동으로 생성해주는 스크립트
function main() {
let data = "nickname,money,last_visit\n";
for (let i = 0; i < 100000; i++) {
data += randName() + ",";
data += randomMoney() + ",";
data += randomDate(new Date("2020-04-01"), new Date(), true);
data += "\n";
}
console.log(data);
}
function randName() {
let text = "";
let first =
"김이박최정강조윤장임한오서신권황안송류전홍고문양손배조백허유남심노정하곽성차주우구신임나전민유진지엄채원천방공강현함변염양변여추노도소신석선설마주연방위표명기반왕모장남탁국여진구";
let last =
"가강건경고관광구규근기길나남노누다단달담대덕도동두라래로루리마만명무문미민바박백범별병보사산상새서석선설섭성세소솔수숙순숭슬승시신아안애엄여연영예오옥완요용우원월위유윤율으은의이익인일자잔장재전정제조종주준중지진찬창채천철초춘충치탐태택판하한해혁현형혜호홍화환회효훈휘희운모배부림봉혼황량린을비솜공면탁온디항후려균묵송욱휴언들견추걸삼열웅분변양출타흥겸곤번식란더손술반빈실직악람권복심헌엽학개평늘랑향울련";
for (var i = 0; i < 1; i++)
text += first.charAt(Math.floor(Math.random() * first.length));
for (var i = 0; i < 2; i++)
text += last.charAt(Math.floor(Math.random() * last.length));
return text;
}
function randomRank() {
return Math.floor(Math.random() * 10) + 1;
}
function randomMoney() {
return Math.floor(Math.random() * 99999998 + 1);
}
function getFormatDate(date) {
var year = date.getFullYear(); //yyyy
var month = 1 + date.getMonth(); //M
month = month >= 10 ? month : "0" + month; //month 두자리로 저장
var day = date.getDate(); //d
day = day >= 10 ? day : "0" + day; //day 두자리로 저장
return year + "-" + month + "-" + day;
}
function randomDate(startDate, endDate, nullOk) {
if (nullOk && Math.random() > 0.5) {
return "";
}
return getFormatDate(
new Date(+startDate + Math.random() * (endDate - startDate))
);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment