Skip to content

Instantly share code, notes, and snippets.

require 'net/http'
require 'xmlsimple'
url = "http://www.user-agents.org/allagents.xml"
xml_data = Net::HTTP.get_response(URI.parse(url)).body
data = XmlSimple.xml_in(xml_data)
agents = data['user-agent'].select{|agent| type = agent["Type"].first; type.include?("R") || type.include?("S")}
agent_names = agents.collect {|agent| agent["String"].first}
@rceee
rceee / User_slugs_without_database.rb
Last active December 14, 2015 03:29
How I set up my Rails 3 User model to have a pretty URL/ID "slug" without adding a slug field to the database
#This is how I set up my Rails 3 User model to have a pretty URL/ID "slug" without adding a slug field to the database