How to terminate a C++ std::thread?

In C++11, C++ introduced built-in support for threads std::thread. Since then, starting a new thread in C++ is as easy as defining an object. However, dynamically terminating a running C++ thread is still very tricky, especially for the joined/detached thread. There are plenty of discussions of this topic, and the conclusion is that

My First Taste of Computational Stock Analysis

Just like many people, I also own a very limited number of stocks. Although I tried my best to massage my portfolio(based on my guess, feeling and luck) last year, its year-end return was only about 3.5%. Compared to the S&P500’s 12% return, the poor performance shocked me. So I decided to study some formal computational stock analysis techniques. This post is the summary of what I learnt and developed. For the complete code, please refer to stock_analysis in my Github.

Python - Run Command With Timeout

This post introduces a Python class Command that can run a shell command with a time limit - the command will be killed after timer expires. This is implemented by threading and subprocess modules.

Shared-memory Based Ring Buffer

This post explains how to implment a ring buffer that can be shared between multiple processes. For the simplicity and efficiency, shared memory is used to store the ring buffer. A read/write lock is also developed to sync the inter-process buffer read/write operations. The source code can be found on my GitHub channel.

Coredump Decode

This is a summary of decoding Linux userspace process corefiles using GDB. For how to enable coredump in Linux, please refer to HOWTO enable core-dumps.

Generate Wireshark-Understandable Hexdump

When debugging network packets in Click, usually the packets are printed to screen as hex string:

A Complete Guide For Installing TFTP Server In CentOS 7

Since CentOS 7(or RedHat 7) is quite different from CentOS 6.x, most notes online for installing TFTP server in CentOS are obsolete already. This post not only summarizes the procedure of installing & configuring TFTP server, but also introduces a general strategy of configuring network services in CentOS 7.

How To Use Local Facilities For Logging?

This post introduces how to configure and use syslogd-compatible syslog tools. These tips should be supported by rsyslog, but rsyslog-specific commands are not covered.

Retrieve Last Log After Crash

In Linux, there are two kinds of crashes - kernel panic/oom and user space core dump. For kernel panic, the standard config is rebooting the system. Unfortunately, the panic log can only be printed to console and will disappear after reboot if there is no additional device to record the console log - most kernel panic/oom logs won’t be written to system log, and even they do, there is no way to sync them to disk storage during panic.

Customizing OpenWRT System Log Timestamp

As explained in previous post Linux System Log, threre is no way to directly change the default timestamps printed on Linux console. However, it is still possible to get human readable timestamp without using fancy syslog tools like syslog-ng.