Skip to content

Instantly share code, notes, and snippets.

@chrisallick
Created August 4, 2013 23:18
Show Gist options
  • Save chrisallick/6152454 to your computer and use it in GitHub Desktop.
Save chrisallick/6152454 to your computer and use it in GitHub Desktop.
This application will figure out your host ip and copy to clip board. It also uses the gotonow application so you can easily open it on mobile safari as described by: http://clubsexytime.com/projects/gotonow/
#!/usr/bin/env ruby
require 'socket'
require 'net/http'
myip = Socket::getaddrinfo(Socket.gethostname,"echo",Socket::AF_INET)[0][3]
def pbcopy(input)
str = input.to_s
IO.popen('pbcopy', 'w') { |f| f << str }
str
end
pbcopy( "http://#{myip}:8000" )
#http://gotonow.herokuapp.com/url
uri = URI('http://gotonow.herokuapp.com/url')
res = Net::HTTP.post_form(uri, 'url' => "http://#{myip}:8000", 'max' => '50')
puts res.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment