Skip to content

Instantly share code, notes, and snippets.

@peterhellberg
Created August 20, 2012 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterhellberg/3409094 to your computer and use it in GitHub Desktop.
Save peterhellberg/3409094 to your computer and use it in GitHub Desktop.
Find RFCs based on Alpha (app.net) user ids.
require 'net/http'
def adn2rfc(user)
abort "You need to specify user on app.net" if user.nil?
http = Net::HTTP.new('alpha.app.net', 443)
http.use_ssl = true
res = http.request_get("/#{user}")
if res.code == "200"
rfc = res.body.match(/title="User Id (\d+)"/)[1]
res = Net::HTTP.new('www.faqs.org', 80).request_get("/rfcs/rfc#{rfc}.html")
res.code == "200" ? res.body.match(/h1>(.+)<\/h1/)[1] : "No RFC #{rfc}"
else
"No user with that name on Alpha"
end
end
puts adn2rfc ARGV[0]
@peterhellberg
Copy link
Author

Examples:

$ ruby adn2rfc.rb phuu
RFC 1022 - High-level Entity Management Protocol (HEMP)
$ ruby adn2rfc.rb hxf148
RFC 860 - Telnet Timing Mark Option
$ ruby adn2rfc.rb marco
RFC 384 - Official site idents for organizations in the ARPA Net
$ ruby adn2rfc.rb ralf
RFC 1694 - Definitions of Managed Objects for SMDS Interfaces us
An error message is shown if no RFC was found:
$ ruby adn2rfc.rb sevvie
No RFC 8377

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