format internet:

…please wait (42% completed)…

Archive for the ‘ruby’ Category

Slides and video for my talk “La herramienta de desarrollo definitiva” in conferencia rails 2009

Posted by javier ramirez on February 28, 2010

I just realized I still hadn’t published in my blog the slides and video of my talk “La herramienta de desarrollo definitiva” in conferencia rails 2009, back in november.

My talk was a reflection about web development and the relative importance of the development tools. I was defending the idea of the individual with good practices being much more important than the choice of a tool or another. I was also talking about why Ruby on Rails is very appealing for such an individual and why it’s still relatively hard to find companies using modern techniques in development.

I talked about which were the best practices I consider an “ultimate developer” should embrace, linking it to concepts found in geek literature such as The Mythical Man Month, The Cluetrain Manifesto, Microserfs o The Soul of a New Machine.

This material is published under a Creative Commons NonCommercial-Attribution-ShareAlike license 2.5



The video is divided in two parts:

Vodpod videos no longer available.

Vodpod videos no longer available.

Advertisements

Posted in conferences, conferenciarails, conferenciarails2009, javier ramirez, ruby, ruby on rails | Tagged: , , , , , | 3 Comments »

Eclipse buttons not working on Ubuntu Karmic Koala

Posted by javier ramirez on December 23, 2009

Lately I was experiencing a strange behavior when working with Eclipse/RadRails. Some of the buttons didn’t work anymore. I could click on them, but they’d just appear as selected, without performing any actions. I had to use the enter key to actually click on the button.

Since I had run an update some days ago, I was blaming some new version of one of the installed plugins.. but I was wrong.

Today I read this post where it explains how to fix it. It’s a conflict between Eclipse and the latest versions of GTK+. By setting the GDK_NATIVE_WINDOWS variable to use native windows, everything is back to normal.

And they lived happily ever after (or until the next major release anyway)

Posted in development, eclipse, javier ramirez, madrid, ruby, ubuntu | 4 Comments »

Ruby on Rails on unofficial Chrome OS

Posted by javier ramirez on September 29, 2009

update: I thought this Chrome OS distribution was THE google distro. I was wrong. It’s just someone who used SUSE Studio to make a customized version of Open SUSE around the Chromium theme. With the site being on a google site and the code on a google code repository, I thought this was it, but no.. this distro is totally unrelated to google.

Chrome OS is by now just a bit more than a curiosity. In the meanwhile, you can go and download a non-official distribution mimicking what it could be, but be warned, all you are going to get is an Open Suse distribution with Chromium installed and a blue theme with a cute logo. Hopefully the real ChromeOS will be much lighter and more user-friendly.

Starting the virtual appliance from VirtualBox is easy. You create a new virtual media with the virtual media manager and then a virtual machine using this new media. That should be it. If you leave the default options (64MB) you’ll end up with a really slow boot. I set the base memory to 512K and things are much better.

What will you find in this distribution apart from Chromium? Zip, Zero, Null.. or if you are into ruby, nil.

Truth is, this distribution is a bit too rough around the edges (when it comes to internationalization, even if it ask you for the keyboard settings, it will just ignore them), but being a SUSE, you can install whatever you want. The only thing you’ll need is the root password. Since I’m such a hacker it took me almost no time to realize the root password was “root” (my other options being “sergei”, “larry” and “640Koughttobeenough”.

Once you have root access, you can use Yast for installing anything you might need. Just for fun I installed ruby, rubygems and sqlite3 via Yast, and then rails using gem. I had to run a gem update –system so I could use rails 2.3.4 and I generated a scaffold to see if everything was fine. Well, it was :)

ruby on rails running on google chrome os

ruby on rails running on google chrome os

Well, even if it was utterly useless, at least I found a cool way of making customized SUSE distros in an easy way ;)

Posted in 1771, development, javier ramirez, ruby, ruby on rails | Tagged: , , , , , , , | 3 Comments »

Multiple rubygems versions, GEM_HOME and GEM_PATH

Posted by javier ramirez on September 28, 2009

Installing rubygems is failrly easy and it’s great to have a package manager so you can forget about manually installing and upgrading the components you use. After installing a gem, you can require it from any ruby script and use it hassle-free. Well, given your ruby interpreter can find it.

When you install rubygems, a lot of default configuration is done behind the scenes. If you must see to believe, you can run

gem environment

do you believe me now?

Unless you are on windows, you have probably experienced already that gems can get installed in different locations. If using a superuser account, the global configuration will be used, but with a regular account gems install under your home directory.

If you are not careful about how you install your gems, or if you are using rake gems:install from regular accounts, you might end up installing the same version of a gem twice. That’s not only WET (not DRY, bear with me here) but it eats up your poor HD.

Things can get a lot worse than that. Suppose you are working with both JRuby and Ruby MRI. When you use rubygems from JRuby, it will try to use a different gem location by default. So, depending on how you are installing gems, you could have up to three different copies of exactly the same version.

And if you are on ubuntu and you upgrade from an old version of rubygems to the latest one —you will have to if you install Rails 2.3.4; if you are having problems you can read right here how to update it— you might be surprised that your gems are being installed *again*. The reason is under older versions the default location was “/var/lib/gems” and the latest one defaults to “/usr/lib/ruby/gems”.

Well, four different copies of ActiveRecord 2.3.4 are three and a half more copies than I wanted, mind you.

So.. how can we stop this gem install frenzy? Easy. Don’t use the defaults. Each of your installations is using default values, but they can be easily overridden with command line parameters or much more conveniently with environment variables.

Remember the title of this post? Can you see anything there that would make a good candidate for environment variables? That’s right, all the rubygems versions honor the GEM_HOME and GEM_PATH variables, so if they are set they will be used.

Depending on your OS, you can set these variables in different places. I’m on ubuntu and a bit lazy, so I chose the easiest, which is by adding this to my .bashrc file.

export GEM_HOME=/var/lib/gems/1.8
export GEM_PATH=/var/lib/gems/1.8

And now, no matter what I’m using: Ruby MRI, JRuby, or the latest rubygems, my already installed gems will be used, and the new ones will be put in the same place.

Saving the world is a hard job, but someone has to do it.

Posted in 1771, development, jruby, ruby, ruby, ruby on rails, ruby on rails | Tagged: , , , , , , | 7 Comments »

Video of my talk “Jruby On Rails” at the Sun Open Communities Forum

Posted by javier ramirez on August 23, 2009

I just knew the video of my talk about JRuby on Rails at the Sun Open communities Forum is already online. Funny how a google alert let me know this video has been published even before the official web page of the event was updated.

The talk is in Spanish and the slides I used are available at slideshare.

If you are a Java developer interested in JRuby and you are going to be in Madrid in September, stay tuned because it’s very likely I will be speaking again about JRuby in SIMO

Posted in conferences, jruby, ruby, ruby on rails | 4 Comments »

it’s not the framework, it’s you

Posted by javier ramirez on July 21, 2009

I’m getting tired already of the hype about Ruby on Rails and how it is better than any other framework past, present or future.

Sure Rails is a cute piece of software, and Ruby is a gorgeous language (supposing you are into programming languages, that is), but if you take a critical look at Rails, you could just say it’s another MVC framework.. Big deal.. And with some coupling issues between the layers too, which are fortunately being targeted on Rails 3.

Moreover, if you take a look at some of its components they could frankly be better. ActiveRecord, for example, is a wrapper ORM, which is implicitly tying you to the physical database layer, with one class per table, as opposed to a mapper ORM such as DataMapper or Hibernate. And the principle of least surprise is kind of a joke when it comes to some of the ActionView helpers and the parameters you have to pass along.

Still, as we like to say around here “Ruby on Rails mola infinito”, and it’s right now my favourite framework for non trivial web applications.

So.. what makes this framework so special? Is it only the absence of configuration and the sensible defaults? Would we sell ourselves for a couple of parlor tricks like those? Surely not.. specially with so many frameworks providing already sensible defaults. Come on, even in Java you can kind of forget about writing so much XML code if you make proper use of annotations and the like. No, it has to be something else.

Ruby on Rails has something that transcends the framework itself. It has you. The Mighty Developer. The Early Adopter. The Status Quo Challenger. The so-called Community —whatever that means.

Bottom line is, when I get together with people working with Rails, they are always in search of the holy grail of web development —or the nearest tavern, whatever comes first.. you have to love that kind of pragmatism. We like to break our assumptions, to learn new things and forget about the ones we already know.

We embrace Rails *today* but we are willing to embrace any other tool as long as we like it better. Do you remember the months before the Merb-Rails love affair? Half the Rails developers I know were already making eyes at Merb without the slightest hint of shame.

And by challenging the system, we are obliged to keep learning… and to find new ways to build the web. And instead of trying to make a carbon copy of what we did before, we like to start anew, because that’s where the fun is.

Sure you can argue this attitude is not the exclusive property of the Rails community. And I would second you on that based on theory.. but in practice, I have seen other some other communities lack this need of challenging. Maybe it’s because they have maturity models and certifications and black belts and whatnot…. And maybe having so many constraints is killing creativity; but fact is in some environments trying to take a step forward is seen as something odd, not desirable.

Rails will pass —or not— but as long as we keep alive the spirit of embracing change, we are entitled to be on the fun side of web development.

So, if you ask me, that’s the secret ingredient of Rails. Sure the language and the framework are cool, but the real power of Ruby on Rails is you.. and me.

update: please read the comments, since I was a bit ambiguous in the post and some points needed further explanation :)

Posted in internet, javier ramirez, madrid, ruby, ruby on rails | Tagged: , , , , , | 10 Comments »

sudo: rake: command not found

Posted by javier ramirez on July 6, 2009

I hate it when it happens, don’t you?

And it’s not only rake, but some other utilities too.

Bottom line is, in Ubuntu sudo is by default set to use a secure path. You can change the secure path if you are compiling from source, but we are talking Ubuntu here, the windows for the rest of us, so you get what your package says you get and that’s fine.

There are a couple of good solutions (other than switching to gentoo or slackware ;) )

If you want to use always the same PATH as you are using in your environment, you can just set an alias to sudo and make it set the PATH every time you are invoking it.

alias sudo=”sudo env PATH=$PATH”

It’s safe enough, but notice every time you are using sudo, you will be setting the environment to that of the calling user. Do your maths and reckon whether you are comfortable with that or not.

The option I chose is a bit pickier, making a link to the rake executable from /usr/local/bin, which is one of the secure paths.

sudo ln -s `which rake` /usr/local/bin/

Either way, your problem is solved. Now go save the world! You’re welcome ;)

Posted in javier ramirez, ruby, ubuntu | 3 Comments »

Speaking at EuRuKo 2009

Posted by javier ramirez on April 23, 2009

It’s only two weeks for EuRuKo 2009, the most important Ruby conference in Europe.

As you probably know, EuRuKo is a grassroots itinerant conference, entirely organized by -and for- Ruby developers. This year, the conference will be held in Barcelona, and I have the honor of being a -tiny- part of the organization as a member of the Spanish Ruby Users Group, the local group preparing the event.

It’s also pretty cool that ASPgems is one of the sponsors. I cannot help but feel a tang of pride (awww, the diva in me ;) ) when I see the commitment and support of the company when it comes to community events.

The list of scheduled talks looks promising. Starting with Matz’s keynote there will be sessions about things like cross-platform mobile development, voice-enabled applications, interacting with MIDI instruments from Ruby, Image processing and other non-typical uses of Ruby. They have the sweet scent of EPIC WIN all over.

Did you take a look at the list of talks? Any familiar names? Well.. yours truly’s talk proposal was accepted and I’ll be speaking about game development using Ruby and Gosu. How cool is that?

I’ve been speaking at other technical events before, and I have a good deal of experience in training, but this will be the first time I do this in English. I’m sure it’s going to be an enriching personal experience.

I’m looking forward to seeing you all there.

Posted in 1771, EuRuKo, javier ramirez, madrid, ruby, ruby, ruby on rails | Tagged: , , , , , , | Leave a Comment »

Parallel Assignment in Ruby and the conditional ternary operator

Posted by javier ramirez on April 8, 2009

You already know how parallel assignment in Ruby works

irb(main):001:0> a,b=1,2
=> [1, 2]
irb(main):002:0> p a
1
=> nil
irb(main):003:0> p b
2
=> nil

and you also know how the conditional operator (the only ternary operator in Ruby) works.

irb(main):004:0> false ? a : b
=> 2

so maybe you are thinking of putting that together and, given a “wadusable” object, do something like

wadusable = 'dummy value'
wadusable_type, wadusable_id = wadusable ? (wadusable.class.name,wadusable_id) : ('DefaultClass',default_id)

Well.. think twice.. the code above will FAIL.. syntax error. So.. does it mean I cannot mix the ternary operator with parallel assignment in Ruby? Not so fast.. after applying the technique of “Complaining Programming” (you heard it first here!) diego pointed me in the right direction.

Sometimes, I tend to forget Ruby plays pretty nice when there are no ambiguities, and allows us to do certain things like omitting parenthesis when calling a method, or forget about brackets in array literals.

But when there are ambiguities, then Ruby needs to know what we really want. In this case, what I have to do is specifically use brackets around the operator return values, so Ruby can properly make the parallel assignment.

wadusable = 'dummy value'
wadusable_type, wadusable_id = wadusable ? [wadusable.class.name,wadusable_id] : ['DefaultClass',default_id]

And that’s it.

Posted in development, javier ramirez, ruby | 2 Comments »

Upgrading to RadRails 1.2.1

Posted by javier ramirez on April 7, 2009

Aptana RadRails 1.2 is out there. If you are lucky enough, your Aptana installation will prompt you to upgrade and everything will go just fine.

In case your installation is a bit too old, or if you installed everything manually and when checking for updates Aptana says there’s nothing new, you can still install the latest version by using Eclipse “software updates”.

As Chris says in the forums, the update site for RadRails is http://update.aptana.com/update/rails/3.2/

When I tried to update by using that site, I got one error because this update depends on the latest version of Aptana Studio but, you guessed it right, Aptana check for updates insisted I had already the latest one.. but I knew I didn’t.

Once again, you can use Eclipse standard update procedure by using the Aptana Studio update site corresponding to your eclipse version, as explained here.

I’ve been using the latest version all day long and so far so good. It has some nice features like the rake files overview and the “explore files” option (I can finally say bye to the EasyStruts plugin), a polished interface, and improved compatibility with Eclipse 3.3 and 3.4.

Great work from the Aptana guys .

Posted in eclipse, javier ramirez, radrails, ruby, ruby on rails | Tagged: , , , | Leave a Comment »