-----Messaggio originale-----
Da: Aaron D. Gifford [mailto:astounding / gmail.com] 
Inviato: mercoled16 novembre 2011 23:59
A: ruby-talk ML
Oggetto: Ruby, How Do I Love Thee? Let Me Count the Ways...

I just have to say that Ruby is very, very convenient.

Today while working I needed to figure out which ethernet MAC was missing
from a device.  So I selected and copied the complete text of a web page
displaying all the MACs on the device.  In another window, using MySQL I
selected a list of all the MACs that device SHOULD have been showing me.

The dilemma--how to eliminate those MACs I could see quickly and efficiently
to leave the missing MACs?  Manually comparing the two lists (one from the
device, one from the database) would take far too long.

Enter Ruby, irb specifically, as a quick-and-dirty text processing CLI.  I
pasted my list of MACs from the device into a temporary file, then did this
with irb:

irb(main):001:0> puts "SELECT * FROM authorized_macs WHERE device_id=
2342592 AND mac!='" +
File.read('macs_seen_on_device.txt').split(/[\r\n]+/).map{|l|
l.split(/\s+/).first}.join("' AND mac!='") + "';"

Thank you, Ruby, for making generating an SQL statement to show me the
missing MACs quick and simple.

Now for a question:

I've been looking at Pry to enhance my irb CLI experience and blend a bit of
shell-like CLI in as well.  Is there a database module along the lines of
Pry I could use to also integrate a MySQL CLI as well?
I'd love to use Ruby as my system CLI shell and MySQL CLI simultaneously...
*drool*

Aaron out.


 
 
 --
 Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f
 
 Sponsor:
 ING DIRECT Conto Arancio. 4,20% per 12 mesi, zero spese, aprilo in due minuti!
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid924&d)-12