Created
December 21, 2012 07:02
-
-
Save hachibeeDI/4351161 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $key_codefile = $args[0] | |
| $random = new-Object random | |
| function get_random_word { | |
| $li = 'abcdefghijklmnopqrstuvwxyz' | |
| return $li[$random.next(0, 26)] | |
| } | |
| function get_random_words([Int]$limit) { | |
| return { (1..$limit | %{ get_random_word }) -join "" }.GetNewClosure() | |
| } | |
| #9以上だとintからあふれるので9まで | |
| function get_random_numbers([int]$limit) { | |
| return { $random.next('0' * $limit, '9' * $limit) }.GetNewClosure() | |
| } | |
| function get_random_bylist { | |
| $limit = $args.Length | |
| $valuelist = $args #scriptblock内でargsへの上書きが起きるので | |
| return { $valuelist[$random.next(0, $limit)] }.GetNewClosure() | |
| } | |
| function get_random_numbers_byrange([int]$limit) { | |
| return { $random.next(0, $limit) }.GetNewClosure() | |
| } | |
| function get_datetime() { | |
| return { Get-Date -format "yyyy-MM-dd hh:mm:ss" } | |
| } | |
| $wor = get_random_words(13) | |
| $num = get_random_numbers(9) | |
| $lis = get_random_bylist '01' '02' '03' '04' '05' '06' '99' | |
| $dat = get_datetime | |
| $each_line = @($wor, $num, $lis, $dat) | |
| # 遅延評価の連鎖 | |
| $csv_line = { $($each_line | %{ "`"$(&$_)`"" } ) -join "," } | |
| $content = 0..100 | % { "$(& $csv_line)" } | |
| $content | %{ echo $_ } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment