Skip to content

Instantly share code, notes, and snippets.

@dillonhafer
Created December 23, 2022 20:21
Show Gist options
  • Save dillonhafer/238e7eb5cd69de86cd885f8c8a966d3a to your computer and use it in GitHub Desktop.
Save dillonhafer/238e7eb5cd69de86cd885f8c8a966d3a to your computer and use it in GitHub Desktop.
Get local ip address for rails servers
function ,lipqr() {
ruby << RUBY
require "rqrcode"
class String
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def bg_black
colorize(40)
end
def bg_gray
colorize(47)
end
end
ip = "`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}'`".chomp
url = "http://#{ip}:3000"
qr = RQRCode::QRCode.new(url)
puts url
puts qr.to_s(dark: " ".bg_black, light: " ".bg_gray)
RUBY
@dillonhafer
Copy link
Author

Screenshot_2022-12-23_at_15 20 29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment