Thursday, December 27, 2007
Managing Stress
Today we have more stress in our lives than ever before – good stress, bad stress, red stress, blue stress . No matter what kind of stress it is, a real crisis or an imagined one, stress is incredibly harmful to our body, mind and soul. Here are a few self-care habits for dealing with stress
1. Get in the habit of noticing.
Take an inventory of all the things that just don't feel right in your life or that you know are causing you stress. For example, when you approach certain people, places or situations do you feel more stress and tension? Once you have your list in place, look at what you can change yourself, and do it. You can also use this list to predict stressful situations before they occur.
2. Get in the habit of asking for help.
For what you can't change yourself, you need a team. Build a team of experts to handle your list. A coach, at the top of the list, will help with the big picture and will keep you honest about your efforts. Other team members might be a family doctor who listens to you, a financial planner, a massage therapist and an exercise partner.
3. Get in the habit of bouncing back.
Think of Plan A as your basic self-care plan while stress is under control. Now imagine something happens and you are under stress. Instead of abandoning all self-care because you can't do it all, have a Plan B ready beforehand.
4. Get in the habit of relaxing.
If you practice relaxation techniques (breathing, meditation, imagery, music) every day, then when stressful situations come up you'll have the tools at your fingertips.
5. Get in the habit of gratitude.
Our attitude comes from our emotions and our emotions come from our thoughts. Thinking about what we're grateful for and what we're good at can keep things positive. It's not about shying away from what's challenging you - it's about approaching life from a place of strength and not as a victim.
6. Get in the habit of creating.
Experiment with a new recipe in the kitchen, write a poem, bang a drum, do a craft, take a dance class or do something else that feels creative to you.
7. Get in the habit of putting your stuff away.
Physical clutter can really impact mental, emotional and physical health. Get rid of things that don't make you happy when you look at them. Organize your stuff. Find a place for everything and keep it there.
8. Get in the habit of breathing.
This is the simplest and quickest way to relax yourself in a stressful situation. The minute you focus on your breathing it automatically gets slower and deeper.
9. Get in the habit of daydreaming.
Take yourself away on an imaginary holiday. Just close your eyes and go! Picture somewhere you've been or somewhere you've dreamed of.
10. Get in the habit of giggling. Laugh out loud every day.
Saturday, October 27, 2007
Some Weird Facts...
tend to chew your food on your right
side. If you are left handed, you will
tend to chew your food on your left
side.
[2] If you stop getting thirsty, you
need to drink more water. For when a
human body is dehydrated, its thirst
mechanism shuts off.
[3] Your tongue is germ free only if
it is pink. If it is white there is a
thin film of bacteria on it.
[4] The Mercedes-Benz motto is 'Das
Beste oder Nichts', meaning 'the best
or nothing.
[5] The Titanic was the first ship to
use the SOS signal.
[6] The pupil of the eye expands as
much as 45 percent when a person looks
at something pleasing.
[7] The average person who stops
smoking requires one hour less sleep a
night.
[ 8] Laughing lowers levels of stress
hormones and strengthens the immune
system. Six-year-olds laugh an average
of 300 times a day. Adults only laugh
15 to 100 times a day.
[9] The roar that we hear when we
place a seashell next to our ear is
not the ocean, but rather the sound of
blood surging through the veins in the
ear.
[ 10] Dalmatians are born without
spots.
[11] The owl is the only bird to drop
its upper eyelid to wink. All other
birds raise their lower eyelids.
[12] Roosters cannot crow if they
cannot extend their necks.
[13] Every time you sneeze some of
your brain cells die.
[14] When you blush, the lining of
your stomach also turns red.
[15] When hippos are upset, their
sweat turns red.
[16] The lion that roars in the MGM
logo is named Volney.
[17] Google is actually the common
name for a number with a million
zeros.
[18] Switching letters is called
spoonerism . For example, saying jag of
Flapan, instead of flag of Japan.
[19] It cost 7 million dollars to
build the Titanic and 200 million to
make a film about it.
[20] The attachment of the human skin
to muscles is what causes dimples.
[21] The sound you hear when you crack
your knuckles is actually the sound of
nitrogen gas bubbles bursting
[22] It takes about 20 seconds for a
red blood cell to circle the whole
body.
[23] Most soccer players run 7 miles
in a game.
[24] The only part of the body that
has no blood supply is the cornea in
the eye. It takes in oxygen directly
from the air.
[25] In most watch advertisements the
time displayed on the watch is 10:10
because then the arms frame the brand
of the watch and make it look like it
is smiling.
[26] Colgate faced big obstacle
marketin g toothpaste in Spanish
speaking countries. Colgate translates
into the command "go hang yourself."
[2 7] The only 2 animals that can see
behind itself without turning its head
are the rabbit and the parrot.
[28] Intelligent people have more zinc
and copper in their hair.
[29] Do you know the names of the
three wise monkeys? They are:
Mizaru (See no evil),
Mikazaru(H ear no evil), and
Mazaru (Speak no evil).
[30] Women blink nearly twice as much
as men.
[31] German Shepherds bite humans more
than any other breed of dog.
[32] Large kangaroos cover more than
30 feet with each jump.
[33] A whip makes a cracking sound
because its tip moves faster than the
speed of sound.
Tuesday, October 16, 2007
Job Hopping
It is really nice piece of an article I found, WORTH READING!
There are never better pastures - only other pastures!
It's yet another day at office. As I logged on to the marketing and advertising sites for the latest updates, as usual, I found the headlines dominated by 'who's moving from one company to another after a short stint', and I wondered, why are so many people leaving one job for another? Is it past now to work with just one company for a sufficiently long period?
Whenever I ask this question to people who leave a company, the answers I get are: "Oh, I am getting a 200% hike in salary"; "Well, I am jumping three levels in my designation"; "Well, they are going to send me abroad in six months".
Then, I look around at all the people who are considered successful today and who have reached the top - be it a media agency, an advertising agency or a company. I find that most of these people are the ones who have stuck to the company, ground their heels and worked their way to the top.
And, as I look around for people who changed their jobs constantly, I find they have stagnated at some level, in obscurity!
In this absolutely ruthless, dynamic and competitive environment, there are still no short cuts to success or to making money. The only thing that continues to pay, as earlier, is loyalty and hard work. Yes, it pays! Sometimes, immediately, sometimes after a lot of time. But, it does pay.
Does this mean that one should stick to an organization and wait for that golden moment? Of course not. After a long stint, there always comes a time for moving in most organizations, but it is important to move for the right reasons, rather than superficial ones, like money, designation or an overseas trip. Remember, no company recruits for charity.
More often than not, when you are offered an unseemly hike in salary or designation that is disproportionate to what that company offers it current employees, there is always unseen bait attached.
The result? You will, in the long-term, have reached exactly the same levels or maybe lower levels than what you would have in your current company.
A lot of people leave an organization because they are "unhappy". What is this so-called-unhappiness? I have been working for donkey's years and there has never been a day when I am not unhappy about something in my work environment-boss, rude colleague, fussy clients etc.
Unhappiness in a workplace, to a large extent, is transient. If you look hard enough, there is always something to be unhappy about. But, more importantly, do I come to work to be "happy" in the truest sense? If I think hard, the answer is "No". Happiness is something you find with family, friends, may be a close circle of colleagues who have become friends.
What you come to work for is to earn, build a reputation, satisfy your ambitions, be appreciated for your work ethics, face challenges and get the job done.
So, the next time you are tempted to move, ask yourself why are you moving and what are you moving into?
Some questions are:
· Am I ready and capable of handling the new responsibility? If yes, what could be the possible reasons my current company has not offered me the same responsibility?
· Who are the people who currently handle this responsibility in the current and new company? Am I as good as the best among them?
· As the new job offer has a different profile, why have I not given the current company the option to offer me this profile?
· Why is the new company offering me the job? Do they want me for my skills, or is there an ulterior motive?
An honest answer to these will eventually decide where you go in your career- to the top of the pile in the long term(at the cost of short-term blips) or to become another average employee who gets lost with time in the wilderness?
"DESERVE BEFORE YOU DESIRE" - Dr. Gopalkrishnan, Chairman TATA Sons.
Saturday, October 6, 2007
Standard C++ Libraries Frequently Asked Questions
A1: The Standard C++ library provides an extensible framework and contains components for language support, diagnostics, general utilities, strings, locales, standard template library (containers, iterators, algorithms, and numerics), and input/output.
The Standard C++ library can be divided into the following categories:
1. | Standard Template Library (STL) components provide a C++ program with access to a subset of the most widely-used algorithms and data structures. STL headers can be grouped into three major organizing concepts:
| ||||||||
2. | Input/Output includes components for forward declarations of iostreams ( | ||||||||
3. | Other Standard C++ headers include:
|
Q2: What is the difference between C-Runtime library and Standard C++ library? What libraries will the Runtime library compiler options such as /ML, /MT, /MD, /MLd, /MTd, and /MDd include?
A2: Visual C++ 5.0 and later include the following libraries in addition to the Microsoft Foundation Classes (MFC) libraries:
• | Basic C-Runtime library. |
• | Standard C++ library. |
• | Old iostream library. |
|--------------------------------|---------------------------|* NOTE: MSVCPRT.lib and MSVCPRTD.lib are static libraries and do not have any dynamic link libraries (DLLs) directly related to them. These libraries are also dependent on MSVCRT.dll and MSVCRTD.dll, respectively. If you have any applications that use MSVCPRT.lib or MSVCPRTD.lib and you use the "Ignore Default Library" (/NOD or NODEFAULTLIB) option, be sure to link MSVCPRT.lib (or MSVCPRTD.lib) and MSVCRT.lib (or MSVCRTD.lib) with your application. Otherwise, you will get linker errors (LNK2001: unresolved externals in MSVCPRT.lib or MSVCPRTD.lib) when linking your application.)
| Library types and | Basic C Runtime |
| related compiler switches | library |
|--------------------------------|---------------------------|
| Single-threaded (ML) | LIBC.lib |
| Multithreaded (MT) | LIBCMT.lib |
| Multithreaded DLL version (MD) | MSVCRT.lib (import |
| | library for |
| | MSVCRT.dll) |
| Debug single-threaded (MLd) | LIBCD.lib |
| Debug multithreaded (MTd) | LIBCMTD.lib |
| Debug multithreaded DLL (MDd) | MSVCRTD.lib (import |
| | library for |
| | MSVCRTD.dll) |
|------------------------------------------------------------|
|--------------------------------|---------------------------|
| Library types and | Standard C++ |
| related compiler switches | library |
|--------------------------------|---------------------------|
| Single-threaded (ML) | LIBCP.lib |
| Multithreaded (MT) | LIBCPMT.lib |
| Multithreaded DLL version (MD) | MSVCPRT.lib*(Also uses |
| | MSVCRT.dll) |
| Debug single-threaded (MLd) | LIBCPD.lib |
| Debug multithreaded (MTd) | LIBCPMTD.lib |
| Debug multithreaded DLL (MDd) | MSVCPRTD.lib* (Also |
| | uses MSVCRTD.dll) |
|------------------------------------------------------------|
|--------------------------------|---------------------------|In Visual C++ 5.0 and later, there are certain default libraries that your program will link with. When you build a release version of your project, one of the basic C-Runtime Libraries (LIBC.lib, LIBCMT.lib, or MSVCRT.lib) is linked by default, depending on the compiler option you choose (single-threaded
| Library types and | Old iostream |
| related compiler switches | library |
|--------------------------------|---------------------------|
| Single-threaded (ML) | LIBCI.lib |
| Multithreaded (MT) | LIBCIMT.lib |
| Multithreaded DLL version (MD) | MSVCIRT.lib (import |
| | library for |
| | MSVCIRT.dll) |
| Debug single-threaded (MLd) | LIBCID.lib |
| Debug multithreaded (MTd) | LIBCIMTD.lib |
| Debug multithreaded DLL (MDd) | MSVCIRTD.lib (import |
| | library for |
| | MSVCIRTD.dll) |
|------------------------------------------------------------|
For example, if you specify the /ML (single-thread version) compiler option and include
Headers determine whether the Standard C++ Libraries and old iostream Libraries will be linked. Compiler options (/ML[d], /MT[d], /MD[d]) determine which version of the libraries (single-threaded, multithreaded, or DLL) is to be linked by default.
NOTE: It may seem that headers without the ".h" extension are Standard C++ headers and ones with the ".h" extension are C-Runtime headers or old iostream headers. This is not true. As explained below, the files
Actually, there are two header files,
The header file
|-------------------------|The header file
| Old iostream headers |
|-------------------------|
| |
| FSTREAM.H | IOMANIP.H |
| IOS.H | IOSTREAM.H |
| ISTREAM.H | OSTREAM.H |
| STDIOSTR.H | STREAMB.H |
| STRSTREA.H | |
|-------------------------|
|-------------------------------------------------|You cannot mix calls to the old iostream library and the new Standard C++ library.
| Standard C++ Headers |
|-------------------------------------------------|
| ALGORITHM | BITSET | COMPLEX | DEQUE |
| EXCEPTION | FSTREAM | FUNCTIONAL | IOMANIP |
| IOS | IOSFWD | IOSTREAM | ISTREAM |
| ITERATOR | LIMITS | LIST | LOCALE |
| MAP | MEMORY | NUMERIC | OSTREAM |
| QUEUE | SET | SSTREAM | STACK |
| STDEXCEPT | STREAMBUF | STRING | STRSTREAM |
| TYPEINFO | UTILITY | VALARRAY | VECTOR |
|-------------------------------------------------|
Q3: How do I retain the old iostream functionality if I port my project from an earlier version of Visual C++?
A3: If you want to retain the old iostream library, include one or more of the old iostream header files in your code. Do not use the new Standard C++ headers. You cannot mix calls to the old iostream library and the new Standard C++ library.
Q4: How do I make the Standard C++ Libraries the default libraries for my application?
A4: If you want to make the Standard C++ Libraries the default, include one or more of the new Standard C++ headers. Remember, you cannot mix calls to the old iostream and the new Standard C++ library. Existing libraries (static or dynamic link) that use old iostream functions will have to be modified to use Standard C++ library iostream functions.
Q5: I want to use Standard C++ Libraries in a Microsoft Foundation Classes (MFC) application. Will this cause any conflicts with the C-Runtime Libraries?
A5: No. MFC does not use any C-Runtime functions that will conflict with the Standard C++ Libraries.
Q6: Why do I get error "error C2065: 'cout' : undeclared identifier" even though I have included
A6: Standard C++ library is implemented in its own namespace "std". Make sure to add the statement
using namespace std;in the beginning of your program or to qualify each Standard C++ library identifier with namespace std, for example, std::cout.
Q7: Why am I getting "compiler error C2371: 'identifier' redefinition; different basic types"?
A7: Mixing Standard C++ headers and old iostream headers will cause this error, even if they are included in different source files. The following are the different headers:
|-------------------------|
| Old iostream Headers |
|-------------------------|
| FSTREAM.H | IOMANIP.H |
| IOS.H | IOSTREAM.H |
| ISTREAM.H | OSTREAM.H |
| STDIOSTR.H | STREAMB.H |
| STRSTREA.H | |
|-------------------------|
|-------------------------------------------------|
| Standard C++ Headers |
|-------------------------------------------------|
| ALGORITHM | BITSET | COMPLEX | DEQUE |
| EXCEPTION | FSTREAM | FUNCTIONAL | IOMANIP |
| IOS | IOSFWD | IOSTREAM | ISTREAM |
| ITERATOR | LIMITS | LIST | LOCALE |
| MAP | MEMORY | NUMERIC | OSTREAM |
| QUEUE | SET | SSTREAM | STACK |
| STDEXCEPT | STREAMBUF | STRING | STRSTREAM |
| TYPEINFO | UTILITY | VALARRAY | VECTOR |
|-------------------------------------------------|
Q8: I have a project that was built with the "Ignore Default Libraries" option (/NOD or /NODEFAULTLIB). With Visual C++ 5.0 or later, I am getting linker error "LNK2001: unresolved external symbol 'symbol' ;" on all iostream function calls. What has changed?
A8: The iostream functions have been removed from the C-Runtime library.
If you are using the old iostream functions, you must add an additional library as follows: LIBCI.lib (single-threaded
If you are using the new iostream functions included with the Standard C++ library, you must add an additional library as follows: LIBCP.lib (single-threaded
Do not mix different versions of the libraries. For example, if you are using the single-threaded version of the C-Runtime library, you must also use the single-threaded version of the old iostream library or Standard C++ library.
You cannot mix calls to the old iostream library functions and the new Standard C++ library iostream functions.
Q9: I am getting compiler warnings C4786 and/or C4788. None of the symbols in my program is anywhere near 255 characters in length. What is causing this?
A9: C4786/C4788 is issued when a symbol's name exceeds 255 characters in length. This often happens with template class, and STL uses template class extensively.
Ignoring this warning is usually safe. Use a #pragma warning (disable: 4786,4788) to suppress the messages.
Q10: I am getting compiler warning "C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX." What does this mean?
A10: Programs that use the Standard C++ library must be compiled with C++ exception handling enabled. C++ exception handling can be enabled by:
• | Selecting the Enable exception handling option in the C++ Language Category of the C/C++ tab in the Project Settings dialog box. -or- |
• | Using the /GX compiler switch. |
Q11: I am getting compiler error C2146, followed by C2065, and finally C2143, all pointing to the same line in my source. What does this mean?
A11: This sequence of errors can be caused by the following type of construct:
vectorThe problem is caused by the consecutive ">>" at the end of the declaration. The solution is to put a space between two characters, so the construct becomes:>iV;
vectorThis is consistent with the proposed ANSII specification.> iV;
Ref: http://support.microsoft.com/default.aspx?kbid=154419
Saturday, September 29, 2007
C and C++ ways of Typecasts and its drawbacks
1) What if the C-style your cast will do whatever is necessary to achieve the target? If you meant to truncate a double to an int, it will do that. If you meant to cast a pointer to an integral type, it will do that too. If you mean to expand a short into an int explicitly to resolve ambiguity, it will do that. And if you mean to remove a const qualifier from a pointer because of a legacy function that isn't const-correct, it will do that.
The C++-style has different keywords for different tasks. If you do a simple, rather safe cast, such as promoting short to int or truncating a double to int, you can use static_cast. Try anything more complex with it, and the compiler will complain. This ensures you don't accidentally cast to some weird type when all you meant to do is truncate. E.g. look at this code:
Code:
void foo(double *val)
{
int v = *val;
}
This will compile, but it will probably emit a warning. Now you apply a C-style cast to tell the compiler, yes, you know it's truncating, but as fate will have it, you accidentally remove the asterisk:
Code:
void foo(double *val)
{
int v = (int)val;
}
Now this code will compile (perhaps with a warning on 64-bit systems, perhaps not). It will also not do what you want: it will give v the value of the pointer passed in, not the pointed-to value, truncated.
C++-style, you would have done this:
Code:
void foo(double *val)
{
int v = static_cast(val);
}
This won't compile: static_cast cannot cast from pointer types to integral types. You just saved yourself from a very hard-to-find bug.
The second cast operator, const_cast, applies to our last example. It will cast the const and volatile modifiers from and to types. (Of course, the addition of them is implicit, so they're rarely used this way.)
Code:
#include
// Function guarantees not to modify the string,
//but alas, nobody made the parameter const.
void legacy(char *str);
void foo(const _TCHAR *txt)
{
legacy(txt); // Doesn't compile.
}
_TCHAR is a special type defined in tchar.h: it is a typedef for char normally, but if the macro _UNICODE is defined, it becomes a typedef for wchar_t. This is very useful in developing for Win9x, 2k and CE at the same time.
OK, once again, you solve this with a C-style cast:
Code:
#include
// Function guarantees not to modify the string,
// but alas, nobody made the parameter const.
void legacy(char *str);
void foo(const _TCHAR *txt)
{
legacy((char*)txt);
}
Now the code compiles. And now it's freaking dangerous: you forgot that _TCHAR might be wchar_t at one point, so you fail to provide for that case, where you should actually call wlegacy(), not legacy(). What happens when someone compiles as Unicode?
Code:
#define _UNICODE
#include
// Function guarantees not to modify the string,
// but alas, nobody made the parameter const.
void legacy(char *str);
void foo(const _TCHAR *txt)
{
legacy((char*)txt);
}
Answer: it still compiles. And legacy() will be very confused by getting a rather meaningless sequence of bytes: typically (if the first character of the string has a code point within 0-255, as would be the case for English text) it will see just the first character of a string, followed by a null byte.
Had you used a const_cast, it would now fail and you would be alerted to the fact that you have to account for these circumstances:
Code:
#include
// Function guarantees not to modify the string,
// but alas, nobody made the parameter const.
void legacy(char *str);
void foo(const _TCHAR *txt)
{
legacy(const_cast(txt)); // Compiles only if _TCHAR is char.
}
reinterpret_cast, finally, is the thing that will do just about anything (except the safe casts the other operators are for). And having to use reinterpret_cast is a good sign that somewhere there might be a design issue.
2) Templates. When you don't know the actual types you get, limiting the stuff a cast may do is more important than ever.
3) Searchability. Imagine your program crashes with an access violation: a pointer is set to nirvana. Now there are typically four causes for this kind of bug.
a. Uninitialized variables.
b. Referencing pointers after they've been deleted.
c. Overwriting the pointer due to a buffer overflow.
d. Bogus casts from integral types.
The first three are tricky to detect, but the fourth is rather easy to double-check: just search for all casts between integrals and pointers and make sure they all make sense.
Except ... how do you find pointer casts? How do they differ from parenthesized expressions, from function declarations or function calls? In C, they don't: it's all a pair of parentheses. In C++, you know it's where the reinterpret_casts are. It's easy to search for.
4) Casts are bad. Every cast is a potential design problem. Some are unavoidable, some are just fine, but every single one must be considered carefully. Hopefully, writing the full operator makes you think harder about using the cast. Typing a pair of parentheses is just too easy.
5) Polymorphism. At the end of the day, the C-style cast simply cannot do what dynamic_cast does.
Rule of thumb: Just because the compiler allows it, doesn't mean it's a good thing. The compiler allows you to write a 10000 line main() littered with goto’s jumping all over the place. Most compilers allow you to call main() explicitly, although such a thing is forbidden by the standard. Look at the entries of the Obfuscated C contest for a taste of all the stuff that the compiler allows that is a really bad idea.
"Writing specifications is like writing a novel. Writing code is like writing poetry."
Friday, September 28, 2007
The first Entry
Thought of creating blog for a long time........
Waited for long, started at the end, not the end now it is the starting........
Why I have selected this name Dravidar?
Thought of having a different and specific.......
Why I got this term as of sudden?
Read a book on Rishi's in the morning and having their evolutions thinking in the mind when I travelled in the train..... Yes, I'm travelling in train daily and hearing a death by train accident daily.........
Ok, its time to get into the work.......
Let me come up with good postings soon...
Bye for now.......