Skip to content

Instantly share code, notes, and snippets.

@DeltaWhy
Created October 15, 2015 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeltaWhy/66876dd00277b6075bca to your computer and use it in GitHub Desktop.
Save DeltaWhy/66876dd00277b6075bca to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'open-uri'
class IpInfoDb
attr_reader :source
URI = "http://ipinfodb.com"
def initialize
@source = open(URI).read
end
def self.get_lat_long
new.get_lat_long
end
def latitude
@latitude ||= get("Latitude")
end
def longitude
@longitude ||= get("Longitude")
end
def get_lat_long
"#{latitude}:#{longitude}"
end
private
def get(which)
source.match(%r{<li>#{which} : (.*)</li>}) && $1
end
end
puts IpInfoDb.get_lat_long
#!/bin/bash
while ! get_lat_long >/dev/null; do
echo "No connection, retrying in 5 seconds"
sleep 5
done
redshift-gtk -l $(get_lat_long)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment