Skip to content

Instantly share code, notes, and snippets.

@Jacke
Last active December 14, 2015 04:29
Show Gist options
  • Save Jacke/5028264 to your computer and use it in GitHub Desktop.
Save Jacke/5028264 to your computer and use it in GitHub Desktop.
Ascii rails app name
# gem install macaddr | into Gemfile if you want
==begin
require 'macaddr'
==end
require 'socket'
gateway = `ip route show`.match(/default.*/)[0].match(/\d\d?\d?\.\d\d?\d?\.\d\d$
def local_ip
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
UDPSocket.open do |s|
s.connect '64.233.187.99', 1
s.addr.last
end
ensure
Socket.do_not_reverse_lookup = orig
end
# need artii gem | gem install artii | also add to gemfile
app = Rails.application.class.name
app = app.split("::Application")
app = app.first.to_s
# For customization check artii project on github https://github.com/miketierney/artii
print `artii #{app}`
print "\n"
print "IP: #{local_ip}"
print "\n"
#print "Mac: #{Mac.address}"
#print "\n"
print "Gateway: #{gateway}"
print "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment