-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentropy.rb
More file actions
executable file
·81 lines (64 loc) · 1.72 KB
/
entropy.rb
File metadata and controls
executable file
·81 lines (64 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require 'rubygems'
require 'socket.io-client-simple'
require 'json'
API_URL = "https://sagipinasV1.herokuapp.com"
socket = SocketIO::Client::Simple.connect API_URL
#!/usr/bin/env ruby
# random bounding box
def randomLatLng()
max_north=18.8
min_north=14
max_east=122
min_east=121.5
puts "#{rand(min_north..max_north)},#{rand(min_east..max_east)}"
end
def randLat()
max_lat=14.9
min_lat=14.0
return rand(min_lat..max_lat);
end
def randLng()
max_lng=120.999
min_lng=120.003
return rand(min_lng..max_lng);
end
def sendReport(type, count, socket,delay)
incidentTypes = ['earthquake','fire','flooding','accident','landslide']
for i in 1..count.to_i
sleep delay.to_f
reportData = {
:id => "2695506260470251",
:type => type,
:specified => "",
:details => "This just a test using entropy script",
:location => {
:lat=> randLat(),
:long=> randLng()
},
:status => "unverified",
:timestamp => Time.now
}
if type == "rand"
reportData[:type] = incidentTypes[rand(0..incidentTypes.length()-1)]
end
puts "[SENT REPORT: #{reportData[:type]}] => #{Time.now}"
socket.emit :test_report_data, reportData
end
end
validArgTypes = ['earthquake','fire','flooding','accident','landslide','rand']
puts "=============================="
puts "Running Entropy test script..."
puts "=============================="
type = ARGV[0]
count = ARGV[1]
delay = ARGV[2]
if count != "inf"
if validArgTypes.include? type
sendReport(type,count,socket,delay)
else
puts "[FATAL ERROR]: unknown incident type provided: #{type}"
puts "Please type rand if you want a random incident value."
end
else
puts "Infinite Requests: not supported yet"
end