How to harness company’s resource?

As an employee, it is no doubt that we should spare no effort to contribute to your employer since it pays us salary. But at the same time, we should also consider how to utilise the company’s resource to enrich ourselves. After all, only if we become more competent and brilliant, the company can benefit more from us, and this will be a definitely win-win situation. In this post, I will illuminate how to take advantage of company’s “hardware” and “software” resource.

(1) “Hardware resource”: The company has many equipments and devices which the single person can’t afford. During my work in Aicent, we have servers embedded with SPARC processor. X86 processor is ubiquitous whilst SPARC is not so common, so I have a very precious opportunity to learn about this RISC architecture: its instruction set, register window, etc. Another example is in HP/HPE, where I can harness the best servers in this world, this is a really amazing experience! As my manager said, the intranet has all the materials about HP/HPE server, and no one has said you can’t learn it. So whether exploit this treasure or not totally depends on yourself.

(2) “Software resource”: Without working in the same company, you may not recognize your current colleagues, so please cherish this luck. You should always try to “steal” knowledge from your partners. For example, A previous HP/HPE fellow is an expert in Linux, and we has the cooperation in a performance tuning task. During the whole work, I tried my best to learn many skills in profiling and taming Linux from him, and the gain still take effect to date. The other instance is many companies may provide training or online courses. So grab these chances!

Hope everyone can fulfil his own work and improve yourself at the same time! Good luck!

The tips of using and debugging C++ std::iostream

(1) Be cautious of '\n' and std::endl.

The std::endl will flush the output buffer while '\n' not. For example, in socket programming, if client sends message to server using '\n', like this:

out << "Hello World!" << '\n';
out << "I am coming" << '\n';

The server may still block in reading operation and no data is fetched. So you should use std::endl in this case:

out << "Hello World!" << std::endl;
out << "I am coming" << std::endl;

(2) Use std::ios::rdstate.

std::ios::rdstate is a handy function to check the stream state. You can use it in gdb debugging:

(gdb) p in.rdstate()
$45 = std::_S_goodbit
(gdb) n
350             return in;
(gdb) p in.rdstate()
$46 = std::_S_failbit

Through step-mode, we can see which operation crashes the stream.

(3) Serialize the data into file.

No matter you want to do test or debug issue, dump the data into a file and read it back is a very effective method:

std::ofstream ofs("data.txt");
ofs << output;
ofs.close();

std::ifstream ifs("data.txt");
ifs >> input;
ifs.close();

The above simple code can verify whether your serialization functions are correct or not. Trust me, it is a very brilliant trouble-shouting std::iostream issue trick, and it saved me just now!