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:
Repeat the procedure for the version you want
Change the hostname to the current version:
- Make sure that the package update-manager-core is installed and install it if it isn’t:
sudo apt-get install update-manager-core
- Change the prompt from lts to normal in the file /etc/update-manager/release-upgrades:
sudo vi /etc/update-manager/release-upgrades
- And upgrade to the next version by doing:
sudo do-release-upgrade -d
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
You want to run a service/script on a server that you have logged in with ssh, but you want to leave it running even after you have terminated the ssh session.
Use the nohup command so do the following in your ssh session:
nohup /service/i_want_to_run &
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
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
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.
You want to search in a directory or some files for a specific string and you also want to know the number in the file that the text is found.
Use grep with the -n for the line number and the -r for directory search as in the following:
grep -n -r 'search_item' /path/to/folder/
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
rvm mount -r https://rvm.io/binaries/debian/6/x86_64/ruby-2.0.0-p247.tar.bz2 --verify-downloads 1
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"
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'
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=
and then go to your Web interface to set a new one.
* Based on this post