Archive for February, 2012

View your logs and program output in color

Multitail allows you to highlight log files or the output of your programs.

Color schemes for various types of logs are provided by default in /etc/multitail.conf

It is quite easy to add a custom color scheme. For example to highlight all directory changes, warnings, and errors during a build you can add the following to your multitail configuration:

# GCC specific colorscheme
colorscheme:build
cs_re:white,,bold:\.+/.*:[1-9]+:
cs_re:yellow:warning:.*
cs_re:red:error:.*
cs_re:green:cd .*
cs_re:red:.*:.*:.* Assertion failed:

Now if you want to follow a log file with the colorscheme definitions you can use:

multitail -cS build ~/build.log

To invoke a program (e.g. make) directly you can use:

multitail -cS build -l "make"
Wednesday, February 29th, 2012 Uncategorized No Comments

Importing part of a bazaar repository

First we export the repository into a dump file.

bzr fast-export myRepository > repository.export

Then we pick out only the subdirectory we want to see in our new repository.

cat repository.export |bzr fast-import-filter -i mySubDirectory > repositoryFiltered.export

Finally we import repositoryFiltered.export.

mkdir repository
cd repository
bzr init-repo .
mkdir newBranch
cd newBranch
bzr init .
bzr fast-import ../../repositoryFiltered.export

The resulting repository contains only the parts we picked out.

Sunday, February 5th, 2012 Uncategorized No Comments

Initialization list order

It is often recommended to keep the initialization lists in the same order as your class members in C++. This article shortly explains the reasons for this.

C++ initializes class members in the order they are declared. The order of the initialization list does not matter for functionality. Consider the following piece of code:


#include
class A
{
public:
A(int in) : b(a+1), a(in) {} // No problem if b occurs first in the list and depends on a.
// The order of declarations really matters for initialization
int a;
int b;
};

int main()
{
int in;
std::cin >> in;
A a(in);
std::cout << a.a << " " << a.b << std::endl; } [/cpp] We can move around the intialization list order, but behavior will stay the same. For readibility however, it is recommended to have the more independent members listed first. If however we would put b as the first class member, we would get unexpected results. What would happen is that a would be initialized first and get a default (0) value, followed by initialization of b (0+1). Only after this, a would be initialized with value given by the user. Therefore, b will always be 1, no matter what input is given.

Friday, February 3rd, 2012 Uncategorized No Comments

Setting up a multi-monitor configuration in XFCE

First of all, enable all your monitors in XFCE. By default this will give you a mirrored image.

Then run:

xrandr

This will give show some information on your monitors and show their identifiers such as DVI-0 and VGA-0.

When you have the identifiers, you can configure the screens to show side-by-side by running:

xrandr --output DVI-0 --left-of VGA-0

Source

Wednesday, February 1st, 2012 Uncategorized No Comments