16. April 2007

Evolution of a Programmer – Printing Hello World.

High School/Jr.High


10 PRINT “HELLO WORLD”

20 END

First year in College


program Hello(input, output)begin
writeln(‘Hello World’)end.

Senior year in College


(defun hello(print
(cons ‘Hello (list ‘World))))

New professional


 #include
void main(void){char *message[] = {“Hello “, “World”};
int i;

for(i = 0; i < 2; ++i)
printf(“%s”, message[i]);

printf(“\n”);
}
Seasoned professional


#include
#include < string.h>class string{
private:int size;
char *ptr;

public:
string() : size(0), ptr(new char(‘\0′)) {}

string(const string &s) : size( s.size)
{

ptr = new char[size + 1];
strcpy(ptr, s.ptr);

}
~string()

{
delete [] ptr;

}
friend ostream &operator <<(ostream &, const string &);

string &operator=(const char *);
};

ostream &operator<<(ostream &stream, const string &s)
{

return(stream << s.ptr);
}

string &string::operator=(const char *chrs)
{

if (this != &chrs)
{

delete [] ptr;
size = strlen(chrs);

ptr = new char[size + 1]; strcpy(ptr, chrs);
}

return(*this);
}

int main()

{
string str;

str = “Hello World”; cout << str << endl;
return(0);

}


Master Programmer


[ uuid(2573F8F4-CFEE-101A-9A9F -00AA00342820)
]library LHello{
// bring in the master libraryimportlib(“actimp.tlb “);
importlib(“actexp.tlb”);

// bring in my interfaces
#include ” pshlo.idl”

[
uuid(2573F8F5-CFEE-101A-9A9F -00AA00342820)

]

cotype THello
{

interface IHello;
interface IPersistFile;

};
};

[
exe,

uuid(2573F890-CFEE-101A-9A9F -00AA00342820)
]

module CHelloLib
{

// some code related header files
importheader();

importheader(< ole2.h>);
importheader(< except.hxx>);

importheader(” pshlo.h”);
importheader(“shlo.hxx”);

importheader(“mycls.hxx”);
// needed typelibs

importlib(” actimp.tlb”);
importlib(“actexp.tlb”);

importlib(“thlo.tlb”);
[

uuid(2573F891-CFEE-101A-9A9F -00AA00342820),
aggregatable

]
coclass CHello

{
cotype THello;

};
};

#include ” ipfix.hxx”
extern HANDLE hEvent;

class CHello : public CHelloBase

{
public:

IPFIX(CLSID_CHello);
CHello(IUnknown *pUnk);

~CHello();

HRESULT __stdcall PrintSz(LPWSTR pwszString);
private:

static int cObjRef;
};

#include
#include

#include

#include

#include ” thlo.h ”
#include “pshlo.h”

#include “shlo.hxx”
#include “mycls.hxx”

int CHello::cObjRef = 0;
CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)

{

cObjRef++;
return;

} HRESULT __stdcall CHello::PrintSz(LPWSTR pwszString)
{

printf(“%ws\n”, pwszString);
return(ResultFromScode(S_OK));

}

CHello::~CHello(void)
{

// when the object count goes to zero, stop the server
cObjRef–;

if( cObjRef == 0 )
PulseEvent(hEvent);

return;
}

#include
#include < ole2.h>

#include ” pshlo.h”
#include ” shlo.hxx”

#include “mycls.hxx” HANDLE hEvent;
int _cdecl main(

int argc,

char * argv[]
) {

ULONG ulRef; DWORD dwRegistration;
CHelloCF *pCF = new CHelloCF();

hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

// Initialize the OLE libraries

CoInitializeEx(NULL, COINIT_MULTITHREADED);
CoRegisterClassObject(CLSID _CHello, pCF, CLSCTX_LOCAL_SERVER,

REGCLS_MULTIPLEUSE, &dwRegistration);

// wait on an event to stop

WaitForSingleObject(hEvent, INFINITE);
// revoke and release the class object

CoRevokeClassObject(dwRegistrat ion);
ulRef = pCF->Release();

// Tell OLE we are going away.

CoUninitialize();

return(0);
}

extern CLSID CLSID_CHello; extern UUID LIBID_CHelloLib;
CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F -00AA00342820 */

0x2573F891,

0xCFEE,

0x101A,

{ 0x9A, 0x9F, 0×00, 0xAA, 0×00, 0×34, 0×28, 0×20 }
};

UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F -00AA00342820 */
0x2573F890,

0xCFEE,
0x101A,

{ 0x9A, 0x9F, 0×00, 0xAA, 0×00, 0×34, 0×28, 0×20 } };
#include

#include < ole2.h >

#include < stdlib.h > #include
#include

#include ” pshlo.h”

#include ” shlo.hxx” #include ” clsid.h ”
int _cdecl main(

int argc,

char * argv[] ) {
HRESULT hRslt;

IHello *pHello;

ULONG ulCnt;
IMoniker * pmk;

WCHAR wcsT[_MAX_PATH];
WCHAR wcsPath[2 * _MAX_PATH];

// get object path

wcsPath[0] = ‘\0′;
wcsT[0] = ‘\0′;

if( argc > 1) {

mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
wcsupr(wcsPath);

}

else { fprintf(stderr, “Object path must be specified\n”);
return(1);

}

// get print string
if(argc > 2)

mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);
else

wcscpy(wcsT, L”Hello World”); printf(“Linking to object %ws\n”, wcsPath);
printf(“Text String %ws\n”, wcsT);

// Initialize the OLE libraries

hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if(SUCCEEDED(hRslt)) {

hRslt = CreateFileMoniker(wcsPath, &pmk); if(SUCCEEDED(hRslt))
hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);

if(SUCCEEDED(hRslt)) {

// print a string out

pHello->PrintSz(wcsT);

Sleep(2000);
ulCnt = pHello->Release();

}

else printf(“Failure to connect, status: %lx”, hRslt);
// Tell OLE we are going away.

CoUninitialize();

}
return(0);

}

Program Manager


“Program Manager” < pm@company.com >
06/14/2006 03:32 PM
 
To teamworker@company.com
ccSubject Urgent,  
Dear Team Member,
Please write a program to print “Hello World” before the EOD.

With regards, PM.

11. April 2007

A Story somehow related to …So called IT Proffessionals

A butcher watching over his shop is really surprised
when he sees a dog
coming inside the shop. He shoos him away. But later,
the dog is back
again. So, he goes over to the dog and notices it has
a note in its mouth.
He takes the note and it reads “Can I have 12 sausages
and a leg of lamb,
please”. The dog has money in its mouth, as well. The
butcher looks inside
and, there is a ten dollar note there. So he takes the
money and puts the
sausages and lamb in a bag, placing it in the dog’s
mouth.

The butcher is so impressed, and since it’s about
closing time, he decides
to shut the shop and follow the dog. So off he goes.
The dog is walking
down the street, when it comes to a level crossing;
the dog puts down the
bag, jumps up and presses the button. Then it waits
patiently, bag in
mouth, for the lights to turn. They do, and it walks
across the road, with
the butcher following him all the way.
The dog then comes to a bus stop, and starts looking
at the timetable. The
butcher is in awe as the dog stops a bus by pulling
its left leg up and
gets in it. The butcher follows the dog into the bus.
Then the dog shows a
ticket which is tied to its belt to the bus conductor.
The butcher is
nearly fainting at this sight, so are the other
passengers in the bus. The
dog then sits near the driver’s seat looking outside
waiting for the bus
stop to come. As soon as the stop is in sight, the dog
stands and wags its
tail to inform the conductor. Then, without waiting
for the bus to stop
completely, it jumps out of the bus and runs to a
house very close to the
stop. It opens the big Iron Gate and rushes inside
towards the door.
As it approaches the wooden door, the dog suddenly
changes its mind and
heads towards the garden. It goes to the window, and
beats its head against
it several times, walks back, jumps off, and waits at
the door.
The butcher watches as a big guy opens the door, and
starts abusing the
dog, kicking him and punching him, and swearing at
him.
The butcher surprised with this, runs up, and stops
the guy. “What in
heaven’s name are you doing? The dog is a genius. He
could be on TV, for
the life of me!” to which the Guy responds: “You call
this clever? This is
the second time this week that this stupid dog’s
forgotten his key.”

*Moral of the story: You may continue to exceed onlooker’s expectations but shall always fall short of the boss’ expectations. It’s dog’s life after all……………...

Sitting postions in front of computer .Useful for Software Engineers



After being through the actual test of 350-001, followed back to back by VCP-310, and before that 640-802 and before even that, 70-290, it is hard not to develop back issues because of constant sitting.


29. March 2007

Software Engineers Movie

Hero is a software engineer. He does not have a life worth speaking of.

He spends eighteen hours a day in the office working and browsing the

net.

Heroine is a software engineer in the same company. She does not have a

life either. She spends eight hours in front of her PC, thirteen hours

in front of the TV and the remaining, sleeping.

One day, Hero meets Heroine in a staff meeting. They argue endlessly

about the insanity of Microsoft applications.. especially Outlook 2003.

Couple of such fights later, Heroine is found drinking coffee with Hero

in Office canteen.

“What is life?” asks the Hero looking at the vacuum right above her

head.

“I’ve been wondering too.” sighs the heroine.

“Why are we fighting over Outlook 2003?” Hero drinks his black coffee.

“And why are we not talking about Lotus NOtes” Heroine sips her Latte.

Hero shakes his head. “It’s not about software products. It is about

life. I guess life is much bigger than OUtlook 2003.”

Heroine nods. “I think it is. I am not sure though. Do you know that

Microsoft has come up with a fix to that bug you’ve been using to prove

Outlook is a worthless piece of garbage?”

“Heroine,” Hero is now determined, “From this moment onwards, I am not

discussing anything remotely related to software.”

“Fine Hero,” says Heroine, “Good bye then.”

Hero then returns all the Sybase manuals to the library and rents out

“how to live a life?”

Heroine meanwhile gets into an altercation with the villain during a

conversation on Sharepoint server. Villain vows to format the hard disk

of the heroine. Heroine takes her PC and runs away from the cubicle

trying to escape from the villain’s evil intentions. Since it is night

shift, no one comes to her rescue.

Hero, who has been reading “how to live a life” very seriously, suddenly

finds out that he loves the heroine as much as he used to love Tetris.

So hero messages Heroine on Yahoo Instant messenger. But there is no

reply. Hero does not understand it. He knows that the heroine is

supposed to be in night shift. What is she doing in Night shift if not

on Yahoo Instant Messenger? As far as he know that is what people are

supposed to do in night shift.

Hero senses trouble. He runs barefooted on the Information Superhighway

and reaches office just in time to see the villain snatch the PC out of

heroine’s hands and type the command “Format C:\”. When his fingers get

to the “Enter” key, hero delivers the killer punch on villain’s face.

Villain is thrown back. But in the process he manages to press the Enter

key…

The world comes to a standstill. The sky roars. The Rain pours.

Heroine breaks down. Villain is on cloud nine. But our Hero isn’t sad.

He is smiling. Villain cannot understand. Hero then says, “Villain, You

should learn DOS properly. Your grave mistake…”. He shows the monitor

to Villain. The DOS command prompt says “Are you sure?”. It is waiting

for a “Y” to commence the formatting operation. Hero then simply presses

“N”.

Villain cries in frustration “Nooooooo” and charges like a bull. Then

follows a lengthy fight. Heroine meanwhile calls the police and they

come right after hero beats the villain to pulp. Without asking any

questions, the police understand who is hero and who is villain and take

him into custody. Heroine, tears in her eyes, takes her PC, switches it

on and jumps with joy when she finds her favorite Calvin and Hobbs

collection in tact in her C drive.

“You saved my data” she exclaims.

“No, you saved it yourself.” hero says.

“No.. Jesus saves. I don’t” she cries.

“Nothing happened na.” Hero consoles.

“Let us get married” heroine sheds some more tears, “I want someone by

my side to protect the Calvin and Hobbscollection on my PC”.

“I love you Heroine” says the hero.

“I love you Hero” says the heroine.

“So you agree that Outlook 2003 is a bad product”.

“No I don’t. Why not we talk about Lotus nOtes?”

The End.

10. January 2007

Awesome reply

It was a hot meeting at the office conference hall. All the people from the department had been called. The VP was looking much tensed.

The mood was so bad. My friend asked me -”Hey, what is this meeting all about? I told – May be they will decide on when to have the next meeting. People around smiled at each other. Then the VP started talking. It was about the recent attrition rate that was so high. Around 10 people had put in their papers. All experienced guys. It was quarter end and so work was huge. If we do not complete the work on time, we need to be paying heavy penalty said the VP. The VP turned to the manager and told “Hey – take how much ever resources you want. Recruit or take them from other departments. But complete the work in another 25 days. Take people and complete it man.

To this the sweet manager replied “Sir! Give me one wife and nine months and I shall show you results. Don’t give me nine wives and one month. I cannot do anything.” Everyone looked at him blank. The VP was not prepared for this answer. We looked at the manager and thought “What an Awesome Reply man!”

Understanding Engineers …

Understanding Engineers – Take One
Two engineering students were walking across campus when one said, “Where did you get such a great bike?” The second engineer replied, “Well, I was walking along yesterday minding my own business when a beautiful woman rode up on this bike. She threw the bike to the ground, took off all her clothes and said, “Take what you want.” The second engineer nodded approvingly, “Good choice; the clothes probably wouldn’t have fit.”
Understanding Engineers – Take Two
To the optimist, the glass is half full. To the pessimist, the glass is half empty. To the engineer, the glass is twice as big as it needs to be.
Understanding Engineers – Take Three
A pastor, a doctor and an engineer were waiting one morning for a particularly slow group of golfers. The engineer fumed, “What’s with these guys? We must have been waiting for 15 minutes!”
The doctor chimed in, “I don’t know, but I’ve never seen such ineptitude!”
The pastor said, “Hey, here comes the greens keeper. Let’s have a word with him.”
“Hi, George. Say, what’s with that group ahead of us? They’re rather slow, aren’t they?”
The greens keeper replied, “Oh, yes, that’s a group of blind firefighters who lost their sight saving our clubhouse from a fire last year, so we always let them play for free anytime.”
The group was silent for a moment. The pastor said, “That’s so sad. I think I will say a special prayer for them tonight.”
The doctor said, “Good idea. And I’m going to contact my ophthalmologist buddy and see if there’s anything he can do for them.”
The engineer said, “Why can’t these guys play at night?”
Understanding Engineers – Take Four
There was an engineer who had an exceptional gift for fixing all things mechanical. After serving his company loyally for over 30 years, he happily retired. Several years later the company contacted him regarding a seemingly impossible problem they were having with one of their multi-million dollar machines. They had tried everything and everyone else to get the machine to work but to no avail. In desperation, they called on the retired engineer who had solved so many of their problems in the past. The engineer reluctantly took the challenge. He spent a day studying the huge machine.
Finally, at the end of the day, he marked a small “x” in chalk on a particular component of the machine and said, “This is where your problem is.”
The part was replaced and the machine worked perfectly again. The company received a bill for $50,000 from the engineer for his service. They demanded an itemized accounting of his charges. The engineer responded briefly: One chalk mark $1; Knowing where to put it $49,999. It was paid in full and the engineer retired again in peace.
Understanding Engineers – Take Five
What is the difference between Mechanical Engineers and Civil Engineers?
Mechanical Engineers build weapons. Civil Engineers build targets.
Understanding Engineers – Take Six
Three engineering students were gathered together discussing the possible designers of the human body. One said, “It was a mechanical engineer. Just look at all the joints.”
Another said, “No, it was an electrical engineer. The nervous system has many thousands of electrical connections.”
The last said, “Actually it was a civil engineer. Who else would run a toxic waste pipeline through a recreational area?”
Understanding Engineers – Take Seven
“Normal people …. believe that if it ain’t broke, don’t fix it.
Engineers believe that if it ain’t broke, it doesn’t have enough features yet.”
Understanding Engineers – Take Eight
An architect, an artist and an engineer were discussing whether it was better to spend time with the wife or a mistress. The architect said he enjoyed time with his wife, building a solid foundation for an enduring relationship. The artist said he enjoyed time with his mistress, because of the passion and mystery he found there. The engineer said, “I like both.”
“Both?” they asked.
Engineer: “Yeah. If you have a wife and a mistress, they will each assume you are spending time with the other woman, and you can go to the lab and get some work done.”
Understanding Engineers – Take Nine
An engineer was crossing a road one day when a frog called out to him and said, “If you kiss me, I’ll turn into a beautiful princess.” He bent over, picked up the frog and put it in his pocket. The frog spoke up again and said, “If you kiss me and turn me back into a beautiful princess, I will stay with you for one week.” The engineer took the frog out of his pocket, smiled at it and returned it to the pocket. The frog then cried out, “If you kiss me and turn me back into a princess, I’ll stay with you and do ANYTHING you want.” Again the engineer took the frog out, smiled at it, and put it back into his pocket. Finally, the frog asked, “What is the matter? I’ve told you I’m a beautiful princess; that I’ll stay with you for a weekend and do anything you want. Why won’t you kiss me?”
The engineer said, “Look. I’m an engineer. I don’t have time for a girlfriend, but a talking frog, now that’s cool.”

« Previous Entries   Next Entries »