Skip to content

Instantly share code, notes, and snippets.

@webflo
Created November 17, 2016 21:27
Show Gist options
  • Save webflo/a597bd2bc226397bc06b636f7c90c615 to your computer and use it in GitHub Desktop.
Save webflo/a597bd2bc226397bc06b636f7c90c615 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'socket'
require 'uri'
if ARGV.first
uri = URI::parse(ARGV.first)
if uri.scheme.nil?
uri = URI::parse("http://" + ARGV.first)
end
end
Socket.ip_address_list.each do |item|
if item.ip_address[0, 6] == "10.19."
hostname = nil
if uri.nil?
link = "http://#{item.ip_address}.xip.io"
else
uri.hostname = "#{uri.hostname}.#{item.ip_address}.xip.io"
link = uri.to_s
end
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
system "start #{link}"
exit
elsif RbConfig::CONFIG['host_os'] =~ /darwin/
system "open #{link}"
exit
elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/
system "xdg-open #{link}"
exit
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment