Archive for October 2011

  • Rails 3.1 and the assert_select_jquery

    October 8, 2011


    This post was originally published in the Rambling Labs Blog on October 8, 2011.


    Diving a little into rails 3.1, I’m really liking some of the stuff I’ve found, like the easy Ajax integration for the views and the functional tests to ensure that the behavior of the controllers is the expected one.

    There is one particular method, assert_select_jquery, that I just don’t understand why it works how it works.

    Let’s say you have an Ajax request whose view to return is content.js.erb like this:

    if($('#container').is(':not(:visible)')) $('#container').show('blind', 1000);
    $('#container').html('<%= render @content %>');
    

    Ok, the page renders as expected, but, as you can see, this code is not too great. We’ll talk about that later. So, say you…

    Continue Reading →

  • Updating and/or uninstalling all installed gems

    October 8, 2011


    This post was originally published in the Rambling Labs Blog on October 8, 2011.


    I like to have an rvm gemset (see more about rvm) with the latest versions of all gems and I usually use this as my sandbox for testing out the latest features and issues of the gems. To update one gem to it’s latest stable version, you just have to run this:

    gem update GEMNAME
    

    The only problem is that for updating every gem you have installed, you have to remember each and every gem you have installed to pass it to the command… Nah, I’m just kidding. Just run the following command, and you’ll be fine:

    gem update `gem list | cut -d ' ' -f 1`
    

    UPDATE

    To uninstall all installed gems, it’s the same command with uninstall instead of update, like this:

    gem…

    Continue Reading →

  • Change cursor highlight color on Vim

    October 7, 2011


    This post was originally published in the Rambling Labs Blog on October 7, 2011.


    One of the first things I do when setting up my Vim on Ubuntu is download akitaonrails’ vimfiles, which has lots of cool stuff bundled. I like the dark theme that is set up (dark gray background and white foreground, and helps my sight issues).

    Normally the blinking cursor is white background and black foreground. I don’t really know exactly when or how it happened (maybe when I installed CommandT), but I lost the blinking cursor… I mean, I didn’t lose it.. It was there… But it was invisible. And that annoys me ‘cause I can’t tell where I’m at in the file.

    Thankfully, it’s an easy recovery. Just run what I found in Vim’s command mode:

    highlight Cursor guifg

    Continue Reading →

  • jQuery Nivo Slider and images of different size

    October 1, 2011


    This post was originally published in the Rambling Labs Blog on October 1, 2011.


    A couple of days ago, I needed to add a slideshow to a project that I’m currently working on.

    When I googled “jQuery Slider”, I found lots and lots of options. I checked some of them out one by one, and one by one I discarded them, because it lacked a feature I wanted or, if it had the feature, it lacked cool animations.

    I finally settled up for the Nivo Slider. But it had an issue. It used the images as the current background for the slider, which then meant that the images had to be the same size.

    That might be fine if you have someone that crops the images to the required size… But what if you’re doing a project where it’s the end users that are going…

    Continue Reading →