Archive for 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 →

  • Android Market 3.1.3 and 3.1.5 crash with "Force stop" error on HTC Inspire4G/DesireHD with Cyanogenmod 7.1.0-RC1

    September 29, 2011


    This post was originally published in the Rambling Labs Blog on September 29, 2011.


    Yesterday, I installed the Cyanogenmod 7.1.0-RC1 on my HTC Inspire 4G phone. It looks and works great, but since the minute I installed it, I started to have issues with the Android Market, specifically versions 3.1.3 and 3.1.2.

    So, I googled for a couple of hours and didn’t find anything until, finally, I stumbled into this fix.

    Ok, that’s fair enough. A little hardcore for the stuff I usually do, but fine. I didn’t like that it was the 2.2.7 version, but I guess that was ok if it fixed it. I tried to find a newer version of the market, but only found ‘.apk’ files, and I needed a zip.

    Well, so I rebooted into recovery mode, wiped out all my data and…

    Continue Reading →

  • git submodule and the libiconv-2.dll issue

    September 27, 2011


    This post was originally published in the Rambling Labs Blog on September 27, 2011.


    Yesterday, I made a fresh install of the latest msysGit (which is 1.7.6 as of right now).

    I usually set up my vim using the akitaonrails vimfiles. So last night I was trying to do as I usually do, clone the repository with git clone git://github.com/akitaonrails/vimfiles, and then cd into the just cloned repository and run git submodule update --init to get all the bundled plugins.

    This last command failed miserably with a The program can't start because libiconv-2.dll is missing from your computer. Try reinstalling the program to fix this problem message. This didn’t happen to me with version 1.7.4 from msysGit, which I had installed before I formatted…

    Continue Reading →

  • jQuery fadeIn and fadeOut: IE bug workaround

    September 26, 2011


    This post was originally published in the Rambling Labs Blog on September 26, 2011.


    I was trying to do some cool effect on a project I’m working on by fading in the front page. The trick looks really nice and it’s easy to implement.

    Just make the body hidden like this:

    <body style="display: none;">
    

    And in the JavaScript file do this:

    $(function(){
      $('body').fadeIn(2000);
    });
    

    Checked it out on Firefox and Chrome. It works perfectly, so smooth. And that’s it!… Or so I thought…

    Checked it out in IE 8 or less and, oh surprise, it doesn’t work. It fades in the background, but the rest of the page is shown with no transparency or fading in at all.

    But why?? Because some elements have a position: relative; or position: absolute; in their…

    Continue Reading →

  • JetBrains and the IdeaVIM plugin

    September 20, 2011


    This post was originally published in the Rambling Labs Blog on September 20, 2011.


    Last night I installed the latest version of RubyMine (just to have it as a backup plan though). I then tried to install the IdeaVIM plugin which, for older versions, had worked fine for me.

    But guess what? I downloaded and installed the plugin, restarted the IDE and it didn’t work. I thought that was odd since it usually worked after restarting. Wondering if it was an issue with RubyMine, I tried with WebStorm and PhpStorm having the same result.

    On my desperation, I went to JetBrains’ YouTrack to report a bug. And tonight, out of nowhere, I remembered that there was an option in the Tools menu…

    There it was… Tools -> VIM Emulator… unchecked…

    God,…

    Continue Reading →

  • Rails 3.1 "rake db:migrate" fails with "stack level too deep" error

    September 20, 2011


    This post was originally published in the Rambling Labs Blog on September 20, 2011.


    I was trying to run the following command on a new rails 3.1 app and it was failing… badly.

    rake db:migrate
    
    /home/edgar/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/version.rb:4: warning: already initialized constant MAJOR
    /home/edgar/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/version.rb:5: warning: already initialized constant MINOR
    /home/edgar/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/version.rb:6: warning: already initialized constant BUILD
    /home/edgar/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/version.rb:3: warning: already initialized constant NUMBERS
    /home/edgar/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/version…

    Continue Reading →

  • Rails 3.1 "rails server" error Could not find a JavaScript runtime

    September 19, 2011


    This post was originally published in the Rambling Labs Blog on September 19, 2011.


    I upgraded to rails 3.1.0 and created a new ‘test_app’.

    rails new test_app
    

    Got into the directory. Everything was fine, until I tried to run:

    rails server
    

    It threw a weird error:

    Could not find a JavaScript runtime.
    See https://github.com/sstephenson/execjs for a list of available runtimes.
    

    That’s kinda weird. What does a rails app have to do with any JavaScript runtime? I guess it’s support for something that I still don’t know anything about.

    I googled that and found a stackoverflow question. So, two solutions for the issue: either*** install nodejs*** or include “gem ‘execjs’” and “gem ‘therubyracer’” in the Gemfile and run bundle install.

    Pick…

    Continue Reading →