How to set background color in ImageMagick

PDF, SVG, PNG and many other image formats can have a transparent background. Sometimes, you might want to set the background color in image files. This can be done easily using the -background and -flatten options.

For example, to convert a PDF to JPG file and set the background color in the resulting file to white:

$ convert foo.pdf -background "#FFFFFF" -flatten foo.jpg

Tried with: ImageMagick 6.7.7.10 and Ubuntu 14.04

How to run program in background using Byobu

When running a training program, that might take hours to complete, I like to run it in the background. However, it should keep running even if I kill my current shell. I should be able to bring it back to the foreground and check its console output and then send it back to background. I should be able to do this any number of times.

The solution that fulfilled these requirements was to run the program in a new Byobu session. This is how I do it:

  • From my current shell, I launch a new Byobu session and start the program I want to run from its shell:
$ byobu
$ ./my-program
  • To detach from this Byobu session, just press Ctrl+a followed by d.

  • To re-attach to the Byobu session and check the progress of my program, invoke Byobu again from any terminal or shell.

The advantage of this setup is that Byobu is not the child of my shell, but rather of the desktop lightdm process. So, it will keep running even if my terminal is hung or killed. It also enables me to see the console output of the program anytime I want.

Tried with: Byobu 5.74, TMux 1.8 and Ubuntu 14.04

How to set background in Vim

The background setting in Vim is used to determine what colors to use for rendering the various elements of the editor. The setting takes one of only two values: dark or light.

By default, light background is used for GVim. For terminal Vim, the default background value is set based on the terminal. So, sometimes you may be using a dark terminal, but Vim might still use the light background. This results in weird colors that make Vim hard to use.

To control the background yourself, set it in your vimrc. For example, I like to set light background for GVim and dark background for all terminals:

Tried with: Vim 7.3 and Ubuntu 12.04 LTS