• February 11th, 2007 • 1 comment
Ruby auto emo generator
From Edward Ocampo Gooding, member of RubyMtl Group:
SOLICITATION FOR AUTO-EMO POETRY GENERATORS : Your Ruby script culls raw emo passion from Myspace, Livejournal and the
like to auto-generate “emo” poetry.
I used the “technorati API”:http://technorati.com/developers/api/ and the Rails framework, which was an error because it was overkill for something like this. “Camping”:http://code.whytheluckystiff.net/camping would have been more suitable. The code is here:
query = params[:emo][:theme1] + ‘+’ + params[:emo][:theme2]
url = “http://api.technorati.com/search?key=1fa5c5362121cf4eb7d70be06c8692cd&query=#{query}”
xml_data = Net::HTTP.get_response(URI.parse(url)).body
@results = Array.new()
if xml_data
xml = XmlSimple.xml_in(xml_data, { ‘ForceArray’ => false })
if xml['document'] and !xml['document'].empty?
xml['document']['item'].each do |post|
@results << post['title']
end
end
end
@results.sort{|x, y| y.length <=> x.length }
Took me a couple of hours to get the “Auto Emo Generator”:http://eumyang.com working. Ironically, the hardest part was deploying. I got the code running locally in 15 minutes but, as usual, it displayed the sandard _rails application 500 error_ on the web server.










July 9th, 2007 at 11:39 pm
@results = Array.new()
if xml_data
xml = XmlSimple.xml_in(xml_data, { ‘ForceArray’ => false })
if xml['document'] and !xml['document'].empty?
xml['document']['item'].each do |post|
@results < < post['title']
end
end
end
@results.sort{|x, y| y.length <=> x.length }