Category Archives: Programming

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

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

Python Hacking – urlopen timeout issue

Recent playing with Python urllib2 reveals an interesting fact that the timeout parameter of urlopen() does not work sometimes. The interesting issue has successfully pushed me deep into the Python source code for debugging. The final debugging, without surprise, shows … Continue reading

Posted in Programming, Stuff about Compiler | Tagged , , , , , , | 4 Comments

Hack Go – generate non-FIPS DSA key parameters using hacked Go compiler

Common DSA key parameter generation follow FIPS 186-3, which requires (L, N) bits length for P and Q, where L is at least 1024 and N is at least 160. However, sometimes we may want non-FIPS (L, N), for example, … Continue reading

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

byte order – Linux kernel byte order APIs

Most of the time, user-space applications do not care about the endian of the running machine, like we call send() and recv() directly expecting the right order of the data and they work! However, things could be changed if you … Continue reading

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

ksig – sending signals from the kernel space to the user space

While syscall kill() gives users the ability to send certain signal to certain process in the user space of Linux, the story is totally different if we want to send signals from the kernel space to the user space. After … Continue reading

Posted in Dave's Tools, OS, Programming | Tagged , , , | Leave a comment

Book Recommendation – Building Probabilistic Graphical Models with Python

“Building Probabilistic Graphical Models with Python” is the 3rd book I have reviewed from PACKT publishing. It has just been released on this June. Compared to the classic book of PGM – “PGM: Principles and Techniques” by Dr. Koller, this … Continue reading

Posted in AI/ML, Programming | Tagged , , , , | Leave a comment

Python hacking – make ElementTree support line number

An easy way to parse XML in Python is using Python xml.etree.ElementTree, which parses the XML document/data into a tree structure, where each node is an Element object. Only within few lines of code, one can extract all the XML … Continue reading

Posted in Programming | Tagged , , , , | 16 Comments

crypto – use Linux kernel crypto API

Crypto is an important part of the Linux kernel source code. One can tell from the standalone crypto directory under the kernel source tree. Device drivers, file system and security all need crypto. This post does not help understand the … Continue reading

Posted in OS, Programming, Security | Tagged , , , , , | 2 Comments