Remove terminated/unused docker containers from your system

Problem

After playing around with docker containers for some time the terminated/unused ones are still hanging around your system, and prevent you from using a new container with the same name as any of the previous ones with the error:

Solution

You can remove all the containers by using the following:

git apply name_of_file.patch does not work

Problem

You are given a patch file to apply to your git repository but using git apply does not work. No errors reported but no changes applied neither.

Solution

Try to use the patch command command possibly with the -p1 parameter like:

NOTE: Make sure that you are in the right folder relative to the file path in the patch file

SSL received a record that exceeded the maximum permissible length.

Problem

You want to install rbenv, but when you are trying to clone the code with:

you get the following error:

Solution

If you are behind a proxy server make sure that you add your proxy server details in your ~/.bash_profile and source the file afterwards.

So first add the details of your proxy like:

And finally source the file before running the installation again:

Creating a simple rails docker image for testing in cloud deployment

Trying to deploy a rails application in a cloud provider ie dreamhost, that uses OpenStack these are the steps needed:

  1. Install docker in your development machine and your cloud provider by following the installation instructions from here
  2. Create an account in Docker Hub, that will be needed later on to push your docker image with the application
  3. Pull the official rails docker image to your development environment:
  4. Create a new simple rails application:
  5. Change to the application directory and add a Dockerfile in the root directory containing the following:
  6. Build your new image by using:
  7. Check that your image was build by using:
  8. Start the container with:
  9. Make sure that you can see the initial rails page by using your browser to go to http://127.0.0.1:3000
  10. Push your image to your Docker Hub account by first logging in to it from the command line: , and then when you get ‘Login Succeeded’, push your image to your account:
  11. TBC

rvm single user installation fails with: curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

Problem

You want to install rvm as a single user in a new linux but when trying to install it with the normal installation instruction:

it fails with the following error:

Solution

You are behind a proxy server and you need to setup your environment variables for the server in your .profile file like the following (and make sure you source the file afterwards with . ~/.profile):

Replacing spaces with underscores in linux busybox

Problem

You want to replace the spaces in filenames (ie in Brennan’s B2 system), that uses busybox and you do not have all the linux commands available.

Solution

Use the following in the directory with the files (ie flac files). At the moment this command only works in the directory that is being run.

Capturing output with UnitTest in Ruby

Problem

You have some ruby code, a rake task for example, that outputs some results in the standard output, but you would like to test it in your unit tests.
MiniTest has capture_io and capture_subprocess_io, but there is nothing similar in UnitTest.

Solution

Looking at the code of the above MiniTest assertions you can create your own assertion to be used in your tests.

Create a new file under your test folder called MyAssertions and use the following code (taken from MiniTest), for your capture_output assertion:

Then include it in your test_helper.rb file with:

and use it in your tests like: