Ruby Coding

From 5dollarwhitebox.org Media Wiki

Jump to: navigation, search

Random Things

Matching IP or MAC Addresses With Ruby

Ruby IP Address Match:

/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})?$/.match("#{@systemIP}")


Ruby MAC Address Match:

/^(\S{1,2}:\S{1,2}:\S{1,2}:\S{1,2}:\S{1,2}:\S{1,2})?$/.match("#{@systemMAC}")


Trouble Installing Ruby MySQL Gem

If you have trouble getting the MySQL Ruby Gem installed, you might need to add a compile switch (with-mysql-config) like so:

root@linuxbox ~]# gem install mysql --version 2.7 --include-dependencies -- --with-mysql-config
Personal tools