Old Emmanuel Oga's Weblog (new one is at www.emmanueloga.com)

Conferencia Locos X Rails tomorrow,

Posted in Uncategorized by emmanueloga on abril 2, 2009

Tomorrow starts Locos X Rails conference in Buenos Aires, Argentina. I’m very exited about it! Yesterday I met Desi McAdam, of DevChix fame, and also the keynote speaker Obie Fernandez, founder of HashRocket. I’m eager to hear their talks, and hope to see you in the conf. too!

Desi and Obie at the press meeting for the LocosXRails conf.

Desi and Obie at the press meeting for the LocosXRails conf.

Anuncios
Tagged with: , ,

Conferencia LocosXRails: falta poco!

Posted in Uncategorized by emmanueloga on marzo 10, 2009

Estamos a poco mas de 20 días para el inicio de la primer conferencia de ruby y rails en Argentina. Todavía no te anotaste? Podes hacerlo mediante la web: http://www.locosxrails.com/registration

Si ya te anotaste, “spread the word” mediante alguno de los siguientes badges:

Saludos!

Tagged with: , ,

Locos X Rails Conference: Registration Opened!

Posted in Uncategorized by emmanueloga on marzo 4, 2009

Locos X Rails

Ya se pueden anotar en la conf. El valor de la entrada es de 300 Argentinos. Claro, antes de anotarse van a querer saber quien va a dar las charlas:

http://eventioz.com/events/locos-x-rails-conference/speakers

Nos vemos ahi!

Tagged with: , ,

Locos por Rails Conference in Buenos Aires, Argentina

Posted in people, rails, ruby by emmanueloga on enero 23, 2009

Badge Locos X Rails Conference

Por fin!, una conferencia de ruby y rails en Argentina! La misma se realizará el 3 y 4 de Abril en la Universidad de Palermo, C.A.B.A. Estan cordialmente invitados. La inscripción no ha empezado todavía, pero si pueden mandar sus propuestas para disertar en la misma.

Locos Por Rails Conference 2009 will be held on April 3rd and 4th in Buenos Aires, Argentina. Registration is not open yet, but the call for papers is already open. Send yours!

Tagged with: , ,

Handling URIs in ruby a walk in the park? Don’t think so….

Posted in rails, ruby, Uncategorized by emmanueloga on octubre 17, 2008

I got sick an tired of juggling around with String urls and URI objects just to get a correct URI for http GETting, POSTing, etc…

For example, if you

Net::HTTP.post_form URI(“www.somewhere.com”)

you get an error…. but if you

Net::HTTP.post_form URI(“www.somewhere.com/”)

(notice trailing slash) you don’t… Boring stuff. The URI lib does provide a normalize method, but it does not always add the trailing “/”. For consistency I wanted normalize to add the trailing slash always. Update: seems like my “consistency” politic is not correct…. Oh, well… at least google does not like it. 🙂 I’m updating my Gist to remove that behavior…. Off course! Adding a trailing slash means you are looking for a directory and not for a resource, so you can’t go berserk adding trailing slashes in all your urls :p

But, the most boring stuff is joining uris and adding query params to them… This should be simple, right?:

uri = URI("something.com/?some=params")
uri.query = "other=params" # WRONG, previous params are overwritten
uri = URI("something.com/")
uri.query << "other=params" # WRONG, previous query is nil
uri = URI("something.com/?some=params")
uri.query << "other=params" # WRONG, params should be joined with & char...
&#91;/sourcecode&#93;

We need to <a href="http://github.com/jnunemaker/httparty/tree/master/lib/httparty.rb#L113">juggle with the URI object</a> to get the job done. More boring stuff. I wrote<a title="Joining an nomrmalizing URIs in ruby" href="http://gist.github.com/17342"> two simple methods to handle these problems</a>. Now I won't have to manually tweak those urls again... never more! (I hope :-).


  describe NormalizeURI do
    it "should add scheme and final / to an uri" do
      NormalizeURI("www.yahoo.com?something=true").to_s.should == "http://www.yahoo.com/?something=true"
    end
  end

  describe JoinURI do
    it "should join a string, an uri and additional query params" do
      one = URI("www.yahoo.com?uno=dos")
      two = URI("/peteco/carabal?tres=4&cinco=seis")
      result = "http://www.yahoo.com/peteco/carabal/?uno=dos&tres=4&cinco=seis"
      JoinURI(one.to_s, two, :more => :params).should.to_s == "#{ result }&more=params"
    end
  end

This is such small stuff I don’t think a gem for this would be cool…. maybe later (no gemspec fighting yet hehe). And yes, because I’m lazy I’m using active_support this time…. I’m using this inside rails anyways.

Tagged with: , ,

Meeting RubyArg (nos visitó Marcel Molina Jr., que calidad!)

Posted in people, rails, rspec by emmanueloga on agosto 18, 2008

El pasado Viernes Pedro Visintin organizo una reunion de railers, con la presencia de un invitado deluxe: Marcel Molina Jr.! Estuvo todo muy bueno, gracias Pedro por organizar el encuentro. No solo charlamos de temas muy interesantes, sino que tambien aprendi un par de lecciones fotográficas:

Diego se va

Diego se va

Otra vez la misma foto

Otra vez la misma foto

No entramos todos

No entramos todos

Ahora si entramos todos

Ahora si entramos todos

Tagged with: , , ,

Ubuntu gutsy problem number two: ruby script/console fails to start (readline)

Posted in rails, ubuntu by emmanueloga on noviembre 29, 2007

Just for the record, number problem one was to set up mongrel_cluster on init.d.

Soooo. Now “ruby script/console” fails with a “require ‘readline’ failure” or something. The problem was that, for some reason, when i built the ruby interpreter (1.8.6) the readline extension was not built and installed. ruby’s readline extension comes with the standard ruby distribution. So, i did a:

  • locate readline” (probably you will need a “sudo updatedb” before, or better just look for the source code of your ruby interpreter where you know it is. You know that, right? 🙂
  • Went to the directory where your ruby source code lives, subdirectory ext/readline. In my case: “cd ~/packages/ruby-1.8.6-p110/ext/readline
  • ruby extconf.rb” –this one generates the makefile for the library
  • make
  • sudo make install“.

In ubuntu you’ll problably need libreadline5 and libreadline5-dev _before_ running make:

sudo apt-get install libreadline5 and libreadline5-dev

Now “ruby script/console” should work.

Tagged with: , , , ,

Script de arranque nginx

Posted in nginx, rails, ubuntu by emmanueloga on noviembre 13, 2007

http://pastie.caboo.se/117444

That’s all folks 🙂

Tagged with: , ,

Update a selectable_enums_as

Posted in enums, rails, ruby, Uncategorized by emmanueloga on julio 26, 2007

Actualice mi “selectable_enums_as” ( http://pastie.caboo.se/82509 ) para:

  1. Obtener un hash para look_up de la descripcion de la constante
  2. Deshabilitar opciones en la vista (o sea, que options_for_select no la vea)

Para que servia esto? Para esos casos en los que un model tiene un campo numerico que representa un tipo. Por ejemplo, en un model Book:

#== Schema Information
# Schema version: 13
#
# Table name: books
#
#
#  id             :integer(11)   not null, primary key
#  description : text
#  type        :integer(11)   default(0)

class Book < ActiveRecord::Base
end&#91;/sourcecode&#93;Si nuestra app solo manejara los tipos 1 == novela y  2 == cuento, en vez de crear otro model BookType y cambiar type por book_type_id, podemos hacer lo siguiente:

&#91;sourcecode language='ruby'&#93;
selectable_enum_as :BOOK_TYPES,
  &#91;'NOVELA', :NOVELA&#93;,
  &#91;'CUENTO', :CUENTO&#93;,
&#93;&#91;/sourcecode&#93;Esto crea varias cosas:
<ol>
	<li>Opciones para options_for_select (podemos hacer simplemente options_for_select(Book::BOOK_TYPES))</li>
	<li>Constantes: Book::CUENTO, Book::NOVELA, cuyos valores son los que se van a guardar en la base de datos.</li>
	<li>Un hash BOOK_TYPES_NAME para obtener la descripcion del  tipo. Por ejemplo: BOOK_TYPES_NAME[Book::Novela]= 'Novela'.</li>
</ol>
Por ultimo, si quieren deshabilitar una opcion, no se debe sacar del array a menos que actualicen todos los registros. Puede que haya registros que esten usando ese tipo. En vez de sacarlo del array, pueden hacer:


  selectable_enum_as :BOOK_TYPES, [
    ['NOVELA', :NOVELA],
    ['CUENTO', :CUENTO,
    ['CUENTO_CORTO', :CUENTO_CRT],
    ['CUENTO_LARGO', :CUENTO_LRG],
  ]

Algo mas… NO SE LES OCURRA USAR UNA COLUMNA DE NOMBRE “type” EN SU MODEL!!! Eso puede ser un lindo bug para trackear hasta que se aviven que ya existia un metodo type en sus objetos… (Object.type les suena??? aunque esta marcado com deprecado en ruby 1.8.6, calculo que queda un rato largo hasta que lo saquen. )

Tagged with: , ,