Archive for December 16, 2011

  • Using RVM within a cron job

    December 16, 2011


    This post was originally published in the Rambling Labs Blog on December 16, 2011.


    Long time no post! I’ve been really busy these days with some projects. Yet, here I am again, so here it goes.

    A couple of days ago, I started working on a big story in one of those projects I’m currently working on. It’s one of those things that needs to be run a couple of times a day… yeah, a scheduled background job.

    Basically, what it need to do is check some database records, check their expiration date against the current date, and take some actions for each one of the expired ones. Simple enough, right?

    I went ahead and wrote a rake task that would do the heavy work. Something like this:

    task :check_expired_records do
      Record.where('expired =…

    Continue Reading →

  • CoffeeScript: The '=>' operator

    December 16, 2011


    This post was originally published in the Rambling Labs Blog on December 16, 2011.


    As you may know, I’ve been playing around with CoffeeScript for a couple of months now.

    One of CoffeeScript’s jewels that I haven’t talked about yet and that I’ve been using lately on the jQuery Rambling Slider codebase, is the => operator. It is basically a custom function definition, which binds that function to the current context. That is, it ties the this value of the outer scope to the this value of the function being defined.

    How many times, writing JavaScript, have you done something like this:

    var outerFunctionWithCallback = function(options, callback) {
      /* Do something with options */
      callback();
    };
    
    var theFunction = function(){
      var self

    Continue Reading →