Ruby On Rails: Manage Ruby version / upgrade / install the latest

The smart thing to do: outsource the job of installing / upgrading / getting the lastest version to RVM. Here’s the website:

To install RVM, in the command line, run:

curl -L | bash -s stable --ruby
If you just happened to install xcode (required for rvm), you may run into the following error message:
Error installing new MacPorts base: command execution failed
If that happens, you just need to finish installing xcode:
sudo xcode-select --install

There is also another error you could get in new machines:
command not found: port

To solve this, in your /etc/paths directory, enter the following at the end:
Once RVM is in place, getting the latest version of Ruby on your machine is also a breeze:
rvm get head && rvm reload
Since RVM allows you to choose which version of Ruby you want to run, it also lets you pick a gem set, which you can customize to work for that version. To do that run:
rvm use 1.9.3@devgemset --create --default
This will instruct rvm to create a get set called devgemset, and set it as the default gem set for 1.9.3
RVM also installs RubyGems as part of its magic, so now you have an in-house gems manager under the hood. To verify RubyGems is there, run:
which gem
To install rails in your system, run:
gem install rails -v 3.2.3

javascript: when scope inside setTimeOut is giving you headaches

Sometimes you have to setTimeOut call a function, but you need to provide the current scope for the function to execute as well.

Say for example, you want to call this.myFunction()

with (this) { setTimeout( function() { myFunction() }, 1000 );}

Doing the with(this) allows you to pass “this” scope, so myFunction will get executed as this.myFunction()

There are a million things wrong with doing the above. First, myFunction will try to execute off the Global, also, with is heavy performance-wise. But it works. Use it sparingly.