Thursday, February 19, 2009

Gnuplot available point types

I keep forgetting the point types available in gnuplot and end up invoking the help each time I have to figure out which integer corresponds to which available point type. I have a real bad case of bad memory ( if that made any sense at all ). Anyways here is what you have to do. Invoke gnuplot at command prompt and issue the command:

test


that will pop up a screen that will help you out.

Monday, February 16, 2009

Prevent autoplaying of youtube videos

This solution will buffer your youtube videos but won't play them automatically. This is nice if you open more than one youtube videos in multiple tabs. Here is what you have to do:
  1. Install the Greasemonkey extension in Firefox
  2. Restart Firefox
  3. Install the Youtube Buffer Video user script
That's it you are done !

Learn't this neat trick at this page :D

Tuesday, January 27, 2009

On some useful MACROS in C/C++ for debugging purposes

Like a stupid idiot I begin all my C++ files with the following construct:

#include
static const std::string thisFileName = "foo.cpp" ;


and then within each function I declare the following

const string thisFuctionName = "void bar()" ;


I do this so that I can print some useful information when I write an error summary to the error stream.

if ( !paraFile.is_open() )
{
cerr << "File: " << thisFileName << endl ;
cerr << "Function: " << thisFunctionName << endl ;
cerr << "ERROR: Could not open "<< paraFileName << endl ;
exit(EXIT_FAILURE);
}


This way I don't have to individually change the filename and function
name keeping the general structure of the construct more or less fixed.

Today I found this useful presentation on this page which informed me that some
useful MACROS are predefined that take care of such situations.

__FILE__

and

__LINE__



I feel like a first class idiot not knowing these things.

Thursday, January 22, 2009

function overloading blues in C++

Can I overload functions with different return types ?

I wanted to overload a function just by changing the return type of the function. Turns out that this is not allowed at all :(
So the following overloading will not work

double squareMe(int x);
int squareMe(int x);

Got my answer here.

One solution is to do this :

void squareMe(double & y, int x);
void squareMe(int & y, int x);



Tuesday, January 6, 2009

Some make questions for C++ files

These questions are related to make when working with C++ files.
  • What is the difference between CPPFLAGS and CXXFLAGS ? What are some common values for these variables ?
    • In this a partial answer ?
  • LDLIBS and LOADLIBES ?

By the way to check the default variables that make uses, do the following:

make -p -f /dev/null


While looking for some answers to these questions I found this very helpful anchor.

C++ header files: angle brackets or double quotes ?

While looking for solution to a problem I stumbled onto this article. Discovered the reasons why C++ headers do not have a .h extension too.

That article also praises the book C++ in a Nutshell by Ray Lischner. I might have to check that one out though I learn't my C++ from Stephen Prata's excellent book C++ Primer.

Friday, December 12, 2008

Edit sudoers file on Fedora Linux

Recently I had to edit the sudoers file and I learnt that a dedicated editor for this task exists. The editor is called visudo. On Fedora Core 7 I found it at /usr/sbin/visudo .

Got the job done but am wondering now if there is something like emacssudo. Hmmm !!!