life ideas

December 6, 2009

Connecting to the internet through recovery mode

Filed under: ubuntu — manoftoday @ 7:31 am

Never mind, I logged on to an Ubuntu chat room and the people there did a great job helping me out. Just in case anyone else needs this done and has no clue how to do it, here is a step-by-step. (Some steps might not be needed or there might be a much easier or better way to to this. This worked for me though)
Step 1: EDIT /etc/network/interfaces
type "sudo nano /etc/network/interfaces" and enter password
There should be two line that say "auto lo" and beneath it "iface lo inet loopback". Now beneath these lines write:
auto <interface>
iface <interface> inet dhcp
wireless-essid <network name>
wireless-key <network key>
When I say <interface> it is the interface for your wireless connection, something like eth0 (mine was eth1). <network name> is the name of the network you’re connecting to and <network key> is the password for that network.
Now I’m not sure which of the next two steps are necessary or not, but I used both (in this order) and it worked for me.
Step 2:
type "sudo ifup <interface>"
Step 3:
type "iwconfig <interface>"
Then my internet was working.

November 11, 2009

Android knowledge

Filed under: android — manoftoday @ 5:58 am

启动模式
G1有以下几种启动模式,每种模式都需要按相应的组合键才可进入。

image

*******************************************************
ROM分区
image

*******************************************************
主要文件和文件类型
DREAIMG.NBH:系统映像文件
.img:特别分区的映像文件(如recovery.img和boot.img等)
update.zip:更新ROM的压缩包(包含映像文件和其他文件,比如:整合的应用程序等)
.apk:Android系统的应用程序文件
*******************************************************
HACK工具

image

*******************************************************

February 20, 2008

my trip

Filed under: Uncategorized — manoftoday @ 4:51 am

CINDY CHEN
P T S TRAVEL
4320 STEVENS CREEK BLVD SUITE 175
SAN JOSE, CA 95129
TEL 408-248-1088
FAX 408-248-1338

ohter travel agent’s number#415.362.4280, her name is Virginia.

Recommend more agents
++ I bought several tickets from Jeniffer at 510-657-3836, ?????, before. Most of the time she can offer good-priced tickets.
++ Try Pamela at Grandview Travel, (415) 434-9290.
++ (Faith Zhang got two recommendations) Faith Zhang Intellife Travel Inc. 4800 Great America Pkwy Suite 222 Santa Clara, CA 95054 tel: 408-980-5188 fax: 408-980-0688 faith@intellifetravel.com

November 20, 2007

behavior questions

Filed under: Uncategorized — manoftoday @ 7:12 pm

General Questions

1. Tell me about yourself.

The most often asked question in interviews. You need to have a short statement prepared in your mind. Be careful that it does not sound rehearsed. Limit it to work-related items unless instructed otherwise. Talk about things you have done and jobs you have held that relate to the position you are interviewing for. Start with the item farthest back and work up to the present.

Start with the present and tell why you are well qualified for the position. Remember that the key to all successful interviewing is to match your qualifications to what the interviewer is looking for. In other words you must sell what the buyer is buying. This is the single most important strategy in job hunting.

So, before you answer this or any question it’s imperative that you try to uncover your interviewer’s greatest need, want, problem or goal.

To do so, make you take these two steps:

1. Do all the homework you can before the interview to uncover this person’s wants and needs (not the generalized needs of the industry or company)

2. As early as you can in the interview, ask for a more complete description of what the position entails. You might say: “I have a number of accomplishments I’d like to tell you about, but I want to make best use of our time together and talk directly to your needs. To help me do, that, could you tell me more about the most important priorities of this position? All I know is what I (heard from the recruiter, read in the classified ad, etc.)”

Then, ALWAYS follow-up with a second and possibly, third question, to draw out his needs even more. Surprisingly, it’s usually this second or third question that unearths what the interviewer is most looking for.

You might ask simply, “And in addition to that?…” or, “Is there anything else you see as essential to success in this position?

This process will not feel easy or natural at first, because it is easier simply to answer questions, but only if you uncover the employer’s wants and needs will your answers make the most sense. Practice asking these key questions before giving your answers, the process will feel more natural and you will be light years ahead of the other job candidates you’re competing with.

After uncovering what the employer is looking for, describe why the needs of this job bear striking parallels to tasks you’ve succeeded at before. Be sure to illustrate with specific examples of your responsibilities and especially your achievements, all of which are geared to present yourself as a perfect match for the needs he has just described.

My background to date has been centered on preparing myself to become the very best financial consultant I can become. Let me tell you specifically how I’ve prepared myself. I am an undergraduate student in finance and accounting at _________ University. My past experiences have been in retail and higher education. Both aspects have prepared me well for this career。

3. Did you bring your resume?

Yes. Be prepared with two or three extra copies. Do not offer them unless you’re asked for one.

4. What is your long-range objective?

The key is to focus on your achievable objectives and what you are doing to reach those objectives.

Then go on to show by your examples what you are doing to reach your goals and objectives.

Although it’s certainly difficult to predict things far into the future, I know what direction I want to develop toward. Within five years, I would like to become the very best develper your company has. I would like to become the expert that others rely upon. And in doing so, I feel I will be fully prepared to take on any greater responsibilities that might be presented in the long term.

5. Are you a team player? (Describe what would be an ideal working environment?)

Team work is the key.

Yes, I’m very much a team player. In fact, I’ve had opportunities in my work, school to develop my skills as a team player. For example, on a recent project, I workded with my classmates. We often discussed the issues together, solved the problemes together. I love the way of learning new staff with classmates, because I found I can know more by changing opion with other classmates. That is a really good way to learn new knowledge. And also I love the feeling to work together, happy and easy. I found it is more efficient to finish the project before deadline and also can do more than what can be done by a single person. . .”

Emphasize teamwork behavioral examples and focus on your openness to diversity of backgrounds. Talk about the strength of the team above the individual. And note that this question may be used as a lead in to questions around how you handle conflict within a team, so be prepared.

You are, of course, a team player. Be sure to have examples ready. Specifics that show you often perform for the good of the team rather than for yourself is good evidence of your team attitude. Do not brag; just say it in a matter-of-fact tone? This is a key point.

6. What is your greatest weakness?

Talk about a true weakness and show what you are doing to overcome it.

I would say my greatest weakness has been my lack of proper planning in the past. I would overcommit myself with too many variant tasks, then not be able to fully accomplish each as I would like. However, since I’ve come to recognize that weakness, I’ve taken steps to correct it. For example, I now carry a planning calendar in my pocket so that I can plan all of my appointments and “to do” items. Here, let me show you how I have this week planned out…

I have had trouble in the past with planning and prioritization. However, I’m now taking steps to correct this. I just started using a pocket planner . . .” then show them your planner and how you are using it.

To make sure this question doesn’t trip you up, here are possible strategies that you — as an interviewee — can use to frame an effective response. Remember that context is as important as content. Whenever you cite a weakness, be sure to remind employers of your strengths. Be honest about your shortcomings, but never cite anything that might genuinely interfere with your ability to do the available job — and do it well. The key is to present your weaknesses in a way that demonstrates your real strengths and character.

Strategy 1: Cite a weakness that, under the right circumstances, can prove to be an asset.

Conventional wisdom suggests that you respond by stating a weakness that really could be perceived as a positive, such as: “I’m a workaholic. I spend a lot of time at work making sure that I do my job right.”

As you can probably guess, employers usually see right through this type of response because it’s both dishonest and self-serving. A better answer is to mention something that may be perceived as a weakness but, in the proper context, constitutes a genuine strength. For example, empathy — the ability to identify with and understand another person’s feelings — is a good quality when trying to understand an enemy. But an empathic manager may be viewed erroneously as “weak” or “soft.” A candidate who offers empathy as a perceived weakness (but knows its strength) can then cite a time when he or she used empathy to gain competitive intelligence.

The “strength as weakness” strategy works well if you: show the value of using the particular trait in a given context; demonstrate that you know how and when to use it most effectively; and explain how you might be able to use it to help your future employer.

Saying, for instance, that you’re a perfectionist would work if you can cite times when this trait is strength instead of a weakness. An example might be when proofreading or editing, since perfectionism can guarantee error-proof copy. On the other hand, a perfectionist chief executive officer might micromanage his top managers and paralyze the organization. Knowing the requirements of the job and the organizational culture can help you decide whether a potential employer will view your perceived weakness as a potential strength.

Although there’s a performance element to interviewing, you aren’t an actor who needs to perform for an audience. You’re engaged in a conversation designed to determine whether you can work together effectively. Towards that end, you can do your part to make the interviewer more of an active participant than a passive observer and critic of your performance.

In the end, it isn’t your mistakes and weaknesses that matter most, it’s whether you’re aware of your weakness, understand its potential impact on others and are willing to work to improve yourself. Your ability to handle this question confidently and effectively can send a powerful message to potential employers about your real strengths.

7. What is your greatest strength?

Numerous answers are good, just stay positive. A few good examples: Your ability to prioritize, Your problem-solving skills, Your ability to work under pressure, Your ability to focus on projects, Your professional expertise, Your leadership skills, Your positive attitude.

You know that your key strategy is to first uncover your interviewer’s greatest wants and needs before you answer questions. And from Question 1, you know how to do this.

Prior to any interview, you should have a list mentally prepared of your greatest strengths. You should also have, a specific example or two, which illustrates each strength, an example chosen from your most recent and most impressive achievements.

You should, have this list of your greatest strengths and corresponding examples from your achievements so well committed to memory that you can recite them cold after being shaken awake at 2:30AM.

Then, once you uncover your interviewer’s greatest wants and needs, you can choose those achievements from your list that best match up.

As a general guideline, the 10 most desirable traits that all employers love to see in their employees are:

1. A proven track record as an achiever…especially if your achievements match up with the employer’s greatest wants and needs. (handmap project)

2. Intelligence…management “savvy”.

3. Honesty…integrity…a decent human being.

4. Good fit with corporate culture…someone to feel comfortable with…a team player who meshes well with interviewer’s team.

5. Likeability…positive attitude…sense of humor.

6. Good communication skills.

7. Dedication…willingness to walk the extra mile to achieve excellence.

8. Definiteness of purpose…clear goals.

9. Enthusiasm…high level of motivation.

10. Confident…healthy…a leader.

8. If you had to live your life over again, what one thing would you change?

Focus on a key turning point in your life or missed opportunity. Yet also tie it forward to what you are doing to still seek to make that change.

For example: “Although I’m overall very happy with where I’m at in my life, the one aspect I likely would have changed would be focusing earlier on my chosen career. I had a great internship this past year and look forward to more experience in the field. I simply wish I would have focused here earlier. For example, I learned on my recent internship…” …then provide examples.

Stay focused on positive direction in your life and back it up with examples.

9. How did you prepare for this interview?

When I found this position posted on the internet (monster.com) I was  immediately interested. I checked out the company website and mission statement, looked at the bios of company founders and executives, and was impressed. Once I had the interview appointment, I talked with friends and acquaintances in the industry. And, I’m sure I’ll find out a lot more in today’s meetings.”

10. What kinds of people do you have difficulties working with?

In my last three jobs I have worked with men and women from very diverse backgrounds and cultures. The only time I had difficulty was with people who were dishonest about work issues. I worked with one woman who was taking credit for work that her team accomplished.  I had an opportunity to talk with her one day and explained how she was affecting the morale. She became very upset that others saw her that way, and said she was unaware of her behavior or the reactions of others. Her behavior changed after our talk. What I learned from that experience is that sometimes what we perceive about others is not always the case if we check it out.

11. How do you handle conflict?

How would you evaluate your ability to deal with conflict?

On the job, there are many possible sources of conflict. Conflicts with: fellow employees management rules, procedures clients, customers demands of work vs. personal life, family The best way to approach a good answer is to look at if from the employers point of view—they want to be your first priority and they want you to solve problems (not bring them any). “I know everything cannot run smoothly at work all the time. When there is a conflict I usually try to determine the source of the problem and see if it can be solved. This might involve other members of the work team discussing the problem and offering possible solutions. I would then try to pick the solution which appears to have the best outcome and put it into action.” A natural follow-up to this would be: Tell me when you solved a conflict at work. So, have a brief example… a short story… to illustrate your approach. Even if not asked, you can offer your story! If it proves your point and accentuates a skill needed for the position, go with it.

I believe I am quite good at handling conflict. Working in retail and in the residence halls required that I make many unpopular decisions at times, whether it was terminating an associate or taking judicial action on a resident. Often the person in conflict with me would be upset and sometimes physically outraged. I would always make sure that I fully explained the situation, the policies behind my decision, and why those policies exist. Usually by the end of the conversation, the person could see the other side of the situation.

12. How do you handle rejection?

Rejection is part of business. People don’t always buy what you sell. The tick here is to separate rejection of your product from rejection of yourself: “I see rejection as an opportunity. I learn from it. When a customer takes a pass, I ask him what we could do to the product, price or service to make it possible for him to say yes. Don’t get me wrong: You’ve got to makes sales. But rejection is valuable, too. It’s a good teacher.”

13. Tell me about a time when you tried and failed?

Has this ever happened to you? No one expects perfection actually; employers are more interested in your ability to cope, to learn from mistakes, and to deal with others who are less than perfect. If you have an example, certainly pick one that happened a while back, was not earth shattering in the results, and one which you learned and applied this knowledge recently. This is a version of ‘damning with faint praise’ by picking an incident that was minor in scope but, since you are so wise and are always willing to learn, has taught you a valuable lesson.

14. What are some of the things you find difficult to do?

The interviewer is looking to determine how well you know yourself, how you react to difficult situations/tasks and credibility. Look back over your work experience for examples of challenges… speaking in public at a meeting, disagreeing with a manager over an important issue, being asked to use a software program you have not had an opportunity to learn… These ’stories’ should illustrate a lesson learned, a problem overcome or a weakness being dealt with. “I always seem to need a day or two to prepare myself to give a presentation to department heads. When I know I have to give a report on my projects, I plan out all the details in advance and rehearse. One time, there was a problem with a supplier and I was asked to update senior management… immediately. The supply chain was crucial to the completion of an important project we had been working on for 5 months and decisions had to be made based on the information I had to prepare and present on a moment’s notice. I gathered the information and presented it simply and in detail. It was much easier than I thought without the hours of concern and practice. The facts spoke for themselves. Since I understood the situation, I was able to make it clear to management and get a rapid decision. I still prefer advance notice but I know I can deliver when asked to.”

15. What are your short and long term goals?

No one can make goals for you. It comes down to where you are in your professional life and what you want to do. Most people have 5-6 careers in their working lifetime—some with 2 careers going at the same time (like us). The best advice is to be certain to relate your answers to the organization that interviews you. Do not make a point of having goals that cannot be realized there (”I want to work in Paris.” Organization is strictly domestic.) If you do your research into the organization, and into what you truly want to do in the future, you will be able to come up with reasonable responses. No one is going to come back to you in five years and chastise you for not meeting these goals! You will not be held to them… it is only an interview and they are interested in how you see yourself (and they want to see you in the job.)

My primary objectives are to learn as much as possible about your company’s product offering, organizational structure, and professional sales techniques so that I may become the most productive member of your sales team.

What are your short-term goals?

Many executives in a position to hire you are strong believers in goal-setting. (It’s one of the reasons they’ve achieved so much.) They like to hire in kind.

If you’re vague about your career and personal goals, it could be a big turnoff to many people you will encounter in your job search.

Be ready to discuss your goals for each major area of your life: career, personal development and learning, family, physical (health), community service, and (if your interviewer is clearly a religious person) you could very briefly and generally allude to your spiritual goals (showing you are a well-balanced individual with your values in the right order).

Be prepared to describe each goal in terms of specific milestones you wish to accomplish along the way, time periods you’re allotting.

My short-term objectives are to graduate from the Professional Development Program before the standard two years and begin developing a clientele. As an intern, I prepared ahead of time by studying for the Series 7 and Series 64 exams that constitute a majority of a beginning financial consultant’s time. I’d like to make the company that hires me wonder what it ever did without me.

16. Where do you see yourself in five years?

This is the interviewer trying to see how you are in making long range plans and if you have goals that mesh with the organizations. One way to answer this question is to look back on your accomplishments to date: “I started out in my profession as a junior clerk while I completed my college studies during the evenings. Once I had my degree, I applied for a transfer to a more advanced position, citing my on-the-job training. This has been my pattern for my career with my past 2 employers. I learn quickly on the job and am willing to take classes and workshops to augment my experience. I have been able to assume greater responsibilities and add more value to the organization. I do not think in terms of titles… I think more in terms of “How can I solve this problem? Since this has been my career style to date, I do not imagine it to change. In five years, I feel I will have continued to learn, to grow into a position of more responsibility and will have made a significant contribution to the organization.”

Although it is hard to predict the future, I sincerely believe that I will become a very good financial consultant. I believe that my abilities will allow me to excel to the point that I can seek other opportunities as a portfolio manager (the next step) and possibly even higher. My ultimate goal continues to be — and will always be — to be the best at whatever level I am working at within Merrill Lynch’s corporate structure.

17. Where do you want to become ten years from now?

Ten years from now I see myself as a successful consultant for a world-class firm like yours. I want to have developed a wonderful bond with my employer I will have proven myself a highly competent systems analyst and will represent my company in helping others find solutions to their information-systems needs in a professional and timely manner.

18. Would you rather work with information or with people?

I like the validity of information and also like the energy that comes with working with people. The best thing about working in a group is combining the great minds from different perspectives and coming up with something extremely great, compared with when you’re working alone. At the same time, information can generate vitality in the project you’re working on. No matter how many heads you’ve got together, without information, you can’t go very far. The perfect situation would be a combination of working with information and people, and I’m confident of my abilities in both areas.

19. Do you have the qualifications and personal characteristics necessary for success in your chosen career?

I believe I have a combination of qualities to be successful in this career. First, I have a strong interest, backed by a solid, well-rounded, state-of-the-art education, especially in a career that is technically oriented. This basic ingredient, backed by love of learning, problem-solving skills, well-rounded interests, determination to succeed and excel, strong communication skills, and the ability to work hard, are the most important qualities that will help me succeed in this career. To succeed, you also need a natural curiosity about how systems work — the kind of curiosity I demonstrated when I upgraded my two computers recently. Technology is constantly changing, so you must a fast learner just to keep up or you will be overwhelmed. All of these traits combine to create a solid team member in the ever-changing field of information systems. I am convinced that I possess these characteristics and am ready to be a successful team member for your firm.

20. What are your weak points?

Don’t say you have one, but give one that is really a “positive in disguise.” I am sometimes impatient and do to much work myself when we are working against tight deadlines.” Or “I compliment and praise my staff, but feel I can improve.”

Education Questions

21. What personal weakness has caused you the greatest difficulty in school or on the job?

My greatest weakness had been delegation. I would take it upon myself to do many small projects throughout my shift as a manager that could have been done by others in an attempt to improve my workers’ efficiency. Once I realized that I was doing more work than the other assistant managers, and they were achieving better results, I reevaluated what I was doing. I quickly realized that if I assigned each person just one small project at the beginning of their shift, clearly state expectations for the project, and then follow up that everything would get done, and I could manage much more efficiently and actually accomplish much more.

22. How has your education prepared you for your career?

This is a broad question and you need to focus on the behavioral examples in your educational background which specifically align to the required competencies for the career.

An example: “My education has focused on not only the learning the fundamentals, but also on the practical application of the information learned within those classes. For example, I played a lead role in a class project where we gathered and analyzed best practice data from this industry. Let me tell you more about the results . . .”

Focus on behavioral examples supporting the key competencies for the career. Then ask if they would like to hear more examples.

As you will note on my resume, I’ve taken not only the required core classes in the _____ field, I’ve also gone above and beyond. I’ve taken every class the college has to offer in the field and also completed an independent study project specifically in this area. But it’s not just taking the classes to gain academic knowledge I’ve taken each class, both inside and outside of my major, with this profession in mind. So when we’re studying _____ in  _____, I’ve viewed it from the perspective of _____. In addition, I’ve always tried to keep a practical view of how the information would apply to my job. Not just theory, but how it would actually apply. My capstone course project in my final semester involved developing a real-world model of _____, which is very similar to what might be used within your company…

23. Have you ever had a conflict with a boss or professor? How was it resolved?

Note that if you say no, most interviewers will keep drilling deeper to find a conflict. The key is how you behaviorally reacted to conflict and what you did to resolve it.

For example: “Yes, I have had conflicts in the past. Never major ones, but there have been disagreements that needed to be resolved. I’ve found that when conflict occurs, it helps to fully understand the other person’s perspective, so I take time to listen to their point of view, and then I seek to work out a collaborative solution. For example . . .”

Focus your answer on the behavioral process for resolving the conflict and working collaboratively.

24. If I were to ask your professors to describe you, what would they say?

This is a threat of reference check question. Do not wait for the interview to know the answer. Ask any prior bosses or professors in advance. And if they’re willing to provide a positive reference, ask them for a letter of recommendation.

Then you can answer the question like this:

“I believe she would say I’m a very energetic person, that I’m results oriented and one of the best people she has ever worked with. Actually, I know she would say that, because those are her very words. May I show you her letter of recommendation?”

So be prepared in advance with your letters of recommendation.

25. Tell me about a time when you had to plan and coordinate a project from start to finish.

I headed up a project which involved customer service personnel and technicians. I organized a meeting to get everyone together to brainstorm and get his or her input. From this meeting I drew up a plan, taking the best of the ideas. I organized teams, balancing the mixture of technical and non-technical people. We had a deadline to meet, so I did periodic checks with the teams. After three weeks, we were exceeding expectations, and were able to begin implementation of the plan. It was a great team effort, and a big success. I was commended by management for my leadership, but I was most proud of the team spirit and cooperation which it took to pull it off.

26. Describe a situation where others you were working with on a project disagreed with your ideas. What did you do?

I was on a project team in a business class in my freshman year in college, the group brainstormed ideas for the video we were assigned to produce, and everyone but me was leaning toward an idea that would be easy. I suggested instead an idea that would be more difficult but would be something different that no other group would be doing. I used my communications skills to persuade the rest of the group to use my idea. During the project, we really learned what teamwork was all about, became a close team, and ended up putting a lot of hard work into the project. All the team members ended up feeling very proud of the video, and they thanked me for the idea — for which we earned an A.

27. Why did you choose to attend your college?

My college has always had a reputation as having an excellent accounting department, so I knew that if I enrolled there, I would achieve first-class preparation for my chosen career field. It is also a highly accredited school known for satisfying employers with the preparation of its graduates — that’s why companies like yours recruit at my school — the school produces top graduates. The school offers an excellent liberal-arts background, which research shows equips graduates with numerous qualities, such as versatility and strong critical-thinking skills. Finally, having visited the campus before enrolling, I knew that the business school emphasized group projects. During my four years in the school, I participated in more than 35 group projects, which taught me invaluable teamwork, communication, and interpersonal skills.

28. What changes would you make at your college?

My major department had a wonderful internship program, and I was able to complete three valuable internships with my department’s guidance. Some other departments in the business school don’t have internship programs that are as strong as my department’s. I’d like to see all the departments have strong internship programs so all my school’s business grads would have the same opportunities that I had.

29. How will the academic program and coursework you’ve taken benefit your career?

As you will note on my resume, I’ve taken not only the required core classes for the finance field, I’ve also gone above and beyond by double majoring in accounting. I doubled majored since I knew that the financial consulting field requires much knowledge of portfolio analysis and understanding of the tax laws. I believe that my success in both areas of study have specifically prepared me for this area. But it’s not just taking the classes in these two areas that allow me to offer Merrill Lynch clients more. I minored in Spanish to understand the growing Hispanic clientele in the Central Florida area, which as you are well aware, is a growing source of revenue for the industry. If you like, I can elaborate on other aspects of my education further.

30. What were your favorite classes? Why?

My favorite classes have been the ones pertaining to my major, which is marketing. These classes have laid the groundwork for my career in marketing. They have also taught me skills that I can bring to my employer, ranging from communication skills to interacting with others.

31. Do you enjoy doing independent research? (Are you the type of student for whom conducting independent research has been a positive experience?)

Yes, I love it. I thoroughly enjoyed my senior research in college while many others in my class were miserable. I was never tired of learning more about my topic and found it exhilarating to be researching something that had not been studied before.

32. Who were your favorite professors? Why? (Describe the type of professor that has created the most beneficial learning experience for you.)

My favorite professors were the ones who gave me hands-on learning experiences that I can apply to my career. Any person can make you memorize the quadratic equation, but someone who can show you how to use it, and why, were the professors I liked. I liked teachers who realized that sometimes there is more then one answer and everyone thinks differently.

33. Why is your GPA not higher? (Do you think that your grades are an indication of your academic achievement?)

I have focused much of my energy on work and obtaining real-world experience. I commend my classmates who have earned high GPAs, but I also feel it’s important to be well-rounded. In addition to work experience, I participated in sports and extracurricular activities in school. These activities taught me leadership, communication, and teamwork skills. Sometimes my heavy load has not allowed me to keep up with some of my studies, but I have learned an enormous amount that I can apply in my future industry. As you will discover if you talk to my supervisors, my ability to work effectively is much more reflective of my future potential than is my GPA.

34. Do you have any plans for further education? (What plans do you have for continued study? An advanced degree? )

I plan to continue my education for the rest of my life. In any technology-related field, keeping up to date through continuing education is of the utmost importance. Continuing education can include on-the-job training, courses sponsored by the employer, and courses taken in new technologies as they emerge. I plan to be not only a career employee but a career student so that I can be the best information systems analyst I can be. I will ensure, however, that any education I pursue not only doesn’t interfere with my job or the company’s policies, but will enhance my value as an employee.

35. Give an example of how you applied knowledge from previous coursework to a project in another class.

Last semester I was taking a microeconomics and a statistics course. One of the microeconomics projects dealt with showing the relationship between the probabilities that customers would stop buying a product if the price was raised a certain amount. Through what I learned in statistics I could find the median where the price was the highest and still kept most of the customers happy.

34. Describe a situation in which you found that your results were not up to your professor’s or supervisor’s expectations. What happened? What action did you take?

Recently I was asked to put together a proposal for a migration of network systems. Misunderstanding my boss, I thought it was just an informal paper. When I presented it to him days later, he was upset with the quality since it had to be presented to our VP. I explained my misunderstanding, apologized, reworked the paper, and had it back to him with enough time for him to review it before he presented it successfully at the meeting.

Job Related Questions

36. What do you know about our organization?

Research the target company before the interview. Basic research is the only way to prepare for this question. Do your homework, and you’ll score big on this question. Talk about products, services, history and people, especially any friends that work there. “But I would love to know more, particularly from your point of view. Do we have time to cover that now?

This question is one reason to do some research on the organization before the interview. Find out where they have been and where they are going. What are the current issues and who are the major players?

37. What experience do you have?

Try to cite experience relevant to the company’s concerns. Also, try answering these questions with a question: “Are you looking for overall experience or experience in some specific area of special interest to you?” Let the interviewer’s response guide your answer.

What experience do you have in this field? Speak about specifics that relate to the position you are applying for. If you do not have specific experience, get as close as you can.

I think I have my current job because of my experiences abroad. Those experiences gave me greater self-confidence and a greater understanding of myself, which led to my willingness to uproot myself and try new work in a new location.”

38. According to your definition of success, how successful have you been so far?

Be prepared to define success, and then respond (consistent record of responsibility)

You should always answer yes and briefly explain why. A good explanation is that you have set goals, and you have met some and are on track to achieve the others.

39. How has your college experience prepared you for a business career?

Emphasize your best and favorite subjects. If grades were average, talk about leadership or jobs you took to finance your education. Talk about extra-curricular activities (clubs, sports, volunteer work)

I have prepared myself to transition into the the work force through real-world experience involving travel abroad, internship, and entrepreneurial opportunities. While interning with a private organization in Ecuador, I developed a 15-page marketing plan composed in Spanish that recommended more effective ways the company could promote its services. I also traveled abroad on two other occasions in which I researched the indigenous culture of the Mayan Indians in Todos Santos, Guatemala, and participate din a total language immersion program in Costa Rica. As you can see from my academic, extracurricular, and experiential background, I have unconditionally committed myself to success as a marketing professional

40. What do you look for in a job?

Flip this one over. Despite the question, the employer isn’t really interested in what you are looking for. He’s interested in what he is looking for. Address his interests, rather than yours. Use words like “contribute,” “enhance,” “improve,” and “team environment.” Fit your answer to their needs Relate your preferences and satisfiers/dissatisfiers to the job opening.

41. How long would you stay with us?

“As long as I feel that I’m contributing, and that my contribution is recognized. I’m looking to make a long term commitment.”

Specifics here are not good. Something like this should work: I’d like it to be a long time. Or As long as we both feel I’m doing a good job.

42. What kinds of people do you find difficult to work with?

Use this question as a chance to show that you are a team player: “The only people I have trouble with are those who aren’t team players, who just don’t perform, who complain constantly, and who fail to respond to any efforts to motivate them.” The interviewer is expecting a response focused on personality and personal dislikes. Surprise her by delivering an answer that reflects company values.

43. Why do you want to work for us?

You feel you can help achieve the companies’ objectives, especially in the short run. You like what you’ve learned about the company, its policies, goals and management: “I’ve researched the company and people tell me it’s a good place to work.”

This may take some thought and certainly, should be based on the research you have done on the organization. Sincerity is extremely important here and will easily be sensed. Relate it to your long-term career goals.

44. Describe some situations in which you have worked under pressure or met deadlines?

Refer to accomplishments. Everyone has had a few of these pressure situations in a career. Behavior-related questions aim at assessing a candidate’s character, attitude, and personality traits by asking for an account of how the candidate handled certain challenging situations. Plan for such questions by making a list of the desirable traits relevant to the needs of the industry or prospective employer and by preparing some job-related stories about your experience that demonstrate a range of those traits and habits of conduct. Before answering the questions, listen carefully and ask any clarifying questions you think necessary. Tell your story and conclude by explaining what you intended your story to illustrate. Finally, ask for feedback: “Does this tell you what you need to know?”

You may say that you thrive under certain types of pressure. Give an example that relates to the type of position applied for.

45. Why haven’t you found a new position before now?

“Finding the right job takes time. I’m not looking for just any job.”

46. How much do you expect if we offer this position to you?

Be careful. If you don’t know the market value, return the question by saying that you would expect a fair salary based on the job responsibilities, your experience and skills and the market value of the job. Express your interest in the job because it fits your career goals – Receptive to a reasonable and competitive offer – don’t talk $’s. It’s always best to put off discussing salary and let PPR Career handle that. ANSWER: I’m open to a competitive offer. I’d prefer to discuss the opportunity and allow my recruiter to handle any salary questions.

47. Tell me about your dream job

Stay away from a specific job. You cannot win. If you say the job you are contending for is it, you strain credibility. If you say another job is it, you plant the suspicion that you will be dissatisfied with this position if hired. The best is to stay genetic and say something like: A job where I love the work, like the people, can contribute and can’t wait to get to work.

48. How do you propose to compensate for your lack of experience?

First, if you have experience that the interviewer does not know about, bring that up: Then, point out (if true) that you are a hard working quick learner.

49. Why should I hire you?

The easy answer is that you are the best person for the job. And don’t be afraid to say so. But then back it up with what specifically differentiates you.

For example: “You should hire me because I’m the best person for the job. I realize that there are likely other candidates who also have the ability to do this job. Yet I bring an additional quality that makes me the best person for the job–my passion for excellence. I am passionately committed to producing truly world class results. For example . . .”

Are you the best person for the job? Show it by your passionate examples.

This may sound suspicious, negative, or just plain harsh. Actually, it’s a call for help. The employer wants you to help him/her hire you. Keep your response brief. Recap any job requirements the interviewer may have mentioned earlier in the interview, then, point by point, match your skills, abilities and qualifications to those items. Relate a past experience which represents success in achieving objectives which may be similar to those of the prospective employer.

I sincerely believe that I’m the best person for the job. I realize that there are many other college students who have the ability to do this job. I also have that ability. But I also bring an additional quality that makes me the very best person for the job — my attitude for excellence. Not just giving lip service to excellence, but putting every part of myself into achieving it. In college and at my previous jobs, I have consistently reached for becoming the very best I can become. I think my leadership awards from my college, and my management positions are the result of possessing the qualities you’re looking for in an employee.

50. What qualities do you feel a successful manager should have?

Focus on two words: leadership and vision.

Here is a sample of how to respond: “The key quality in a successful manager should be leadership–the ability to be the visionary for the people who are working under them. The person who can set the course and direction for subordinates. The highest calling of a true leader is inspiring others to reach the highest of their abilities. I’d like to tell you about a person whom I consider to be a true leader . . .”

Then give an example of someone who has touched your life and how their impact has helped in your personal development.

A successful manager should have the vision and capabilities to formulate strategies to reach his or her objectives and communicate these ideas to his or her team members. In addition to serving as a positive role model for co-workers, successful managers must also be capable of inspiring others to recognize, develop, and apply their talents to their utmost potential to reach a common goal. These are the traits I hope to demonstrate when I’m a manager.

51. What is your most important accomplishment to date?

It is important when answering this question to focus on an accomplishmentthat highlights the skills needed to be successful in the specific position youare applying for. For instance, when interviewing for an investment researchassociate or assistant position it is important to mention an accomplishment that required keen quantitative skills, problem solving ability and success asa team member. Be sure when answering this question that you providetangible and measurable results to your accomplishment.

52. Why did you choose this career?

I chose medicine because I loved science. Even when I was very young, I was completely enamored with doctors–how they cared about other people, especially people who were sick and hurting. Anesthesiology has allowed me to combine my interests and continues to keep me challenged.

My past experiences have shown me that I enjoy facing and overcoming the challenge of making a sale. Without a doubt, once I have practiced my presentation and prepared myself for objections, I feel very confident approaching people I don’t know and convincing them that they need my product. Lastly, I like sales because my potential for success is limited only by how much of myself I dedicate toward my goal. If any profession is founded on self-determinism, it surely must be sales.

53. What is your salary expectation for this job?

I’ll need more information about the job and the responsibilities involved before we can begin to discuss salary. Can you give me an idea of the range budgeted for this position?”

54. How do you keep current and informed about your job and the industries that you have worked in?

Pride myself on my ability to stay on top of what is happening in my industry. I do a lot of reading – the business section of the newspapers and magazines. I belong to a couple of professional organizations and network with colleagues at the meetings. I take classes and seminars whenever they are of interest, or offer new information or technology.

Try to include improvement activities that relate to the job. A wide variety of activities can be mentioned as positive self-improvement. Have some good ones handy to mention.

55. When have you been most satisfied in your career?

The job before the one I am currently at was my most rewarding experience for me. I worked in a wonderful team environment. There was a lot of camaraderie. I worked with a team of four people and we did some really original thinking. It is that kind of environment I want to be involved in again.

56. Why do you want this job?

I’ve been very careful about the companies where I have applied. When I saw the ad for this position, I knew I found what I was looking for. What I can bring to this job is my seven years of experience, and knowledge of the industry, plus my ability to communicate and build customer relationships. That, along with my flexibility and organizational skills, makes me a perfect match for this position. I see some challenges ahead of me here, and that’s what I thrive on. I have what you need, and you have what I want.

I am convinced that there would be no better place to work than Accenture. You are the top consulting firm in the United States. You provide your employees with the tools they need to stay competitive and sharpen their skills while working in an open, team-based environment. I am also aware that you provide a mentor for all new employees, and I would embrace any opportunity to work with a mentor and eventually become one myself.

57. Describe a challenging work issue you had to face, and how you dealt with it?

Consider what would be the requirements of the ‘new’ job/organization and find something in your past that highlights a skill, experience or situation that might occur or be needed going forward. It is always a good idea to make lists in preparation for interviews: New job will need I can provide Proof/example For your proofs, list (for yourself) examples of when you used the skill, exhibited the characteristic or handled the problem. This will not only give you ’short stories’ to relate in an interview, it will also bolster your confidence and target your job search.

58. In what way do you think you can contribute to our company?

Preparing to answer this question requires a 2-step preparation: assessing your skills and researching the needs of the company. An integral part of skill assessment (looking at your own experience, education and talents) is to ’skill-match’. Considering the job opening, what are the skills needed? Make a list of the requisite skills (in priority order) and then list concrete examples of your possession of the skill. For example: a sales representative would need good interpersonal skills, the ability to deal with difficult people. For ‘proof’ of this skill, you could list experiences and examples of how you were successful in a difficult situation. These matched skills are your key selling points. Next, what appears to be the current problems at the organization, based upon your research? What are their needs that you can meet? In other words, given the specifics of the company, what value can you add? After these two steps, you are in a great position to come up with concrete examples of what you can offer the company. This question, by the way, is just another version of “Why should we hire you?”. In the interview, when asked this question, you could respond with: “In my experience in sales, I know having the ability to deal effectively with all types of people is not merely a positive element — it is an essential one. With your plans to expand into ____ market, a sales representative with a proven ability to meet with all types of people and to be able to assess and meet their immediate needs would be a great asset. In the past __ years, I have increased sales __… ..”

59. Tell me a story.

Many interviewers like to hear ’stories’ or examples from your work life. So pick something that is more usual than not (not the day of a plant explosion and you saved 10 lives!) but a story that shows how you handle yourself, handle difficult people or situations. Can you think on your feet? Do you adhere to the rules? Consider the type of organization you are aiming at… each has its own culture. The World Wrestling Federation entertainment culture is different than the American Bible Society and also different from Amazon.com. Gear your stories to give the listener a feeling that you could fit in… you could do the job here.

60. Tell us about your analytical skills.

This should be easy if you have done a realistic skill inventory for yourself, listing what skills you do have and how you can offer proof of this skill (where you learned it, last used it). Working off your inventory, focus on various analytical skills and match them to the skills you feel are most important for the job you are considering. You can now give specific examples of skills you can offer. (Do not neglect skills obtained in extracurricular activities, such as volunteer work.)

61. What can you add to what we have already asked you that should make us want to hire you?

Think grocery shopping… all those brands in the soap aisle begging for your attention. Each one comes with its own key selling points. Remember the comics, Superman? On TV, he sold himself… stronger than a locomotive, faster than a speeding bullet, able to leap tall buildings in a single bound. What are your key selling points? Plan this out ahead of time for the next interview… or include in a thank you letter for this past interview. Think a 1 minute infomercial about yourself. What are your core strengths? Is it communicating with children, being a mentor to other teachers, being able to keep topics current and interesting… . Think of what is needed to be successful in the job and how you specifically meet those needs—provide examples. Increased reading scores by using… Math scores jumped __% due to my … Offer some proof from your past to support your claims. But it is your ability to assess the situation and analyze your potential contributions that will sell your candidacy. Do not think it too late — send a strong thank you and include in your request for the job the key reasons why you are the best candidate.

62. What does “customer service” mean to you?

Think of yourself as a customer — what do you expect from salespeople … regardless of the circumstances and/or the problem. An example may be “Customer service is a two-piece reaction. First—respect; second — problem solving.” See if that makes sense and if you sound convincing when you do practice it. If you can give a brief story or two of what you have witnessed as extraordinary examples of customer service behavior. By using yourself as a focal point you will be able to enunciate clearly your understanding of customer service.

63. What do you know about our company?

If you can relate your knowledge to the area that you would be involved in, it would show that already you have an active interest in the organization. For example, if you were interested in marketing, “I understand that you are one of the top 10 companies in sales to Europe but are currently interested in expanding your market into Asia. Competition is keen in that area but you have an advantage in that you product offers features that others do not, such as… ..” It is not only showing that you have done the research but also that you like/know what you have learned about the company and have applied it to how you can add value in the position.

You’re large and respected worldwide. You’re both a clinical and teaching hospital. Over the last 60 to 70 years you’ve produced award-winning research. In reviewing your Web site, I’ve familiarized myself with many of your corporate goals and objectives.

64. What do you wish to gain from our company?

Excellent question! Research is the answer (know everyone is tired of hearing this but we feel this is one great way for applicants to make a difference in their candidacy). Determine some of the key elements in the corporate structure, product base, employees/management team or recent history. What appeals to you about working at this company? Go with what you know. “In the past, I have had opportunities to work on new products being launched. I am very excited about your plans to start an entire new line of products. With my prior experience I know I can provide insights and make contributions immediately and I will also learn so much from the excellent team you have in place. Having done single products, I would love to be in on the give-and-take meetings planning the new line… there is much I can offer but also much for me to learn.” Finding something specific… the opportunity to use a new technology, a new skill, to work with ‘experts on their team”… are ways for you to find job satisfaction, which is another way of asking this question

65. What do you think the employee’s responsibilities are to the company?

As an employee you have several responsibilities to your employer. They are as follows: to perform a good day’s work to be loyal to act as part of the team to value the relationship to earn the employer’s trust to grow with a passion for the product/service.

66. What motivates you?

Other than looking into your past experiences….Times when you were motivated and times when you were not… no one but you has this answer. Find concrete examples when you had to pull it all together and get motivated to get the job done; what does it for you?

This is a personal trait that only you can say, but good examples are: Challenge, Achievement, and Recognition

You would think that because I am interested in sales, only financial compensation would motivate me to achieve. Although monetary rewards are important to me, I am driven to succeed internally. More than anything, I want to be respected by my friends and coworkers for being the best at what I do. Whether I am considered to be the best car detailer in my hometown or the best columnist for my college newspaper, I want to be recognized as the best.

67. What things make a good team member?

Consider first the situational context of the question. What is the team environment of the organization that you are interviewing—do they have a strong, organized team-based work environment or is it based on informal authority and fluctuating teams? Ideally, you should have had an opportunity to research and ask some questions about the organization to determine how they operate (and if indeed you want to work in that environment.) Model your responses to the organization. Obviously, you are describing yourself = good team member. My ideas of what makes a good team member may be very different from yours—and from the organization. Also depends on where you are in the team—new member, leader, support. How do you see yourself? How do you make yourself fit into a new team? How do you elicit cooperation from other team members? What do you think the organization’s biggest problem is relative to teams and team-building? And, what solution could you provide?

68. Why do you feel we should hire you for this position?

Before you submit a resume or draft a cover letter and certainly before you go to an interview you should do 2 things: Research the job and the organization. What do they need? What are the requirements for the position? What role does this job play in the overall goals of the organization? Research yourself. What skills and experiences and interests can you offer? How will you add value to the organization? How can you prove that you have the required skills and experience needed for the job? Do a skill matching exercise: The organization/job needs… (skill/experience) and I have it because I did ….. The organization needs….. And i can provide….. Be certain to have specific examples of how you have added value in the past and be enthusiastic on how you can add value to this organization. Do not forget… the organization is looking to solve a problem and you are selling yourself as a solution.

69. What do you expect your starting salary to be?

Discussions of salaries and compensation should not be held until an offer is made. With that said, let’s look into the real world when this is not the case most of the time. Employers are shopping, trying to guess your price tag. This is one of those screening questions used to either screen in or screen out… so a response is important. Have you done your homework? What is the price for this job in the marketplace? Have you checked out classified ads or online ads for similar positions? Are you within the range, given your level of experience? Pegging yourself mentally to the right price is the first step. Second step is sharing this information correctly. Do you have enough information about this new job to determine your salary? If not… state it and ask for the information that is needed. “Before I can discuss salary, I would like to know the reporting requirements and how many people I would be supervising. In addition, what are the skill levels and experience of my staff?” You can also ask “What are others in similar positions being paid?” When you can no longer stall or seek additional information… “Based on what you have told me and exclusive of other compensation elements I feel that the position would warrant a salary range of $_______ to $___________” Name a range such as $40,000 to $45,000 to give both sides some wiggle room and allow for some give-and-take when benefits and other compensation is considered. If you know what you are willing to accept as salary and what the market pays, using a salary range should permit you to be negotiable.

70. When did you decide on this career?

I decided to pursue this career while studying art during my freshman and sophomore years in college. The decision to focus on design came naturally as I took as many of the fine arts and graphics course electives that the schedule would allow; I really did not have to think about it, it just happened. I was always interested in art, and found myself much more suited for the “structure” of graphic design versus the fine arts courses I was taking. I always admired magazines and catalogs for their layout even before I knew much about the profession of graphic design. Though I enjoy fine arts very much, I found graphic design to be the perfect fit for my half left brain, half right brain personality!

71. What goals do you have in your career?

Think in terms of short term goals and long term goals. What do you want to accomplish in the short term of 3 to 5 years? What do you want to achieve in that short time span? Same information applies for your long term career goals. Why did you chose the profession you chose – interest, pay, benefits — what do you see yourself doing in the long term goal of 10 to 20 years. Brainstorm your ideas and write them down. Set realistic goals and not far fetched. Not everyone can be a president or CEO of a company. Set high enough standards you think you can achieve. Any goal worth achieving is the sacrifices you made to get there.

72. How do you plan to achieve these goals? (What specific goals have you established for your career?)

Remember, all goal setting must be immediatly followed by massive and consistent action toward its fullfillment. In most cases, setting the goal alone doesn’t make it happen, I learned that from experience.

Good question. I’ll try to offer some of the aspects I consider when setting goals for myself…I mean there are some questions that you should ask yourself in formulating your goals, such as:

– What do I want? (This is usually best stated in the positive. Goals like “I don’t know any more of the same old crap.” tend to not be that useful.

– Where am I now in relation to that?

– What specifically do I want and how will I know when I have it? (Be specific in describing what you want. What will you see, feel, and hear when you have accomplished your goal. Who will you be with? Where will you be? Also make sure that this goal is dis-associated…I’ll explain that in a minute if it’s not clear).

– Is it consistent with my values and other goals? (Sometimes people make goals like, I want to be a coporate executive in a Fortune 500 company AND be home for dinner by 6 o’clock everyday to spend time with my family. Not saying it couldn’t happen, but you might want to outline how specifically you plan to accomplish it).

– Is accomplishing this goal something I can control? (Who else has to be involved? Are you doing this for yourself or because of other people?)

– What resources will you need to accomplish the goal? (Do you need money, time, more friends, and special contacts in foreign governments?)

– For what purpose do I want this? Some corrolaries to the last question are: – How else could I get this same thing? – What will happen if I do get my goal? – What will happen if I don’t get my goal? – What won’t happen if I do get my goal? – What won’t happen if I don’t get my goal?

Okay so there are some questions that are helpful in exploring goals and deciding on what goals are appropriate and how they will integrate together with other goals into your life. The important thing for me is to program these into my future using “Time Lines”. For me I tend to see the future as a line that shoots off to my right at a 45 degree angle and when I look there I see the future, the things that WILL happen. And this is quite a different place than where I seem to keep my hopes…See the things that I keep as hopes are the things I’d like to see happen but have never quite put in the right place to make it all happen.

Do you see why it’s important to distinguish between hopes and your future? Too many people make goals and then say “Gosh I sure hope that happens” and quicker than you can blink all the representations of their goal have been tossed right into that pile of hopes…and maybe with incredible luck it will happen, but only because of luck. So I would recommend taking a little inventory by imagining your future, where are you keeping track of what you know will happen, the things you are absolutely committed to? And where are you keeping your hopes/wish-it-would-happens? When you make pictures of these things where do you seem them? Are there differences in focus, clarity, location? Are there sounds associated with one class and not the other? What are the differences in the feelings you get with each?

Now decide how important your goal is and make sure that when you imagine that goal that you mentally sort it into the right place so it’s just like the things you know will happen. And make sure that you are “dis-associated” from your goal, that means that you can see it in the future but aren’t actually experiencing it right now.

There are people who habitually fail to achieve there goals for one simple reason, and that is this. They imagine a really great goal and then they imagine how great it will feel when they accomplish their goal. Then they step into those great feelings, experience them now, and then think, “Gosh that was great, and since I’ve already had all the pleasure of accomplishing the goal, I guess I should think about something else.” So when I say stay disassociated, I mean keep the feelings out there, make sure your goal is compelling but make sure that you don’t allow yourself to feel the rewards until you’ve actually got the whole thing. It will help propel you into the future that you’ve built.

My goals include becoming a Certified Financial Advisor so I can obtain a better working knowledge of financial research analysis, which would allow me contribute to my client base as a better financial consultant since I would have that extra insight into the companies they are seeking to invest in. Also this is the foundation block to advancing my career to portfolio manager or even branch office manager.

73. How do you personally define success?

Success: In a career, being good at something you love and believing that your expertise helps other people. Being aware that hard works AND luck (or blessings — choose your own words) play a part in any success, being grateful rather than smug.

In life: Doing your best at your work and in dealing with your family and friends (not necessarily in that order), but taking time for a few pet projects or dreams of your own. Devoting all of your time to any one endeavor (be it work, play or raising a family) can never make you successful, just boring and bored.

Last semester I was hired by by university’s Council for Student Activities. The group negotiates contracts of entertainers, sets up sound equipment, markets the entertainers to students, and generally decides what kind of programming should be done. When I got hired, I didn’t know the first thing about how fill any of those responsibilities. I decided, however, that I wasn’t going to fail. Four months later, I have become the Webmaster for the group. I also write our campus newsletter and created Game Night, a student competition of table games. That event yielded the biggest audience ever for a non-concert event.

74. What will it take to attain your goals, and what steps have you taken toward attaining them?

I’ve already done some research on other workers at Merrill Lynch to see how they achieved similar goals. I know that Merrill Lynch encourages the pursuit and will reimburse for tuition of a graduate degree. I plan on pursuing a MBA to give me an even more extensive knowledge of business and financial analysis.

75. Describe a situation in which you were successful.

76. What do you think it takes to be successful in this career?

I believe successful salespeople put forth that extra effort that turns potential clients into first-time customers. Salespeople who attend to the details by doing whatever it takes to win over a prospective customer distinguish themselves from the countless others who don’t go to any extra effort. Second, I think that if you label success as an attainable goal, you will never consistently remain successful. You can only succeed if you learn all there is to learn about your product, your competitors, and personal selling. Since this learning process is continuous, it’s an unattainable goal. With good reason, salespeople should not consider success an attainable ending point but an objective that will always linger slightly beyond their reach.

77. What accomplishments have given you the most satisfaction in your life?

78. How would you describe yourself in terms of your ability to work as a member of a team?

I have had many opportunities in both athletics and academics to develop my skills as a team player. My tenure as a rower with my college’s crew team serves as a good example. I learned a great deal about teamwork while rowing because all the rowers in the boat must act as one, which meant that we incessantly worked to keep each movement in the boat synchronized. On an individual basis, we still worked toward group goals through weightlifting and land-rowing. My experience as a marketing research team leader also helped me to learn the role of “team player.” I viewed my position as that of group leader and of group member. I ensured that everyone in the group had equal opportunity to contribute, maintained excellent communication among group members, and coordinated their energies toward reaching our team’s goal.

79. Are you a goal-oriented person?

80. Tell me about some of your recent goals and what you did to achieve them. (Give me an example of an important goal which you had set in the past and tell me about your success in reaching it.)

As a senior in high school, my goal was to attend college and play college golf. But I was nowhere near the player I needed to be to play or even get on the team. So over that summer I worked on my golf game to the point where I won almost every tournament I entered. I spent every hour I had during the day to make myself a better all-around player. I eventually walked on my freshmen year and was exempted from qualifying because I played so well in my first outing.

81. What major problem have you had to deal with recently?

82. Do you handle pressure well?

83. How much training do you think you’ll need to become a productive employee?

My background has been focused on preparing me for the financial consulting industry, so I can be productive right away. I already have obtained the educational credentials and skills to allow me to become an immediate asset to Merrill Lynch. After interning for a semester, I am well aware of the shared beliefs of the organization and its corporate values. I already have a very good working knowledge of the financial consulting business. I am confident of my ability to get up to speed quickly in any assignment with which I’m not familiar.

84. Why do you want to work in the _____ industry?

85. Are you willing to travel? How much?

I am more than willing to travel. I understand the importance of going above and beyond the call of duty to satisfy customer requests is sometimes required and that Merrill Lynch’s customer focus belief means that travel is expected in some circumstances. I am willing to make this commitment to do whatever it takes to develop that long-term relationship with a small business or client. It is only through this relationship that loyalty can be maintained and financial gains and growth can occur for both the client and Merrill Lynch. It is my understanding from other financial consultants that I have interviewed at Merrill Lynch that this occurs maybe one or two times a month.

86. Is money important to you? (Which is more important to you, the job itself or your salary?)

A salary commensurate with my experience and skills is important, but it’s only one piece of the package. Many other elements go into making up a compensation package, but more importantly, it’s critical to me to enjoy what I’m doing, fit into the corporate culture, and feel I’m making a genuine contribution.

87. How much money do you need to make to be happy? (What level of compensation would it take to make you happy?)

I am not depending on money to make me happy. What makes me happy is having a satisfying job that provides challenge and new situations daily.

88. Tell of a time when you worked with a colleague who was not completing his or her share of the work. Who, if anyone, did you tell or talk to about it? Did the manager take any steps to correct your colleague? Did you agree or disagree with the manager’s actions?

During a group project in college, we had one member who would do no work whatsoever. The project was to compare and contrast four companies in a single industry, so his work was vital. We first discussed the situation and asked for the bare-bones minimum of what we needed from him. We got just below that. As a result we as a group went to the professor and told her our situation — not expecting or requesting action — just informing her the situation we were dealing with. Then we as a group split up the non-contributor’s work, and completed our work collectively on his share. In phase two in which we analyzed the information and reported how each of our companies fared compared to the others, we did not get a paper from the group member. As a result, we told the teacher that we had our work done, and were willing to do the extra paper but that we would rather spend time polishing our own work, and not picking up slack. She agreed and said to focus on the three companies we had compiled the most info on while not entirely neglecting the fourth. The papers came out very well, but were understandably weak when comparing the fourth company. The professor understood, and we received the grades we deserved. I was pleased with our teamwork and the way we handled the situation.

89. Describe a situation in which you had to arrive at a compromise or guide others to a compromise.

My first semester in college, I was a political-science major. My introductory government class professor had a differing political view then I. We disagreed on everything, and many classes were filled with criticizing each others’ view. However, on one test I answered a question with the view I believe in, and she marked it wrong. So I asked her how an opinion can be wrong, and she said because her opinion is the way she taught it in class. I pointed out that my answer showed I understood the concepts of the question. She agreed, and I also agreed not be so combative in answers on tests. Compromise is the key to problem resolution.

90. What steps do you follow to study a problem before making a decision?

Following standard models for problem-solving and decision-making can be very helpful. Here are the steps and how they helped me solve a problem with a group project:

  1. Define the problem to be solved and decision to be made. For a project in an introductory management class the assignment was to report on the corporate structure and financial situation of a couple of companies. The decision to be made was what companies to profile and how to present the information.
  2. Gather the necessary information. Some group members wanted to report on automakers, while others wanted to do electronics firms. We gathered information on both types of company.
  3. List all possible choices. We made lists of companies in both categories.
  4. Consider possible outcomes for each choice. We decided that a report about car companies could have a positive outcome, but one about electronics firms might be more futuristic with high-tech products such as HDTV, video game consoles, and DVD players.
  5. Check out how you feel about each of the choices. Given that this was a group project, we had to consider the feelings of all group members.
  6. Relate the choices to your values and priorities. Again, all group members weighed in on their values and priorities.
  7. From the possible alternatives, choose one. We decided that we’d do electronics companies because we could bring in products from each company and show what lies ahead.
  8. Commit yourself to your chosen decision and disregard the others. Concentrate your energies in one direction. Once we made our decision, we focused all our work on electronics forms.
  9. Take steps to turn your decision into positive action. All group members got interested in how the companies were doing.
  10. Evaluate your progress from time to time. Change your decision if necessary. We were pleased with our progress and didn’t feel a need to change our decision. We got an A on the project.

Sample Questions for You to Ask

What is it you saw in my background that made you want to speak with me?

What qualifications would the ideal person for this job have?

What is the biggest challenge facing the person you hire for this position?

What are the three most important things you would expect me to accomplish in my first 30/60/90 days on the job? -And/or-

What is the first priority of the person who is hired for this position?

What are the reporting relationships for this position?

What are the biggest challenges facing your company in the next few years?

How would you characterize the corporate culture here?

When will the job performance evaluation take place? -And/or-

How are performances reviews handled here?

What do you like best about working for this company? -And/or-

What’s the most frustrating thing about working for this company? -Similarly-

If you could make one constructive suggestion to top management, what would it be? -Or-

What areas does the company need to focus on to become more competitive?

When you look at people who have been successful here, what tend to be their strengths? Conversely, when people don’t work out, are there any common themes as to why?

How would you describe a typical day on the job? -Or-

What are the daily duties and work of an intern?

What are the overlying goals of the program?

How much discretion is I allowed and expected to exercise?

What do you look for in applicants?

What continuing education and supervision is provided?

In what directions do you see your organization going in the near future?

What are some current challenges here?

What do you like most about your work here?

What makes a successful employee in your organization?

How would I be evaluated?

What’s a normal work week like?

Is there other information I can provide you?

When will your hiring decisions and offers be made?

What are the specific duties required?

Please tell me about your experiences with this organization.

November 19, 2007

SIP protocol indepth analysis

Filed under: Uncategorized — manoftoday @ 6:57 pm

Source: Tech Invite — SIP Dialog and Routing of Requests

http://web.archive.org/web/20030213031908/http://www.egyed.com/faq/sip_faq.html#tag

http://4z.com/people/emin-gabrielyan/public/070410-SIP-transactions/

[call-id, transaction,dialog,call-leg]

one transaction : same branches stack in Via; (INVITE,100,180,200) ACK is out of scope of the INVITE transaction of normal setup.

  • (1)If the request is INVITE
  • the final response is a 2xx response, The ACK is a separate transaction;
  • the final response is a non-2xx, the transaction also includes an ACK to the response;
  • (2) otherwise, Transaction comprises all messages from the first request sent from the client to the server up to a final (non-1xx) response sent from the server to the client;

one call-leg: end-to-end, may contains many transactions; The CSeq spaces in the two directions of a call leg are independent.

one dialog/call: from, to, cal-id, to be exact, it should be the combination of the To tag, From tag, and Call-ID . the tag is a pseudo-random sequence inserted by the SIP application. It works as an identifier of the caller in the dialog. A dialog used to be referred as a ‘call leg’.

relation.gif

The Call-ID is an identifier, carried in the SIP messages, that refers to the call. It is a globally unique identifier of the call generated as the combination of a pseudo-random string and the softphone’s IP address.

A call may contain several dialogs. we can say a cal is a session.

Since a phone call (i.e. an SIP dialog) consists of several transactions, and SER (an open source Proxy) does not keep information about transactions throughout a particular phone call, the consequence is that SER does not know that a call is on-going, nor can SER calculate the length of an ended or active call. Neither can SER terminate a phone call. However, SER can store the times at which an INVITE (or ACK) and a BYE message are received and record this info together with the Call-Id. A billing application can then match the INVITE with the BYE and calculate the lengths of calls

The tags and the Call-Id field are generated by endpoint SIP phones and are maintained by them constantly during the phone conversation. Tag parameters are random strings, while Call-Id is generated by a combination of a random string and the originating phone’s host name or IP address. The combination of the To tag, From tag, and Call-ID completely defines a peer-to-peer SIP relationship between two SIP phones and is referred to as a dialog [rfc3261, p.12].

[via fields]

Within the scope of one transaction SIP requests and all replies follow the same signalling path. It is ensured by a stack of Via fields.

When processing SIP request messages each intermediary proxy adds its own Via field on top of the stack of Via header fields. Each Via field contains the IP address of the proxy and a branch parameter identifying the transaction (i.e. all messages in the transaction have the same branch parameter).

The replies are transmitted by the destination UA with the same stack of Via fields as they received by UA in the request message (recall that the stack of Via fields is summed up on the way from the originating UA to the destination UA). The top most Via field of reply message dictates the next hop where the message should be transmitted (i.e. the last proxy of the request before it arrived to UA). At each hop the proxy server removes its own Via field from the top and forwards the message according to the top most Via field of the reduced stack.

[record-route]

record-route: http://4z.com/People/emin-gabrielyan/public/070412-SIP-record-route/

However, the proxies can request to maintain the signalling path during the dialog. Record-Route header is designed for these purposes. A stack of Record-Route headers works similarly as the stack of Via headers but is a little bit more complex. (1)Each proxy server (wishing to stay in the signalling path) adds on top of the Record-Route headers stack its IP address (or its domain name). (2)Record-Route headers are usually added by proxies only in the first request of the first transaction (i.e. in the INVITE message).

When processing the first request of the first transaction, each intermediary proxy adds its own Record-Route field on top of the stack of Record-Route header fields.when the destination UA receives a stack of Record-Route headers which is similar to the stack of Via headers. The destination UA will copy the stack of Record-Route headers from the request to all responses replied within the scope of the transaction. The Record-Route headers will not be removed (unlike the Via header) as the reply traverses back to the originating UA. Recall that replies are delivered back through a path dictated by the stack of Via headers. The Record-Route headers are therefore not required for determining the path of replies. Therefore the originating and destination User Agents will be in possession of the same stack of Record-Route headers at the end of the SIP dialog’s first transaction.

(Although the callee phone 309 learned the direct contact of the originating phone 308 from the Contact field of the INVITE request, and the calling phone 308 learned the direct contact of the callee phone from the Contact field of the 200 OK reply (see the message above), the User Agents give a priority to Record-Route instructions and will not use the available direct contact information.)

The endpoint User Agents form Route header stacks from the received Record-Route header stacks. The Route header stack of the destination UA is the copy of the Record-Route header stack (only the header name is changed from “Record-Route:” to “Route:”). The Route header stack of the originating UA is the copy of the Record-Route header stack but in the reversed order.

The Route header stack added to request messages dictates the path of the message. Each time an intermediary proxy receives a message with its own IP in the top most Route header field, the proxy will remove its Route field from the stack and will forward the request to the next proxy listed in the stack. The routing according to the Route fields with removals of top most Route fields is called loose routing. Using the stack of Route fields (for maintaining the signalling path) during the phone conversation is the obligation of User Agents. They follow that during the entire duration of the phone conversation the request messages will be transmitted by both User Agents with the stacks of Route fields (associated to the current phone conversation). The proxies only provide the Record-Route headers once in the call setup transaction.

[c-seq]

All requests sent from A to B within a dialog, independent of the
method, have increasing CSeq, by value of 1, with two exceptions:

  1. ACK for an INVITE has the same cseq as the invite
  2. cancel for a request has the same cseq as request
http://www1.ietf.org/mail-archive/web/sip/current/msg03423.html

[autehtication]

for register authentication, the server challenges with the header field WWW-Authenticate and the user responses with the header field Authorization. For call setup, the proxy server challenges with a different header field Proxy-Authenticate, and the user responses with the header field Proxy-Authorization

http://4z.com/People/emin-gabrielyan/public/070501-sip-docs/

[misc]

Understanding SIP exchanges by experimentation

http://4z.com/People/emin-gabrielyan/public/070410-SIP-transactions/

other sip docs

http://4z.com/People/emin-gabrielyan/public/070501-sip-docs/

November 13, 2007

network

Filed under: Uncategorized — manoftoday @ 1:34 am

1. TCP/IP 3 ways synchronization

1. the client, sends a SYN segment to the server to synchronize the sequence numbers. It specifies its initial sequence number (ISN) (8221822) . To initialize a connection, the client and server must synchronize each other’s sequence numbers. There is also an option for the Maximum Segment Size (MSS) to be set, which is defined by the length (len: 4). This option communicates the maximum segment size the sender wants to receive. The Acknowledgement field (ack: 0) is set to zero because this is the first part of the three-way handshake.

2. In the second frame, the server, sends an ACK and a SYN on this segment (TCP .A..S.). In this segment the server is acknowledging the request of the client for synchronization.

At the same time, the server is also sending its request SYN to the client for synchronization of its sequence numbers(1109645). The server transmits an acknowledgement number (8221823) to the client. the server increments the client’s sequence number by one and uses it as its acknowledgement number.

3. In the third frame, the client sends an ACK of seq (8221823) on this segment (TCP .A….). In this segment, the client is acknowledging the request from the server for synchronization with ACK (1109646).

http://support.microsoft.com/kb/172983

for terminaltion, because of duplex, there are 4 frames

FIN—>

<—ACK

<—FIN

ACK—>

IPSec handshake

http://www.tech-invite.com/Security/Ti-SSL-main.pdf

A HTTP-based SSL connection is always initiated by the client using a URL starting with https:// instead of with http://. At the beginning of an SSL session, an SSL handshake is performed. This handshake produces the cryptographic parameters of the session. A simplified overview of how the SSL handshake is processed is shown in the diagram below.

SSL handshake with server authentication

  1. The client sends a client “hello” message that lists the cryptographic capabilities of the client (sorted in client preference order), such as the version of SSL, the cipher suites supported by the client, and the data compression methods supported by the client. The message also contains a 28-byte random number.
  2. The server responds with a server “hello” message that contains the cryptographic method (cipher suite) and the data compression method selected by the server, the session ID, and another random number.Note:The client and the server must support at least one common cipher suite, or else the handshake fails. The server generally chooses the strongest common cipher suite.
  3. The server sends its digital certificate. (In this example, the server uses X.509 V3 digital certificates with SSL.)If the server uses SSL V3, and if the server application (for example, the Web server) requires a digital certificate for client authentication, the server sends a “digital certificate request” message. In the “digital certificate request” message, the server sends a list of the types of digital certificates supported and the distinguished names of acceptable certificate authorities.
  4. The server sends a server “hello done” message and waits for a client response.
  5. Upon receipt of the server “hello done” message, the client (the Web browser) verifies the validity of the server’s digital certificate and checks that the server’s “hello” parameters are acceptable.If the server requested a client digital certificate, the client sends a digital certificate, or if no suitable digital certificate is available, the client sends a “no digital certificate” alert. This alert is only a warning, but the server application can fail the session if client authentication is mandatory.
  6. The client sends a “client key exchange” message. This message contains the pre-master secret, a 46-byte random number used in the generation of the symmetric encryption keys and the message authentication code (MAC) keys, encrypted with the public key of the server.If the client sent a digital certificate to the server, the client sends a “digital certificate verify” message signed with the client’s private key. By verifying the signature of this message, the server can explicitly verify the ownership of the client digital certificate.Note:

    An additional process to verify the server digital certificate is not necessary. If the server does not have the private key that belongs to the digital certificate, it cannot decrypt the pre-master secret and create the correct keys for the symmetric encryption algorithm, and the handshake fails.

  7. The client uses a series of cryptographic operations to convert the pre-master secret into a master secret, from which all key material required for encryption and message authentication is derived. Then the client sends a “change cipher spec” message to make the server switch to the newly negotiated cipher suite. The next message sent by the client (the “finished” message) is the first message encrypted with this cipher method and keys.
  8. The server responds with a “change cipher spec” and a “finished” message of its own.
  9. The SSL handshake ends, and encrypted application data can be sent.

2. IP address

IP Subnetting: for instance ,Class C has fixed length of the network mark address at 24 bits. To subnet this network, MORE than 24 bits must be set to ‘1’ on the left side of the subnet mask. For instance, the 25-bit mask 255.255.255.128(11111111,1111111,11111111,1000000) of 192.168.1.0 creates a two-subnet networks as there is one extra bit of mask :192.168.1.0 and 192.168.1.128 (xxxxxxxx,xxxxxxxx,xxxxxxxx,0/1000000)

A two-bit subnet number can support up to four subnets, a three-bit number supports up to eight subnets, and so on.

SUM: extra bits stands power of 2 subnets are divided;

CIDR is an alternative to traditional IP subnetting that organizes IP addresses into subnetworks independent of the value of the addresses themselves.
CIDR is also known as supernetting as it effectively allows multiple subnets to be grouped together for network routing.(subnet mark length is LESS than default subnet mark length)

192.168.12.0/23 ([xxxxxxxx.xxxxxxxx.0000110]0.0000 where default marsk is 24 bits.)

applies the network mask 255.255.254.0 to the 192.168 network, starting at 192.168.12.0. This notation represents the address range 192.168.12.0 – 192.168.13.255. Compared to traditional class-based networking, 192.168.12.0/23 represents an aggregation of the two Class C subnets 192.168.12.0 and 192.168.13.0 each having a subnet mask of 255.255.255.0. In other words,

SUM: less bits stands power of 2 subnets are aggredated;

Additionally, CIDR supports Internet address allocation and message routing independent of the traditional class of a given IP address range. For example,

represents the address range 10.4.12.0 – 10.4.15.255 (network mask 255.255.252.0). This allocates the equivalent of four Class C networks within the much larger Class A space.

You will sometimes see CIDR notation used even for non-CIDR networks. In non-CIDR IP subnetting, however, the value of n is restricted to either 8 (Class A), 16 (Class B) or 24 (Class C). Examples:

http://www.tenouk.com/Module39.html

struct sockaddr

struct sockaddr {
    u_char  sa_len;

u_short sa_family; // address family, AF_xxx

char sa_data[14]; // 14 bytes of protocol address

};

struct sockaddr_in

struct sockaddr_in {
    u_char  sin_len;

u_short sin_family; //Address family

u_short sin_port; //Port number

struct in_addr sin_addr; //Internet or IP address

char sin_zero[8]; //Same size as struct sockaddr

};

Data type struct in_addr – this data type is used in certain contexts to contain an Internet host address. It has just one field, named s_addr, which records the host address number as an unsigned long int in network order.

#include <unistd.h>

#include <sys/types.h>

#include <sys/socket.h>

#include <netinet/in.h>

/*the port users will be connecting to*/

#define MYPORT 3440

/* how many pending connections queue will hold */

#define BACKLOG 10

int main()

{

/* listen on sock_fd, new connection on new_fd */

int sockfd, new_fd;

/* my address information, address where I run this program */

struct sockaddr_in my_addr;

/* remote address information */

struct sockaddr_in their_addr;

int sin_size;

sockfd = socket(AF_INET, SOCK_STREAM, 0);

if(sockfd == -1){

perror(“socket() error lol!”);

exit(1);

}

else

printf(“socket() is OK…\n”);

/* host byte order */

my_addr.sin_family = AF_INET;

/* short, network byte order */

my_addr.sin_port = htons(MYPORT);

/* auto-fill with my IP */

my_addr.sin_addr.s_addr = INADDR_ANY;

/* zero the rest of the struct */

memset(&(my_addr.sin_zero), 0, 8);

if(bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1)

{

perror(“bind() error lol!”);

exit(1);

}

else

printf(“bind() is OK…\n”);

if(listen(sockfd, BACKLOG) == -1)

{

perror(“listen() error lol!”);

exit(1);

}

else

printf(“listen() is OK…\n”);

sin_size = sizeof(struct sockaddr_in);

new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size);

if(new_fd == -1)

perror(“accept() error lol!”);

else

printf(“accept() is OK…\n”);

/*…..other codes…….*/

while(1) {

recv(..);

send(…);

}

close(new_fd);

close(sockfd);

return 0;

}

[bodo@bakawali testsocket]$ cat test2.c

#include <unistd.h>

#include <sys/types.h>

#include <sys/socket.h>

#include <netinet/in.h>

#define DEST_IP “127.0.0.1”

#define DEST_PORT 80

int main(int argc, char *argv[])

{

int sockfd;

/* will hold the destination addr */

struct sockaddr_in dest_addr;

sockfd = socket(AF_INET, SOCK_STREAM, 0);

if(sockfd == -1){

perror(“Client-socket() error lol!”);

exit(1);

}

else

printf(“Client-socket() sockfd is OK…\n”);

/* host byte order */

dest_addr.sin_family = AF_INET;

/* short, network byte order */

dest_addr.sin_port = htons(DEST_PORT);

dest_addr.sin_addr.s_addr = inet_addr(DEST_IP);

/* or better

inet_aton(“10.12.110.57”, &(my_addr.sin_addr));

*/

/* zero the rest of the struct */

memset(&(dest_addr.sin_zero), 0, 8);

if(connect(sockfd, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr)) == -1)

{

perror(“Client-connect() error lol”);

exit(1);

}

else

printf(“Client-connect() is OK…\n”);

/*…other codes…*/

while(1) {

send(…);

recv(..);

}

close(sockfd)

return 0;

}

write a sample TCP/IP program

TCP congestion control

what is ICMP

leaky bucket

什么是big endian, little endian,写个函数来区分;

Little Endian and big Endian issue regarding the use of the different processors.

– On Intel based machines the hex value 0x01020304 would be stored in 4 successive bytes as: 04, 03, 02, 01. This is little endian. (least-significant byte first.)

– On an Most Significant Bit (MSB)-first (big endian) machine (IBM RS6000), this would be: 01, 02, 03, 04. (most-significant byte first )

– The standard network order is actually big-endian

http://betterexplained.com/articles/understanding-big-and-little-endian-byte-order/

char * s = malloc(2);

*s=’W’;

*(s+1)=’X’;

So, K is a pointer to a short, and is now looking at byte location 0 (which has W), byte location s+1 (which has X). What happens when we read the value at K?

I think a short is two bytes, so I’ll read them off: location s is address 0 (W, or 0x12) and locaiton s + 1 is address 1 (X, or 0x34).

  • Big endian machine: Since the first byte is biggest (I’m big-endian!), the number must be 256 * byte[0] + byte[1], or 256*W + X, or 0x1234.
  • Little endian machine: But in my world, the first byte is the littlest! The value of the short is byte[0] + 256 * byte[1], or 256*X + W, or 0x3412.

socket programming中何时用到(htons,htonl,ect)

bind , connect, sendto, data translated.

* choose an unused port at random */

my_addr.sin_port = htons(8080);

my_addr.sin_addr.s_addr = htonl(INADDR_ANY);

TCP/IP hdr checksum : what method is used ?

Answer
Header Checksum: A checksum computed over the header to
provide basic protection against corruption in transmission.
This is not the more complex CRC code typically used by data
link layer technologies such as Ethernet; it’s just a 16-bit
checksum. It is calculated by dividing the header bytes into
words (a word is two bytes) and then adding them together.
The data is not checksummed, only the header. At each hop
the device receiving the datagram does the same checksum
calculation and on a mismatch, discards the datagram as damaged.

Code Correctness Verification

SNMP

SNMPv1 (RFC’s 1155, 1157, and 1212), SNMPv2c (RFC’s 1901 through 1908), and SNMPv3 (RFC’s 3411 though 3418). The co-existence of all three versions are detailed in RFC 3584.

SNMPv1 is the original standard for community based management.

SNMPv2 was derived from the SNMPv1 framework but had no message definition, which was later revamped aa SNMPv2c, a community based version of SNMPv2 with a message format similar to SNMPv1. SNMPv2 added several new datatypes (Counter32, Counter64, Gauge32, UInteger32, NsapAdress, and BIT STRING), as well as enhancements to OID tables and the setting of OID values. Within the MIB-II standard several OID groups are defined

SNMPv3 is an extensable SNMPv2 framework with a new message format, ACL and security abilities, and remote configuration of SNMP parameters.

SNMP Proxy agent requires only when network has SNMP V1 and V2 agents. SNMP V1 supports Get, GetNext, Set and trap.
SNMP V2 supports Get, GetBulk, set, trap and Inform. When SNMP V2 Network management Service wants to get data from
SNMP V1 device, it sends GetBulk message to Proxy agent. Proxy agent will translate the GetBulk request to GetNext
request in order to get data from SNMP V1 agent

OID: .1.3.6.1.4.1. (.iso.org.dod.internet.private.enterprises.)

Cisco 9, Microsoft 311

Lay2 vs lay3 switch

http://www.cisco.com/web/about/ac123/ac147/archived_issues/ipj_1-2/switch_evolution.html

SIGBUS vs SIGSEGV

The difference between the two is that :

SEGV – Tends to mean you have attempted to access a segment of memory that does not exist.
BUS – Tends to mean you have attempted to access a segment of memory that does exist but have accessed it in correctly
sometimes certin cpu’s require address to be aligned on certin boundryies eg 8 / 16 / 32 / 64 bit address

Based on experience from many years ago (and not having access to source code and the time) I learned that SIGSEGV tended to mean that you either dereferenced a NULL pointer which would mean you are trying to access a non-existant segment or that you generated and were trying to use an address which was pointing into the “text” segment.

In contrast SIGBUS basically meant that you were trying to use an address which was illegal (i.e. outside the ability of the manhine to address).

http://blogs.sun.com/peteh/entry/sigbus_versus_sigsegv_according_to

Candidate UNIX qualifying questions.  Candidate
preparation.

Ø Is your current system more BSD or System IV based
and why?

Ø How do you boot into single user mode?

Ø What are the options for the shutdown command?

Ø What is the su du command used for?

Ø What is a super block? http://images.google.com/imgres?imgurl=http://web.syr.edu/~nshenvi/summaryUnix_files/image003.gif&imgrefurl=http://web.syr.edu/~nshenvi/summaryUnix.htm&h=445&w=581&sz=22&hl=en&start=11&um=1&tbnid=Z9U7GxRrnK_VCM:&tbnh=103&tbnw=134&prev=/images%3Fq%3Dinode%2BSuperBlock%26svnum%3D10%26um%3D1%26hl%3Den%26sa%3DG state of the file system, size of file system , where to find space, how many files  

Ø What command do you use to access the Super Block? fsck 

Ø What is the difference between a symbolic and hard
link? When would you use each?

Ø What directory holds file with the sticky bit and
when is it used?
/tmp 
Ø What command do you use to change file ownership and
privileges?
chown , chgrp

Ø What is another name for the kill command?

Ø What is the default value if you put no options on
the kill command?

Ø What is the letter equivalent of the -9 and -15
options? -9: KILL -15 TERM -1 HUP

Ø What are the nice and renice commands used for?

Ø What are the 7 fields in the /etc/passwd file? (on 1
line)

Ø What command do you use to create a device? What are
the 2 numbers associated with it?

Ø What are the termcap and terminfo commands used for?

Ø What is /etc/remote file used for?

Ø What command or tool do you use to format a disk?
fdisk 
Ø How do you create a mount point for a disk
partition?

Ø How do you create a file system on a new disk?

Ø Why wouldn't you use default options on mkfs?

Ø What it the lost+found directory and where does it
live?

Ø Name 3 tape mediums for backup

Ø What is a level 0 backup?  Level 1?  Level 2?

Ø Where is the backup info kept?

Ø Other than dump, name 2 other backup commands.

Ø What is SYSLOG? How does it work?

Ø What is a loadable kernel module?

Ø What is the difference between a classful and
classless IP address?

On the other hand, the use of an IP Address with a subnet mask other than the default results in the standard Host bits (the Bits used to indentify the HOST ID) being divided in to two parts: a Subnet ID and Host ID. These type of IP Addresses are called Classless IP Addresses.

http://www.firewall.cx/ip-subnetting-mask-effect.php

Ø What is the difference between the ARP and Reverse
ARP commands?

Ø What is a subnet mask?
Ø What is a default router? Where is used?

Ø What protocol does ping use?

Ø What is the difference between a hub, a switch, and
a router?

Ø What is the difference between DNS lookup and
reverse DNS lookup?

Ø What is PPP?

Ø Do you use USENET?  What version of Sendmail?

Ø Name 3 deamons on a UNIX system.

Ø What deamon is the system master deamon?

Ø What is the portmap deamon?

Ø What is the difference between x-server and
x-client?

Network engineer interview questions

Dikumpulin dari beberapa website, mungkin aja pertanyaan2 dibawah ini keluar pada interview network engineer.

OSPF

  • Describe OSPF in your own words.
  • OSPF areas, the purpose of having each of them
  • Types of OSPF LSA, the purpose of each LSA type
  • What exact LSA type you can see in different areas
  • How OSPF establishes neighboor relation, what the stages are
  • If OSPF router is stucked in each stage what the problem is and how to troubleshoot it
  • OSPF hierarchy in the single or multi areas. Cool OSPF behavior in broadcast and nonbroadcast
  • Draw the diagram of typical OSPF network and explain generally how it works, DR, BDR, election, ASBR, ABR, route redistribution and summarization

STP

  • How it works and the purpose
  • Diff types (SSTP, MSTP, RSTP) Cisco – PVST/PVST+
  • root election
  • Diff. port stages and timing for convergence
  • Draw the typical diagram and explain how diff types of STP work
  • What ports are blocking or forwarding
  • How it works if there are topology changes

ACLs

  • What are they
  • Diff types
  • Write an example if you want to allow and to deny…
  • Well-known port numbers (DNS – 53 and etc…)

QOS

  • What is that
  • What is the diff b/w L2 and L3 QoS
  • How it works

Network:

  • Draw the typical network diagram you have to deal with
  • explain how it works
  • What part of it you are responsible
  • firewall, what is that, how it works, how it is diff from ACLs
  • What problems with the network you had had and how you solved it.
  • What are the ways to troubleshoot the network, techniques, commands
  • network security, ways to achieve it

Switching:

  • VLANs
  • STP
  • How a L2 switch works with broadcast, unicast, multicast, known/unknown traffic
  • VRRP, GLBP
  • port monitoring and mirroring
  • L3 switch, how it works
  • PIM sparse and dense modes
  1. User(s) are complaining of delays when using the network. What would you do?
  2. What are some of the problems associated with operating a switched LAN?
  3. Name some of the ways of combining TCP/IP traffic and SNA traffic over the same link.
  4. What sort of cabling is suitable for Fast Ethernet protocols?
  5. What is a Class D IP address?
  6. Why do I sometimes lose a server’s address when using more than one server?
  7. What is Firewall?
  8. How do I monitor the activity of sockets?
  9. How would I put my socket in non-blocking mode?
  10. What are RAW sockets?
  11. What is the role of TCP protocol and IP protocol.
  12. What is UDP?
  13. How can I make my server a daemon?
  14. How should I choose a port number for my server?
  15. Layers in TCP/IP
  16. How can I be sure that a UDP message is received?
  17. How to get IP header of a UDP message
  18. Writing UDP/SOCK_DGRAM applications
  19. How many bytes in an IPX network address?
  20. What is the difference between MUTEX and Semaphore?
  21. What is priority inversion?
  22. Different Solutions to dining philosophers problem.
  23. What is a message queue?
  24. Questions on Shared Memory.
  25. What is DHCP?
  26. Working of ping, telnet, gopher.
  27. Can I connect two computers to internet using same line ?
  1. Explain how traceroute, ping, and tcpdump work and what they are used for?
  2. Describe a case where you have used these tools to troubleshoot.
  3. What is the last major networking problem you troubleshot and solved on your own in the last year?
  4. What LAN analyzer tools are you familiar with and describe how you use them to troubleshoot and on what media and network types.
  5. Explain the contents of a routing table (default route, next hop, etc.)
  6. What routing protocols have you configured?
  7. Describe the commands to set up a route.
  8. What routing problems have you troubleshot?
  9. How do you display a routing table on a Cisco? On a host?
  10. How do you use a routing table and for what?
  11. What is a route flap?
  12. What is a metric?
  13. When do you use BGP, IGRP, OSPF, Static Routes?
  14. What do you see as current networking security issues (e.g. NFS mounting, spoofing, one time passwords, etc.)?
  15. Describe a routing filter and what it does.
  16. Describe an access list and what it does.
  17. What is a network management system?
  18. Describe how SNMP works.
  19. Describe the working environment you are currently in, e.g. frequent interruptions, frequent priority shifting, team or individual.
  20. What do you use to write documentation? Editor? Mail reader?
  21. What platform (s) do you currently work on at your desk?
  22. How do you manage multiple concurrent high level projects?
  23. Describe a recent short term stressful situation and how you managed it.
  24. How do you manage a long term demanding stressful work environment?
  25. Have you worked in an assignment based environment, e.g. work request/trouble ticket system, and if so, describe that environment.
  26. Describe what network statistics or measurement tools you are familiar with and how you have used them.
  27. Describe what a VPN is and how it works.
  28. Describe how VoIP works.
  29. Describe methods of QoS.
  30. How does ToS bit work?

1. How do you implement a packet filter that distinguishes following cases and selects first case and rejects…

2.What are TP-Lite and TP-Heavy Monitors?

3.List out the benefits obtained by using the Client/Server oriented TP MonitorsClient/Server applications…

4.What are the main components of Transaction-based Systems?

5.What is a TP Monitor?

6.What is the difference between an unspecified passive open and a fully specified passive open?

7.Explain the function of Transmission Control Block?

8.What is a Management Information Base (MIB)?

9.What is anonymous FTP and why would you use it?

10.What is a pseudo tty?

11.What is REX?

12.What does the Mount protocol do?

13.What is the difference between interior and exterior neighbor gateways?

14.What are the advantages and disadvantages of the three types of routing tables?

15.What is a TCP connection table?

16.What is source route?

17.What is Proxy ARP?

18.What is a Multi-homed Host?

19.What is NVT (Network Virtual Terminal)?

20.What is Gateway-to-Gateway protocol?

Latest Questions in Networking Interview Questions

1.what is the difference between packet switched, cell switched and circuit switched technology?

2.how can we configure mail-server in win2003ADS

3.What is Frame Relay?

4.difference b/w subnetmask and default gateway

5.I have been called up for the tech interview on next week for the post of Network Engineer. Help me out…

6.What is difference between TCP/IP and UDP?

7.Encryption operation performed at what layer1.presentation layer2.physical layer3.transport layer

presentation

8.If you have 3 pc’s with static IP’s and there is one PC workstation that has FTP going through a router…

9.What are the network monitoring tools? Like what tools do you use to monitor network connections?

10.In tcp/ip udp is connection less , why?

	       	Systems Programmer Questionnaire	Rev. 3/30/99

1. What is the difference between .xinitrc and .xsession?

2. What is the difference between a gateway and a router?

3. Describe your experience with Microsoft Windows registry?

4. How many SCSI devices can be connected to a workstation with one single
   channel SCSI-2 controller?

5. Name the basic data types in PERL.

6. What must a text file begin with to be recognized as postscript code?

7. What does the UNIX gutinteg command do?

8.  What files, ownerships and permissions must be set for rsh to work without
    a password?

9.  How do you calculate the total number of blocks or sectors available on
    a disk?

10. If a SCSI hard drive was formatted on a SUN workstation and no data has
    yet been written to it, what needs to be do to use it on a non -SUN Linux
    system?

11. Describe an SNMP application you have developed.

12. Describe the procedure for permanently modifying the initialization string
    on a modem connected to a Cisco termianl server.

13. In what subdirectory is the X windows hardware configuration file
    XF86Config found on a system configured with Linux?

14. Describe some of the software project management tools you have used.

15. What is the path to the shutdown command on a DEC Alpha running OS/F?

16. Name the seven most important tools a System Administrator uses?

17. Describe methods you have used to assure completion of projects on
    schedule. 

18. How would you set up cron entries for a non-priviledged account?

19. What is the path to the sendmail configuration file?

20. How would you remove all the core files on a filesystem.
i think you can search core**
21. What is the difference between Cnews and INN?

22. Briefly describe the sequence of events when printing a file under BSD..

23. What do the options 2755 mean to chmod? -rwx r-s r-x

24. What is RAID level 5? Level 0?

25. Describe the steps, tools and procedures you have used in project
    management.

26. Describe the most complex client/server anomaly you have encountered and
    how you solved it.

27. Describe your experience in forecasting server load and equipment
    replacement.

28. What were your considerations in specifying a PC hardware standard?

             Unix Administrator Technical Interview Questions
              ================================================

Please answer as many questions as correctly as you can within a 1 hour
time-limit.  Answers valid for the Solaris or FreeBSD operating systems are
preferred but not required, be sure to specify on which operating system
your answer is valid.

1) What is the first line of defense in system security?

2) What should be used to maintain the /etc/shadow file?

3) What is the default shell for the "root" logonid?  What other shells
are acceptable for this logonid?

4) What is the function of the kernel?

5) Using the Bourne shell syntax, show the command that sets the PATH
environment variable to look in /usr/bin first, /usr/local/bin second,
and the current directory last.

6) Show the command to search for any files or directories with question
marks in their names.

7) Which of the following commands redirects output to a file?

	rd somefile > test
	cat somefile > test
	cat somefile >> test
	cat somefile | test

8) You are using "vi" to edit a file with multiple pages.  Which command
will take you down one page the fastest?

9) What command do you use to quit "vi" without saving changes? q!

10) Which command do you use to display a directory listing of files,
including the file type?

11) What is the command to display on-line help for a unix command? man

12) To display a list of all manual pages containing the keyword "date", what
command would you type?

man -k keyword apropos   13) What command will display the first 10 lines of a file called "junk"? head

14) What file will tell you where system log files are being written (if any)? /etc/syslog.conf

15) What command diplays a full listing of processes, including headers?

16) How do you terminate a process? kill -9    : KILL kill -15   : TERM kill -3    : quit   

17) Using symbolic mode, add group write permissions to the file "junk".
	Do the same using octal mode.

18) In the following, where does the output for standard error go?

	/usr/lib/sendmail -OQueueSortOrder=host -oQ/var/spool/mqueue-8h \
				-q >> /var/adm/log/mqueue-8h 2>&1

19) What is the command to check the available free disk space on all local
filesystems?  Which operating environment does the syntax used apply to?

20) You have need to configure a new network client and have been given the IP
128.194.49.48 in the 128.194.48.0/23 subnet.  You configure the machine
with that IP and set the default router as you were told but are not
getting packets or response to pings.  What is probably wrong?

21) Describe the X Window system client/server model.

22) Please list and describe 2 or more authentication mechanisms when displaying
X applications on remote displays.  Which one is "better" in terms of
security?

23) You added a line to /etc/aliases, but it doesn't seem to be working.  Why?

24) You commented out a server in inetd.conf, but it's still active. Why?

25) What's a process? What's an inode? Describe the difference between a
symlink and a hard link.

26) Name as many shells as you can.

27) How do you plan to document changes to this environment?

28) You have a problem and you don't know how to solve it.  Name all the
resources you can think of that you might consult.

29) What have you done recently that you particularly liked, or are proud of?

30) I have a file named 'dash fr' (-fr); how do I get rid of it?

# rm ./-thefile   31) Why did I just ask that question?

32) What's the difference between a library function and system call?

33) The command to see who is on the system is:

  who
  what
  why
  where   who

34) Which commercial UNIX platform dominated the computer industry?

  FreeBSD
  Microsoft McUnix
  Solaris
  HP-UX
  Linux

35) In which file is the default router address kept?

  /etc/resolv.conf    DNS
  /etc/nsswitch.conf  passwd/group in nis
  /etc/hosts
  /etc/defaultrouter

36) The first field field in an /etc/passwd entry is:

  The uid
  The name
  The gid
  The home directory.   uipd 

37) According to POSIX.2, which of the following tests to see if file foo
exists and is readable?

  test -f foo
  test -r foo
  test -w foo
  test -x foo     -f

38) According to POSIX.2, which option tells sort to compare the keys in a
case-insensitive manner?

  -c
  -f
  -i
  -v

39) The renice command may alter the priority of:

  A single process
  All process in a process group
  All processes owned by a user
  All of the above  <---

40) To setup a master/slave NIS system such that the slave takes over lookup
requests when the master crashes:

  run ypserv on the master; ypbind on the slave
  run ypserv,ypbind on the master; ypset on the slave
  run ypserv,ypbind on the master; ypserv,ypbind on the slave
  run ypserv on the master; ypserv -s on the slave

41) You boot a client machine and attempt to mount an NFS drive from the
server.  The NFS mount worked yesterday, and neither the server nor its NFS
export list has been modified since then.  The mount command just hangs.
Where do you look for the problem?

42) Acceptable levels of bad nfs calls fall under what percentages?

  10-15%
  1-2%
  45-55%
  anything under 90%

43) When debugging a core in gdb, what does the command "bt" give?

  the core memory
  heap usage
  the calling stack

44) Please describe the complete boot process for a Unix system (your choice,
but preferably Sun if known).  Start at the moment the power switch is
turned on.

45) What is the main negative aspect of telnet/rshell/rlogin with respect to
security?  Please list 2 or more mechanisms of overcoming that aspect.

46) How many devices can be attached to a SCSI/SCSI-2 bus?  A "wide" SCSI bus?

47) A user performed a "cd;chmod 644 ." before logging out.  What problem
occurs when they log in the next time, and what level of priviledge is
required to correct the problem?

48) Please describe the path and types of programs that handle an e-mail message
starting from when a system receives the first packet of information until
the recipient reads it.

49) A customer has created a web page and complains that attempts to view
it result in "forbidden" messages.  What is the main problem?  Directory
listing is as follows:

# ls -al
total 240
drwxr-xr-x   2 joeuser   other        8192 Apr 19 17:54 .
drwx------  57 joeuser   other        8192 Apr 16 14:13 ..
-rw-------   1 joeuser   other        6311 Apr 19 17:50 back.xbm
-rw-------   1 joeuser   other        9650 Apr 19 17:50 daemon.gif
-rw-------   1 joeuser   other       11230 Apr 19 17:50 ferret.jpg
-rw-------   1 joeuser   other       11925 Apr 19 17:50 giraffe.gif
-rw-------   1 joeuser   other       32760 Apr 19 17:50 help.gif
-rw-r--r--   1 joeuser   other         967 Apr 19 17:46 index.html
-rw-------   1 joeuser   other        3871 Apr 19 17:50 kewl.jpg
-rw-------   1 joeuser   other        9018 Apr 19 17:50 luser.jpg
-rw-------   1 joeuser   other        2143 Apr 19 17:50 news.gif
-rw-------   1 joeuser   other        9055 Apr 19 17:50 noms.gif
-rw-------   1 joeuser   other        3071 Apr 19 17:50 race.gif
-rw-------   1 joeuser   other        3301 Apr 19 17:50 sailbot.jpg
-rw-------   1 joeuser   other       10511 Apr 19 17:50 tamu.gif
-rw-------   1 joeuser   other       19696 Apr 19 17:50 tsip.jpg
-rw-------   1 joeuser   other        6376 Apr 19 17:50 unix.gif
-rw-------   1 joeuser   other        2267 Apr 19 17:50 xray.gif
-rw-------   1 joeuser   other        3858 Apr 19 17:50 zoom.jpg

50) What happens when you issue the following commands (as root):

	# kill -1 1

	# kill -1 -1

	# init 0

	# sync

	# rm /dev/console

webservice, soap, wsdl,uddi

soap tutorial:

http://www.w3schools.com/webservices/ws_summary.asp

http://www.soapuser.com/basics1.html

soap faq:

http://www.soapuser.com/faq.html

http://www.soaprpc.com/faq.html#q12

ou may be curious about the distinction I make between marshaling and serialization, having seen the terms used interchangeably. I distinguish between them because with Web services different standards define the rules for the two processes. SOAP defines the rules for marshaling and encoding data into XML messages, but doesn’t specify how data is actually serialized across the interface. SOAP can bind to any protocol (usually either HTTP or Simple Mail Transport Protocol [SMTP]) for serialization, which means the specifications for those protocols actually define the serialization rules.

http://webservices.sys-con.com/read/39901.htm

RPC vs Document

Section 5 encoding vs Literal encoding

In reality, the choices are between what combo of Style and Use to implement:

RPC/ENCODING -non conforming.

RPC/LITERAL -conforming

DOCUMENT/LITERAL.-conforming

excellent explaining: http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/

http://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?topic=/com.ibm.wbit.help.ui.doc/topics/rwsdlstyle.html

http://www.ibm.com/developerworks/webservices/library/ws-soapenc/

DOCUMENT: in WSDL, part tag is <part … element= ../>, SOAP message has no operation name;

RPC: in WSDL, part tag is <part … type= ../>, SOAP message has operation name;

Encoded: SOAP message includes data type;

Literal: SOAP message doesn’t include data type; Under any literal style, the href attribute is not available

The fighters have STYLE:

  • RPC Style
    • The RPC style specifies that the <soap:body> contains an element with the name of the Web method being invoked. This element in turn contains an entry for each parameter and the return value of this method.
  • Document Style
    • The message parts appear directly under the <soap:body> element. There are no SOAP formatting rules for what the <soap:body> contains. The server application is responsible for mapping the server objects (parameters, method calls, and so forth) and the values of the XML documents.
What they are USEing:
  • Encoding
    • Each message part references an abstract type using the type attribute defined in Section 5.0. Applications using SOAP encoding are focused on remote procedure calls and will likely use the RPC message style.
  • Literal

o Each part references a concrete schema definition using either the element or type attribute; in other words, data is serialized according to a given schema.

<wsdl:binding name=“…” type=”tns:…”>

<soap:binding style=“rpc“ …>

<wsdl:operation name=“Add”>

<wsdl:input name=“Add”>

<soap:body namespace=”operationNS” use=”literal“/>

</wsdl:input>

</wsdl:operation>

</wsdl:binding>

http://blogs.msdn.com/beatsch/archive/2004/08/13/214124.aspx

http://www.eherenow.com/soapfight.htm

http://searchsoa.techtarget.com/ateQuestionNResponse/0,289625,sid26_cid494324_tax289201,00.html

Best practices of SOAP : http://java.sun.com/developer/technicalArticles/xml/jaxrpcpatterns/#1

November 12, 2007

Algorithm

Filed under: Uncategorized — manoftoday @ 7:05 pm

 

BFS and FDS

Background

There’re 2 ways to traverse a tree, “Breadth-First Search (BFS)” and “Depth-First Search (DFS).” The following are their strategies.(Both of them begins from the root.)

BFS
  1. Traverse the node.
  2. Expand the node (if it has at least one child) and put its children (in the same level) into a queue respectively (leftest child first).
  3. If the queue is NOT empty, take out the first element from the queue and go to 1. Go to 4 if empty.
  4. End the process.

 

DFS
  1. Traverse the node.
  2. Expand the node (if it has at least one child) and push its children (in the same level) into a stack respectively (leftest child first). <— i think rightest child first is better and clearer
  3. If the stack is NOT empty, pop the top element from the stack and go to 1. Go to 4 if empty.
  4. End the process.

The binary search tree (BST) holds some `nice’ properties (it will be mentioned in your Data Structure course). Now, I just tell you its definition.

BST
  • It’s a binary tree. and its node holds one of these properties.
    1. The node has no children.
    2. The node has either one or two children. The value of all left descendent is smaller than the node, while the value of all right descendent is larger. 

 

Implementation

 DFS

DFS():  non-recursive

Initialize Stack S with root node ROOT;  //if it is graph, it is any beginning node K;

while S.isNotEmpty()

{

node v = S.pop();

 if   v.isVisitedBefore() == false

{

            process(v);

            mark v as visited;

            for all children i of node v // if it is graph, all vertices i adjacent to v

                    push i into Stack S;

}

 
dfs(v) //recursive
{
    if v.isVisitedBefore()
            return;
    process(v)
    mark v as visited
    for all children i of v   //if it is graph, all vertices i adjacent to v 
        dfs(i)
}
 

sorting

http://cs.fit.edu/~wds/classes/algorithms/Sort/sort/sort.html

Quick sort

First, the sequence to be sorted a is partitioned into two parts, such that all elements of the first part b are less than or equal to all elements of the second part c (divide). Then the two parts are sorted separately by recursive application of the same procedure (conquer).

void quicksort (int[] a, int lo, int hi)
{
//  lo is the lower index, hi is the upper index
//  of the region of array a that is to be sorted
    int i=lo, j=hi, h;
    int x=a[(lo+hi)/2];

    //  partition
    do
    {    
        while (a[i]<x) i++; 
        while (a[j]>x) j--;
        if (i<=j)
        {
            swap(i, j);
            i++; j--;
        }
    } while (i<=j);

    //  recursion
    if (lo<j) quicksort(a, lo, j);
    if (i<hi) quicksort(a, i, hi);
}
Average: O(nlogn), Best: O(logn), Worst: O(n2)
It requires log n space for recursion.
 
Merge sort

Similar to Quicksort, the Mergesort algorithm is based on a divide and conquer strategyexplanation. First, the sequence to be sorted is decomposed into two halves (Divide). Each half is sorted independently (Conquer). Then the two sorted halves are merged to a sorted sequence (Combine)

 

void mergesort(int lo, int hi)
{
    if (lo<hi)
    {
        int m=(lo+hi)/2;
        mergesort(lo, m);
        mergesort(m+1, hi);
        merge(lo, m, hi);
    }
}
 
// Straightforward variant
void merge(int lo, int m, int hi)
{
    int i, j, k;

    // copy both halves of a to auxiliary array b
    for (i=lo; i<=hi; i++)
        b[i]=a[i];

    i=lo; j=m+1; k=lo;
    // copy back next-greatest element at each time
    while (i<=m && j<=hi)
        if (b[i]<=b[j])
            a[k++]=b[i++];
        else
            a[k++]=b[j++];

    // copy back remaining elements of first half (if any)
    while (i<=m)
        a[k++]=b[i++];
}
Similar to QuickSort, but requires  O(n) extra space.

Exchange sort:

[[Bubble sort]]=
public void  bubbleSort (Record[] record) {
  for (int i = record.length; i > 1; i--) {
    for (int j = 1; j < i; j++) {
      if (record[j-1].key > record[j].key) { 
        record.swap(j-1, j);
      }
    }
  }
}
Average: O(n2), Best: O(1), Worst: O(n2)

Insertion Sort

 

Let a0, …, an-1 be the sequence to be sorted. At the beginning and after each iteration of the algorithm the sequence consists of two parts: the first part a0, …, ai-1 is already sorted, the second part ai, …, an-1 is still unsorted (i element 0, …, n).

In order to insert element ai into the sorted part, it is compared with ai-1, ai-2 etc. When an element aj with aj<=ai is found, ai is inserted behind it. If no such element is found, then ai is inserted at the beginning of the sequence.

After inserting element ai the length of the sorted part has increased by one. In the next iteration, ai+1 is inserted into the sorted part etc. While at the beginning the sorted part consists of element a0 only, at the end it consists of all elements a0, …, an-1.

nsertion sort is an elementary sorting algorithm. It has a time complexity of Θ(n2), thus being slower than heapsort, merge sort and also shellsort. Insertion sort is well suited for sorting small data sets or for the insertion of new elements into a sorted sequence.

 

private void insertionsort()
    {
        int i, j, t;
        for (i=1; i<n; i++)
        {
            j=i-1;
            value=A[i];
            while (j>0 && A[j]>value)
            {
                A[j+1]=A[j]; //shift right side for one more position
                j--;
            }
            A[j]=value;
        }
    }

sorting by selection

the smallest (largest) item is found and placed first (last), then the next smallest (largest) is selected, and so on.

Straight selection sort

Find the smallest key and transfer it to output (or the first location in the file). Repeat this step with the next smallest key, and continue. 
Notice after i steps, the records from location 0 to i - 1 will be sorted.
 
[[Straight selection sort]]=
public void selectionSort(Record[] record) {
  for (int i = 0; i < record.length; i++) {
    int min = i;
    for (int j = i+1; j < record.length; j++) { 
      if (record[j].key < record[min].key)  min = j;   //find the min value's location
    }
    Swap (record[min], record[i]);
  } 
}

Average: O(n2)

HeapSort

 

That is, a heap is a binary tree which is completely filled at all levels except possibly the last, which is filled from

left to right and the key in each node is larger than (or equal to) the keys of its children.

[Build a heap]=
  buildHeap(Record[] record) {
  for (int k = Math.floor (record.length/2); i > 0; i--) {
    heapify(record, k);
  }
}
[[Heapify from Node k ]]=
public void  heapify (Record[] records, int k) {
  int j = k;
  int left = 2*k;
  int right = 2*k+1;
  if (left <= records.length-1 && records[left].key > records[k].key) {
    j = left;
  }
  if (right <= records.length-1 && records[right].key > records[largest].key) {
    j = right;
  }
  if (largest != k) {
    records.swap(k, j);
    heapify(records, j);
  }
}
Building a heap is O(n).
[[Heapsort]]=
public void  heapSort(Record[] record) {
  int n = record.length;
  buildHeap(record);
  for (int k = n-1; k > 1; k--) {
    record.swap(1, k);  //Exchange the root of the tree with the last element of the tree;
    --record.length;    //Decrement the heap size by one;
    heapify(record, 1); //Heapify from the root of the tree;
  }
  record.length = n;
}
Swapping the root and the last element and decrementing heap size are $ \Omega$(1). Each time we heapify from the root of the tree it will take 
time  O(logK), thus total time is O(nlogK)
 

Shell Sort

The idea of Shellsort is the following:

  1. arrange the data sequence in a two-dimensional array
  2. sort the columns of the array

The effect is that the data sequence is partially sorted. The process above is repeated, but each time with a narrower array, i.e. with a smaller number of columns. In the last step, the array consists of only one column.

 
 

Sorting by Distribution :  counting sort, radix sort, and bucket (or bin) sort

Sorting by Insertion    straight insertion sort, binary insertion, and Shell’s sort

Sorting by selection   straight selection sort, tree sort, and heapsort

Sorting by Exchange bubblesort and  cocktail shaker sort.

 

A sorting technique that guarantees that records with the same primary key occurs in the same order in the sorted list as in the original unsorted list is said to be stable

 

 

You want to check whether a given set of items is sorted or not.Which of the following sorting methods will be the most efficient if it is already in sorted order?
a. Bubble sort b. Selection sort c. Insertion sort d.Merge sort
Ans. c

Dijkstra  Prim Kruskal

The shortest path algorithm gives minimum distance between any two nodes.  Floyd’s algorithm

Dijkstra  : Given a connected graph G=(V,E), a weight d:E->R+ and a fixed vertex s in V, find a shortest path from s to each vertex v in V.  Time complexity:  O(E+VlogV);  Dijkstra  gives Shortest path only between a given source and multiple destinations;

Prim:    Given a connected graph G=(V,E) and a weight d:E->R+, find a minimum spanning tree.   In minimum spanning tree,we get the shortest path between the source and the destination.

Kruskal: Given a connected graph G=(V,E) and a weight d:E->R+, find a minimum spanning tree T.  O(E*logV);

 

Encoding algorithms

Lossless encoding techniques include
i) Run length encoding
ii) Huffman encoding
iii) Transform coding
The correct option is
a. i
b. i and ii
c. all of the above
d. only ii
Ans. b

Greedy algorithms

Greedy algorithms are simple and straightforward. They are shortsighted in their approach in the sense that they take decisions on the basis of information at hand without worrying about the effect these decisions may have in the future. They are easy to invent, easy to implement and most of the time quite efficient. Many problems cannot be solved correctly by greedy approach. Greedy algorithms are used to solve optimization problems

A greedy strategy usually progresses in a top-down fashion, making one greedy choice after another, reducing each problem to a smaller one.

November 11, 2007

IT大哥大总结关于工作与人生

Filed under: Uncategorized — manoftoday @ 9:30 pm

 

【前言】
  我有个有趣的观察,外企公司多的是25-35岁的白领,40岁以上的员工很少,二三十岁的外企员工是意气风发的,但外企公司40岁附近的经理人是很尴尬的。我见过的40岁附近的外企经理人大多在一直跳槽,最后大多跳到民企,比方说,唐骏。外企员工的成功很大程度上是公司的成功,并非个人的成功,西门子的确比国美大,但并不代表西门子中国经理比国美的老板强,甚至可以说差得很远。而进外企的人往往并不能很早理解这一点,把自己的成功90%归功于自己的能力,实际上,外企公司随便换个中国区总经理并不会给业绩带来什么了不起的影响。好了问题来了,当这些经理人40多岁了,他们的薪资要求变得很高,而他们的才能其实又不是那么出众,作为外企公司的老板,你会怎么选择?有的是只要不高薪水的,要出位的精明强干精力冲沛的年轻人,有的是,为什么还要用你?
  从上面这个例子,其实可以看到我们的工作轨迹,二三十岁的时候,生活的压力还比较小,身体还比较好,上面的父母身体还好,下面又没有孩子,不用还房贷,也没有孩子要上大学,当个外企小白领还是很光鲜的,挣得不多也够花了。但是人终归要结婚生子,终归会老,到了40岁,父母老了,要看病要吃药,要有人看护,自己要还房贷,要过基本体面的生活,要养小孩……那个时候需要挣多少钱才够花才重要。所以,看待工作,眼光要放远一点,一时的谁高谁低并不能说明什么。
  从这个角度上来说,我不太赞成过于关注第一份工作的薪水,更没有必要攀比第一份工作的薪水,这在刚刚出校园的学生中间是很常见的。正常人大概要工作35年,这好比是一场马拉松比赛,和真正的马拉松比赛不同的是,这次比赛没有职业选手,每个人都只有一次机会。要知到,有很多人甚至坚持不到终点,大多数人最后是走到终点的,只有少数人是跑过终点的,因此在刚开始的时候,去抢领先的位置并没有太大的意义。刚进社会的时候如果进500强公司,大概能拿到3k-6k/月的工资,有些特别技术的人才可能可以到8k/月,可问题是,5年以后拿多少?估计5k-10k了不起了。起点虽然高,但增幅有限,而且,后面的年轻人追赶的压力越来越大。
  我前两天问我的一个销售,你会的这些东西一个新人2年就都学会了,但新人所要求的薪水却只是你的一半,到时候,你怎么办?
  职业生涯就像一场体育比赛,有初赛、复赛、决赛。初赛的时候大家都刚刚进社会,大多数都是实力一般的人,这时候努力一点认真一点很快就能让人脱颖而出,于是有的人二十多岁做了经理,有的人迟些也终于赢得了初赛,三十多岁成了经理。然后是复赛,能参加复赛的都是赢得初赛的,每个人都有些能耐,在聪明才智上都不成问题,这个时候再想要胜出就不那么容易了,单靠一点点努力和认真还不够,要有很强的坚忍精神,要懂得靠团队的力量,要懂得收服人心,要有长远的眼光……
  看上去赢得复赛并不容易,但,还不是那么难。因为这个世界的规律就是给人一点成功的同时让人骄傲自满,刚刚赢得初赛的人往往不知道自己赢得的仅仅是初赛,有了一点小小的成绩大多数人都会骄傲自满起来,认为自己已经懂得了全部,不需要再努力再学习了,他们会认为之所以不能再进一步已经不是自己的原因了。虽然他们仍然不好对付,但是他们没有耐性,没有容人的度量,更没有清晰长远的目光。就像一只愤怒的斗牛,虽然猛烈,最终是会败的,而赢得复赛的人则象斗牛士一样,不急不躁,跟随着自己的节拍,慢慢耗尽对手的耐心和体力。赢得了复赛以后,大约已经是一位很了不起的职业经理人了,当上了中小公司的总经理,大公司的副总经理,主管着每年几千万乃至几亿的生意。
  最终的决赛来了,说实话我自己都还没有赢得决赛,因此对于决赛的决胜因素也只能凭自己的猜测而已,这个时候的输赢或许就像武侠小说里写得那样,大家都是高手,只能等待对方犯错了,要想轻易击败对手是不可能的,除了使上浑身解数,还需要一点运气和时间。世界的规律依然发挥着作用,赢得复赛的人已经不只是骄傲自满了,他们往往刚愎自用,听不进去别人的话,有些人的脾气变得暴躁,心情变得浮躁,身体变得糟糕,他们最大的敌人就是他们自己,在决赛中要做的只是不被自己击败,等着别人被自己击败。这和体育比赛是一样的,最后高手之间的比赛,就看谁失误少谁就赢得了决赛。
【根源】
  你工作快乐么?你的工作好么?
  有没有觉得干了一段时间以后工作很不开心?有没有觉得自己入错了行?有没有觉得自己没有得到应有的待遇?有没有觉得工作像一团乱麻每天上班都是一种痛苦?有没有很想换个工作?有没有觉得其实现在的公司并没有当初想象得那么好?有没有觉得这份工作是当初因为生存压力而找的,实在不适合自己?你从工作中得到你想要得到的了么?你每天开心么?
  天涯上愤怒的人很多,你有没有想过,你为什么不快乐?你为什么愤怒?
  其实,你不快乐的根源,是因为你不知道要什么!你不知道要什么,所以你不知道去追求什么,你不知道追求什么,所以你什么也得不到。
  我总觉得,职业生涯首先要关注的是自己,自己想要什么?大多数人大概没想过这个问题,唯一的想法只是——我想要一份工作,我想要一份不错的薪水,我知道所有人对于薪水的渴望,可是,你想每隔几年重来一次找工作的过程么?你想每年都在这种对于工作和薪水的焦急不安中度过么?不想的话,就好好想清楚。饮鸩止渴,不能因为口渴就拼命喝毒药。越是焦急,越是觉得自己需要一份工作,越饥不择食,越想不清楚,越容易失败,你的经历越来越差,下一份工作的人看着你的简历就皱眉头。于是你越喝越渴,越渴越喝,陷入恶性循环。最终只能哀叹世事不公或者生不逢时,只能到天涯上来发泄一把,在失败者的共鸣当中寻求一点心理平衡罢了。大多数人都有生存压力,我也是,有生存压力就会有很多焦虑,积极的人会从焦虑中得到动力,而消极的人则会因为焦虑而迷失方向。所有人都必须在压力下做出选择,这就是世道,你喜欢也罢不喜欢也罢。
  一般我们处理的事情分为重要的事情和紧急的事情,如果不做重要的事情就会常常去做紧急的事情。比如锻炼身体保持健康是重要的事情,而看病则是紧急的事情。如果不锻炼身体保持健康,就会常常为了病痛烦恼。又比如防火是重要的事情,而救火是紧急的事情,如果不注意防火,就要常常救火。找工作也是如此,想好自己究竟要什么是重要的事情,找工作是紧急的事情,如果不想好,就会常常要找工作。往往紧急的事情给人的压力比较大,迫使人们去赶紧做,相对来说重要的事情反而没有那么大的压力,大多数人做事情都是以压力为导向的,压力之下,总觉得非要先做紧急的事情,结果就是永远到处救火,永远没有停歇的时候。(很多人的工作也像是救火队一样忙碌痛苦,也是因为工作中没有做好重要的事情。)那些说自己活在水深火热为了生存顾不上那么多的朋友,今天找工作困难是当初你们没有做重要的事情,是结果不是原因。如果今天你们还是因为急于要找一份工作而不去思考,那么或许将来要继续承受痛苦找工作的结果。
  我始终觉得我要说的话题,沉重了点,需要很多思考,远比唐笑打武警的话题来的枯燥乏味,但是,天下没有轻松的成功,成功,要付代价。请先忘记一切的生存压力,想想这辈子你最想要的是什么?所以,最要紧的事情,先想好自己想要什么。
【什么是好工作】
  当初微软有个唐骏,很多大学里的年轻人觉得这才是他们向往的职业生涯,我在清华bbs里发的帖子被这些学子们所不屑,那个时候学生们只想出国或者去外企,不过如今看来,我还是对的,唐骏去了盛大,陈天桥创立的盛大,一家民营公司。一个高学历的海归在500强的公司里拿高薪水,这大约是很多年轻人的梦想,问题是,每年毕业的大学生都在做这个梦,好的职位却只有500个。
  人都是要面子的,也是喜欢攀比的,即使在工作上也喜欢攀比,不管那是不是自己想要的。大家认为外企公司很好,可是好在哪里呢?好吧,他们在比较好的写字楼,这是你想要的么?他们出差住比较好的酒店,这是你想要的么?别人会羡慕一份外企公司的工作,这是你想要的么?那一切都是给别人看的,你干吗要活得那么辛苦给别人看?另一方面,他们薪水福利一般,并没有特别了不起,他们的晋升机会比较少,很难做到很高阶的主管,他们虽然厌恶常常加班,却不敢不加班,因为“你不干有得是人干”,大部分情况下会找个台湾人香港人新加坡人来管你,而这些人又往往有些莫名其妙的优越感。你想清楚了么?500强一定好么?找工作究竟是考虑你想要什么,还是考虑别人想看什么?
  我的大学同学们大多数都到美国了,甚至毕业这么多年了,还有人最近到国外去了。出国真的有那么好么?我的大学同学们,大多数还是在博士、博士后、访问学者地挣扎着,至今只有一个正经在一个美国大学里拿到个正式的教职。国内的教授很难当么?我有几个表亲也去了国外了,他们的父母独自在国内,没有人照顾,有好几次人在家里昏倒都没人知道,出国,真的这么光彩么?就像有人说的“很多事情就像看A片,看的人觉得很爽,做的人未必。”
  人总想找到那个最好的,可是,什么是最好的?你觉得是最好的那个,是因为你的确了解,还是因为别人说他是最好的?即使他对于别人是最好的,对于你也一定是最好的么?
  对于自己想要什么,自己要最清楚,别人的意见并不是那么重要。很多人总是常常被别人的意见所影响,亲戚的意见,朋友的意见,同事的意见……问题是,你究竟是要过谁的一生?人的一生不是父母一生的续集,也不是儿女一生的前传,更不是朋友一生的外篇,只有你自己对自己的一生负责,别人无法也负不起这个责任。自己做的决定,至少到最后,自己没什么可后悔。对于大多数正常智力的人来说,所做的决定没有大的对错,无论怎么样的选择,都是可以尝试的。比如你没有考自己上的那个学校,没有入现在这个行业,这辈子就过不下去了?就会很失败?不见得。
  我想,好工作,应该是适合你的工作,具体点说,应该是能给你带来你想要的东西的工作,你或许应该以此来衡量你的工作究竟好不好,而不是拿公司的大小,规模,外企还是国企,是不是有名,是不是上市公司来衡量。小公司,未必不是好公司,赚钱多的工作,也未必是好工作。你还是要先弄清楚你想要什么,如果你不清楚你想要什么,你就永远也不会找到好工作,因为你永远只看到你得不到的东西,你得到的,都是你不想要的。
  可能,最好的,已经在你的身边,只是,你还没有学会珍惜。人们总是盯着得不到的东西,而忽视了那些已经得到的东西。
【普通人】
  我发现中国人的励志和国外的励志存在非常大的不同,中国的励志比较鼓励人立下大志愿,卧薪尝胆,有朝一日成富成贵。而国外的励志比较鼓励人勇敢面对现实生活,面对普通人的困境,虽然结果也是成富成贵,但起点不一样,相对来说,我觉得后者在操作上更现实,而前者则需要用999个失败者来堆砌一个成功者的故事。
  我们都是普通人,普通人的意思就是,概率这件事是很准的。因此,我们不会买彩票中500万,我们不会成为比尔盖茨或者李嘉诚,我们不会坐飞机掉下来,我们当中很少的人会创业成功,我们之中有30%的人会离婚,我们之中大部分人会活过65岁……
  所以请你在想自己要什么的时候,要得“现实”一点,你说我想要做李嘉诚,抱歉,我帮不上你。成为比尔盖茨或者李嘉诚这种人,是靠命的,看我写的这篇文章绝对不会让你成为他们,即使你成为了他们,也绝对不是我这篇文章的功劳。“王侯将相宁有种乎”但真正当皇帝的只有一个人,王侯将相,人也不多。目标定得高些对于喜欢挑战的人来说有好处,但对于大多数普通人来说,反而比较容易灰心沮丧,很容易就放弃了。
  回过头来说,李嘉诚比你有钱大致50万倍,他比你更快乐么?或许。有没有比你快乐50万倍,一定没有。他比你最多也就快乐一两倍,甚至有可能还不如你快乐。寻找自己想要的东西不是和别人比赛,比谁要得更多更高,比谁的目标更远大。虽然成为李嘉诚这个目标很宏大,但你并不见得会从这个目标以及追求目标的过程当中获得快乐,而且基本上你也做不到。你必须听听你内心的声音,寻找真正能够使你获得快乐的东西,那才是你想要的东西。
  你想要的东西,或者我们把它称之为目标,目标其实并没有高低之分,你不需要因为自己的目标没有别人远大而不好意思,达到自己的目标其实就是成功,成功有大有小,快乐却是一样的。我们追逐成功,其实追逐的是成功带来的快乐,而非成功本身。职业生涯的道路上,我们常常会被攀比的心态蒙住眼睛,忘记了追求的究竟是什么,忘记了是什么能使我们更快乐。
  社会上一夜暴富的新闻很多,这些消息,总会在我们的心里面掀起很多涟漪,涟漪多了就变成惊涛骇浪,心里的惊涛骇浪除了打翻承载你目标的小船,并不会使得你也一夜暴富。“只见贼吃肉,不见贼挨揍。”我们这些普通人既没有当贼的勇气,又缺乏当贼的狠辣绝决,虽然羡慕吃肉,却更害怕挨揍,偶尔看到几个没挨揍的贼就按奈不住,或者心思活动,或者大感不公,真要叫去做贼,却也不敢。
  我还是过普通人的日子,要普通人的快乐,至少,晚上睡得着觉。
【跳槽与积累】
  首先要说明,工作是一件需要理智的事情,所以不要在工作上耍个性,天涯上或许会有人觉得你很有个性而叫好,煤气公司电话公司不会因为觉得你很有个性而免了你的帐单。当你很帅地炒掉了你的老板,当你很酷地挖苦了一番招聘的HR,账单还是要照付,只是你赚钱的时间更少了,除了你自己,没人受损失。
  我并不反对跳槽,但跳槽决不是解决问题的办法,而且频繁跳槽的后果是让人觉得没有忠诚度可言,而且不能安心工作。现在很多人从网上找工作,很多找工作的网站常常给人出些馊主意,要知道他们是盈利性企业,当然要从自身盈利的角度来考虑,大家越是频繁跳槽频繁找工作他们越是生意兴隆,所以鼓动人们跳槽是他们的工作。所以他们会常常告诉你,你拿的薪水少了,你享受的福利待遇差了,又是“薪情快报”又是“赞叹自由奔放的灵魂”。至于是否会因此让你不能安心,你跳了槽是否解决问题,是否更加开心,那个,他们管不着。
  要跳槽肯定是有问题,一般来说问题发生了,躲是躲不开的,很多人跳槽是因为这样或者那样的不开心,如果这种不开心,在现在这个公司不能解决,那么在下一个公司多半也解决不掉。你必须相信,90%的情况下,你所在的公司并没有那么烂,你认为不错的公司也没有那么好。就像围城里说的,“城里的人拼命想冲出来,而城外的人拼命想冲进去。”每个公司都有每个公司的问题,没有问题的公司是不存在的。换个环境你都不知道会碰到什么问题,与其如此,不如就在当下把问题解决掉。很多问题当你真的想要去解决的时候,或许并没有那么难。有的时候你觉得问题无法解决,事实上,那只是“你觉得”。
  人生的曲线应该是曲折向上的,偶尔会遇到低谷但大趋势总归是曲折向上的,而不是象脉冲波一样每每回到起点,我见过不少面试者,30多岁了,四五份工作经历,每次多则3年,少则1年,30多岁的时候回到起点从一个初级职位开始干起,拿基本初级的薪水,和20多岁的年轻人一起竞争,不觉得有点辛苦么?这种日子好过么?
  我非常不赞成在一个行业超过3年以后换行业,基本上,35岁以前我们的生存资本靠打拼,35岁以生存的资本靠的就是积累,这种积累包括人际关系,经验,人脉,口碑……如果常常更换行业,代表几年的积累付之东流,一切从头开始,如果换了两次行业,35岁的时候大概只有5年以下的积累,而一个没有换过行业的人至少有了10年的积累,谁会占优势?工作到2-3年的时候,很多人觉得工作不顺利,好像到了一个瓶颈,心情烦闷,就想辞职,乃至换一个行业,觉得这样所有一切烦恼都可以抛开,会好很多。其实这样做只是让你从头开始,到了时候还是会发生和原来行业一样的困难,熬过去就向上跨了一大步,要知道每个人都会经历这个过程,每个人的职业生涯中都会碰到几个瓶颈,你熬过去了而别人没有熬过去你就领先了。跑长跑的人会知道,开始的时候很轻松,但是很快会有第一次的难受,但过了这一段又能跑很长一段,接下来会碰到第二次的难受,坚持过了以后又能跑一段,如此往复,难受一次比一次厉害,直到坚持不下去了。大多数人第一次就坚持不了了,一些人能坚持到第二次,第三次虽然大家都坚持不住了,可是跑到这里的人也没几个了,这点资本足够你安稳活这一辈子了。
  一份工作到两三年的时候,大部分人都会变成熟手,这个时候往往会陷入不断的重复,有很多人会觉得厌倦,有些人会觉得自己已经搞懂了一切,从而懒得去寻求进步了。很多时候的跳槽是因为觉得失去兴趣了,觉得自己已经完成比赛了。其实这个时候比赛才刚刚开始,工作两三年的人,无论是客户关系,人脉,手下,和领导的关系,在业内的名气……还都是远远不够的,但稍有成绩的人总是会自我感觉良好的,每个人都觉得自己跟客户关系铁得要命,觉得自己在业界的口碑好得很。其实可以肯定地说,一定不是,这个时候,还是要拿出前两年的干劲来,稳扎稳打,积累才刚刚开始。
  你足够了解你的客户吗?你知道他最大的烦恼是什么吗?你足够了解你的老板么?你知道他最大的烦恼是什么吗?你足够了解你的手下么?你知道他最大的烦恼是什么吗?如果你不知道,你凭什么觉得自己已经积累够了?如果你都不了解,你怎么能让他们帮你的忙,做你想让他们做的事情?如果他们不做你想让他们做的事情,你又何来的成功?
【TBC】

 

 

【等待】
  这是个浮躁的人们最不喜欢的话题,本来不想说这个话题,因为会引起太多的争论,而我又无意和人争论这些,但是考虑到对于职业生涯的长久规划,这是一个躲避不了的话题,还是决定写一写,不爱看的请离开吧。
  并不是每次穿红灯都会被汽车撞,并不是每个罪犯都会被抓到,并不是每个错误都会被惩罚,并不是每个贪官都会被枪毙,并不是你的每一份努力都会得到回报,并不是你的每一次坚持都会有人看到,并不是你每一点付出都能得到公正的回报,并不是你的每一个善意都能被理解……这个,就是世道。好吧,世道不够好,可是,你有推翻世道的勇气么?如果没有,你有更好的解决办法么?有很多时候,人需要一点耐心,一点信心。每个人总会轮到几次不公平的事情,而通常,安心等待是最好的办法。
  有很多时候我们需要等待,需要耐得住寂寞,等待属于你的那一刻。周润发等待过,刘德华等待过,周星驰等待过,王菲等待过,张艺谋也等待过…… 看到了他们如今的功成名就的人,你可曾看到当初他们的等待和耐心?你可曾看到金马奖影帝在街边摆地摊?你可曾看到德云社一群人在剧场里给一位观众说相声?你可曾看到周星驰的角色甚至连一句台词都没有?每一个成功者都有一段低沉苦闷的日子,我几乎能想象得出来他们借酒浇愁的样子,我也能想象得出他们为了生存而挣扎的窘迫。在他们一生最中灿烂美好的日子里,他们渴望成功,但却两手空空,一如现在的你。没有人保证他们将来一定会成功,而他们的选择是耐住寂寞。如果当时的他们总念叨着“成功只是属于特权阶级的”,你觉得他们今天会怎样?
  曾经我也不明白有些人为什么并不比我有能力却要坐在我的头上,年纪比我大就一定要当我的领导么?为什么有些烂人不需要努力就能赚钱?为什么刚刚改革开放的时候的人能那么容易赚钱,而轮到我们的时候,什么事情都要正规化了?有一天我突然想,我还在上学的时候他们就在社会里挣扎奋斗了,他们在社会上奋斗积累了十几二十年,我们新人来了,他们有的我都想要,我这不是在要公平,我这是在要抢劫。因为我要得太急,因为我忍不住寂寞。二十多岁的男人,没有钱,没有事业,却有蓬勃的欲望。
  人总是会遇到挫折的,人总是会有低潮的,人总是会有不被人理解的时候的,人总是有要低声下气的时候,这些时候恰恰是人生最关键的时候,因为大家都会碰到挫折,而大多数人过不了这个门槛,你能过,你就成功了。在这样的时刻,我们需要耐心等待,满怀信心地去等待,相信,生活不会放弃你,机会总会来的。至少,你还年轻,你没有坐牢,没有生治不了的病,没有欠还不起的债。比你不幸的人远远多过比你幸运的人,你还怕什么?路要一步步走,虽然到达终点的那一步很激动人心,但大部分的脚步是平凡甚至枯燥的,但没有这些脚步,或者耐不住这些平凡枯燥,你终归是无法迎来最后的那些激动人心。
  逆境,是上帝帮你淘汰竞争者的地方。要知道,你不好受,别人也不好受,你坚持不下去了,别人也一样,千万不要告诉别人你坚持不住了,那只能让别人获得坚持的信心,让竞争者看着你微笑的面孔,失去信心,退出比赛。胜利属于那些有耐心的人。
  在最绝望的时候,我会去看电影《The Pursuit of Happyness》《Jerry Maguire》,让自己重新鼓起勇气,因为,无论什么时候,我们总还是有希望。当所有的人离开的时候,我不失去希望,我不放弃。每天下班坐在车里,我喜欢哼着《隐形的翅膀》看着窗外,我知道,我在静静等待,等待属于我的那一刻。
  原贴里伊吉网友的话我很喜欢,抄录在这里:
    每个人都希望,自己是独一无二的特殊者
    含着金匙出生、投胎到好家庭、工作安排到电力局拿1w月薪这样的小概率事件,当然最好轮到自己
    红军长征两万五、打成右派反革命、胼手胝足牺牲尊严去奋斗,最好留给祖辈父辈和别人
    自然,不是每个吃过苦的人都会得到回报
    但是,任何时代,每一个既得利益者身后,都有他的祖辈父辈奋斗挣扎乃至流血付出生命的身影
    羡慕别人有个好爸爸,没什么不可以
    问题是,你的下一代,会有一个好爸爸吗?
    至于问到为什么不能有同样的赢面概率?我只能问:为什么物种竞争中,人和猴子不能有同样的赢面概率?
    物竞天择。猴子的灵魂不一定比你卑微,但你身后有几十万年的类人猿进化积淀。
【入对行跟对人】
  在中国,大概很少有人是一份职业做到底的,虽然如此,第一份工作还是有些需要注意的地方,有两件事情格外重要,第一件是入行,第二件事情是跟人。第一份工作对人最大的影响就是入行,现代的职业分工已经很细,我们基本上只能在一个行业里成为专家,不可能在多个行业里成为专家。很多案例也证明即使一个人在一个行业非常成功,到另外一个行业,往往完全不是那么回事情,“你想改变世界,还是想卖一辈子汽水?”是乔布斯邀请百事可乐总裁约翰•斯考利加盟苹果时所说的话,结果这位在百事非常成功的约翰,到了苹果表现平平。其实没有哪个行业特别好,也没有哪个行业特别差,或许有报道说哪个行业的平均薪资比较高,但是他们没说的是,那个行业的平均压力也比较大。看上去很美的行业一旦进入才发现很多地方其实并不那么完美,只是外人看不见。
  说实话,我自己都没有发大财,所以我的建议只是让人快乐工作的建议,不是如何发大财的建议,我们只讨论一般普通打工者的情况。我认为选择什么行业并没有太大关系,看问题不能只看眼前。比如,从前年开始,国家开始整顿医疗行业,很多医药公司开不下去,很多医药行业的销售开始转行。其实医药行业的不景气是针对所有公司的,并非针对一家公司,大家的日子都不好过,这个时候跑掉是非常不划算的,大多数正规的医药公司即使不做新生意撑个两三年总是能撑的,大多数医药销售靠工资撑个两三年也是可以撑的,国家不可能永远捏着医药行业不放的,两三年以后光景总归还会好起来的,那个时候别人都跑了而你没跑,那时的日子应该会好过很多。有的时候觉得自己这个行业不行了,问题是,再不行的行业,做得人少了也变成了好行业,当大家都觉得不好的时候,往往却是最好的时候。大家都觉得金融行业好,金融行业门槛高不说,有多少人削尖脑袋要钻进去,竞争激励,进去以后还要时时提防,一个疏忽,就被后来的人给挤掉了,压力巨大,又如何谈得上快乐?也就未必是“好”工作了。
  太阳能这个东西至今还不能进入实际应用的阶段,但是中国已经有7家和太阳能有关的公司在纽交所上市了,国美苏宁永乐其实是贸易型企业,也能上市,鲁泰纺织连续10年利润增长超过50%,卖茶的一茶一座,卖衣服的海澜之家都能上市……其实选什么行业真的不重要,关键是怎么做。事情都是人做出来的,关键是人。
  有一点是需要记住的,这个世界上,有史以来直到我们能够预见得到的未来,成功的人总是少数,有钱的人总是少数,大多数人是一般的,普通的,不太成功的。因此,大多数人的做法和看法,往往都不是距离成功最近的做法和看法。因此大多数人说好的东西不见得好,大多数人说不好的东西不见得不好。大多数人都去炒股的时候说明跌只是时间问题,大家越是热情高涨的时候,跌的日子越近。大多数人买房子的时候,房价不会涨,而房价涨的差不多的时候,大多数人才开始买房子。不会有这样一件事情让大家都变成功,发了财,历史上不曾有过,将来也不会发生。有些东西即使一时运气好得到了,还是会在别的时候别的地方失去的。
  年轻人在职业生涯的刚开始,尤其要注意的是,要做对的事情,不要让自己今后几十年的人生总是提心吊胆,更不值得为了一份工作赔上自己的青春年华。我的公司是个不行贿的公司,以前很多人不理解,甚至自己的员工也不理解,不过如今,我们是同行中最大的企业,客户乐意和我们打交道,尤其是在国家打击腐败的时候,每个人都知道我们做生意不给钱的名声,都敢于和我们做生意。而勇于给钱的公司,不是倒了,就是跑了,要不就是每天睡不好觉,人还是要看长远一点。很多时候,看起来最近的路,其实是最远的路,看起来最远的路,其实是最近的路。
  跟对人是说,入行后要跟个好领导好老师,刚进社会的人做事情往往没有经验,需要有人言传身教。对于一个人的发展来说,一个好领导是非常重要的。所谓“好”的标准,不是他让你少干活多拿钱,而是以下三个。
  首先,好领导要有宽广的心胸,如果一个领导每天都会发脾气,那几乎可以肯定他不是个心胸宽广的人,能发脾气的时候却不发脾气的领导,多半是非常厉害的领导。中国人当领导最大的毛病是容忍不了能力比自己强的人,所以常常可以看到的一个现象是,领导很有能力,手下一群庸才或者手下一群闲人。如果看到这样的环境,还是不要去的好。
  其次,领导要愿意从下属的角度来思考问题,这一点其实是从面试的时候就能发现的,如果这位领导总是从自己的角度来考虑问题,几乎不听你说什么,这就危险了。从下属的角度来考虑问题并不代表同意下属的说法,但他必须了解下属的立场,下属为什么要这么想,然后他才有办法说服你,只关心自己怎么想的领导往往难以获得下属的信服。
  第三,领导敢于承担责任,如果出了问题就把责任往下推,有了功劳就往自己身上揽,这样的领导不跟也罢。选择领导,要选择关键时刻能抗得住的领导,能够为下属的错误买单的领导,因为这是他作为领导的责任。
  有可能,你碰不到好领导,因为,中国的领导往往是屁股决定脑袋的领导,因为他坐领导的位置,所以他的话就比较有道理,这是传统观念官本位的误区,可能有大量的这种无知无能的领导,只是,这对于你其实是好事,如果将来有一天你要超过他,你希望他比较聪明还是比较笨?相对来说这样的领导其实不难搞定,只是你要把自己的身段放下来而已。多认识一些人,多和比自己强的人打交道,同样能找到好的老师,不要和一群同样郁闷的人一起控诉社会,控诉老板,这帮不上你,只会让你更消极。和那些比你强的人打交道,看他们是怎么想的,怎么做的,学习他们,然后跟更强的人打交道。
【选择】
  我们每天做的最多的事情,其实是选择,因此在谈职业生涯的时候不得不提到这个话题。
  我始终认为,在很大的范围内,我们究竟会成为一个什么样的人,决定权在我们自己,每天我们都在做各种各样的选择,我可以不去写这篇文章,去别人的帖子拍拍砖头,也可以写下这些文字,帮助别人的同时也整理自己的思路,我可以多注意下格式让别人易于阅读,也可以写成一堆,我可以就这样发上来,也可以在发以前再看几遍,你可以选择不刮胡子就去面试,也可以选择出门前照照镜子……每天,每一刻我们都在做这样那样的决定,我们可以漫不经心,也可以多花些心思,成千上万的小选择累计起来,就决定了最终我们是个什么样的人。
  从某种意义上来说我们的未来不是别人给的,是我们自己选择的,很多人会说我命苦啊,没得选择阿,如果你认为“去微软还是去IBM”“上清华还是上北大”“当销售副总还是当厂长”这种才叫选择的话,的确你没有什么选择,大多数人都没有什么选择。但每天你都可以选择是否为客户服务更周到一些,是否对同事更耐心一些,是否把工作做得更细致一些,是否把情况了解得更清楚一些,是否把不清楚的问题再弄清楚一些……你也可以选择在是否在痛苦中继续坚持,是否抛弃掉自己的那些负面的想法,是否原谅一个人的错误,是否相信我在这里写下的这些话,是否不要再犯同样的错误……生活每天都在给你选择的机会,每天都在给你改变自己人生的机会,你可以选择赖在地上撒泼打滚,也可以选择咬牙站起来。你永远都有选择。有些选择不是立杆见影的,需要累积,比如农民可以选择自己常常去浇地,也可以选择让老天去浇地,诚然你今天浇水下去苗不见得今天马上就长出来,但常常浇水,大部分苗终究会长出来的,如果你不浇,收成一定很糟糕。
  每天生活都在给你机会,他不会给你一叠现金也不会拱手送你个好工作,但实际上,他还是在给你机会。我的家庭是一个普通的家庭,没有任何了不起的社会关系,我的父亲在大学毕业以后就被分配到了边疆,那个小县城只有一条马路,他们那一代人其实比我们更有理由抱怨,他们什么也没得到,年轻的时候文化大革命,书都没得读,支援边疆插队落户,等到老了,却要给年轻人机会了。他有足够的理由象成千上万那样的青年一样坐在那里抱怨生不逢时,怨气冲天。然而在分配到边疆的十年之后,国家恢复招研究生,他考回了原来的学校。研究生毕业,他被分配到了安徽一家小单位里,又是3年以后,国家第一届招收博士生,他又考回了原来的学校,成为中国第一代博士,那时的他比现在的我年纪还大。生活并没有放弃他,他也没有放弃生活。10年的等待,他做了他自己的选择,他没有放弃,他没有破罐子破摔,所以时机到来的时候,他改变了自己的人生。你最终会成为什么样的人,就决定在你的每个小小的选择之间。
  你选择相信什么?你选择和谁交朋友?你选择做什么?你选择怎么做?……我们面临太多的选择,而这些选择当中,意识形态层面的选择又远比客观条件的选择来得重要得多,比如选择做什么产品其实并不那么重要,而选择怎么做才重要。选择用什么人并不重要,而选择怎么带这些人才重要。大多数时候选择客观条件并不要紧,大多数关于客观条件的选择并没有对错之分,要紧的是选择怎么做。一个大学生毕业了,他要去微软也好,他要卖猪肉也好,他要创业也好,他要做游戏代练也好,只要不犯法,不害人,都没有什么关系,要紧的是,选择了以后,怎么把事情做好。
  除了这些,你还可以选择时间和环境,比如,你可以选择把这辈子最大的困难放在最有体力最有精力的时候,也可以走一步看一步,等到了40岁再说,只是到了40多岁,那正是一辈子最脆弱的时候,上有老下有小,如果在那个时候碰上了职业危机,实在是一件很苦恼的事情。与其如此不如在20多岁30多岁的时候吃点苦,好让自己脆弱的时候活得从容一些。你可以选择在温室里成长,也可以选择到野外磨砺,你可以选择在办公室吹冷气的工作,也可以选择40度的酷热下,去见你的客户,只是,这一切最终会累积起来,引导你到你应得的未来。
  我不敢说所有的事情你都有得选择,但是绝大部分事情你有选择,只是往往你不把这当作一种选择。认真对待每一次选择,才会有比较好的未来。
【TBC】

 

 

【选择职业】
  职业的选择,总的来说,无非就是销售、市场、客服、物流、行政、人事、财务、技术、管理几个大类,有个有趣的现象就是,500强的CEO当中最多的是销售出身,第二多的人是财务出身,这两者加起来大概超过95%。现代IT行业也有技术出身成为老板的,但实际上,后来他们还是从事了很多销售和市场的工作,并且表现出色,公司才获得了成功,完全靠技术能力成为公司老板的,几乎没有。这是有原因的,因为销售就是一门跟人打交道的学问,而管理其实也是跟人打交道的学问,这两者之中有很多相通的东西,他们的共同目标就是“让别人去做某件特定的事情。”而财务则是从数字的层面了解生意的本质,从宏观上看待生意的本质,对于一个生意是否挣钱,是否可以正常运作有着最深刻的认识。
  公司小的时候是销售主导公司,而公司大的时候是财务主导公司,销售的局限性在于只看人情不看数字,财务的局限性在于只看数字不看人情。公司初期,运营成本低,有订单就活得下去,跟客户也没有什么谈判的条件,别人肯给生意做已经谢天谢地了,这个时候订单压倒一切,客户的要求压倒一切,所以当然要顾人情。公司大了以后,一切都要规范化,免得因为不规范引起一些不必要的风险,同时运营成本也变高,必须提高利润率,把有限的资金放到最有产出的地方。对于上市公司来说,股东才不管你客户是不是最近出国,最近是不是那个省又在搞严打,到了时候就要把业绩拿出来,拿不出来就抛股票,这个时候就是数字压倒一切。
  前两天听到有人说一句话觉得很有道理,开始的时候我们想“能做什么?”,等到公司做大了有规模了,我们想“不能做什么。”很多人在工作中觉得为什么领导这么保守,这也不行那也不行,错过很多机会。很多时候是因为,你还年轻,你想的是“能做什么”,而作为公司领导要考虑的方面很多,他比较关心 “不能做什么”。
  我并非鼓吹大家都去做销售或者财务,究竟选择什么样的职业,和你究竟要选择什么样的人生有关系,有些人就喜欢下班按时回家,看看书听听音乐,那也挺好,但就不适合找个销售的工作了,否则会是折磨自己。有些人就喜欢出风头,喜欢成为一群人的中心,如果选择做财务工作,大概也干不久,因为一般老板不喜欢财务太积极,也不喜欢财务话太多。先想好自己要过怎样的人生,再决定要找什么样的职业。有很多的不快乐,其实是源自不满足,而不满足,很多时候是源自于心不定,而心不定则是因为不清楚究竟自己要什么,不清楚要什么的结果就是什么都想要,结果什么都没得到。
  我想,我们还是因为生活而工作,不是因为工作而生活,生活是最要紧的,工作只是生活中的一部分。我总是觉得生活的各方方面都是相互影响的,如果生活本身一团乱麻,工作也不会顺利。所以要有娱乐、要有社交、要锻炼身体,要有和睦的家庭……最要紧的,要开心,我的两个销售找我聊天,一肚子苦水,我问他们,2年以前,你什么都没有,工资不高,没有客户关系,没有业绩,处于被开的边缘,现在的你比那时条件好了很多,为什么现在却更加不开心了?如果你做得越好越不开心,那你为什么还要工作?首先的首先,人还是要让自己高兴起来,让自己心态好起来,这种发自内心的改变会让你更有耐心,更有信心,更有气质,更能包容……否则,看看镜子里的你,你满意么?
  有人会说,你说得容易,我每天加班,不加班老板就会把我炒掉,每天累得要死,哪有时间娱乐、社交、锻炼?那是人们把目标设定太高的缘故,如果你还在动不动就会被老板炒掉的边缘,那么你当然不能设立太高的目标,难道你还想每天去打高尔夫?你没时间去健身房锻炼身体,但是上下班的时候多走几步可以吧,有楼梯的时候走走楼梯不走电梯可以吧?办公的间隙扭扭脖子拉拉肩膀做做俯卧撑可以吧?谁规定锻炼就一定要拿出每天2个小时去健身房?你没时间社交,每月参加郊游一次可以吧,周末去参加个什么音乐班,绘画班之类的可以吧,去尝试认识一些同行,和他们找机会交流交流可以吧?开始的时候总是有些难的,但迈出这一步就会向良性循环的方向发展。而每天工作得很苦闷,剩下的时间用来咀嚼苦闷,只会陷入恶性循环,让生活更加糟糕。
虽然离开惠普仅有十五天,但感觉上惠普已经离我很远。我的心思更多放在规划自己第二阶段的人生,这并非代表我对惠普没有任何眷恋,主要还是想以此驱动自己往前走。
万科王石登珠穆朗玛峰的体验给我很多启发,虽然在出发时携带大量的物资,但是登顶的过程中,必须不断减轻负荷,最终只有一个氧气瓶和他登上峰顶。登山如此,漫长的人生又何尝不是。
我宣布退休后,接到同事朋友同学的祝贺。大部分人都认为我能够在这样的职位上及年龄选择退休,是一种勇气,也是一种福气。
还有一部分人怀疑我只是借此机会换个工作,当然还有一些人说我在HP做不下去了,趁此机会离开。
我多年来已经习惯别人对我的说三道四,但对于好友,我还是挺关心大家是否真正理解我的想法,这也是写这篇文章的目的。
由于受我父亲早逝的影响,我很早就下定决心,要在有生之年实现自己的愿望,我不要像我父亲一样,为家庭生活忙碌一辈子,临终前感伤,懊恼自己有很多没有实现的理想。
一本杂志的文章提到我们在生前就应该思考自己的墓志铭,因为那代表你自己对完美人生的定义,我们应该尽可能在有生之年去实现它。
我希望我的墓志铭上除了与家人及好友有关的内容外,是这样写着:
1.这个人曾经服务于一家全球最大的IT公司(HP)25年,和她一起经历过数次重大的变革,看着她从以电子仪表为主要的业务变革成全球最大的IT公司。
2.这个人曾经在全球发展最快的国家(中国)工作16年,并担任HP中国区总裁7年,见证及经历过中国改革开放的关键 最新突破阶段,与中国一起成长。
3.这个人热爱飞行,曾经是一个有执照的飞行员,累积飞行时数超过X小时,曾经在X个机场起降过。
4. 这个人曾经获得管理硕士学位,在领导管理上特别关注中国企业的组织行为及绩效,并且在这个领域上获得中国企业界的认可。
我费时25年才总结1和2两项成果,我不知还要费时多久才能达成3和4的愿望,特别是第4个愿望需要经历学术的训练,才能将我的经验总结成知识。
否则我的经验将无法有效影响及传授他人。因此重新进入学校学习,拿一个管理学位是有必要的,更何况这是我一个非常重要的愿望。
另一方面,我25年的时间都花在运营(operation) 的领域,兢兢业业的做好职业人士的工作,它是一份好工作,特别是在HP,这份工作也帮助我建立财务的基础,支持家庭的发展。
但是我不想终其一生,都陷入在运营的领域,我想象企业家一样,有机会靠一些点子 (ideas)赚钱,虽然风险很高,但是值得一试,即使失败,也不枉走一回,这也是第4个愿望其中的一部份。
Carly Fiorina 曾经对我说过“这个世界上有好想法的人很多,但有能力去实现的人很少”,2007 年5月21日在北大演讲时,有人问起那些书对我影响较大,我想对我人生观有影响的其中一本书叫“Trigger Point”,它的主要观点是:人生最需要的不是规划,而是在适当的时机掌握机会,采取行动。
我这些愿望在我心中已经酝酿一段很长的时间,开始的时候,也许一年想个一两次,过了也就忘掉,但逐渐的,这个心中的声音,愈来愈大,出现的频率也愈来愈高,当它几乎每一个星期都会来与我对话时,我知道时机已经成熟。
但和任何人一样,要丢掉自己现在所拥有的,所熟悉的环境及稳定的收入,转到一条自己未曾经历过,存在未知风险的道路,需要绝大的勇气,家人的支持和好友的鼓励。有舍才有得,真是知易行难,我很高兴自己终于跨出了第一步。
我要感谢HP的EER提前退休优惠政策,它是其中一个关键的Trigger Points,另一个关键因素是在去年五六月发生的事。
当时我家老大从大学毕业,老二从高中毕业,在他们继续工作及求学前,这是一个黄金时段,让我们全家可以相聚一段较长的时间,我为此很早就计划休一个长假,带着他们到各地游玩。
但这个计划因为工作上一件重要的事情(Mark Hurd 访华)不得不取消。这个事件刺激了我必须严肃的去对待那心中的声音,我会不会继续不断的错失很多关键的机会?
我已经年过50,我会不会走向和我父亲一样的道路?人事部老总Charles跟我说,很多人在所有对他有利的星星都排成一列时,还是错失时机。
我知道原因,因为割舍及改变对人是多么的困难,我相信大部分的人都有自己人生的理想,但我也相信很多人最终只是把这些理想当成是幻想,然后不断的为自己寻找不能实现的藉口,南非前总统曼德拉曾经说过,“与改变世界相比,改变自己更困难”,真是一针见血。
什么是快乐及有意义的人生?我相信每一个人的定义都不一样,对我来说,能实现我墓志铭上的内容就是我的定义。
在中国惠普总裁的位置上固然可以吸引很多的关注及眼球,但是我太太及较亲近的好友,都知道那不是我追求的,那只是为扮演好这个角色必须尽力做好的地方。
做一个没有名片的人士,虽然只有十多天的时间,但我发现我的脑袋里已经空出很多空间及能量,让我可以静心的为我Chapter II的新生活做细致的调研及规划。
我预订以两年的时间来完成转轨的准备工作,并且花多点时间与家人共处。这两年的时间我希望拿到飞行执照,拿到管理有关的硕士学位,提升英文的水平,建立新的网络,多认识不同行业的人,保持与大陆的联系。希望两年后,我可以顺利回到大陆去实现我第四个愿望。
毫不意外,在生活上,我发现很多需要调整的地方。
二十多年来,我生活的步调及节奏,几乎完全被公司及工作所左右,不断涌出的deadline及任务驱动我每天的安排,一旦离开这样的环境,第一个需要调整的就是要依靠自己的自律及意志力来驱动每天的活动,睡觉睡到自然醒的态度绝对不正确,放松自己,不给事情设定目标及时间表,或者对错失时间目标无所谓,也不正确,没有年度,季度,月及周计划也不正确。
担任高层经理多年,已经养成交待事情的习惯,自己的时间主要花在思考,决策及追踪项目的进展情况,更多是依靠一个庞大的团队来执行具体的事项及秘书来处理很多协调及繁琐的事情。
到美国后,很多事情需要打800号电话联系,但这些电话很忙,常让你在waiting line上等待很长的时间,当我在等待时,我可以体会以前秘书工作辛苦的地方,但同时也提醒我自己,在这个阶段要改变态度,培养更大的耐性及自己动手做的能力。
生活的内容也要做出很大的调整,多出时间锻炼身体,多出时间关注家人,多出时间关注朋友,多出时间体验不同的休闲活动及飞行,一步步的,希望生活逐步调整到我所期望的轨道上,期待这两年的生活既充实又充满乐趣及意义。
第一个快乐的体验就是准备及参加大儿子的订婚礼,那种全心投入,不需担忧工作数字的感觉真好。同时我也租好了公寓,买好了家具及车子,陪家人在周末的时候到Reno 及Lake Tahoe玩了一趟,Lake Tahoe我去了多次,但这次的体验有所不同,我从心里欣赏到它的美丽。
但同时我也在加紧调研的工作,为申请大学及飞行学校做准备,这段时间也和在硅谷的朋友及一些风险投资公司见面,了解不同的产业。
我的人生观是“完美的演出来自充分的准备”,“勇于改变自己,适应不断变化的环境,机会将不断出现”,“快乐及有意义的人生来自于实现自己心中的愿望,而非外在的掌声”。
我离开时,有两位好朋友送给我两个不同的祝语,Baron的是“多年功过化烟尘”,杨华的是“莫春者,风乎舞雩,咏而归”,它们分别代表了我离开惠普及走向未来的心情。
我总结人生有三个阶段,一个阶段是为现实找一份工作,一个阶段是为现实,但可以选择一份自己愿意投入的工作,一个阶段是为理想去做一些事情。
我珍惜我的福气,感激HP及同事、好朋友给我的支持,鼓励及协助,这篇文字化我心声的文章与好友分享。
振耀

Source: 海归论坛 :: 阅读主题 – 【吐血奉送正经人生道理帖】IT大哥大总结关于工作与人生 【上】

如何在国内购买A股基金, edition III

Filed under: Uncategorized — manoftoday @ 12:01 am

 

股市有风险,入市须谨慎!
对国内的individual stocks说老实话不太了解。但个人认为国内股市还有的涨。我在去年年底写第一版的时候说1000点到2000点这才刚刚开了一个头,现在到了4600+,不算低了,但也不像有些人说的那样bubbly,很多factors都point to a higher market.不细说了。因为体系制度还不完善,大户相对于散户还是有很大优势,所以基金很容易跑赢大盘,跑赢散户,所以我从来没碰过国内的individual stocks. 今年国内基金截至7/26/2007,大多已经翻番,而散户挣钱的据说不到30%,meaning 30% of people have return > 0%, 而return超过100%的不知道一百个人里面能挑出几个。另外,到7/26/2007,大盘收在5/29的高点,而不少基金已经超过5/29好几个百分点了。另外,和美国不同,国内股票,基金的capital gain是不缴税的。投资中国也是回国发展的一种方式。有可能我今天说完明天股市就大跌,大家别骂我,也别笑我,我写这篇文章的目的不是要预测股市的涨跌。
国内大多数基金可以在基金发行公司的网站上开户购买(叫做直销),申/认购费大多有折扣,一般是四折,0.6%, 最好挑一些赎回费用几年后降至0的。这里是各大基金网站:
http://info.cmbchina.com/cmb2005stock/investaspxbin/fund/fundCompanyWebSites.aspx?title=JJGSWZYLB
这里是非网上直销收费一览表:
http://info.cmbchina.com/cmb2005stock/investaspxbin/fund/fundCompare.aspx?lm=jjbj&&channel=JJFLBJ
搜狐新浪财经版都有很多信息,morningstar的中文网站更系统化一些, 和美国的morningstar一样,有各基金的星级评价,排名,详细信息,fund selector等。
www.cn.morningstar.com
还有招行的:
http://info.cmbchina.com/fund
认购是指购买新发行的基金,一般一元每份, 申购是指购买老基金. 网上买基金需要有国内各大银行的银联卡, 建行的最好用,直接从账户里划钱走,很方便,不收手续费。广发的也不错,买易方达的基金只要0.3%的申购费. 但因为money market fund都没有fee, 所以可以先用建行卡买易方达的money market fund, 然后再转成其他基金,只收0.3%的转换费, 和用广发卡一样. 有些基金用兴业的方便,和银联有关系,不用另外申请银联账户,但转账要收费, 5000收2元,5000以上收3元。。。由建行和兴业的卡一般就可以买百分之九十以上的基金了. 易方达的申购费0.3%是最便宜的,嘉实沪深300的管理费最便宜,只要0.5%. 你也可以到各大银行去买或在银行的网站上交易(叫银行代销),比如说招行的银基通. 但要pay full 1.5% 申购费,招商银行的系统做的是最好的。并不一定要迷信新基金或是低净值,高分红的基金,最好把分红方式设成分红再投资,不然分的红再买成基金还要再付一次申购费。
在各大基金网站上开户非常方便, follow instructions就行了. 我开第二个账户只花了五分钟不到. (在公司上网较快,特别是今年年初海底光缆故障的时候,公司有VPN的可以连到亚洲的服务器,奇快无比)。有的基金公司一定要留手机号码或email,会给你发短消息,trade confirmation, 还会定期收到paper statements, 和美国一样. 从来没收到过unsolicited calls or emails.
回国如果没有身份证,可以用护照开户。如果你在美国,让国内的亲朋替你在建行开个账户,办一张一卡通,理论上开户要本人,可以让别人用复印件代办看行不行,我听说有这么办成的。 I’m sure there are ways around it, if you know somebody. 如果信得过的话,用别人的账户也行。跟teller说要开通网上银行for基金直销,他一般会给你一张龙卡,一个密码,你就可以在网上set up account,会让你下载一个证书,follow instructions 就可以了。如果你图方便,不介意1.5%的申购费, 想在一家银行统一操作的话,最好用招商银行。开户之后可以直接从你在美国的银行账户wire美元过去(receiving money 不收费,Citibank wiring money online up to $50000的手续费是$30, fidelity $15, Washington Mutual 不收费,但要show up in person.在WAMU 一般美东时间周一上午汇款,国内周二下午钱就到帐) 再兑换成人民币操作,很快很方便。最好别用Western Union。招行的卡买直销基金不方便,很少有基金用招行的卡,最好的是建行的, 但招行向同城别的银行划款,每笔只要两元手续费。我都是把钱wire到招行,结汇,再汇到建行或兴业银行,都可以在网上操作。好像只有招行可以网上换汇,至少一两年前是这样。顺便说一句, 如果你在国内开户有困难, 可以在美国买MSCI China A Share Fund, 这是一个ETF, symbol是CAF, track MSCI China A Share index. 记住要limit order 因为spread比较大。
推荐几个:
上投摩根中国优势:my all time favorite, best among the best, 申购费只打六折, 0.9%,but it’s well worth the extra 0.3%
www.51fund.com
易方达策略成长,易方达价值精选,great company, great records, 申购费只要0.3%,赎回费用两年后降至0.
www.efunds.com.cn
嘉实沪深300, 指数基金,track 沪深300指数,管理费只要0.5%/per year, compared with 1.75% for most other funds.
www.jsfund.cn
华安中国A股,指数基金,track MSCI China A Share Index, 申购费0.6%,赎回费0% anytime.这个Index在美国有个ETF, traded under symbol CAF.
www.huaan.com.cn
广发小盘,Best mid-small cap stock fund, good diversification.
www.gffunds.com.cn
以上基金除华安A股外,两至三年后赎回费用均降至0%。
先写这么多,想起来再补充。
股市有风险,入市须谨慎!

Source: 另类回国发展–如何在国内购买A股基金, edition III – 文学城: 热点论坛 web.wenxuecity.com

November 10, 2007

How to find a good lawyer

Filed under: Uncategorized — manoftoday @ 11:57 pm

 

1. Evaluate a Lawyer with Exclusive Peer Review Ratings™ System on Martindale.com®

 

1. General Ethical Standards Rating
The General Ethical Standards Rating denotes adherence to professional standards of conduct and ethics, reliability, diligence and other criteria relevant to the discharge of professional responsibilities.

The General Recommendation Rating is:
V – Very High

A lawyer must receive a General Ethical Standards Rating before his or her review can proceed to the next step.

2. Legal Ability Ratings
Legal Ability Ratings take into consideration the standard of professional ability in the area where the lawyer practices, the lawyer’s expertise, and other professional qualifications. If a lawyer’s practice is limited or specialized, Peer Review Ratings are based on performance in those specific fields of law.

Legal Ability Ratings are:
C – Good to High
B – High to Very High
A – Very High to Preeminent

When both categories of Peer Review Ratings are confirmed, a lawyer receives an CV, BV or AV Rating.

If a lawyer moves to a different state, his or her rating will appear in Martindale-Hubbell with the state abbreviation indicating that it was established in another state or province.

Source: Evaluate a Lawyer with Exclusive Peer Review Ratings™ System on Martindale.com®

http://www.allbusiness.com/3913310-1.html

 

2. Check similar cases from PACER

Join the Pacer. It is very important to join the Pacer even if you are filing through an attorney. Go to http://pacer.psc.uscourts.gov/ ,After you get your login id and password from the Pacers, go to this site
http://dockets.justia.com/ to find similar cases.

http://boards.immigrationportal.com/showthread.php?t=194681&page=727&pp=15

 

 

3. Check lawyer ‘s current status on state BAR website

4. Legal Records  or Lawyers.com

http://legalrecords.findlaw.com/ss/namesearch_index.jsp?ch=LP

http://www.lawyers.com/

5. Search on internet for any negative or good recommendation of the lawyer

6. Groups and Forums

alt.lawyers http://groups.google.com/group/alt.lawyers/topics?hl=en&gvc=2

alt.support.divorce http://groups.google.com/group/alt.support.divorce/topics?hl=en

misc.immigration.usa http://groups.google.com/group/misc.immigration.usa/topics?hl=en

7. Top 10 Mistakes Made When Hiring a Lawyer

http://www.allbusiness.com/legal/law-firms-attorneys/3982-1.html

(ZT)金融资本家在行动

Filed under: Uncategorized — manoftoday @ 7:08 am

 

制造金融恐怖是金融资本家快速扩张的一道豪华大餐。而制造股市的暴跌是资本家的搞
金融恐怖主意的拿手好戏!历史一遍又一遍的重复:1907年金融巨头JP摩根制造公立纽
约银行的谣言,导致灾提,促使美国建立了拥有发行货币的私人机构,美联储。从此美
联储开始操从美国股市:1929年美股的大暴跌,国际资本家整垮了美国的16000家地方
性银行,从而垄断美国金融;1987年美国股市大跌,导致金融资本家用新发明的股指期
货掠夺了当时最富有的日本,使之进入了长达10多年的萧条。1997年的东南亚金融风暴
同样由美国的大暴跌开始,天才的金融资本家再次发明利用联系汇率和股市做空的对冲
洗劫了亚洲小龙,其后利用全球资本对新兴市场的恐惧,建立了美国Nasdaq的金融泡沫
,2000年纳斯达克的暴跌,金融资本家再次洗劫了全球的美元投资者。
中国的崛起使得国际金融资本开始垂涎于在日益强大的中国身上剪羊毛了。由于中国拥
有庞大的外汇储备和封闭的外汇汇率和金融市场,国际金融资本家根本无法下手,于是
先在中国的美元资本上做文章,不断贬值的美金是美国方面赖账的一个方法。中美的外
汇纷争于是演化成了中国和美国的金融决斗了。中国希望找到一种新的投资方式,以避
免负利率的被动局面。美国则必需要要威慑中国不要放弃美国国债而投资国际股市。中
国的第一步投资黑石就遭到美国政府的打压,显然,如果中国持续减持国债而投资美国
企业,会动摇美元资本家的根本利益,目前美国的意思明显是,你放着6%的年回报不拿
,那你就拿黑石的 -30%吧。第一步的损失没有吓退中国政府,中国政府在美元债券不
断贬值和国内流动性泛滥的情况下,毅然启动了第二步,批量放行QDII,如果中国的
QDII成功,美国的国债就会彻底完蛋了,美国的资本家就得痛苦到骨头。因此,资本家
开始了回招:打压全球股市,用巨额投资亏损恐吓和迫使从国债中撤出资本回到美元债
券上去。
如果周一美股暴跌,将会进一步冲击全球股市,提升美国债券的吸引力。

November 9, 2007

Java Interview Questions

Filed under: Uncategorized — manoftoday @ 1:50 am

http://www.javareference.com/mvnforum/viewthread?thread=705

1. Java says “write once, run anywhere”. What are some ways this isn’t quite true? Any time you use system calls specific to one operating system and do not create alternative calls for another operating system, your program will not function correctly. Solaris systems and Intel systems order the bits of an integer differently. (You may have heard of little endian vs. big endian) If your code uses bit shifting, or other binary operators, they will not work on systems that have opposide endianism.

2. What’s the difference between == and equals method? The typical “gotcha” for most people is in using == to compare two strings when they really should be using the String class’s equals() method. From above, you know that the operator will only return “true” when both of the references refer to the same actual object. But, with strings, most uses want to know whether or not the value of the two strings are the same — since two different String objects may both have the same (or different) values.

3. two types of stream

basically there are 2 types of streams.

byte streams that are used to handle stream of bytes and character streams for handling streams of characters.

in byte streams inputStream/outputStream are the abstract classes at the top of hierarchy,while writer/reader are abstract classes at the top of character streams hierarchy.

4.What class allows you to read objects directly from a stream? The ObjectInputStream class supports the reading of objects from input streams.

5. Can you write Java code for declaration of multiple inheritance in Java ? Class C extends A implements B { }

6. Given two tables Student(SID, Name, Course) and Level(SID, level) write the SQL statement to get the name and SID of the student who are taking course = 3 and at freshman level.

SELECT Student.name, Student.SID

FROM Student, Level

WHERE Student.SID = Level.SID AND Level.Level = “freshman” AND Student.Course = 3;

7. advantagesof OOPL The features of OOPL as inheritance, polymorphism, encapsulation makes it powerful.

8. marker interfaces in java except Serializable.

java.rmi.Remote

java.util.EventListener

An interface having no methods is called as a Marker Interface.

9. instanceof() vs isInstance()

Point pt = new Point(3, 4);

 

System.out.println(“Is pt a String? [using instanceof] ” +

((Object)pt instanceof String));

 

 

try {

System.out.println(

“Is pt a String? [using isInstance()] ” +

(Class.forName(“java.lang.String”).isInstance(pt))); //you need a Class object.

}

catch(Throwable e) {

System.err.println(e);

}

10. Are constructors inherited? Can a subclass call the parent’s class constructor? When? You cannot inherit a constructor. By giving the developer the ability to override a superclasses onstructor you would erode the encapsulation abilities of the language. but you can call the parent’s class constructor. 

11. synchronization

When you synchronize on an object your thread gains exclusive use of that object until synchronization ends or wait is called on the object.Language support for synchronization:

1. Use the synchronized block:

In a method you may: synchronized(object) { code here }

synchronized(SomeClass.class) { code here }

 In the first case access to the instance variables/methods of the class are synchronized.

In the second case access to the static methods/fields are synchronized.

2. Declare the method synchronized:

public synchronized foo() { code here }

public static synchronized foo() { code here }

These two act just like synchronized(this) or synchronized(MyClass.class) (depending if the method is static or not).

In addition the Object class defines the wait, notify, notifyAll, and sleep methods. To execute any of these methods the object must be in a synchronized block (this can be in a calling method). The compiler will not check this, a runtime error will be thrown if this is not the case. The wait method temporaly releases the lock on the object. The notify/notifyAll method allows a previously waiting thread to continue to execute.

Also when executing the static block of a class: public class Foo { static { code here } } A special lock is placed on the class, this lock is different from the synchronized lock, as no other thread may access the class until the static block is done.

12. access control

Public : Any other class from any package can instantiate and execute the classes and methods.

Protected : Only classes inside of the package and subclasses can access the classes and methods.

Private : The original class is the only class allowed to execute the methods.

Default : Only classes inside of the package can access the classes and methods.

13. JDBC steps

The standard steps to connecting the database as follows:

try{

      1: Loading the drivers Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

      2:Getting the connection Connection con=DriverManager.getConnection(“jdbc:odbc:datasourcename”,”scott”,”tiger”);

      3:Create the Statement Statement st=con.createStatement();

      4:Execute the Statement ResultSet rs=st.executeQuery(“select * from emp”);

      5:Accessing the data from the backend

                     while(rs.next())

                        System.out.println(rs.getString(1)); System.out.println(rs.getInt(2)); System.out.println(rs.getString(3));

      6:close the connection }catch(SQLException se) { se.printStackTrace(); } finally{ con.close(); rs.close(); st.close(); }

14. java different from c++;

         java : no goto; no destructor;has garbage collection;

         Java has method overloading, but no operator overloading.

        java package;     c++: namespace

15. String abc= “xyz”;

 Important to note that you are NOT calling a java.lang.String constuctor when you type String s = “abc”; For example String x = “abc”; String y = “abc”; refer to the same object. While String x1 = new String(“abc”); String x2 = new String(“abc”); refer to two different objects. 

16. Java Network Programming

 Java supports “low-level” and “high-level” classes.

“Low-level” classes provide support for socket programming: Socket, DatagramSocket, and ServerSocket classes.

“High-level” classes provide “Web programming”: URL, URLEncoder, and URLConnection classes. Networking programming classes ease the programming of network applications, but do not substitute your knowledge of networking. Java networking like anything else in Java is platform-independent.

17.  unreachable object becomes reachable. An unreachable object may become reachable again. This can happen when the object’s finalize() method is invoked and the object performs an operation which causes it to become accessible to reachable objects.

18. modifiers for top class   A top-level class may be public, abstract, or final.

19. default value of boolean The default value of the boolean type is false.

20. Expain the reason for each keyword of public static void main(String args[])?

public- main(..) is the first method called by java environment when a program is executed so it has to accessible from java environment. Hence the access specifier has to be public.

static: Java environment should be able to call this method without creating an instance of the class , so this method must be declared as static.

void: main does not return anything so the return type must be void

The argument String indicates the argument type which is given at the command line and arg is an array for string given during command line.

21. What is the difference between Abstract class and …


1. Abstract Class may contains constructor but interface does not contain constructor.
2.By default, all variables in interfaces are static and final,then we can’t declare method as final.
3.In Interface all methods shuld be public but mot in abstract class.
4.interface supportes multiple inheritance but abstract class does not support.
5.we should initialise variables in interface but not necessory in abstract class.

6.interface has no method implementation.

http://www.geekinterview.com/question_details/546/page1

 

 

 

22. How to track “memory leak” and how to prevent it i…


To reduce possibility of memory leaks, following things should be kept in mind.

Try to avoid long recursive loops in the code. This leads to an OutOfMemoryError.

Avoid collections as static members of a class. If so, carefully manage removals and additions to the Collection. If the collection continues adding members without removing them, it might lead to a leak. Static members persist throughout the life of the program. A static collection will keep references to objects, whether you are using it or not. So the garbage collector might miss collecting the unused contents of the collection.

Avoid populating the HttpSession with too much data. Session persists in the system as long as the user is online, and it might get filled up fast. Additions and removals in the session should be checked.

If you are using AWT/Swing components, call dispose() to kill the windowing component completely.

Check your native code for memory leaks, if you are calling C/C++ code from Java using JNI.

There are other things too, to take care of, but these are the most important ones.

tool: JProbe Memory debugger

Filed under: Uncategorized — manoftoday @ 12:45 am

http://www.techinterviews.in/how-to-answer-23-of-the-most-common-interview-questions/40

Creating FireFox extensions » gHacks tech news

behavior questions.

1. So, tell me a little about yourself.
You don’t need to explain everything from birth to present day. Relevant facts about education, your career and your current life situation are fine.

2. Why are you looking (or why did you leave you last job)?
This should be a straightforward question to answer, but it can trip you up. Presumably you are looking for a new job (or any job) because you want to advance your career and get a position that allows you to grow as a person and an employee. It’s not a good idea to mention money here, it can make you sound mercenary. And if you are in the unfortunate situation of having been downsized, stay positive and be as brief as possible about it. If you were fired, you’ll need a good explanation. But once again, stay positive.

3. Tell me what you know about this company.
Do your homework before you go to any interview. Whether it’s being the VP of marketing or the mailroom clerk, you should know about the company or business you’re going to work for. Has this company been in the news lately? Who are the people in the company you should know about? Do the background work, it will make you stand out as someone who comes prepared, and is genuinely interested in the company and the job.

4. Why do you want to work at X Company?
This should be directly related to the last question. Any research you’ve done on the company should have led you to the conclusion that you’d want to work there. After all, you’re at the interview, right? Put some thought into this answer before you have your interview, mention your career goals and highlight forward-thinking goals and career plans.

5. What relevant experience do you have?
Hopefully if you’re applying for this position you have bags of related experience, and if that’s the case you should mention it all. But if you’re switching careers or trying something a little different, your experience may initially not look like it’s matching up. That’s when you need a little honest creativity to match the experiences required with the ones you have. People skills are people skills after all, you just need to show how customer service skills can apply to internal management positions, and so on.

6. If your previous co-workers were here, what would they say about you?
Ok, this is not the time for full disclosure. If some people from your past are going to say you’re a boring A-hole, you don’t need to bring that up. Stay positive, always, and maybe have a few specific quotes in mind. “They’d say I was a hard worker” or even better “John Doe has always said I was the most reliable, creative problem-solver he’d ever met.”

7. Have you done anything to further your experience?
This could include anything from night classes to hobbies and sports. If it’s related, it’s worth mentioning. Obviously anything to do with further education is great, but maybe you’re spending time on a home improvement project to work on skills such as self-sufficiency, time management and motivation.

8. Where else have you applied?
This is a good way to hint that you’re in demand, without sounding like you’re whoring yourself all over town. So, be honest and mention a few other companies but don’t go into detail. The fact that you’re seriously looking and keeping your options open is what the interviewer is driving at.

9. How are you when you’re working under pressure?
Once again, there are a few ways to answer this but they should all be positive. You may work well under pressure, you may thrive under pressure, and you may actually PREFER working under pressure. If you say you crumble like aged blue cheese, this is not going to help you get your foot in the door.

10. What motivates you to do a good job?
The answer to this one is not money, even if it is. You should be motivated by life’s noble pursuits. You want recognition for a job well done. You want to become better at your job. You want to help others or be a leader in your field.

11. What’s your greatest strength?
This is your chance to shine. You’re being asked to explain why you are a great employee, so don’t hold back and stay do stay positive. You could be someone who thrives under pressure, a great motivator, an amazing problem solver or someone with extraordinary attention to detail. If your greatest strength, however, is to drink anyone under the table or get a top score on Mario Kart, keep it to yourself. The interviewer is looking for work-related strengths.

12. What’s your biggest weakness?
If you’re completely honest, you may be kicking yourself in the butt. If you say you don’t have one, you’re obviously lying. This is a horrible question and one that politicians have become masters at answering. They say things like “I’m perhaps too committed to my work and don’t spend enough time with my family.” Oh, there’s a fireable offense. I’ve even heard “I think I’m too good at my job, it can often make people jealous.” Please, let’s keep our feet on the ground. If you’re asked this question, give a small, work-related flaw that you’re working hard to improve. Example: “I’ve been told I occasionally focus on details and miss the bigger picture, so I’ve been spending time laying out the complete project every day to see my overall progress.

13. Let’s talk about salary. What are you looking for?
Run for cover! This is one tricky game to play in an interview. Even if you know the salary range for the job, if you answer first you’re already showing all your cards. You want as much as possible, the employer wants you for as little as you’re willing to take. Before you apply, take a look at salary.com for a good idea of what someone with your specific experience should be paid. You may want to say, “well, that’s something I’ve thought long and hard about and I think someone with my experience should get between X & Y.” Or, you could be sly and say, “right now, I’m more interested in talking more about what the position can offer my career.” That could at least buy you a little time to scope out the situation. But if you do have a specific figure in mind and you are confident that you can get it, I’d say go for it. I have on many occasions, and every time I got very close to that figure (both below and sometimes above).

14. Are you good at working in a team?
Unless you have the I.Q. of a houseplant, you’ll always answer YES to this one. It’s the only answer. How can anyone function inside an organization if they are a loner? You may want to mention what part you like to play in a team though; it’s a great chance to explain that you’re a natural leader.

15. Tell me a suggestion you have made that was implemented.
It’s important here to focus on the word “implemented.” There’s nothing wrong with having a thousand great ideas, but if the only place they live is on your notepad what’s the point? Better still, you need a good ending. If your previous company took your advice and ended up going bankrupt, that’s not such a great example either. Be prepared with a story about an idea of yours that was taken from idea to implementation, and considered successful.

16. Has anything ever irritated you about people you’ve worked with?
Of course, you have a list as long as your arm. But you can’t say that, it shows you as being negative and difficult to work with. The best way to answer this one is to think for a while and then say something like “I’ve always got on just fine with my co-workers actually.

Use this question as a chance to show that you are a team player: “The only people I have trouble with are those who aren’t team players, who just don’t perform, who complain constantly, and who fail to respond to any efforts to motivate them.” The interviewer is expecting a response focused on personality and personal dislikes. Surprise her by delivering an answer that reflects company values

17. Is there anyone you just could not work with?
No. Well, unless you’re talking about murderers, racists, rapists, thieves or other dastardly characters, you can work with anyone. Otherwise you could be flagged as someone who’s picky and difficult if you say, “I can’t work with anyone who’s a Bronco’s fan. Sorry.”

18. Tell me about any issues you’ve had with a previous boss.
Arrgh! If you fall for this one you shouldn’t be hired anyway. The interviewer is testing you to see if you’ll speak badly about your previous supervisor. Simply answer this question with exteme tact, diplomacy and if necessary, a big fat loss of memory. In short, you’ve never had any issues.

The answer to 18 is completely wrong. I am a director at a major media company’s interactive division. Our company is expanding and I am almost in a constant state of hiring. I ask a variation of this question in every single interview and if a candidate has never had one issue or disagreement with anyone, (I stated a variation: I ask if it has happened with anyone in the workplace) I peg them as a liar and reject them immediately.

I went well with my previous boss. If there is an conflict, I will be open mind and talk about facts. once decision is made, I execute it well.

19. Would you rather work for money or job satisfaction?
It’s not a very fair question is it? We’d all love to get paid a Trump-like salary doing a job we love but that’s rare indeed. It’s fine to say money is important, but remember that NOTHING is more important to you than the job. Otherwise, you’re just someone looking for a bigger paycheck.

20. Would you rather be liked or feared?
I have been asked this a lot, in various incarnations. The first time I just drew a blank and said, “I don’t know.” That went over badly, but it was right at the start of my career when I had little to no experience. Since then I’ve realized that my genuine answer is “Neither, I’d rather be respected.” You don’t want to be feared because fear is no way to motivate a team. You may got the job done but at what cost? Similarly, if you’re everyone’s best friend you’ll find it difficult to make tough decisions or hit deadlines. But when you’re respected, you don’t have to be a complete bastard or a lame duck to get the job done.

21. Are you willing to put the interests of X Company ahead of your own?
Again, another nasty question. If you say yes, you’re a corporate whore who doesn’t care about family. If you say no, you’re disloyal to the company. I’m afraid that you’ll probably have to say yes to this one though, because you’re trying to be the perfect employee at this point, and perfect employees don’t cut out early for Jimmy’s baseball game.

it is situational. if you… ; if you …. Ethics and professionalism

 

22. So, explain why I should hire you.
As I’m sure you know, “because I’m great” or “I really need a job” are not good answers here. This is a time to give the employer a laundry list of your greatest talents that just so happen to match the job description. It’s also good to avoid taking potshots at other potential candidates here. Focus on yourself and your talents, not other people’s flaws.

23. Finally, do you have any questions to ask me?
I’ll finish the way I started, with one of the most common questions asked in interviews. This directly relates to the research you’ve done on the company and also gives you a chance to show how eager and prepared you are. You’ll probably want to ask about benefits if they haven’t been covered already. A good generic one is “how soon could I start, if I were offered the job of course.” You may also ask what you’d be working on. Specifically, in the role you’re applying for and how that affects the rest of the company. Always have questions ready, greeting this one with a blank stare is a rotten way to finish your interview. Good luck and happy job hunting.

ponder for a moment, and then ask your interviewer “what aspect of your job do you find most challenging”.

I would ask the interviewer, “Why do you like to work here?”

24. Where do you want to be in 5 to years?

They dont want to hear in the same job you are interviewing for. Ultimately, the HR people are searching for someone who can handle the job now, and has the potential to grow into a high level management job in the future. Do you have those goals too?

24. Would you rather work for a big company or a small one?

Favorite answer: I’d treat any company like it was my own regardless. Total ownership of the situation can get you a long way.

General , the worst answer was “I don’t know.” I’ve since learned that “it depends,” with a couple of examples, is perfectly appropriate.

November 8, 2007

美元贬值下的投资策略-投资人该买什么?

Filed under: Uncategorized — manoftoday @ 12:40 am

(本篇文章由美股财经阔网Quote123.com提供)

今年以来,美元持续走弱,但是包括欧元、澳币、加币等多个国家外币却持续走强,许多投资人开始考虑买进强势货币的区域股票,例如欧元股票,来增加获利率; 也有些投资人想直接投资外汇市场。美股阔网表示,对於大多数人而言,投资外汇市场仍然是一种相对新颖的概念,加上风险高,其实并不适於一般投资大众,反倒 是手续费低廉,又以外汇货币为投资标地的ETF,不但能够帮助投资人赚取汇率升值的优惠,又省却了一堆不必要的管理和手续费用。

很多投资人都已经知道投资ETF(指数型基金)的好处,包括资讯透明、交易较共同基金简便、手续费与股票相同等优点,但是很多投资人可能不知道,利用投资 货币型ETF 也可以达成投资外汇的管道。目前在美股市场中,与外汇货币相关的基金有:十大工业国货币套息交易基金 (DBV)、美元贬值基金 (UDN)、美元升值基金 (UUP)、瑞典克郎基金 (FXS)、墨西哥披索基金 (FXM)、日圆基金(FXY)、瑞士法郎基金 (FXF)、欧元基金 (FXE)、加币基金 (FXC)、英镑基金(FXB)、澳元基金 (FXA)等。

举例来说,加币相对美元的汇率近期上涨至三十年来的最高水准, CurrencyShares Canadian Dollar Trust加币基金(FXC)也在短短三个月当中,从$95上涨至$103美元,涨幅惊人。除此之外,瑞典克郎基金 (FXS)、澳元基金 (FXA)也都是表现亮眼的货币型ETF。很多投资人都认为哪里涨,就该直接去哪开户投资。事实上,如果全部以该国货币做为投资标的,风险是很大的,而分 散风险是投资的第一堂课,加上投资人也无法到各个国家开户,所以当面对美元持续看贬,不妨投资货币型ETF,或是直接投资美元贬值基金 (UDN),换言之,美元贬值UDN就涨,实际上观察UDN近期三个月走势,也上涨了近一成左右,算是已充分反映美元走势。

另一个享受货币升值的方法,则是投资该国家的ETF。如以投资中国A股市场为主的Morgan Stanley China摩根史坦利中国指数型基金(代号CAF),一年内从$25涨到最高$72元,除了代表中国股市的成长之外,也有人民币升值的因素。另外如 iShares MSCI Taiwan 台湾指数基金 (代号EWT),近期除受惠台湾股票大涨外,台币升值也不定期反映其中,股价从今年的$13上涨到$17.25。其它区域ETF包括代表亚洲50股的 (ADRA)、代表拉丁美洲40股(ILF)、投资欧亚澳三洲的(FA)等,都是可以享受到该区域成长和货币升值,但又不用大老远转换投资跑道的优良投资 标的。

相较美股逐渐走高,美元跌幅却愈来愈深,来到近18个月新低位置,可能许多投资人担心投资美股汇差会造成损失。不过多数金融专家表示,美元已大跌一阵,短 中期反扑可以预料。除此,投资人不妨考虑投资货币型ETF,或是投资具前景的新兴亚洲、拉丁美洲及澳洲等,藉由投资当地货币与资产,让投资组合有效防御美 元贬值风险、持续获利的效果。

November 7, 2007

brainstorm

Filed under: Uncategorized — manoftoday @ 3:54 am

1. Exchanging values with xor

Here’s some weird code I ran across once. It uses xor to exchange two values (x and y). Never use it; this is just a curiosity from the museum of bizarre code.

x = x ^ y;
y = x ^ y;
x = x ^ y;
 

2. Multiple a number by 7 without using * and + operator.

NewNum = Num << 3; // mulitplied by 2 ^ 3 = 8

NewNum = NewNum – Num; // 8 – 1 = 7

 

 

3. print integer using only putchar

//

// recursive version

//

void PrintNum ( int Num )

{

if ( Num == 0 )

return;

PrintNum ( Num / 10 );

Puthcar ( ‘0’+ Num % 10 );

}

 

4. Counting set bits in a number.

First version:

int CoutSetBits(int Num)

{

for(int count=0; Num; Num >>= 1)

{

          if (Num & 1)  count++;

}

return count;

}

5. notions

Big O notation is used for Asymptotic(an sem ‘totic) upper bound

θ notation is used for tight bound

Ω notation is used for Asymptotic lower  bound

 

6. Given an array of integers or other numbers (reals, doubles, etc), tell us if any two of the numbers in the array sum up to another given number.

 

There’s an n2 solution in which you compute all the possible pairs of numbers and then add them together to test the termination condition. Obviously, this is less than ideal. However, it is well known that integers can be sorted in O(n) time, where n is the number of integers to sort. Therefore, I proposed this additional precondition:

Allow the list of integers to be sorted in natural order before calling this method

The algorithm then is quite simple: keep an index at the far left side, and the far right side. If the indices become equal, or cross, we’ve failed to find a pair that works. To try to exhaustively find a matching pair, we try adding the numbers at our indices. If the sum too big, we decrement the right index. If the sum is too small, we increment the left index. If the sum is equal to what we’re looking for, we can return true. Pseudocode resembling Java might look like this:

public boolean inArr(int [] arr, int sought) {
  int left = 0;
  int right = arr.length - 1;

  while(left < right) {
    int test = arr[left] + arr[right] - sought;
    if(test > 0) {
      right–;
    } else if(test < 0) {
      left++;
    } else {
      return true;
    }
  }

  return false;
}
good solution
http://blog.kirupa.com/?p=20
 
 

Let’s take some values as an example:

       array = { 1, 12, 10, 4, 5, 7};
       sumvalue = 16;

The array is my list of numbers, and number is the sum I am trying to find two numbers in the array to add up to.

So, I am going to scan through each element in the array and add the value at array[i] to my dictionary (hashtable). The Key is the number at i itself – array[i], and the Value is the difference, sumvalue – array[i]:

This is because the array[i] where i is 0 is 1, and that is our key, but I do check to make sure that the key doesn’t already exist in our hashtable first. Next, the difference between the value we seek and this number is 16 -1 = 15. This number becomes our value. Finally, I check whether the hashtable contains 15 as its key. It doesn’t, so I continue repeating this process of:

  1. Checking if array[i] key exists in our hashtable.
  2. If the key does not exist in our hashtable:
    1. Add the key to the hashtable
    2. The value mapped with this key is the difference between the sumvalue and array[i].
  3. Check if the difference between sumvalue and array[i] exists as a key in our hashtable.
  4. Continue loop if the difference value does not exist as a key.

Notice that all of this is done in linear time – Ɵ(n).

 

Give a one-line C expression to test whether a number is a power of 2. [No loops allowed – it’s a simple test.]

if (x && !(x & (x-1)) == 0)

(a-1) xor a == 0 – What does this do?

a is a power of 2.

How many points are there on the globe where by walking one mile south, one mile east and one mile north you reach the place where you started.

The answer is “many points”. The set of such points is given as {North pole, special circle}.

 

You are given a list of n numbers from 1 to n-1, with one of the numbers repeated. Devise a method to determine which number is repeated.

The sum of the numbers 1 to n-1 is (n)(n-1)/2. Add the numbers on the list, and subtract (n)(n-1)/2. The result is the number that has been repeated.

 

You have 5 jars of pills. Each pill weighs 10 gram, except for contaminated pills contained in one jar, where each pill weighs 9 gm. Given a scale, how could you tell which jar had the contaminated pills in just one measurement?

Take one pill from first, two from second, three from third and so on. Total pills are n(n+1)/2 and should weigh 10n(n+1)/2. If it weighs x gm less than that then the x’th jar is contaminated, since we took x pills from that jar which weighed 1 gm less.

 

 

You have 12 balls. All of them are identical except one, which is either heavier or lighter than the rest – it is either hollow while the rest are solid, or solid while the rest are hollow. You have a simple two-armed scale, and are permitted three weighings. Can you identify the odd ball, and determine whether it is hollow or solid.

Let the balls be numbered 1 to 12. Firstly, put 1-4 on one side and 5-8 on other side. If both are equal then one of 9-12 is odd. Then second try, weigh 9-10 vs 1-2, if equal, one of 11-12 is bad, else 9-10 is bad. Testing which one is bad can be done by (third try) weighing 11 or 9, respectively, with good ball 1. It also gives whether the odd ball is heavy or light.

 

 

Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).

int main()
{
int a[10]={1, 2, 4, 4, 7, 8, 9, 14, 14, 20};
int i;
for (i = 0;i<9;i++)
{
if (a[i] != a[i+1])
printf("%d\n",a[i]);
}
return 0;
}
 

Write an algorithm to detect loop in a linked list.

You are presented with a linked list, which may have a “loop” in it. That is, an element of the linked list may incorrectly point to a previously encountered element, which can cause an infinite loop when traversing the list. Devise an algorithm to detect whether a loop exists in a linked list. How does your answer change if you cannot change the structure of the list elements?

One possible answer is to add a flag to each element of the list. You could then traverse the list, starting at the head and tagging each element as you encounter it. If you ever encountered an element that was already tagged, you would know that you had already visited it and that there existed a loop in the linked list. What if you are not allowed to alter the structure of the elements of the linked list? The following algorithm will find the loop:

  1. Start with two pointers ptr1 and ptr2.
  2. Set ptr1 and ptr2 to the head of the linked list.
  3. Traverse the linked list with ptr1 moving twice as fast as ptr2 (for every two elements that ptr1 advances within the list, advance ptr2 by one element).
  4. Stop when ptr1 reaches the end of the list, or when ptr1 = ptr2.
  5. If ptr1 and ptr2 are ever equal, then there must be a loop in the linked list. If the linked list has no loops, ptr1 should reach the end of the linked list ahead of ptr2.

 

There are 4 men who want to cross a bridge. They all begin on the same side. You have 17 minutes to get all of them across to the other side. It is night. There is one flashlight. A maximum of two people can cross at one time. Any party who crosses, either 1 or 2 people, must have the flashlight with them. The flashlight must be walked back and forth, it cannot be thrown, etc. Each man walks at a different speed. A pair must walk together at the rate of the slower mans pace.

Man 1:1 minute to cross
Man 2: 2 minutes to cross
Man 3: 5 minutes to cross
Man 4: 10 minutes to cross

1 and 2 cross together. 1 comes back. then 3 and 4 cross. 2 comes back. then 1 and 2 cross. Total time is 2+1+10+2+2 = 17.

 

 

给一个matrix of int,每个value的右面的值和下面的值都比它大,在里面search.

 

标准答案如下:
从右上角开始,和你要查找目标作比较。如果比目标小,往下走一格;如果比目标大,
往左走一格。算法复杂度O(m+n)。

 

 

给出一个任意pattern(abc*xyz,*abc,*abc*xyz*)
*代表任意0-N字母
给一个input string,要求写code匹配(不是伪代码)
bool matchPattern(string pattern, string input);

 

bool matchPattern(const char* pattern, const char* input)
{
int match=false;
while(*pattern==’*’ && *pattern!=”)
++pattern;
if(*pattern==”)
return true;
const char* patternStart=pattern;
while(*input!=”)
{
//match from beginning
const char* inputPos=input;
if(!match && *input==*pattern)
{
do
{
match=true;
++pattern;
// updated on 11/09/2007
int wildcard=false;
if(*pattern==’*’)
{
wildcard=true;
while(*pattern==’*’ && *pattern!=”)
++pattern;
}
if(wildcard)
{
while(*input!=” && *input!=*pattern)
++input;
}
else
++input;
}while(*input!=” && *pattern!=” && *input==*pattern);
while(*pattern==’*’ && *pattern!=”)
++pattern;
}
if(match && *pattern==”)
{
return true;
}
pattern=patternStart;
match=false;
input=inputPos+1;
}
return false;
}
int _tmain(int argc, _TCHAR* argv[])
{
cout<<matchPattern(“*”,”*a”)<<endl;
cout<<matchPattern(“a*”,””)<<endl;
cout<<matchPattern(“*a”,”a”)<<endl;
cout<<matchPattern(“*ba*saf*”,”*abasaf”)<<endl;
cout<<matchPattern(“ba*saf**k”,”akbaadwesabawerwrsafaf2321k”)<<endl;
}

 

What new feature would you add to MSWORD if you were hired?

Ability to open .pdf files, Word completion, totally web interface based. To publish MS word docs as blogs on the sites, in one click , support wiki.

 

solution: reverse a string – word by word

problem: reverse “the house is blue”, the answer should be “blue is house the”. the words are reversed, but the letters are still in order (within the word).

solution: solving the initial problem of just reversing a string can either be a huge help or a frustrating hinderance. most likely the first attempt will be to solve it the same way, by swapping letters at the front of the string with letters at the back, and then adding some logic to keep the words in order. this attempt will lead to confusion pretty quickly.

for example, if we start by figuring out that “the” is 3 letters long and then try to put the “t” from “the” where the “l” from “blue” is, we encounter a problem. where do we put the “l” from “blue”? hmm… well we could have also figured out how long “blue” was and that would tell us where to put the “l” at… but the “e” from “blue” needs to go into the space after “the”. argh. its getting quite confusing. in fact, i would be delighted to even see a solution to this problem using this attack method. i don’t think its impossible, but i think it is so complex that it’s not worth pursuing.

here’s a hint. remember before when we just reversed “the house is blue”? what happened?

initial: the house is blue
reverse: eulb si esuoh eht

look at the result for a minute. notice anything? if you still don’t see it, try this.

initial: the house is blue
reverse: eulb si esuoh eht
wanted : blue is house the

the solution can be attained by first reversing the string normally, and then just reversing each word.

 

part I: what is the angle between the minute hand and the hour hand at 3:15 on an analog clock? no, its not 0.

part II: how often does the minute hand pass the hour hand on an analog clock?

answer: part I: 12 hours on the clock make 360 deg. so one hour is 30 deg. the hour hand will be directly on the 3 when the minute hand is at 12 (3:00). after 15 minutes or 1/4 of an hour, the hour hand will be 1/4 * 30 deg = 7.5 deg. away from the minute hand.

part II: if you just think about it, intuitively you’ll see the minute hand passes the hour hand 11 times every 12 hours, so it must pass it every 1 1/11 hours. but this doesn’t make sense to me. i need to prove it.

http://www.techinterview.org/Solutions/fog0000000120.html

November 6, 2007

C++ Questions

Filed under: Uncategorized — manoftoday @ 9:59 pm

1. type  size

#include <climits>

Base type  Minimum size (bits)  Minimum value (signed) Maximum value (signed)     Maximum value (unsigned)

char          8                                       -127(SCHAR_MIN)         127(SCHAR_MAX)                 255(UCHAR_MAX)

short int  16                                     -32,767(SHRT_MIN)       32,767(SHRT_MAX)              65,535(USHRT_MAX)

int             32                                     -2,147,483,647             2,147,483,647(INT_MAX)    4,294,967,295(UINT_MAX)

long         32                                      -2,147,483,647            2,147,483,647(LONG_MAX) 4,294,967,295(ULON_MAX)

If you might need large values (above 32,767 or below -32,767), use long. Otherwise, if space is very important (i.e. if there are large arrays or many structures), use short. Otherwise,use int.

2. difference between reference and pointer

A reference must always refer to some object and, therefore, must always be initialized; pointers do not have such restrictions.

A pointer can be reassigned to point to different objects while a reference always refers to an object with which it was initialized.

3. const

const function :  A member function can only be declared const if it doesn’t modify any of its fields(ie. this object).

const parameter;

const return value;

4. Micro vs inline function

the ordinary function do a lot of activity store the argument into stack,saving register control goes to the function and return value to the calling function ,but in inline function body replace to the calling the function (like as macro expansion). wherever the compiler finds the call for that function it puts the code for that function dere!! the functions are defined as inline when the function is small and is called many times.

it is reqest  to the compiler not a command,compiler may ignore the request if function is so length

5. name space

//Foo.hpp
namespace NS
{
  class Foo
  {
  public:
    void f();
    void g();
  };
}//close NS

//Foo.cpp
#include "Foo.hpp"
void NS::Foo::f()
{ /*..*/ }

void NS::Foo::g()
{ /*..*/ }

//Bar.hpp
namespace NS //Same Name space
{
  class Bar
  {
  public:
    void a();
  };
}
//Bar.cpp 
#include "Bar.hpp"
void NS::Bar::a()
{/*..*/}

void NS::Bar::b()
{/*..*/}
//main.cpp
#include "Bar.hpp"
#include "Foo.hpp"
int main()
{
  using NS::Bar; //a using declaration
  /* using namespace NS; // a using-directive  */
  Bar b;
  NS::Foo f;
  f.f();
  //...
}

6. How the compilers arranges the various sections in the executable image?

the compilers arranges the various sections in the executable image as following :

  • Data Section (uninitialized data variable section, initialized data variable section )
  • Code Section

Remember that all static variables are allocated in the initialized variable section.

7. C++ struct vs C++ class

This is one of the commonly misunderstood aspects of C++. Believe it or not, many programmers think that a C++ struct is just like a C struct, while a C++ class has inheritance, access specifies, member functions, overloaded operators, and so on. Actually, the C++ struct has all the features of the class. The only differences are that a struct defaults to public member access and public base-class inheritance, and a class defaults to the private access specified and private base-class inheritance(it makes all of the public functions of the parent class private in the child class.).

8. malloc/free vs new/delete

Malloc/free do not know about constructors and destructors. New and delete create and destroy objects, while malloc and free allocate and deallocate memory.

9. When is a template a better solution than a base class?

When you are designing a generic class to contain or otherwise manage objects of other types, when the format and behavior of those other types are unimportant to their containment or management, and particularly when those other types are unknown (thus, the generality) to the designer of the container or manager class.

10. default constructor, copy constructor, assignment operator

default constructor is required for Fred x[100]; or Fred abc; or Fred * p = new Fred[100];

class Fred {
public:

Fred(); // Default constructor: can be called with no args
Fred(int i=3, int j=5); // Default constructor: can be called with no args

};

You can NOT within one constructor of a class call another constructor of the same class to initialize. like :

Foo::Foo(char x)
{

Foo(x, 0); // this line does NOT help initialize the this object!!

}

but Java can accomplish this. solution is to have a init() routine that do the common work.

C++ implicitly declares a copy constructor and an assignment operator for every class, struct and union unless the user declared them explicitly.In C++, the implicitly declared assignment operator is a public and inline member function. C++ also guarantees member-wise assignment. The difference between member-wise copying and bitwise copying (such as a memcpy() call) is significant in two cases:

  • copying of subobjects (member-wise copying)

A shallow copy of an object copies all of the member field values. This works well if the fields are values, but may not be what you want for fields that point to dynamically allocated memory. The pointer will be copied. but the memory it points to will not be copied — the field in both the original object and the copy will then point to the same dynamically allocated memory, which is not usually what you want. The default copy constructor and assignment operator make shallow copies.

  • copying of padding bytes (bitwise copying)

A copy constructor will be called only when a new object is being instantiated. The assignment operator is called for an existing object to which a new value is being assigned.

Difference between copy constructor and assignment

  1. There is no need to test to see if it is being initialized from itself.
  2. There is no need to clean up (eg, delete) an existing value (there is none).
  3. A reference to itself is not returned.

When copy constructor is called?

  • A variable is declared which is initialized from another object, eg,
Person q("Mickey"); // constructor is used to build q.
Person r(q);        // copy constructor is used to build r.
Person p = q;       // copy constructor is used to initialize in declaration.
  • A value parameter is initialized from its corresponding argument.
    f(p);               // copy constructor initializes formal value parameter of function f(...)
  • An object is returned by a function.

Don’t write a copy constructor if shallow copies are ok

If the object has no pointers to dynamically allocated memory, a shallow copy is probably sufficient. Therefore the default copy constructor, default assignment operator, and default destructor are ok and you don’t need to write your own.

If you need a copy constructor, you also need a destructor and operator=

If you need a copy constructor, it’s because you need something like a deep copy, or some other management of resources. Thus is is almost certain that you will need a destructor and override the assignment operator.

A a;
A a2=a; //copy constructor call
A a3(a); //copy constructor call
a2=a3; //assignment operator for a2

As you can see, the fact that operator= is used doesn’t necessarily mean that the assignment operator is being called. The difference ere is semantic not syntactic — if the program is instantiating a new object, t’s the copy constructor call. If the object isn’t new, the ssignment expression translates into an assignment operator call.

Sample copy ctor and assignment operator

class Point {
public:
. . .
Point(const Point& p);   // copy constructor
. . .
//=== file Point.cpp ==========================================
. . .
Point::Point(const Point& p) {
x = p.x;
y = p.y;
}

class Person : public Parent
{
    private:
        char* _name;
        int   _id;
    public:
        Person& Person::operator=(const Person& p);
    . . .
}
//--- file Person.cpp
. . .
//=================================================== operator=
Person& Person::operator=(const Person& p) {
    if (this != &p) {  // (1)make sure not same object
        this->Parent::operator=(p);          // call base class's assignment 
        delete [] _name;                     // (2)Delete old name's memory.
        _name = new char[strlen(p._name)+1]; // (3)Get new space
        strcpy(_name, p._name);              // (4)Copy new name
        _id = p._id;                         // (4)Copy id
    }
    return *this;    // (5)Return ref for multiple assignment
}//end operator=

How to prevent object copying operation?

Declare the copy constructor and the assignment operator as private members, without defining them. Any statement that involves direct or indirect  copying of that class will cause a compilation error.

Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?

No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.

11.  operator overloading

Prefix and Postfix

class Number {
public:
Number& operator++ ();
// prefix ++
Number operator++ (int);
// postfix ++ you must *not* make the postfix version return the ‘this’ object by reference;
};

Number& Number::operator++ ()    //Number abc(4); ++abc;
{

return *this;
}
Number Number::operator++ (int)

// Number abc(4); Number xyz = abc++; Number xyz2=abc.operator++(2); NOTE: xyz and xyz2 are the old value of abc
{
Number ans = *this;
++(*this);
// or just call operator++()
return ans;
}

The other option for the postfix version is to return nothing:

void Number::operator++ (int)
{
++(*this);
// or just call operator++()
}

subscriptor

When you have multiple subscripts, the cleanest way to do it is with operator() rather than with operator[]. The reason is that operator[] always takes exactly one parameter, but operator() can take any number of parameters (in the case of a rectangular matrix, two parameters are needed).

class Matrix {
public:
Matrix(unsigned rows, unsigned cols);
double& operator() (unsigned row, unsigned col);
subscript operators often come in pairs, m(5,8) = 106.15;
double operator() (unsigned row, unsigned col) const;
subscript operators often come in pairs,std::cout << m(5,8);

~Matrix();
// Destructor
Matrix(const Matrix& m);
// Copy constructor
Matrix& operator= (const Matrix& m);
// Assignment operator

private:
unsigned rows_, cols_;
double* data_;
};
inline
Matrix::Matrix(unsigned rows, unsigned cols)
: rows_ (rows)
, cols_ (cols)
//data_ <–initialized below (after the ‘if/throw’ statement)
{
if (rows == 0 || cols == 0)
throw BadIndex("Matrix constructor has 0 size");
data_ = new double[rows * cols];
}
inline
Matrix::~Matrix()
{
delete[] data_;
}
inline
double& Matrix::operator() (unsigned row, unsigned col)
{
if (row >= rows_ || col >= cols_)
throw BadIndex("Matrix subscript out of bounds");
return data_[cols_*row + col];
}
inline
double Matrix::operator() (unsigned row, unsigned col) const
{
if (row >= rows_ || col >= cols_)
throw BadIndex("const Matrix subscript out of bounds");
return data_[cols_*row + col];
}

stream overloading

Declare friend functions outside the public and private sections of the header file. Often they are placed first as in the example below.

//=== Point.h file =============================
class Point {
    friend ostream& operator<<(ostream& output, const Point& p);
    friend istream& operator>>(istream& input, Point& p);
    public:
        . . .
    private:
        . . .

ostream& operator<<(ostream& output, const Point& p) {
    output << "(" <<  p.x << ", " << p.y <<")";
    return output;  // for multiple << operators.
}

istream& operator>>(istream& input, Point& p){
      input >> p.x;
      input >> p.y
      return input ;
}
Binary operators
with the operator-assignments (like +=) ,which change the left-hand argument and return a reference
Integer& operator+=(Integer& left,const Integer& right) {
   if(&left == &right) {/* self-assignment */}
   left.i += right.i;
   return left;
}
Return by value as const(my note, not necessary to be perfect, non-constant is fine)
const Integer  operator+(const Integer& left, const Integer& right) {
  return Integer(left.i + right.i);
}

12. static key word

You may wonder why a global variable isn’t used instead. The beauty of a static variable is that it is unavailable outside the scope of the function, so it can’t be inadvertently changed. This localizes errors;

13. handle constructor and destructor fail

for constructor fail, throw an exception;

for destructor, The C++ rule is that you must never throw an exception from a destructor that is being called during the “stack unwinding” process of another exception. instead , Write a message to a log-file.

For example, if someone says throw Foo(), the stack will be unwound so all the stack frames between the throw Foo() and the } catch (Foo e) { will get popped. This is called stack unwinding. During stack unwinding, all the local objects in all those stack frames are destructed. If one of those destructors throws an exception (say it throws a Bar object), the C++ runtime system is in a no-win situation: should it ignore the Bar and end up in the } catch (Foo e) { where it was originally headed? Should it ignore the Foo and look for a } catch (Bar e)

So the C++ language guarantees that it will call terminate() at this point, and terminate() kills the process. Bang you’re dead.

14. Exception

Generally, it’s best to throw objects, The most common practice is to throw a temporary:

#include <stdexcept>
class MyException : public std::runtime_error {
public:
MyException() : std::runtime_error(“MyException”) { }
};
void f()
{
// …
throw MyException();
}

Here, a temporary of type MyException is created and thrown. C++ allows you a variety of options for catching.

  • You can catch by value.
  • You can catch by reference.
  • You can catch by pointer.

Given all this flexibility, how do you decide what to catch? Simple: unless there’s a good reason not to, catch by reference. Avoid catching by value, since that causes a copy to be made and the copy can have different behavior from what was thrown. Only under very special circumstances should you catch by pointer.

What does throw; (without an exception object after the throw keyword) mean? means “re-throw the current exception.”

try {

}
catch (MyException& e) {
e.addInfo(“f() failed”);
throw;
}

the advantage is that we can implement the re-throwing idiom as “exception dispatcher” in common place:

void handleException()
{
try {
throw;
}
catch (MyException& e) {
…code to handle MyException…
}
catch (YourException& e) {
…code to handle YourException…
}
}
void f()
{
try {
…something that might throw…
}
catch (…) {
handleException();
}
}

This idiom allows a single function (handleException()) to be re-used to handle exceptions in a number of other functions.

15. function pointer

http://www.newty.de/fpt/fpt.html

Many compilers have several calling conventions.you can precede __cdecl, __stdcall or __pascal to a function's type to indicate its calling convention (__cdecl is the default). C++ Builder also supports the __fastcall calling convention.


// calling convention,functions and function pointers with different calling convention are incompatible with each other!
void __cdecl DoIt(float a, char b, char c);                             // Borland and Microsoft
void DoIt(float a, char b, char c)  __attribute__((cdecl));     // GNU GCC

define a function pointer and initialize to NULL


int
(*pt2Function)(float, char, char) = NULL;                        // C
int (TMyClass::*pt2Member)(float, char, char) = NULL;                // C++
int (TMyClass::*pt2ConstMember)(float, char, char) const = NULL;     // C++

or

  typedef int (*PT2FUNCTION)(float, char, char);
  PT2FUNCTION pt2Function = NULL;
  typedef int (TMyClass::*PT2MEMBER)(float, char, char);
  PT2MEMBER  pt2Member = NULL;



assign an address to the function pointer
//     Note: Although you may ommit the address operator on most compilers
//     you should always use the correct way in order to write portable code.

// C
int DoIt  (float a, char b, char c){ printf("DoIt\n");   return a+b+c; }
int DoMore(float a, char b, char c)const{ printf("DoMore\n"); return a-b+c; }

pt2Function = DoIt;      // short form
pt2Function = &DoMore;   // assignment using address operator looks better

// C++
class TMyClass
{
public:
   int DoIt(float a, char b, char c){ cout << "TMyClass::DoIt"<< endl; return a+b+c;};
   int DoMore(float a, char b, char c) const
         { cout << "TMyClass::DoMore" << endl; return a-b+c; };

   /* more of TMyClass */
};

pt2ConstMember = &TMyClass::DoMore; // assignment using address operator
pt2Member = &TMyClass::DoIt; // note: <pt2Member> may also legally point to &DoMore
invoke function pointer

// 2.5 calling a function using a function pointer
int result1 = pt2Function    (12, 'a', 'b');          // C short way
int result2 = (*pt2Function) (12, 'a', 'b');          // C

TMyClass instance1;
int result3 = (instance1.*pt2Member)(12, 'a', 'b');   // C++
int result4 = (*this.*pt2Member)(12, 'a', 'b');       // C++ if this-pointer can be used

TMyClass* instance2 = new TMyClass;
int result4 = (instance2->*pt2Member)(12, 'a', 'b');  // C++, instance2 is a pointer
delete instance2;

16. casting

A static_cast is used for all conversions that are well-defined. 
// Forcing a conversion from void* :
  void* vp = &i;
  // Old way produces a dangerous conversion:
  float* fp = (float*)vp;
  // The new way is equally dangerous:
  fp = static_cast<float*>(vp);
// well type cast
  double d = 0.0;
  int x = d; // Automatic type conversion
  x = static_cast<int>(d); // More explicit
If you want to convert from a const to a nonconst or from a volatile to a nonvolatile, you use const_cast.
A reinterpret_cast pretends that an object is just a bit pattern that can be treated (for some dark purpose)
as if it were an entirely different type of object.
A dynamic_cast is for type-safe downcasting
Shape * bp = new Circle();
Circle * cp = dynamic_cast<Circle*>(bp);

17. Array

Array Initialization

An array can be initialized in the declaration by writing a comma-separated list of values enclosed in braces following  an equal sign.

 int days[12] = {31,28,31,30,31,30,31,31,30,31,30,31};

If the size is omitted, the compiler uses the number of values. For example,

int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};

  • If an array has no initialization, the values are undefined.
   float pressure[10];   // Initial values of pressure undefined.
  • Missing initialization values use zero, If an explicit array size is specified, but an shorter initiliazation list is specified, the unspecified elements are set to zero.
   float pressure[10] = {2.101, 2.32, 1.44};

Array pointer

   int abc[100];
   int *p = NULL;
   p = abc;
   p = &abc[0];
   abc == &abc == p != &p;

18. functor

There are several advantages in using a function object instead of a pointer to function.

  • First, they are more resilient to design changes because the object can be modified internally without changing its external interface.because if it is a pointer to function, the parameter is pre-fixed
  • A function object can also have data members that store the result of a previous call. when using ordinary functions, you need to store the result of a previous call in a global or a local static variable. However, global and local static variables have some undesirable characteristics.
  • Finally, compilers can inline a call made through a function object, thereby enhancing performance even further. In general, function objects do not define constructors and destructors. Therefore, they do not incur any overhead during their creation and destruction.

  class GenericNegate
  {
  public:
     template <class T>
     T operator() (T t) const {return -t;}
  };

  int main()
  {
   GenericNegate negate;
   cout<< negate<double>(5.3333); // double
   cout<< negate<__int64>(10000000000i64); // __int64
  }

19. Templates


/--- file generic/CheckedArray.h
#ifndef CHECKEDARRAY_H
#define CHECKEDARRAY_H

#include <stdexcept>

/////////////////////////////////// class CheckedArray<T>
template<class T>
class CheckedArray {
private:
    int size;  // maximum size
    T* a;      // pointer to new space
public:
    CheckedArray<T>(int max);
    ~CheckedArray<T>();
    T& CheckedArray<T>::operator[](int index);
};//end class CheckedArray<T>

//================================= constructor
template<class T>
CheckedArray<T>::CheckedArray<T>(int max) {
    size = max;
    a = new T[size];
}//end constructor
//================================= destructor
template<class T>
CheckedArray<T>::~CheckedArray<T>()
{
delete [] a;
}
//================================= operator[]
template<class T>
T& CheckedArray<T>::operator[](int index) {
    if (index < 0 || index >= size)
        throw out_of_range("CheckedArray");

    return a[index];
}//end operator[]
#endif

Partial Specializations and Explicit Specializations


template <class T> class Vector //primary template #1
{...};
template <class T> class Vector <T*> //partial specialization #2
{
....
void push_back(const T *p);
...
};
template <class T> class Vector <volatile T*> //partial specialization #3
{...};
template <> class Vector <bool> //explicit specialization #4
{};

Partial specialization
template<class T, class U, int I> struct X
  { void f() { cout << "Primary template" << endl; } };

template<class T, int I> struct X<T, T*, I> //note : no class U
  { void f() { cout << "Partial specialization 1" << endl;
  } };

template<class T, class U, int I> struct X<T*, U, I>
  { void f() { cout << "Partial specialization 2" << endl;
  } };

template<class T> struct X<int, T*, 10>
  { void f() { cout << "Partial specialization 3" << endl;
  } };

template<class T, class U, int I> struct X<T, U*, I>
  { void f() { cout << "Partial specialization 4" << endl;
  } };

20. Quick Answers

Polymorphism: C++ provides a simple mechanism for class-based polymorphism. Member  functions can be marked as polymorphic using the virtual keyword

The compiler starts with the Instrument pointer, which points to the starting address of the derived object. All Instrument objects or objects derived from Instrument have their VPTR in the same place (often at the beginning of the object), so the compiler can pick the VPTR out of the object. The VPTR points to the starting address of the VTABLE. All the VTABLEs are laid out in the same order, regardless of the specific type of the object. play( ) is first, what( ) is second, and adjust( ) is third. The compiler knows that regardless of the specific object type, the adjust( ) function is at the location VPTR+2. Thus instead of saying, “Call the function at the absolute location Instrument::adjust” (early binding; the wrong action), it generates code that says, in effect, “Call the function at VPTR+2.” Because the fetching of the VPTR and the determination of the actual function address occur at runtime, you get the desired late binding. You send a message to the object, and the object figures out what to do with it.

http://web.mit.edu/merolish/ticpp/Chapter15.html#Heading440

why constructor can’t be virtual?2.


A constructor cannot be virtual because at the time when the constructor is invoked the virtual table (vtable) would not be available in the memory. Hence we cannot have a virtual constructor.

The ‘virtual’ mechanism works on a logically complete (completely constructed) object. We know that we use constructors to logically initialize our objects. In other words, the object is not completely constructed until the constructor has finished executing. Thus, we can’t have virtual constructors.

There is a misconception that by then virtual table is incomplete so we can’t have virtual constructors. Just before the constructor starts executing : 1)the virtual table is properly constructed and 2)the ‘this’ pointer passed to the constructors. Moreover, virtual table mechanism is implementation depended, and finds no place in the C++ standard. And hence, to argue over this issue using the virtual table concept is illogical.

Now, as the constructor finishes executing any other function can be virtual. Destructor is no exception to this rule as it is a function. Virtual destructors are required in case we use a base class pointer to refer to a derived class object, use it, and then delete it. If we have virtual destructor, using ‘delete’, a chain of destructors is called starting from the derived to the base. But, had there been no ‘virtual’ in destructor only the base class destructor is called (and not the derived). This (may) generate inconsistencies in the program.


How virtual functions are implemented C++?

Virtual functions are implemented using a table of function pointers, called the vtable.  There is one entry in the table per virtual function in the class.  This table is created by the constructor of the class. When a derived class is constructed, its base class is constructed first which creates the vtable. If the derived class overrides any of the base classes virtual functions, those entries in the vtable are overwritten by the derived class constructor. This is why you should never call virtual functions from a constructor: because the vtable entries for the object may not have been set up by the derived class constructor yet, so you might end up calling base class implementations of those virtual functions


What are all the implicit member functions of the class? Or what are all the functions which compiler implements for us if we don’t define one.??

default ctor

default destructor

copy ctor

assignment operator

address operator

diff of static vs global

there are 3 main uses for the static.
1. If you declare within a function: It retains the value between function calls

2.If it is declared for a function name:
By default function is extern.so it will be visible from other files.  if the function declaration is as static.it is invisible for the outer files

3. Static for global variables:

By default we can use the global variables from outside files If it is static global..that variable is limitied to with in the file.

common:  lifetime is the entire program….

What are C++ storage classes?

auto(deafult)
register
static
extern

auto: the default. Variables are automatically created and initialized when they are defined and are destroyed at the end of the block containing their definition. They are not visible outside that block

register: a type of auto variable. a suggestion to the compiler to use a CPU register for performance

static: a variable that is known only in the function that contains its definition but is never destroyed and retains its value between calls to that function. It exists from the time the program begins execution

extern: a variable whose definition and placement is determined when all object and library modules are combined (linked) to form the executable code file. It can be visible outside the file where it is defined.

What are storage qualifiers in C++ ?

They are..

const
volatile
mutable

Const keyword indicates that memory once initialized, should not be altered by a program.

volatile keyword indicates that the value in the memory location can be altered even though nothing in the program
code modifies the contents. for example if you have a pointer to hardware location that contains the time, where hardware changes the value of this pointer variable and not the program. The intent of this keyword to improve the optimization ability of the compiler.

mutable keyword indicates that particular member of a structure or class can be altered even if a particular structure variable, class, or class member function is constant.

struct data
{
char name[80];
mutable double salary;
}

const data MyStruct = { “Satish Shetty”, 1000 }; //initlized by complier

strcpy ( MyStruct.name, “Shilpa Shetty”); // compiler error
MyStruct.salaray = 2000 ; // complier is happy allowed

What is Memory alignment??

The term alignment primarily means the tendency of an address pointer value to be a multiple of some power of two. So a pointer with two byte alignment has a zero in the least significant bit. And a pointer with four byte alignment has a zero in both the two least significant bits. And so on. More alignment means a longer sequence of zero bits in the lowest bits of a pointer.

What do you mean by Stack unwinding?

It is a process during exception handling when the destructor is called for all local objects in the stack between the place where the exception was thrown and where it is caught.

What is overloading??

With the C++ language, you can overload functions and operators. Overloading is the practice of supplying more than one definition for a given function name in the same scope.

– Any two functions in a set of overloaded functions must have different argument lists.
– Overloading functions with argument lists of the same types, based on return type alone, is an error.

what is Overriding?

To override a method, a subclass of the class that originally declared the method must declare a method with the same name, return type (or a subclass of that return type), and same parameter list.
The definition of the method overriding is:
· Must have same method name.
· Must have same data type.
· Must have same argument list.
Overriding a method means that replacing a method functionality in child class. To imply overriding functionality we need parent and child classes. In the child class you define the same method signature as one defined in the parent class.

How are prefix and postfix versions of operator++() differentiated?

The postfix version of operator++() has a dummy parameter of type int. The prefix version does not have dummy parameter.

What is the difference between const char *myPointer and char *const myPointer?

Const char *myPointer is a non constant pointer to constant data; while char *const myPointer is a constant pointer to non constant data.

What is name mangling in C++??

The process of encoding the parameter types with the function/method name into a unique name is called name mangling. The inverse process is called demangling.

For example Foo::bar(int, long) const is mangled as `bar__C3Fooil’.
For a constructor, the method name is left out. That is Foo::Foo(int, long) const is mangled as `__C3Fooil’.

What does extern “C” int func(int *, Foo) accomplish?

It will turn off “name mangling” for func in c++ so that one can link to code of func implementation compiled by a C compiler.

What are the access privileges in C++? What is the default access level?

The access privileges in C++ are private, public and protected. The default access level assigned to members of a class is private. Private members of a class are accessible only within the class and by friends of the class. Protected members are accessible by the class itself and it’s sub-classes. Public members of a class can be accessed by anyone.

What is a nested class? Why can it be useful?

A nested class is a class enclosed within the scope of another class. For example:

//  Example 1: Nested class
//
class OuterClass
{
class NestedClass
{
// …
};
// …
};
Nested classes are useful for organizing code and controlling access and dependencies. Nested classes obey access rules just like other parts of a class do; so, in Example 1, if NestedClass is public then any code can name it as OuterClass::NestedClass. Often nested classes contain private implementation details, and are therefore made private; in Example 1, if NestedClass is private, then only OuterClass’s members and friends can use NestedClass.

When you instantiate as outer class, it won’t instantiate inside class.

What is a local class? Why can it be useful?

local class is a class defined within the scope of a function — any function, whether a member function or a free function. For example:

//  Example 2: Local class
//
int f()
{
class LocalClass
{
// …
};
// …
};
Like nested classes, local classes can be a useful tool for managing code dependencies.

What is the difference between a variable definition and a variable declaration?

A definition tells the compiler to set aside storage for the variable. A declaration makes the variable known to parts of the program that may wish to use it. A variable might be defined and declared in the same statement.

What is the difference between an lvalue and an rvalue?

The lvalue refers to the left-hand side of an assignment expression. It must always evaluate to a memory location. The rvalue represents the right-hand side of an assignment expression; it may have any meaningful combination of variables and constants.

How to make sure all objects created in a function be destroyed (?)(C++)

overload new/delete;

check-memory usage enter/exit func;

auto_ptr;

Note that our detector detects leaks without doing any monitoring of allocations or frees. It simply takes a snapshot of the heap just before the process terminates and determines if there are any leaks based on that snapshot. A snapshot of the heap only tells us if there are leaks; it does not tell us how they were leaked. Clearly, to determine the “how” we also need to obtain a stack trace. But to obtain a stack trace, we need to be able to monitor every allocation on-the-fly at runtime. This is what will distinguish our leak detector from the built-in one.

How to implement smart pointer

A common pitfall of regular pointers is the dangling pointer: a pointer that points to an object that is already deleted.

Here is part of auto_ptr’s implementation, to illustrate what it does:

template <class T>
class auto_ptr
{
    T* ptr;
public:
    explicit auto_ptr(T* p = 0) : ptr(p) {}
    ~auto_ptr()                 {delete ptr;ptr=NULL}
    T& operator*()              {return *ptr;}
    T* operator->()             {return ptr;}
    // ...
};

http://ootips.org/yonat/4dev/smart-pointers.html

why initialization list is listed?

(1)According to the rules of C++, const objects and references cannot be assigned; they can only be initialized

(2)The second reason for using the initializer list—efficiency—arises when the member class has a default constructor as well as an assignment operator. MFC’s CString offers a perfect example. Say you have a class CMyClass with a CString member m_str and you want to initialize m_str to “yada yada.” You have two choices

CMyClass::CMyClass() {
    // use assignment operator
    // CString::operator=(LPCTSTR);
    m_str = _T("yada yada");
}

or

// use initializer list
// and constructor CString::CString(LPCTSTR)
CMyClass::CMyClass() : m_str(_T("yada yada"))
{
}

Is there any difference between these methods? Yes. The compiler always insures that all member objects are initialized before the body of the constructor executes, so in the first example the compiled code will call CString::CString to initialize m_str before control reaches the assignment statement. In the second example, the compiler generates a call to CString:: CString(LPCTSTR), passing “yada yada” as the string. The upshot is that in the first example two CString functions are called (constructor and assignment operator), whereas in the second example only one function is called.

dead lock sample, how to avoid

  public static Object cacheLock = new Object();
  public static Object tableLock = new Object();
  ...
  public void oneMethod() {
    synchronized (cacheLock) {
      synchronized (tableLock) {
        doSomething();
      }
    }
  }
  public void anotherMethod() {
    synchronized (tableLock) {
      synchronized (cacheLock) {
        doSomethingElse();
      }
    }
  }

that thread A acquires the lock on cacheLock, and, at the same time, thread B acquires the lock on tableLock. Now the threads are deadlocked: neither thread will give up its lock until it acquires the other lock, but neither will be able to acquire the other lock until the other thread gives it up.

How to avoid deadlocks

http://www.javaworld.com/javaworld/jw-10-2001/jw-1012-deadlock.html?page=3

One of the best ways to prevent the potential for deadlock is to avoid acquiring more than one lock at a time, which is often practical. for instance, Shrink synchronized blocks to avoid multiple locking;

otherwise, ensure that you use a consistent locking order. or enforce business logic to avoid deadlock happen.

How would you detect a loop in a linked list? Write a C program to detect a loop in a linked list.

http://vijayinterviewquestions.blogspot.com/2007/05/how-would-you-detect-loop-in-linked.html

This is also one of the classic interview questions
There are multiple answers to this problem. Here are a few C programs to attack this problem.

Brute force method
Have a double loop, where you check the node pointed to by the outer loop, with every node of the inner loop.

typedef struct node

{

void *data;

struct node *next;

}mynode;

mynode * find_loop(NODE * head)

{

mynode *current = head;

while(current->next != NULL)

{

mynode *temp = head;

while(temp->next != NULL && temp != current)

{

if(current->next == temp)

{

printf(“\nFound a loop.”);

return current;

}

temp = temp->next;

}

current = current->next;

}

return NULL;

}

Visited flag
Have a visited flag in each node of the linked list. Flag it as visited when you reach the node. When you reach a node and the flag is already flagged as visited, then you know there is a loop in the linked list.

Fastest method
Have 2 pointers to start of the linked list. Increment one pointer by 1 node and the other by 2 nodes. If there’s a loop, the 2nd pointer will meet the 1st pointer somewhere. If it does, then you know there’s one.

Here is some code
p=head;

q=head->next;
while(p!=NULL && q!=NULL)

{

if(p==q) { //Loop detected! exit(0); }

p=p->next;

q=(q->next)?(q->next->next):q->next;

}
// No loop.

What is the difference between far pointer and nea…


In 16 bit development environment like DOS or WIN 3.0 memory management is done in terms of segment:offset addressing style. so in this environment we have segment registers like CS,DS.SS,ES if we declare a near pointer we will be able to access the pointer within the segment i.e with 64 kb boundary

on the contrary if we declare it as far pointer we can access the pointer across segment boundary i.e pointer declared in one segment can be accessed from other segments also.
In 32 bit environment we have linear addressing scheme no segments and offsets so all pointers are treated as far only, no differentiation as near or far.

Why an empty Structure will occupy 2Bytes in C++


Size of empty structure in C++ is 1 byte, because compiler assign 1 byte for structure name.

Why the size of empty Class is one byte?


Yes, the compiler will generate 1 byte of memory to mark the existence of the class.  This doesn’t answer WHY though.  The reason is the language standard states that all classes must have a memory size of at least 1 byte so that the class doesn’t occupy the same memory space with another class. This is to prevent name mangling.  i.e., if I declare a class A {};, the compiler will still generate an entry in its table to something called “A”.  If behind that I declare another class, say class B, if A takes 0 bytes of memory, and B’s data gets written in the place where A was declared.  In this case, an instantiation of A would take on the properties of B.

What is difference between obeject oriented progra…


Object Oriented Programming :  It means, which follows object oriented concepts that is object oriented programming for example : c++, java and also c++ is not complete objected oriented. But java is pure objected oriented programming.
object oriented programming is bottom up approach.
program works based on object.
object is nothing set of members and methods.
Structure Oriented Programming : it means, which follows and structure ( function ) oriented concepts, a program which follows a procedure ( or a structure ) is called structure oriented programming for example : c lang
Structure Oriented Programming is top down approach.

program works based on functions.

what are proxy objectives


A proxy class is a class that implements a list of interfaces specified at compile time. The proxy object typically holds a reference to an internal object that implements the same interfaces (or parts of them).

Rational Purify, sleaker,valgrind,Electric Fence

Ref:

http://www.fredosaurus.com/notes-cpp/index.html

http://www.freejavaguide.com/cppint.htm

http://www.shettysoft.com/interview/C_C++_interview_questions_answers.htm

http://www.coders2020.com/c-faq-for-placement-and-interviews

http://c-faq.com/decl/

October 12, 2007

海归论坛 :: 阅读主题 – [分享]对冲基金精英榜(Elite of the Hedge Fund)

Filed under: Uncategorized — manoftoday @ 8:44 pm

 

english version:

http://nymag.com/news/features/2007/hedgefunds/30342/

2007年07月31日 《当代金融家》
  乔治·索罗斯、JulianRobertson、Michael Steinhardt、Stanley Druckenmiller、Louis Bacon、Paul Tudor Jones二世、Bruce Kovner、Arthur Samberg等人都是对冲基金领域的传奇英雄。他们并不会在接下来的文章中露面,因为他们都已功成名就,不需要再证明任何东西了。本文对10位熟悉对冲基金的人士进行匿名调查,基于调查结果,对6个组别的当今最杰出的对冲基金经理进行排名。10位接受调研的人士中有5位本身就是对冲基金经理,2位在著名的投资银行中从事与冲基金相关的业务,1位是投资人,其余两位是财经记者。
笑傲江湖,领袖群伦型
  ◎ Steve Cohen /SAC投资顾问(SAC Capital Advisors)
  规模:120亿美元类型:交易员
  地址:Stamford,康涅狄格州
  被议论最多的对冲基金经理。在康涅狄格州的格林威治拥有一所32000平方英尺的大房子,其建筑占地14英亩。房屋本身堪称当代建筑的伟大艺术品。2006年10月,他花了6350万美元从娱乐业巨子、梦工场(DreamWorks)共同创始人大卫o格芬(David Geffen)手里买下当代艺术大师威廉o德o库宁(Willemde Kooning)的名画Police Gazette。他的个人净资产估计高达30亿美元。老手评价:“出身草根,是位了不起的交易者,异常强悍。”
  对冲基金投资人评价:“此公卵翼下造就的那些投资组合经理将是对冲基金界的下一拨明星。”新手评价:“以交易量而言,可能是世界上最大的交易商。而且公司中绝大多数资产是他自己的!”
  ◎ Stephen Feinberg /Cerberus资本
  规模:191.5亿美元
  类型:危机投资者
  地址:曼哈顿
  在“垃圾债券大王”米尔肯(MichaelMilken)麾下,供职于DrexelBurnhamLambert。 “秃鹫投资者”中的顶级高手。刚刚从奔驰手上买下克莱斯勒汽车公司。喜欢共和党:美国前副总统丹o奎尔(DanQuayle)就在Cerberus的团队中,前财政部长斯诺(John Snow)任公司董事长。老手评价:“最伟大的积极主义投资者之一。”
  对冲基金投资人评价:“一个安静的家伙,几乎不在任何社交场合露面的。简直是个投资机器。不露声 色地将一家危机投资公司变身为专门从事收购的公司。”
  新手:“危机投资界、中级市场以及私募交易界的顶尖人物。”
  ◎ David Tepper /Appaloosa 管理公司
  规模:53亿美元
  类型:危机投资者
  地址:Chatham,新泽西
  在高盛主管垃圾债券业务。1993年,步众多前高盛同事后尘,创办Appaloosa。和 Cerberus一样,在汽车行业寻找机会。与Cerberus在德尔福(Delphi)汽车配件公司一案中合作。净资产约15亿美元。老手评价:“伟大的危机投资者,同样了不起的积极主义投资者。”
  对冲基金投资人评价:“大手笔,但很冒险。给卡耐基梅隆大学商学院捐了不少钱,以至于商学院就用他的名字命名。”
  新手评价:“过去10年中最卓越的危机投资家。”
  ◎ Eddie Lampert /ESL投资
  规模:180亿美元
  类型:拣股者
  地址:康涅狄格的格林威治
  曾经被绑架。被誉为他那一代人中最伟大的投资者,积极主义投资者的领军人物。专注于零售业,拥有西尔斯百货(西尔斯拥有卡玛特连锁超市)和全美最大的汽车零售连锁AutoNation。净资产约38亿美元,是康涅狄格州首富。
  老手评价:“在管理他投资的公司时亲力亲为、兢兢业业。没什么特别的嗜好,但是个了不起的人。”对冲基金投资人评价“:他正在把西尔斯变成下一个伯克夏·哈撒威(Berkshire Hathaway)。不出意外的话,将成为下一个沃伦·巴菲特。”
  新手评价:“集权掌控他投资的公司。”
  ◎ Kenneth Griffin /Citadel投资集团
  规模:135亿美元
  类型:交易员
  地址:芝加哥
  过去是最深居简出的神秘家伙。去年在出售债券为自己公司筹钱时成了媒体的红人,彼时恰逢此公从Amaranth彻底垮台中大捞了一票。以8000万美元价格从格芬手上买下现代艺术大师JasperJohns的名作False Start。净资产约17亿美元。
  老手评价:“还在哈佛念书时就开始在宿舍里从事交易。”对冲基金投资人评价:“在凡尔赛宫结的婚。”
  新手评价:“对员工期待很高的老板,风格强悍。”
  ◎ Michael Novogratz /Fortress 投资集团
  规模:46亿美元
  类型:交易员
  地址:曼哈顿
  Fortress投资集团总裁,2007年早些时候公司上市,和同事PeterBriger以及Wesley densortress一道赚了大钱。和本排行榜上许多人一样,事业是从高盛起步的。曾是美国空军直升机飞行员。净资产约23亿美元。
  新手评价:“爱上 Fortress的股价。”
奇门遁甲,神机妙算型
  ◎ James Simons /复兴科技(Renaissance Technologies)
  规模:240亿美元类型:定量投资者
  地址:纽约East Setauket
  曾是数学教授,被誉为“黑匣投资者之王”(king of black box)。黑匣投资基金的特点是运用最为玄妙的数学运算法则,由电脑操作完成大部分投资行为。最近瞄准一项1000亿美元的基金,着实令同行目瞪口呆。收取5%的管理费和 44%的提成,为业内最高,但没人对此说三道四。净资产约40亿美元。
  老手评价:“此公从来不雇用那些知道华尔街在哪里的家伙。他那里都是博士,用的算法没人能明白,但看起来效果不错。”
  对冲基金投资人评价:“和 Dalio 并称定量投资之王。”
  新手:“别的不说,在过去几年里当仁不让是薪酬最高的基金经理之一。”
  ◎ David Shaw /D.E.Shaw
  规模:263亿美元
  类型:定量投资者
  地址:曼哈顿
  帮助建立了摩根士丹利的自动交易系统。曾是计算机科学教授。1988年离职后创办自己的基金公司,从事传统统计套利(statisticalarbitrage)交易。2005年退居二线,专注于生物分子科学研究,但仍然能赚到业内最高的薪水,2005年收入约为5亿美元。净资产估计10亿美元左右。老手评价“:不声不响,这家公司已经累积了大笔资产。雇佣了离开哈佛后无所事事的拉里o萨默斯(Larry Summers,曾任美国财政部长、哈佛大学校长)。”
  新手评价:“好像是那个时代最大的对冲基金吧?”
  ◎ Clifford Asness /AQR 资本管理
  规模:95亿美元
  类型:定量投资者
  地址:康涅狄格州格林威治
  又一位离开高盛自创公司的天才。1998年与合伙人DavidKabiller,RobertKrail,JohnLiew共同创办了AQR资本管理公司。据说离开高盛的理由是高盛不愿意按业绩给他的团队成员支付合理报酬。在写作和投资方面一样有天赋。
  老手评价:“建立了伟大的事业。但是,很多人都对公司2006业绩欠佳想不通。”对冲基金投资人评价:“被邀请投资于AMG资产管理公司,大概买了25%的股份?”
  ◎ Ray Dalio /Bridgewater Associates
  规模:302亿美元
  类型:定量投资者
  地址:康涅狄格的Westport
  如果对冲基金界有一位哲学家的话,RayDalio是不二人选。“Bridgewater是一个令我们彼此命运息息相关的社区。”“钱并不会带来幸福,而追求卓越的过程却可以。”老手评价:“真正出色的定量投资者,但投资结果好坏参半。”对冲基金投资人评价:“和 Simons 并称定量投资者之王。”
  新手评价:“稳健,波澜不惊,悄无声息地建起一家财富管理巨擘。”
  ◎ Mark Carhart /高盛资产管理(Goldman Sachs Asset Management)
  规模:325亿美元
  类型:定量投资者
  地址:曼哈顿
  曾经是芝加哥大学的学者。1997年在同事CliffAsness另谋高就后,成为高盛“旗舰”全球阿尔法(GlobalAlpha)基金共同掌门人。尽管有一个好的开始,但之后的路并不平坦:2006年损失6%,整个华尔街都在传着他的流言蜚语。但2007年,这位曾经的高中数学竞赛冠军再次赢得所有人的关注。
  老手评价:“噢,2006年他真的不行过?”
好勇斗狠,快意恩仇型
  ◎ Daniel Loeb /Third Point
  规模:42亿美元
  类型:拣股者
  地址:曼哈顿
  这一行的“捣蛋分子”。花4500万美元买下了RobertA。M。Stern大厦的顶层公寓。据说是瑜伽和冲浪爱好者。
  老手评价:“大胆、直率的积极主义投资者。”
  对冲基金投资人:“总爱写些引人捧腹的邮件。你一定得读读他写给一位来自欧洲的招聘对象的邮件。Google一下好了。”
  新手评价:“纯粹的逐利者。从不惮于将无能的管理层搅得天翻地覆。”
  ◎ Thomes Hudson /海盗资本(Pirate Capital)
  规模:11亿美元
  类型:拣股者
  地址:康涅狄格州Norwalk
  因婚外恋被高盛解雇。开创海盗资本的本钱中有150万美元是自己的,其余50万是父母的。高调的行动主义者,最近的目标有汽车配件零售商 Pep Boys 和 Outback牛排餐厅的东主OSI饭店合伙公司。
  对冲基金投资人评价:“这条船可能会沉。”
  ◎ Israel Englander /千年管理(Millennium Management)
  规模:86亿美元
  类型:交易员
  地址:纽约
  犹太事业的捐赠人。付给证交会(SEC)1.8亿美元了结择时交易(markettiming)指控,其中3000万美元是自掏腰包。
  新手评价:“掉进共同基金丑闻陷阱,被逮个正着。”
  ◎ Warren Lichtenstein /Steel Partners
  规模:39亿美元
  类型:拣股者
  地址:曼哈顿
  行动主义投资者,关注美国和日本。同他的偶像CarlIcahn一道企图收购韩国烟草商 KT&G,掀起韩国历史上最大的敌意收购战事。眼下正盯着日本的札幌控股(SapporoHoldings),这家公司为全世界的寿司老饕们耳熟能详。
  老手评价:“又是一位行动主义者,但是我觉得他在BKF交易中的表现并不很好,但不可否认他仍然做过很多漂亮的交易。”
  对冲基金投资人评价:“行动主义的早期实践者,成功进军日本,现在正在向亚洲其他国家进发。”新手评价:“不怕起诉,也不怕被起诉。”
  ◎ Barry Rosenstein /JANA Partners
  规模:58亿美元
  类型:拣股者
  地址:旧金山
  曾经是美林投资银行家(竟然不是高盛出来的!)。一次风帆冲浪事故造成局部瘫痪,最后通过练瑜伽康复。引人注目的行动主义投资者。追杀那些刚愎自用的公司高管,结果被人们认为已变得像Daniel Loeb一样好勇斗狠。
  老手评价:“一位真正的行动主义者,一个聪明人。”新手:“投资回报令人印象深刻。”
不辞跬步,稳扎稳打型
  ◎ Richard Chilton /Chilton投资公司
  规模:43亿美元
  类型:拣股者
  地址:Stamford,康涅狄格州
  使康涅狄格州格林威治成为世界对冲基金圣地的先驱者之一。大都会艺术博物馆董事会成员。美式家具的爱好者,共和党的拥护者。老手评价“:在建立一个伟大组织同时也能创立一个伟大基金的典型范例。此外,还有一群很棒的孩子。”
  ◎ Larry Robbins /Glenview资本管理公司
  规模:61亿美元
  类型:拣股者
  地址:曼哈顿
  过去曾为Leon Cooperman的欧米加顾问公司(Omega Advisor)工作。一度赌马。
  老手评价:“去年境况不太好,但是他就像收购业务的传奇英雄LeonCooperman一样,完全为自己的事业疯狂了。”
  对冲基金投资人:“大事制造者。”
  新手:“利用各种策略的大人物。”
  ◎ Richard Perry /Perry资本
  规模:123.4亿美元
  类型:交易员
  地址:曼哈顿
  太太在为民主党筹款方面十分活跃,过去3届大选中为民主党捐赠超过100万美元。和许多顶级对冲基金经理人一样出身高盛,是EddieLampert的哥们儿。由于在King制药公司的交易中有可疑的举动被SEC调查。一度拥有鲜花和礼品速递公司FTD集团。
  ◎ Lief Rosenblatt /卫星资产管理公司(Satellite Asset Management)
  规模:54亿美元
  类型:交易员
  地址:曼哈顿
  曾经是索罗斯的下属。罗兹奖学金获得者(Rhodes scholar)。生活低调。
  老手评价:“伟大的套利者,索罗斯的门徒。似乎对快速成长不感兴趣,而更关注于优雅的生活。”
  新手:“岂弟君子,急公好义。”
犯难涉险,一击必杀型
  ◎ T. Boone Pickens /BP资本管理
  规模:25亿美元
  类型:交易员
  地址:达拉斯
  义无反顾地做多石油成就了他的第一桶金。大慈善家,2005年捐赠额超过了2亿美元。估计拥有净资产25亿美元。
  老手评价:“发家于能源业,过去从能源公司赚钱,现在转行做对冲基金。”
  新手评价:“赌得很大,有好几次差一点就倾家荡产。”
  ◎ Timothy Barakett /Atticus资本
  规模:140亿美元
  类型:拣股者
  地址:曼哈顿
  曾经回绝去新泽西魔鬼队(NewJerseyDevils)打职业冰球的机会。长期关注全球股票交易,包括纽约证交所、泛欧交易所(Euronext)和德国证交所(Deutsche Boers)。
  老手评价:“毫无疑问,一位伟大的全球拣股者。”
  新手评价:“此公家族的基因里有某种神秘的东西,他的兄弟Brett也在经营一家对冲基金,叫Tremblant资本。”
  ◎ Stephen Mandel /孤松资本(Lone Pine Capital)
  规模:79.4亿美元
  类型:拣股者
  地址:康涅狄格州格林威治
  Julian Robertson老虎基金培养出的“小老虎”之一。最近一次成功是选中了Google。和许多成功的对冲基金经理人一样出身高盛。
  老手评价:“真正的劲敌。一个安静、私密的家伙。他的公司可能是这一行里组织得最好的。如果这一行里有哪一家公司在创始人退下来后还能存在并继续发展繁荣,孤松是最好例子。”
  新手:“年收入2.5亿美元。”
  ◎ James Chanos /Kynikos Associates
  规模:30亿美元
  类型:拣股者
  地址:曼哈顿
  少有的几个靠卖空从1990年代的大牛市中全身而退的人之一。很早发现安然(Enron)的问题,并透露给《财富》杂志记者Bethany Mclean,让后者一举成名。当然,在这个过程中自己也发了财。
  老手评价:“卖空交易高手,深思熟虑,但不是一个交易者。”
  新手:“过去10年中最棒的、纯粹的短线投资者,看在上帝的份上,他竟料到安然会出事!”
芝兰玉树,后生可畏型
  ◎ Chase Coleman /老虎全球管理(Tiger Global Management)
  规模:30亿美元
  类型:拣股者
  地址:曼哈顿
  老虎基金培养出来的“小老虎”。荷兰驻新阿姆斯特丹殖民地(今纽约)总督Peter Stuyvesant的后裔,正是此公的这位先人建起了让华尔街因之得名的那道墙。钟情于小公司股票。
  老手评价:“一位优秀的全球投资者,从容且有章法地建立起自己的事业。”
  对冲基金投资人评价:“现在不仅关注技术股,还做点风险投资。”
  ◎ Peter Thiel /Clarium资本管理公司
  规模:19亿美元公司
  类型:交易员
  公司地址:旧金山
  不收固定管理费,只拿25%提成,很少有对冲基金这么做。PayPal共同创始人。信奉自由意志,美国保守派学生报纸《斯坦福评论》创始人。副业包括风险投资,投资过Friendster、Facebook 和 li<x>nkedln等公司。电影《感谢你抽烟》的执行制片人。
  ◎ William von Mueffering /Cantillon资本管理
  规模:81亿美元
  类型:拣股者
  地址:曼哈顿
  曾供职于国际投资银行Lazard,其间,靠投资于科技类和通信类公司一举成名,该银行能够在对冲基金业务中占有一席之地也应归功于此公。2003年从Lazard辞职。喜欢收集黑白照片,国际摄影中心(International Center for Photography)董事会成员。
  对冲基金投资人评价:“离开Lazard时孤立无援。他们真应该花点努力留住他。”
  新手评价:“迅速升起的明星。”
  ◎ Eric Mindich /Eton Park
  规模:62亿美元
  类型:交易员
  地址:曼哈顿
  高盛历史上最年轻的合伙人。在高盛风险套利部门赢得声誉。
  老手评价:“评价他还太早,他出手很大,但最近的交易可不怎么样。人人都想知道究竟出什么事了。”
  新手评价:“史上在首发时募集资金数额最大的对冲基金。”
  ◎ David Ganek /Level全球投资
  规模:N/A
  类型:拣股者
  地址:康涅狄格州格林威治
  SAC的第一位雇员,之后自己创业。在艺术收藏界的名声与其在投资领域不相上下。崇拜后现代艺术大师杰夫·孔斯(Jeff Koons)。在寸土寸金的纽约公园大道740 号拥有住所。老手评价:“出色的财富管理者,稳健、可靠。”
  新手评价:“与前老板Steve Cohen在艺术收藏上志趣相投。”
  ◎ John Arnold /Centaurus能源公司
  规模:30亿美元
  类型:交易员
  地址:休斯敦
  前安然交易员。美国参议员DianneFeinstein指责他的公司操纵美国能源市场。雇用了很多安然事件的“倒霉鬼”。天然气期货交易专家。据说是Amaranth崩盘的受益者。
  对冲基金投资人:“这小子刚刚在RichardBranson(英国大富豪,维珍集团老板)的私人小岛上结婚。还是个可怕的能源交易员。”
《外交政策》杂志日前对全球规模最大5只对冲基金进行盘点,分析了其投资策略。
  1.摩根大通资产管理公司
  总资产:330亿美元
  所在地:纽约
  投资方向:各种领域均有投资,包括一系列静态套利产品。该基金在中国、印度等国家投资房地产业。近一段时间以来,该基金开始涉足基础设施领域,例如投资德克萨斯州的高速公路。此外,该基金正在逐渐拓展亚洲市场,并刚刚获得在韩国运营的牌照。
  投资策略:多样化。摩根大通资产管理公司雇佣了多名投资经理,各自采用不同的投资策略。该基金宣称追求金融工具数量与质量的平衡,并据此来评估风险和回报。不过,该基金目前主要致力于“完全回报投资”,即不考虑市场整体走势,仅以实现投资目标为最终目的。
  2.高盛资产管理公司
  总资产:325亿美元
  所在地:纽约
  投资方向:该基金的投资方向一直保密。不过,全球市场的股票是该基金的一个重点投资对象,尤其是一些估值较低的股票。该基金的其他投资方向包括货币市场、固定收入资产、私募基金、风投基金以及基础设施等领域。
  投资策略:该基金倾向于投资一些未得到充分研究的市场,并追求一些套利机会。该基金大量使用依赖于市场模型计算的数量化投资策略。由于次级债风波,该基金旗下的两只基金今年以来损失了30%的市值。
  3.Bridgewater Associates
  总资产:302亿美元
  所在地:康涅狄格州Westport
  投资方向:货币市场,全球固定收入资产,债券,新兴市场,货物。最近开始投资股票市场。
  投资策略:大量采用数量化投资策略。该基金目前追求向客户提供高alpha,即通过投资独立于市场整体走势的股票来获取收益。该基金的客户多为机构性投资者,例如外国政府、中央银行、大学基金、养老金基金以及慈善基金等。
  4.D.E.Shaw集团
  总资产:273亿美元
  所在地:纽约
  投资方向:收购现有公司,尤其是濒临破产的公司。向新兴公司注资。其他投资包括风投基金、债券、能源业等。该基金近年来开始涉及私募基金并尝试直接借贷。
  投资策略:选择最好的投资经理。据透露,该基金的每一位投资经理均是从500名应聘者中挑选出来的。D.E.Shaw是数量化投资策略的先行者,通过数学方法和计算技术得出最佳的投资方式。采用高新技术是该公司的一大特色,该公司自称为“全球投资与技术发展公司”。
  5.Farallon资本管理公司
  总资产:262亿美元
  所在地:旧金山
  投资方向:债券与股票市场,公司的并购与重组,风投基金,房地产以及新兴市场。
  投资策略:大量的套利,例如在风险投资及公司并购等领域。该基金的客户包括大学基金和全球超级富翁,业绩在很大程度上受市场事件驱动。该基金对上市公司的动向密切关注,寻求增值机会。例如,该基金在近日的次级债危机之后以较低的价格投资了房地产市场。

Source: 海归论坛 :: 阅读主题 – [分享]对冲基金精英榜(Elite of the Hedge Fund)

October 11, 2007

Writing and Compiling A Simple Program For OpenWrt

Filed under: Uncategorized — manoftoday @ 5:03 am

 

Writing and Compiling A Simple Program For OpenWrt

Written by Eric Bishop <ericpaulbishop-at-gmail.com>

Part I added 8/23/2007
Part II added 10/10/2007

Introduction

I’m writing this document because I found the documentation available on the OpenWrt wiki (http://wiki.openwrt.org) difficult to follow. I found myself in the position of wanting to compile a very simple program that I could run on my OpenWrt router. I ended up spending hours wading through the frustratingly incomplete documentation on the wiki, going through dozens of forum posts, and conducting extensive trial-and-error before my code would compile. I especially appreciated the examples on the wiki that contain the warning: “Note this Makefile is provided as an example only; it will not compile.” If something doesn’t work, it isn’t a very good example, is it? Here, then, is a (hopefully) more straightforward guide to building a program for OpenWrt. I found that existing documentation focuses more on porting existing, complicated programs to OpenWrt. My intention is to focus on getting a small, very simple, home-grown application running on OpenWrt. My goal is to explain this in as simple and complete a manner as possible, explaining each and every step necessary to write and compile a program that will run on OpenWrt. The process is actually very simple and straightforward — provided you know what you’re doing. For the purposes of this tutorial I’m going to assume you have a development box running linux and a router running OpenWrt. I will also assume you are at least somewhat familiar with C/C++ and standard Unix Makefiles.

The code for the examples in this tutorial can be downloaded from here. The example from the first part of the tutorial is in the openwrt-programming-examples/c directory and the example from the second part is in the openwrt-programming-examples/c++ directory.

Part I: A Simple Program in C

First, we’re going to need to write the code for the program itself and get it compiling on our local linux machine. Let’s write a simple “hello world” program that we want to run on the router:

~/helloworld/src/helloworld.c:

/****************
* Helloworld.c
* The most simplistic C program ever written.
* An epileptic monkey on crack could write this code.
*****************/
#include <stdio.h>

int main(void)
{
	printf("Hell! O' world, why won't my code compile?\n\n");
	return 0;
}
	

Alright, we have our code. Note the location of this file. Make a helloworld directory and then a src subdirectory. Place the code in the src subdirectory. Now, let’s write a standard Unix Makefile to compile this code for us:

~/helloworld/src/Makefile:

# build helloworld executable when user executes "make"
helloworld: helloworld.o
	$(CC) $(LDFLAGS) helloworld.o -o helloworld
helloworld.o: helloworld.c
	$(CC) $(CFLAGS) -c helloworld.c

# remove object files and executable when user executes "make clean"
clean:
	rm *.o helloworld
	

Notice that instead of hard-coding “gcc” in the makefile to compile the program, we use a variable that holds the C compiler, $(CC). If you’re compiling a c++ program you would use $(CXX) instead of $(CC) and $(CXXFLAGS) instead of $(CFLAGS). The use of the compiler variable is not necessary to compile the code locally, but in order to compile the code for OpenWRT it is critical because we won’t be using the standard gcc compiler. Place the makefile in the same src directory our code is in. We can now go to the src directory, type “make” and the program should compile. You can run it by typing “./helloworld”

mockingbird@linuxbox:~/helloworld/src$ make
cc -c helloworld.c
cc helloworld.o -o helloworld
mockingbird@linuxbox:~/helloworld/src$ ./helloworld
Hell! O' world, why won't my code compile?

mockingbird@linuxbox:~/helloworld/src$ make clean
rm *.o helloworld
mockingbird@linuxbox:~/helloworld/src$ 
	

So far this should be a review on how to write simple C programs and how to use Makefiles. Now comes the tricky part, compiling the code so that it will run on our router. The router uses a distinctly different architecture than our linux development box. Because there isn’t enough memory/disk space on the router to install a compiler and compile the code natively, we need to “cross-compile” the code on our development box for use on the router. To do this we need a special compiler and development environment called the OpenWRT SDK. You can download the SDK from http://downloads.openwrt.org The SDK varies depending on the architecture of your development box, the architecture of your router and the version/release of OpenWrt your router is running. I currently have whiterussian v0.9 installed on my Linksys WRT54G router, and my development box is an i686, so the SDK I use is this one. Extract the SDK files from the downloaded archive, and enter the SDK directory, which should have the same name as the tar.bz2 file (in my case OpenWrt-SDK-Linux-i686-1).

mockingbird@linuxbox:~$ tar xfj OpenWrt-SDK-Linux-i686-1.tar.bz2
mockingbird@linuxbox:~$ cd OpenWrt-SDK-Linux-i686-1
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ ls
dl  docs  examples  include  Makefile  package  README.SDK  rules.mk  scripts  staging_dir_mipsel
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ 
	

Our goal is to build a package for OpenWrt using the source we already have. When you execute the “make” command in the SDK directory, the SDK will compile all properly configured packages in the package subdirectory under the SDK directory. The next step (and the trickiest) is to properly configure our code so that the SDK will build it. First, copy the helloworld directory we made earlier into the package subdirectory of the SDK:

mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ cp -r ~/helloworld package
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ 
	

In order to tell the OpenWrt SDK how to build our program we need to create a special Makefile in the helloworld directory, above the src directory which contains our conventional makefile. Writing this file is 90% of the work involved in compiling our program for OpenWrt. Below is an OpenWrt makefile for building the helloworld program. Each section is heavily commented so that it should be fairly clear what is going on:

~/OpenWrt-SDK-Linux-i686-1/package/helloworld/Makefile:

##############################################
# OpenWrt Makefile for helloworld program
#
#
# Most of the variables used here are defined in
# the include directives below. We just need to 
# specify a basic description of the package, 
# where to build our program, where to find 
# the source files, and where to install the 
# compiled program on the router. 
# 
# Be very careful of spacing in this file.
# Indents should be tabs, not spaces, and 
# there should be no trailing whitespace in
# lines that are not commented.
# 
##############################################

include $(TOPDIR)/rules.mk

# Name and release number of this package
PKG_NAME:=helloworld
PKG_RELEASE:=1


# This specifies the directory where we're going to build the program.  
# The root build directory, $(BUILD_DIR), is by default the build_mipsel 
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)


include $(INCLUDE_DIR)/package.mk



# Specify package information for this program. 
# The variables defined here should be self explanatory.
define Package/helloworld
	SECTION:=utils
	CATEGORY:=Utilities
	TITLE:=Helloworld -- prints a snarky message
	DESCRIPTION:=\
	If you can't figure out what this program does, \\\
	you're probably brain-dead and need immediate \\\
	medical attention.
endef


# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default.  The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)/
endef


# We do not need to define Build/Configure or Build/Compile directives
# The defaults are appropriate for compiling a simple program such as this one


# Specify where and how to install the program. Since we only have one file, 
# the helloworld executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running 
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install 
# directory if it does not already exist.  Likewise $(INSTALL_BIN) contains the 
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/helloworld/install
	$(INSTALL_DIR) $(1)/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef


# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.
$(eval $(call BuildPackage,helloworld))
	

As indicated, most OpenWrt make files specify how to download the source of an application from a URL, and most documentation assumes that you want to do this. However, if you’re building your own application from scratch it doesn’t make sense to download from a URL. It’s much simpler to have the source locally and use the Build/Prepare section to copy the source to the build directory, as shown above. Also, be very careful of spacing in the Makefile. The indentation under the define sections should be tabs, not spaces and there should be no whitespace at the end of lines that are not comments. The trailing whitespace can be a problem when variables are being defined, as the compiler may think there is a space at the end of a directory name. If we’re copying something to dir_with_trailing_space/subdir the copy command may be executed as “cp my.file dir_with_trailing_space /subdir”. Not only don’t you want anything in /subdir, you probably dont have permission to create it and write to it.

Now we’re all set to compile the helloworld package. Go to the root SDK directory (if you’re not already there) and type “make V=99” The “V=99” option is optional, but it is useful for debugging as it instructs the compiler to be “verbose” and output all the details of what it is doing.

mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ make V=99
make package/compile
make[1]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1'
Collecting package info...
make -C package compile SDK=1
make[2]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[2]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[2]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make -j1 compile-targets
make[3]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make -C helloworld compile
make[4]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package/helloworld'
CFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include -I/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/include " LDFLAGS="-L/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib -L/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/lib " make -C /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld AR=mipsel-linux-uclibc-ar AS="mipsel-linux-uclibc-gcc -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time" LD=mipsel-linux-uclibc-ld NM=mipsel-linux-uclibc-nm CC="mipsel-linux-uclibc-gcc" GCC="mipsel-linux-uclibc-gcc" CXX=mipsel-linux-uclibc-g++ RANLIB=mipsel-linux-uclibc-ranlib STRIP=mipsel-linux-uclibc-strip OBJCOPY=mipsel-linux-uclibc-objcopy CROSS="mipsel-linux-uclibc-" CXXFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include -I/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/include " ARCH="mipsel" ;
make[5]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld'
make[5]: `helloworld' is up to date.
make[5]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld'
touch /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/.built
install -d -m0755 /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/bin
install -m0755 /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/helloworld /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/bin/
mkdir -p /home/mockingbird/OpenWrt-SDK-Linux-i686-1/bin/packages
find /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld -name CVS | xargs rm -rf
find /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld -name .svn | xargs rm -rf
find /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld -name '.#*' | xargs rm -f
STRIP="/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/bin/sstrip" STRIP_KMOD="mipsel-linux-uclibc-strip --strip-unneeded --remove-section=.comment" /home/mockingbird/OpenWrt-SDK-Linux-i686-1/scripts/rstrip.sh /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld
rstrip.sh: /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/bin/helloworld:executable
ipkg-build -c -o 0 -g 0 /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld /home/mockingbird/OpenWrt-SDK-Linux-i686-1/bin/packages
Packaged contents of /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld into /home/mockingbird/OpenWrt-SDK-Linux-i686-1/bin/packages/helloworld_1_mipsel.ipk
make[4]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package/helloworld'
make[3]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[2]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[1]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1'
( \
        cd package; \
        find . -maxdepth 2 -name Config.in | \
                sed -e 's,/Config.in,,g' | \
                xargs -r -n1 make compile -C; \
)
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$
	

It compiled! The new package, helloworld_1_mipsel.ipk, is now located in the bin/packages subdirectory of the root SDK directory.

mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ cd bin/packages
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1/bin/packages$ ls
helloworld_1_mipsel.ipk
mockingbird@linuxbox:~OpenWrt-SDK-Linux-i686-1/bin/packages$
	

This file is a ipk file which is used by the ipkg (itsy package management) system. Ipkg is a package management system for embedded devices, where space is an issue. Let’s copy this package onto the router, which is located at 192.168.1.1 on my network.

mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1/bin/packages$ scp helloworld_1_mipsel.ipk root@192.168.1.1:
root@192.168.1.1's password: 
helloworld_1_mipsel.ipk                                                            100% 1875     1.8KB/s   00:00    
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1/bin/packages$ 
	

Now, ssh into the router. We just copied the package to root’s home directory so we are finally ready to install our program. In root’s home directory, (where we end up immediately after connecting to the router via ssh) type “ipkg install helloworld_1_mipsel.ipk” and the ipkg system will do the rest.

mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1/bin/packages$ ssh root@192.168.1.1
root@192.168.1.1's password: 


BusyBox v1.00 (2007.01.30-11:42+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 WHITE RUSSIAN (0.9) -------------------------------
  * 2 oz Vodka   Mix the Vodka and Kahlua together
  * 1 oz Kahlua  over ice, then float the cream or
  * 1/2oz cream  milk on the top.
 ---------------------------------------------------
root@OpenWrt:~# ls
TZ                       ip-up                    resolv.conf              spool
dhcp.leases              log                      resolv.conf.auto         usr
helloworld_1_mipsel.ipk  net                      run
root@OpenWrt:~# ipkg install helloworld_1_mipsel.ipk
Installing helloworld (1) to root...
Configuring helloworld
Successfully terminated.
root@OpenWrt:~# 
	

The executable has now been installed into the /bin directory on the router, per our instructions in the OpenWrt Makefile listed above. So, all we have to do to run the program is type “helloworld” at the prompt. Note that because the executable has been installed to the /bin directory you should be able to execute the program no matter what directory you are in on the router.

root@OpenWrt:~# helloworld
Hell! O' world, why won't my code compile?

root@OpenWrt:~# 
	

It works! Great success!

 

Now that you have a simple program compiling, you can start expanding on it to do whatever you want. If you run into problems I suggest you browse existing package Makefiles to see if someone else has done something similar to what you are trying to do. You can browse the files for these packages here. If you still have problems, browse the posts on the developer forum to see if anyone else has had a similar problem. If not, post your problem to the forum with a detailed explanation of what you’re trying to do, your OpenWrt Makefile and the errors you’re getting. Hopefully, some experienced developer will be kind enough to help out. Please do not email me personally if you have a problem with your code. If, however, you believe there is an error or serious omission in this tutorial, please let me know. I am relatively new to working with OpenWrt and it is certainly possible that I’ve made a mistake somewhere in this document. I have, however, personally tested all code included here on my own setup, and made every effort to be as accurate as possible.

Good luck with your programming!

Part II: C++ and the Standard Template Library (STL)

If you only want to compile C programs, the first part of my tutorial should be enough to get you started. However, if you want to use C++ there is another issue you’re likely to run into. Let’s say we want to compile the following C++ program for OpenWrt:

~/OpenWrt-SDK-Linux-i686-1/package/helloworld/src/helloworld.cpp:

/****************
* Helloworld.cpp
*****************/
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s = "Hell! O' world, why won't my c++ code run?\n\n";
	cout << s;
	return 0;
}
	

So, let’s do exactly as we did before and see what happens. We just have to update the compiler flags in the Makefile to indicate that we’re using a C++ compiler instead of a C compiler, right?

~/OpenWrt-SDK-Linux-i686-1/package/helloworld/src/Makefile:
NOTE: This code will compile but not run, further modifications are needed which are described below

# build helloworld executable when user executes "make"
helloworld: helloworld.o
	$(CXX) $(LDFLAGS) helloworld.o -o helloworld
helloworld.o: helloworld.cpp
	$(CXX) $(CXXFLAGS) -c helloworld.cpp

# remove object files and executable when user executes "make clean"
clean:
	rm *.o helloworld
	

If you use the exact same OpenWrt Makefile as before, this program will compile just fine. It will even install properly when you copy the helloworld_1_mipsel.ipk file to the router and type “ipkg install helloworld_1_mipsel.ipk” However, watch what happens if you try to run the program:

root@OpenWrt:~# helloworld
helloworld: can't load library 'libstdc++.so.6'
root@OpenWrt:~#
	

So, what went wrong? The problem is that this program uses strings and iostreams which are a feature of the C++ standard template library (STL). However, because memory is so critical in an embedded application like OpenWrt, the standard template library is not available. Instead, we need to link to a special implementation of the standard library for embedded devices called uClibc++. This library implements the same functions and data structures as the standard library but takes up less memory.

Before we adjust our Makefiles to use to this alternate library, let’s first make sure that it’s installed on the router so that it is available to link to. Log into your router. Then, make sure your list of packages is up to date by using the “ipkg update” command:

root@OpenWrt:~# ipkg update
Downloading http://downloads.openwrt.org/backports/0.9/Packages
Updated list of available packages in /usr/lib/ipkg/lists/0.9-backports
Downloading http://download2.berlios.de/pub/xwrt/packages/Packages
Updated list of available packages in /usr/lib/ipkg/lists/X-Wrt
Downloading http://downloads.openwrt.org/whiterussian/packages/Packages
Updated list of available packages in /usr/lib/ipkg/lists/whiterussian
Downloading http://downloads.openwrt.org/whiterussian/packages/non-free/Packages
Updated list of available packages in /usr/lib/ipkg/lists/non-free
Successfully terminated.
root@OpenWrt:~# 
	

Once you have updated your package list, install uclibc++ by typing “ipkg install uclibc++” If you do not have uclibc++ installed this should install it:

root@OpenWrt:~# ipkg install uclibc++
Installing uclibc++ (0.1.11-2) to root...
Downloading http://downloads.openwrt.org/whiterussian/packages/uclibc++_0.1.11-2_mipsel.ipk
Configuring uclibc++
Successfully terminated.
root@OpenWrt:~# 
	

Otherwise, if the library is already installed, you’ll see this confirmation:

root@OpenWrt:~# ipkg install uclibc++
Package uclibc++ (0.1.11-2) installed in root is up to date.
Nothing to be done
Successfully terminated.
root@OpenWrt:~# 
	

Now it’s time to modify the Makefiles. First, the one in the src directory. Only a small change is necessary here, to the line where we link the objects together. We need to be able to tell the linker to link to another library, and the way we do that is by defining a variable called $(LIBS). The variable will be defined in the special OpenWrt Makefile, but will be used here, so we need to add it to the end of the line which specifies how to do the linking:

~/OpenWrt-SDK-Linux-i686-1/package/helloworld/src/Makefile:

# build helloworld executable when user executes "make"
helloworld: helloworld.o
	$(CXX) $(LDFLAGS) helloworld.o -o helloworld $(LIBS)
helloworld.o: helloworld.cpp
	$(CXX) $(CXXFLAGS) -c helloworld.cpp

# remove object files and executable when user executes "make clean"
clean:
	rm *.o helloworld
	

The OpenWrt Makefile needs a slightly more complex modification. Recall the comment I placed in the OpenWrt Makefile we used before, “We do not need to define Build/Configure or Build/Compile directives. The defaults are appropriate for compiling a simple program such as this one.” Well, guess what? In order to link to uclibc++ we need to customize how we’re going to compile the program, and we’re going to do this in the Build/Compile directive. Before we re-define this directive to suit our purposes, let’s see what the default looks like:

TAKEN FROM: ~/OpenWrt-SDK-Linux-i686-1/include/package.mk:

define Build/Compile/Default
	CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) " \
	LDFLAGS="$(EXTRA_LDFLAGS) " \
	$(MAKE) -C $(PKG_BUILD_DIR) \
		$(TARGET_CONFIGURE_OPTS) \
		CROSS="$(TARGET_CROSS)" \
		CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) " \
		ARCH="$(ARCH)" \
		$(1);
endef
	

This code specifies the make command (the third line) and a bunch of flags and parameters for compilation. In order to link to uClibc++ we add the definition of the $(LIBS) variable as “-nodefaultlibs -lgcc -lc -luClibc++” Also, we need to specify “-nostdinc++” in the compiler flags to tell the compiler that c++ standard template library functions and data structures will be linked to in specified external libraries and not the standard libraries:

~/OpenWrt-SDK-Linux-i686-1/package/helloworld/Makefile:

##############################################
# OpenWrt Makefile for helloworld program
#
#
# Most of the variables used here are defined in
# the include directives below. We just need to 
# specify a basic description of the package, 
# where to build our program, where to find 
# the source files, and where to install the 
# compiled program on the router. 
# 
# Be very careful of spacing in this file.
# Indents should be tabs, not spaces, and 
# there should be no trailing whitespace in
# lines that are not commented.
# 
##############################################

include $(TOPDIR)/rules.mk

# Name and release number of this package
PKG_NAME:=helloworld
PKG_RELEASE:=1


# This specifies the directory where we're going to build the program.  
# The root build directory, $(BUILD_DIR), is by default the build_mipsel 
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)


include $(INCLUDE_DIR)/package.mk



# Specify package information for this program. 
# The variables defined here should be self explanatory.
define Package/helloworld
	SECTION:=utils
	CATEGORY:=Utilities
	TITLE:=Helloworld -- prints a snarky message
	DESCRIPTION:=\
	If you can't figure out what this program does, \\\
	you're probably brain-dead and need immediate \\\
	medical attention.
endef


# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default.  The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)/
endef



#########################################################################################
# The Build/Compile directive needs to be specified in order to customize compilation
# and linking of our program.  We need to link to uClibc++ and to specify that we 
# do NOT want to link to the standard template library.
#
# To do this we define the LIBS variable.  To prevent linking to the standard libraries we 
# add "-nodefaultlibs" to the $(LIBS) variable and then specify "-lgcc -lc" to ensure that 
# there are no unresolved references to internal GCC library subroutines. Finally 
# "-luClibc++" to link to the  uClibc++ library.  Also, we need to specify "-nostdinc++" 
# in the compiler flags to tell the compiler that c++ standard template library functions
# and data structures will be linked to in specified external libraries and not the 
# standard libraries.
#########################################################################################
define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR) \
		LIBS="-nodefaultlibs -lgcc -lc -luClibc++" \
		LDFLAGS="$(EXTRA_LDFLAGS)" \
		CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) -nostdinc++" \
		$(TARGET_CONFIGURE_OPTS) \
		CROSS="$(TARGET_CROSS)" \
		ARCH="$(ARCH)" \
		$(1);
endef


# Specify where and how to install the program. Since we only have one file, 
# the helloworld executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running 
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install 
# directory if it does not already exist.  Likewise $(INSTALL_BIN) contains the 
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/helloworld/install
	$(INSTALL_DIR) $(1)/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef


# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.
$(eval $(call BuildPackage,helloworld))
	

That’s it! That modification should be sufficient to enable linking to uClibc++. Compile it as before, copy the .ipk file to the router, install it with ipkg and run it:

mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ make clean
rm -rf build_* bin
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ make
make package/compile
make[1]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1'
Collecting package info...
make -C package compile SDK=1
make[2]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[2]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[2]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[4] -C package compile-targets
make[5] -C package/helloworld compile
make[2]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[1]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1'
( \
        cd package; \
        find . -maxdepth 2 -name Config.in | \
                sed -e 's,/Config.in,,g' | \
                xargs -r -n1 make compile -C; \
)
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ scp bin/packages/helloworld_1_mipsel.ipk root@192.168.1.1:
root@192.168.1.1's password: 
helloworld_1_mipsel.ipk                                                100% 2570     2.5KB/s   00:00    
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ ssh root@192.168.1.1
root@192.168.1.1's password: 


BusyBox v1.00 (2007.01.30-11:42+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 WHITE RUSSIAN (0.9) -------------------------------
  * 2 oz Vodka   Mix the Vodka and Kahlua together
  * 1 oz Kahlua  over ice, then float the cream or
  * 1/2oz cream  milk on the top.
 ---------------------------------------------------
root@OpenWrt:~# ipkg install helloworld_1_mipsel.ipk
Installing helloworld (1) to root...
Configuring helloworld
Successfully terminated.
root@OpenWrt:~# helloworld
Hell!  Why won't my c++ code run?
root@OpenWrt:~# 
	

It works! Our Jedi programming skills have prevailed!

Once again, please do not contact me about any issues you might have with your own programs. If, however, you think there is an error in one of my examples or that I have omitted a critical detail, please contact me and I will try to resolve the issue as soon as possible.

This tutorial is provided under the Creative Commons License, version 3.0.

Source: Writing and Compiling A Simple Program For OpenWrt

Error 1068 When Starting WZC – Tech Support Forum

Filed under: Uncategorized — manoftoday @ 3:41 am

 

Today I became aware that my computer also had this problem (HP dv100 with Intel (R) Pro/Wireless Adapter), so I did an extensive search on the internet to get it to work (including this post).
As you mention it, if you try to start the WZCSVC service in the MMC, an error code appears referring to its parent services appears (1068, this parent services are Remote Procedure Call and something called NDIS Protocol [I have no idea what this is… ¬¬]). So, if you check the RPC service, it must be enabled (system essential), but you cannot find the other “service”.
I have also seen answers referring to disabling any 3rd Party Wireless Management Software (but I don’t have one, so it cannot be that).
However, I did find such Protocol Service in the regedit, and I found out it was disabled (it was set to 4). So, in sum, I recommend you to go to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Ndisuio
and check that the “Start” Value is set to 1, 2 or 3 (I set it to 1).
And this solved my problem, after a System Restart the Wireless Zero Config Service can be readily started.
Note: today I found a couple of Win32 Trojan and Worms and a fake service called DirectX.exe, located on the System Directory and considered as a Blaxe and LogPole Virus o_O (I already got rid of it). Maybe they had something to do with this problem.
I hope this works for you, and if it does, there are many posts on other forums related to this, maybe you can spread the info.

Source: Error 1068 When Starting WZC – Tech Support Forum

October 10, 2007

Tunneling trafiic over SSH with OpenWRT, DynDNS and Putty

Filed under: Uncategorized — manoftoday @ 12:57 am

 

1)  Tunneling HTTP over SSH

To connect to the SSH server and tunnel HTTP you will need the Putty SSH client.

To connect to your router enter the hostname or IP address of your router on the Session tab:



Next, to setup the tunnel.  click on Tunnels, enter 3000 (or whatever local port you’d like to use) for the source port, click Dynamic and click Add. This will create a SOCKS proxy on your local machine on port 3000 (or whatever port your chose) that you can use with your web browser.

Now you can click Open to log into your router. The tunnel isn’t created until you log in. Remember that your username is root and your password is your router password (you changed it right?).

Now you’re ready to connect your web browser. Using Firefox, you will have to configure a proxy server. Click Tools->Options->advanced. Then under Network tab, click on Settings… button . On the popup window screen, you can configure the SOCKS proxy that you’ve set up using Putty. Select Manual proxy configuration, enter localhost for the SOCKS host and 3000 for the port (or whatever you used). Click OK. You should now be tunneling through your home router over ssh.  after the setting, you have to close ALL OPENED firefox windows and restart Firefox to make it effect.

 

You can verify that the connections are being forwarded by looking at the Putty Event Log. You should see something similar to the following after loading www.google.com in your web browser.

or verify by closing the putty session, then you won’t be able to view any webpage.

 

Source: Random Bits: HOWTO: Tunneling HTTP over SSH with DD-WRT, DynDNS and Putty

2)  Tunneling VNC over SSH

       https://manoftoday.wordpress.com/2006/10/07/putty/

 

3)  Tunneling RemoteDesktop over SSH

Configure PuTTY for auto-login (if you choose to use PuTTY):

suppose sshd is on port 22 in your wireless router which has OpenWrt.

open putty

- type in your dyndns ip address of your router
- choose port 22
- connection -> SSH -> Tunnels
- source Port: 127.0.0.2:3390  <--- NOTE here, mstsc can't connect to 127.0.0.1, so we have to use 127.0.0.2
- Destination -> ip_address_of_your_home_PC_Server_behind_OpenWrt:3389   (if remote desktop is used)
- press add
- open the connection to your router
- if you don't have free internet access, you can use also a proxy server to connect.
- if proxy is needed: connection -> proxy
- proxy type: http
then run windows terminal service client: mstsc , and connect to 127.0.0.2:3390

in the following example, home windows server is running at 192.168.1.8 with both windows terminal service running at port 3389(default) and VNC services at 5900(default)

 
 

4)  Configure PuTTY for auto-login

Configure PuTTY for auto-login (if you choose to use PuTTY):

  1. Make a shortcut to putty.exe on your Desktop
  2. Right click the shortcut, Properties > Shortcut tab > Target field
  3. Add the following to the end of the string in the field: -load “[your profile name]” -l [login name] -pw [password]
  4. Example: -load “home” -l Mark -pw mypassword
Older Posts »

Create a free website or blog at WordPress.com.