Skip to content

Instantly share code, notes, and snippets.

@avsm
Created August 25, 2009 17:33
Show Gist options
  • Save avsm/174856 to your computer and use it in GitHub Desktop.
Save avsm/174856 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'findmyiphone'
username = ENV.fetch("MOBILEME_USERNAME")
password = ENV.fetch("MOBILEME_PASSWORD")
puts "logging in as: #{username}@me.com"
i = FindMyIphone.new(username, password)
f = File.new("location.csv", "a")
while true
begin
loc = i.locateMe
time = Time.now().to_f
f.puts "#{time},#{loc['accuracy']},#{loc['latitude']},#{loc['longitude']}"
f.flush
sleep 30
rescue Exception => exc
puts "relogging in (exc: #{exc.message})"
i = FindMyIphone.new(username, password)
sleep 5
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment