Heri • 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.

One response to “Ruby auto emo generator”

  1. oo says:

    @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 }

Leave a Reply

Categories

from heri.tumblr.com



Photos

samedi samedi samedi samedi soirée samedisoirée samedisoirée samedisoirée samediSénégalun soir d'été

See more pictures

Heri is also at

Heri does not use Instant Messenging or other communications means that disrupts workflows.


© 2007 2008 Heri Rakotomalala
Photographs and Screenshots are under Creative Commons. Attribution-NonCommercial-ShareAlike 2.0
Screenshots, logos, videos, and trademarks showcased on this blog are the property of their respective owners.