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

ImageMagick vs GraphicsMagick, quick showdown

Posted in Uncategorized by emmanueloga on marzo 13, 2009

ImageMagick vs GraphicsMagick, no strings attached.

[emmanuel@going_merry ~/Desktop/test]
$ gm -version
GraphicsMagick 1.3.5 2009-01-26 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2009 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.

[emmanuel@going_merry ~/Desktop/test]
$ convert –version
Version: ImageMagick 6.4.9-2 2009-02-08 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

[emmanuel@going_merry ~/Desktop/test]
$ du src -h

62M src

[emmanuel@going_merry ~/Desktop/test]
$ time find src -type f | xargs -I {} gm convert -sample 25%x25% {} ./dst/{
}

real 0m24.593s
user 0m22.172s
sys 0m1.383s

[emmanuel@going_merry ~/Desktop/test]
$ time find src -type f | xargs -I {} convert -sample 25%x25% {} ./dst/{
}

real 0m29.137s
user 0m24.888s
sys 0m2.953s

Conclusion: GraphicsMagick 1.2X faster than ImageMagick

EOF

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: , ,

Have you ever been told….

Posted in Uncategorized by emmanueloga on diciembre 28, 2008

…that your code sucks, that one of your ideas is horrible, totally unusable or even (alas) that you or other developers are dumb because they choose to do things in certain way? I have, once or twice…. :-).

Leaving aside the fact that the person proffering those kind of comments has probably not reached maturity yet and/or has not good people skills, there are some good tips to take into consideration when that happens.

I’ve stumbled upon this excellent article:  http://mumak.net/stuff/your-code-sucks.html. I will simply copy-paste cites from it in blue. It talks specifically about code reviews, but we can adapt its tips if we think of a comment like mocking/stubbing is a horrible idea and it can hurt the development process” as if it were a code review… (By the way, David show us in his article the proper way to handle these kind of statements. Excellent post!)

First, don’t take it personally. Very often programmers tend to confuse personal preference with objective worth. I tend to take the “let’s do it your way” path -in cases where there is no harm in doing so- to avoid never ending discussions.

In the positive side of things, consider:

…someone has just tried to improve your product. They’ve put thought, effort and creativity into helping you, and now they have put their work up for critique: thank them.

Divmod have a policy of always saying one good thing in each code review. There is always something nice to say, even if it’s just I’m glad someone is looking at this part of the code

Code reviews provide an amazing opportunity to grow as a programmer and to improve the software we make. Off course! Just because the comment does not come wrapped in a polite sentence does not mean that it is wrong.

At the other side of the coin, If we are the ones reviewing other people work, then:

Ad hominem

This ought to go without saying: review the code and not the coder. Comments about a person will only make it harder for that person to apply critiques about their code.

When making negative comments, refer to the patch or the branch rather than you. For example, You’ve introduced a bug in get_message becomes this patch introduces a bug in get_message.

Unclear Outcomes

If all you say is, this patch introduces a bug in get_message, then you have failed as a reviewer. The goal is to improve the code, not to provide a series of puzzles for the author.

The author should be able to look at a review and be able to tell how to address each point and also when they have addressed all points. Reviews with unclear outcomes turn into open-ended discussions about the patch, which sometimes become focused on making the reviewer happy, rather than improving the code.

Confusing personal preference with objective worth

This is a problem in all spheres of review. Film critics, literary editors and acadamic reviewers all do it. What I like is not necessarily the same as what’s good, although part of becoming a better programmer is having your preferences align better with reality. What I dislike is perhaps even less likely to be the same as what’s bad.

When reviewing a perfectly acceptable patch that solves a problem using imperative-style programming, do not criticize it simply because it isn’t in a more functional style. Doing otherwise makes reviews a game of guess what the reviewer likes rather than write good code.

Reviewers can avoid this trap by phrasing review comments as questions, Did you consider using a more functional style?, Why aren’t you using regular expressions to solve this problem? etc.

I encourage you to read Jonathan Lange’s post, there are a lot of excellent tips on it!

Tagged with: ,

facebooker gem outdated on rubyforge

Posted in ruby by emmanueloga on diciembre 8, 2008

If you are building a facebook applicaction using facebooker gem, beware the version of the gem in rubyforge is outdated. The easier way to deal with this is to clone the github repo of facebooker and install the gem from there.

  1. git clone git://github.com/mmangino/facebooker.git
  2. cd facebooker

Then:

  1. rake gem
  2. cd pkg
  3. sudo gem install facebooker-[insert-version-here]

UPDATE

But this won’t work… the updated method is:

  1. rake gemspec
  2. gem build facebooker.gemspec
  3. sudo gem install facebooker-[insert-version-here]

At this point, the lastest version on github is 0.9.9 1.0.8!!! (0.9.5 in rubyforge), and this is a version you are going to need because of this commit.

UPDATE:

Although the procedure above still works, you may find it easier to install the gem directly from github, now that its gemspec has been made github-compatible:

  1. gem sources
  2. sudo gem sources –add http://gems.github.com (if it is not already listed when you run step 1)
  3. sudo gem install mmangino-facebooker

…although because of github gemspec security policy, the gem there is _not always_ the lastest…

Tagged with:

Reunion Ruby Argentina del sábado pasado

Posted in rails, rspec, ruby by emmanueloga on diciembre 6, 2008

Con tan solo una semana de demora :), una pequeña descripción de la reunir del sábado pasado con los muchachos de #ruby-ar.

Ricardo Markiewicz consiguió el aula en la facultad de ingeniería, donde estuvimos muy cómodos a pesar del calor, y  fue el “maestro de ceremonias”.

Matías Pablo Brutti nos habló muy brevemente acerca de uno de los proyectos en los que trabaja, sicherheit. Ojalá Matías pueda dar una charla más prolongada acerca de seguridad en aplicaciones web en alguna próxima reunión :).

Luís Lavena nos mostró rake-compiler, una gema que contiene tareas de rake que ayudan a cross-compilar código. Con rake-compiler es muy sencillo compilar extensions de ruby que funcionen tanto para un sistema operativo basado en unix como para Windows, ahora que el one click installer utiliza mingw como compilador. Luís utilizó cucumber para planear y testear la funcionalidad de su gema. Además, mostró algunas deficiencias que a veces cometemos por “vagancia”, como hardcodear paths a herramientas del sistema en los scripts de instalación. Además, Luís se incluyo el modulo acts_as_photographer y sacó las fotos que pueden ver más abajo.

Pedro Visintin invitó a Pelle Braendgaard, desarrollador de la gema  http://oauth.rubyforge.org/, quien nos habló un poco de porque querríamos utilizar OAuth para compartir información sensible de los usuarios de nuestras aplicaciones.

Además, Pedro dió su propia charla: “Como ser freelancer y no morir en el intento”. Nos habló de los riesgos que corremos como freelancers y como prepararnos para los mismos. Nos animó a no tomar nuestra profesión como un trabajo, sino mas bién disfrutar de lo que hacemos, y nos recomendó este libro. También, he aqui los slides de su charla.

Rafaél Bidegain, representando a CaFeLUG,  trajo algunos libros que se sortearon al final de la reunión, junto con una remera que trajo Pedro. Obviamente yo no me gane nada jajaja.

Como resumen todo muy bueno, ¡que se repita!

Tagged with: ,

require or not article on Space Vatican blog

Posted in rails, ruby by emmanueloga on noviembre 14, 2008

This article is so cool I want to recommend it, and also keep it linked here (hmmmm, I really need to resurrect my delicious account… :p)

http://www.spacevatican.org/2008/9/28/required-or-not

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: , ,

rspec 1.1.8 in `exit?’: undefined method `run?’ (rails 2.1.0)

Posted in Uncategorized by emmanueloga on octubre 16, 2008

I had to add this to the bottom of my spec_helper.rb:

  self.class.send :remove_const, "Test" if defined? Test

to avoid this error when running my specs:
...
Finished in 0.064605 seconds

1 example, 0 failures, 1 pending
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.8/lib/spec.rb:25:in `exit?’: undefined method `run?’ for Test::Unit:Module (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.8/lib/spec/runner.rb:193:in `register_at_exit_hook’

Fake update 🙂 (because I found this while writing this post) : Lighthouse Ticket describing the problem.

A somehow less ugly solution is to require ‘spec’ after you required your library code.