Using own search predicate in C++ find_if() for finding attributes in collections of data structures

If you want to find a complex data structure in a collection but looking only for a single attribute, e.g. the ID of a monster in a collection of monsters.

You need to write your own search predicate:

struct find_monster
    DWORD id;
    find_monster(DWORD id) : id(id) {}
    bool operator () ( const monster& m ) const
        return == id;

it = std::find_if( monsters.begin(), monsters.end(), find_monster(monsterID));

Thanks to:

Posted in Uncategorized | Leave a comment

Using Open Office date/time values for calculations with regular numbers

I had a a date/time field in a time sheet which contained the sum of other date/time fields in the form hh:mm. I want to use it as a regular number to convert them in a very client specific format. The solution is very simple:

24:00 will be converted to 1.0

I hope that’s a general rule, not specific to my current Open Office version.

Posted in Uncategorized | Leave a comment

Add a NIS user to be a member of a local group

sudo groupadd local_group
sudo gpasswd -a nis_user local_group

linux – Can an NIS user be a member of a local group? – Super User.

Posted in Uncategorized | Leave a comment

Clean Up Task Tags in eclipse which are already deleted

Using eclipse as an IDE for multiple languages, especially for C/C++ i have disabled automatic build. The problem was, that some TODO / Taks tags from ruby integtreation tests were still shown in the Tasks view, but already deleted from the corresponding ruby file. The solution to fix this is quiet simple:

Just select the project in Project Explorer and choose “clean” in the Project menu. Select only clean selected project and youre done.

Posted in Uncategorized | Leave a comment

Running a junit test in eclipse multiple times

If you need to execute a specific junit test multiple times because it fails only sporadicly, just add it multiple times in a loop during testsuite creation. For an example have a look at the question at stackoverflow:

java – Is there a way to make Eclipse run a JUnit test multiple times until failure? – Stack Overflow.

Posted in Uncategorized | Tagged | Leave a comment

How to install Go 1.1 on CentOS 5.9 | Dave Cheney

Nice guide to install google go 1.0 or 1.1 on RHEL 5 although it’s no supported system due to the very old kernel used.

How to install Go 1.1 on CentOS 5.9 | Dave Cheney.

Posted in Uncategorized | Leave a comment

Mac OS X: Set / Change $PATH (or other) environment variable

The two convenient ways to set the PATH (or any other) environment variable in Apple Mac OS X Snow Leopard (10.6) and higher.

  1. Edit .bash_profile in $HOME
  2. Use path_helper tool (for PATH and MANPATH only)

Detailed description:

Mac OS X: Set / Change $PATH Variable.

Posted in Uncategorized | Leave a comment