-
-
Save ss2k/0be7e62fbbaad30aafec to your computer and use it in GitHub Desktop.
This file contains 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
require 'json' | |
COUNTRY_CODES = %w[AF BR US NO CN RU AU NZ MX IN BD IR NG SA ZA FR] | |
Thread.new do | |
loop do | |
sleep 1 | |
set_json | |
end | |
end | |
def set_json | |
temp_json = {} | |
COUNTRY_CODES.each { |c| temp_json[c] = rand(1..2500) } | |
write_to_json temp_json | |
end | |
def write_to_json(json) | |
File.open("visitors.json", "w") do |f| | |
f.write(json.to_json) | |
end | |
puts "Wrote new json" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment