Saturday, September 8, 2012

Ubuntu 12.04LTS Bug - Close, minimize and Maximize button becomes invisible in GNOME

Recently, I faced this issue of application window not showing the top most bar - containing close, minimize and maximize button.

I was using Ubuntu 12.04 LTS with GNOME Desktop Theme. As usual the problem was with ccsm (CompizConfig Setup Manager).

All I had to do was to go to Application -> Settings ->Compizconfig Setup manager (just type ccsm on the shell.)

once that is done, unmark (if already marked) and then mark again the Effects -> Window manager tab.



Try opening a shell. I hope this time you see the close minimize and maximize buttons.

==Don==

Wednesday, September 5, 2012

DPRINTF Debug Macro in C

Extremely useful for Debugging projects in C.


#define DEBUG   // comment if you do not want the debug statments to appear.

#ifdef DEBUG
#define DPRINTF(fmt, ...) \
    do { printf("my_file: " fmt, ## __VA_ARGS__); } while (0)
#else
#define DPRINTF(fmt, ...) \
    do { } while (0)
#endif




Usage -> DPRINTF("This is a debug statement");

if you want the debug statements to appear, then define DEBUG
#define DPRINTF
at start of the code.

if, on the other hand, you do not wish the debug statements to appear, comment it.

you can add additional information to your debug statement, for example -

DPRINTF("%p:%d Debug statement\n",__func__,__LINE__);

this gives both the function name and the line number of the DPRINTF statement along with the message "Debug statement".



Sunday, September 2, 2012

Get real clock time in C to nanosecs approximation

struct timespec start,end;

clock_gettime (CLOCK_REALTIME, &start);
<add code here>
clock_gettime (CLOCK_REALTIME, &end);
float time= (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1000000000;

This code snippet would give you the time taken to execute the added code in real time.

Dont forget to compile your code with a -lrt flag. Not including this flag could  give you a ld error for not finding clock_gettime function.