Skip to content

Instantly share code, notes, and snippets.

@ss2k

ss2k/js.rb Secret

Last active August 29, 2015 14:21
Show Gist options
  • Save ss2k/0be7e62fbbaad30aafec to your computer and use it in GitHub Desktop.
Save ss2k/0be7e62fbbaad30aafec to your computer and use it in GitHub Desktop.
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