Skip to content

Instantly share code, notes, and snippets.

@pocari
Created November 11, 2012 04:55
Show Gist options
  • Save pocari/4053770 to your computer and use it in GitHub Desktop.
Save pocari/4053770 to your computer and use it in GitHub Desktop.
4051188 用のテストデータ
#https://gist.github.com/4051188 用のテストデータ
require 'date'
def by_min
Rational(1, 1440) #24 * 60
end
def gen_range
ret = []
fmt = '%Y/%m/%d %H:%M:%S'
stime = DateTime.strptime('2011/11/10 09:00:00', fmt)
etime = DateTime.strptime('2011/11/11 12:00:00', fmt)
t = stime
while t <= etime
ret << t.strftime('%Y/%m/%d %H:%M:%S')
t += by_min
end
ret
end
def gen_sample
range = gen_range
300.times.inject([]) {|acc, id|
prog_id = "prog_%04d" % (id + 1)
s_index = rand(range.size)
e_index = s_index + rand(range.size - s_index - 1) + 1
acc << [prog_id, range[s_index], range[e_index]]
acc
}.each {|rec|
puts rec.join("\t")
}
end
gen_sample
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment