Upgrading and creating new virtualbox vagrant boxes from the standard precise32 box


You would like to use a current version of a Virtualbox vagrant box, based on the official precise32 box, like saucy32.


  • Build your first vagrant box using the precise32 box
  • Install any packages that you need
  • Upgrade your distribution by doing the following:
    1. Make sure that the package update-manager-core is installed and install it if it isn’t:
      sudo apt-get install update-manager-core
    2. Change the prompt from lts to normal in the file /etc/update-manager/release-upgrades:
      sudo vi /etc/update-manager/release-upgrades
    3. And upgrade to the next version by doing:
    4. sudo do-release-upgrade -d
  • Repeat the procedure for the version you want
  • Change the hostname to the current version:
    sudo vi /etc/hostname
    sudo vi /etc/hosts
  • Logout from the box and package it:
    vagrant package --output /home/path_to_new/packagename.box
  • Add the box to the list of boxes:
    vagrant box add quantal32 /home/path_to_new/packagename.box
  • You can use your new box now in a new vagrant box:

    vagrant init --packagename.box

Ruby on Rails and Django

There was a need recently to start a new web application using Python as the development language.

Having spent most of the last few years developing using Ruby with Ruby on Rails, this presented a nice challenge.
So the first thing, that needed some research was to be able to find a web framework in Python that is as close as possible to Ruby on Rails.

A quick web framework comparison and some web searches, indicated that the closest framework to Ruby on Rails, was Django.

So here I intend to list the similarities and the differencies of the two frameworks, as I go along the route and discover new things. The initial impression after a couple of days is that there is a surprising similarity between them, which hopefully will make the road smoother.

  • MVC In the Ruby on Rails we have Models, Views and Controllers. In Django that becomes Models, Templates and Views.
  • Package installation While in Ruby on Rails we have gem install in Django that becomes pip install
  • RVM(rbenv) To keep ruby versions and gems in different environments in Ruby we could use RVM or rbenv. On Python that is virtualenv
  • In Ruby on Rails we have an application but in Django we have a project that can contain multiple applications
  • Create a new application Because of the note above in Rails we create a new application with rails new app_name, where in Django we create the project first with django-admin.py startproject project_name and then the application with python manage.py startapp app_name
  • Database configuration In Ruby on Rails the database configuration can be found in the config/database.yml. In Django the database configuration, among other configuration options, is in the file project_name/settings.py
  • Starting the development web server With Ruby on Rails is rails s, on Django is python manage.py runserver
  • Running the console In Rails we can use rails c, and in Django python manage.py shell
  • Route information While in Ruby on Rails we set the routes in config/routes, in Django that takes place in project_name/urls.py and in app_name/urls.py
  • Deployment automation Capistrano for Ruby on Rails and Fabric for Django
  • Dependencies file is the Gemfile in Ruby on Rails and requirements.txt in Python’s virtualenv

Session secret should not be included in version control near line …


After using brakeman to test for security issues in your rails application you get the following warning about the config/initializers/secret_token.rb file:

Session secret should not be included in version control near line xx


Since you may have already pushed the original secret_token.rb in your version control you may need to do the following.

  • Make a copy of the file : cp config/initializers/secret_token.rb config/initializers/copy_of_secret_token.rb
  • Delete the original file that is also on your version control: rm config/initializers/secret_token.rb
  • Add it to .gitgnore
  • Commit your changes and push to your version control: git commit -a -m “remove secret token and include it in .gitignore”, git push (origin master)
  • Create a new secret key by running: rake secret
  • Copy the value from above to the file config/initializers/copy_of_secret_token.rb replacing the original value of config.secret_key_base
  • Rename the file to secret_token.rb again: mv config/initializers/copy_of_secret_token.rb config/initializers/secret_token.rb
  • Check that the new file is not listed in git when you do : git status

Refreshing locally remote branches that have been deleted in git


You would like to refresh your local git repository after deleting some remote branches, usually after merging them to a develop,master etc repository, so doing branch -a or branch -r would not display them anymore.


You would need to issue the following git command:

git remote prune origin

And then doing a branch -r or branch -a should not display the deleted remote branches anymore.

Dreamhost keeps asking for password when installing rvm ruby version


After installing rvm on dreamhost, when trying to install any ruby version afterwards, there is a prompt for password, and when entering the user’s password there is the message that the user is not in the sudoers list.


To be able to install the rvm ruby version you would like you should be installing them by using the following which is based on the answer here :

rvm list remote

and then:

rvm mount -r https://rvm.io/binaries/debian/6/x86_64/ruby-2.0.0-p247.tar.bz2 --verify-downloads 1

fatal: cannot exec ‘/tmp/…/git-ssh.sh’: Permission denied – Capistrano, Dreamhost, permission denied for git-ssh.sh


When trying to use the new Capistrano 3.x to set up your rails project in a dreamhost account, you get the following error complaining that the git-ssh.sh script copied to your account by capistrano cannot be executed as the permission is denied:

fatal: cannot exec '/tmp/example.com/git-ssh.sh': Permission denied


It seems that Dreamhost, and quite possibly other hosting providers are not allowing executables from the /tmp directory, which is where Capistrano places the git-ssh.sh script. So in order to be able to execute the script you can change the directory where the script is copied in the first place and put is in your home directory. You can do that by adding the following to the config/deploy.rb file:

set :tmp_dir, "/home/dh_user_name/tmp"

Creating an alias that migrates both development and test databases in rails project


In your rails project very often, after creating a new migration, you have to run the migration in the development database and then in the test database.


A neat way to combine both these steps as one, taken from the book Rails 4 in Action, is to create an alias in your ~/.bashrc configuration file with the following, so that you only have to run migrate after each migration that would apply the migration in both development and test databases:

alias migrate='bin/rake db:migrate && bin/rake db:test:prepare'

Resetting the web-gui dd-wrt password with telnet


You have forgotten your web-gui credentials to login into your dd-wrt router but you have still telnet access to it.


Login with telnet to your router and then run the following two commands to reset the web interface:

nvram set http_passwd=
nvram commit

and then go to your Web interface to set a new one.

* Based on this post