Category Archives: Programming

Programming – C/C++, Java, Ksh, Python, ML

Pitfalls in negative indexing in C

Negative indexing in C, such as a[-1], is legit, although rarely used. There are reasons (pitfalls) why negative indexing is not recommended. This post discusses these pitfalls when using negative indexing (for fun). 1. Negative indexing within the bound In … Continue reading

Posted in Programming | Tagged , | Leave a comment

getdelays – get delay accounting information from the kernel

Top may be the most common tool in use whenever a preformance issue is hit. It is simple, quick and dumb. Besides the heavy metal stuffs like perf and gprof, another really useful and simple tool is getdelays, which provides … Continue reading

Posted in OS, Programming | Tagged , , , , , | Leave a comment

Linux kernel I/O Stack Diagram

Found this figure online. The title of this diagram may be biased as it is not the complete I/O stack but a concentration on block devices with a focus on SCSI layer. Some important missing stuffs, in my opinion, include … Continue reading

Posted in OS, Programming | Tagged , , | Leave a comment

Python Levenshtein distance – Choose Python package wisely

Brad and I were working on some text similarity computation. One of the most popular string distance functions is the Levenshtein distance, which is also called the edit distance. We use Python for its brevity and widely-library support (OK, I … Continue reading

Posted in Programming | Tagged , , , | Leave a comment

Retrieve PID from the packet in Unix domain socket – a complete use case for recvmsg()/sendmsg()

The original question was how to retrieve the PID of the packet (sender) in the Unix domain socket. As titled, the answer is recvmsg()/sendmsg(). However, the most useful information I could find online is Michael’s man7.org. People keep talking about … Continue reading

Posted in OS, Programming | Tagged , , , , , , | 1 Comment

Bash Hacking – bash2, add setting CPU affinity support to the Bash

This post is NOT initially designed for how to hack Bash. But it does tell the truth that hacking Bash is not that hard, by adding a useful feature to Bash itself – setting CPU affinity support. Have fun and … Continue reading

Posted in OS, Programming | Tagged , , , , , , | 4 Comments

Python Internals – Integer object pool (PyIntObject)

Starting from this post, I will try to make a series of blogs on Python Internals, where Python object mechanism, Python bytecode (pyc) and Python VM are gonna be discussed. We will also talk about the limited resource online about … Continue reading

Posted in Programming, Stuff about Compiler | Tagged , | Leave a comment