After eight years of development, my patch implementing a RISC-V JIT backend for PyPy was merged upstream in 2024. This work is now included in the PyPy v7.3.17 release in this August. To share my journey and my insights, I decided to write this article. A brief introduction …
In Django, One-to-Many relations are modeled by the ForeignKey . Under some circumstances, we may wish to collect some information (e.g. count , min , max , avg , etc) from related objects. For example, in a blog app, we may wish to build a table which lists the title and the number of …
Schroot allows users to switch between different Linux distributions or releases conveniently. As a software developer, I have to test software between different Debian and Ubuntu releases. Schroot perfectly fits my use case. Besides, schroot has good balance between isolation and convenience . By default, it will mount the home directory …
qemu-user-static is an important tool for cross-architecture developers. It allows developers to create a chroot environment and run the cross-compiled programs. For example, a developer may run an AArch64 executable without the overhead of system-level emulation. I usually install the qemu-user-static binaries from Ubuntu apt repository. However, I encountered some …
Two weeks ago, I came across an interesting bug. The convert() function below returns 0x80000001 when p points to 0x01 , 0x00 , 0x00 , 0x80 , but the expected return value is 0x00000001 instead. int32_t convert ( const uint8_t * restrict p ) { uint32_t x = ( p [ 0 ] + 256 * p [ 1 ] + 256 * 256 * p [ 2 ] + 256 * 256 …
POSIX shared memory is an inter-process communication (IPC) mechanism defined in POSIX specification. After setting up the shared memory, two (or more) processes may read from and write to the shared memory region. Compared to other IPC mechanisms (e.g. pipe, socket, etc), POSIX shared memory does not impose copy …
Django has several PostgreSQL database functions to support full-text search. If you are using PostgreSQL as the database backend, then it is easy to add full-text search to your Django app. In this post, I would like to build an demo app with full-text search. This post covers several PostgreSQL-specific …
User-mode QEMU translates the instructions and the system calls. To run a static executable , you may wrap the command line with qemu-${arch} . For example, you may wrap an ARM64 static executable with qemu-aarch64 : $ qemu-aarch64 /path/to/static-executable However, running a dynamically linked executable requires more efforts. To run a …
Counters are common in website development. Most websites collect the number of page views with counters. E-commerce websites keep track of the quantity of a commodity with counters. However, it is hard to implement a correct counter with Django ORM . In this post, I would like to cover three ways …
My dynamic IP address, which is provided by my ISP, seems to be blocked by Freenode (because it is easy for us to get another IP.) According to the error message, I should connect and login with SASL . It took me a while to figure out a solution, thus I …
Recently, I was tracing the source code of PyPy , and a special decorator named property caught my attention. It seems to be a mechanism for Python programmers to create a getter, a setter, and a deleter for an instance variable. For example, how could we intercept the access to a …
I have been a Vim user for a long time. However, I found that Vim is not good enough for me to write blog with Pelican. I need a good reStructuredText previewer, but I am not very satisfied with InstantRst . I wish to have a two-panel editor that I can …
I came across a weird line in a shell script: : ${ parameter :=word } It is so weird that I don't even know how to search for further information. Fortunately, I found a post after searching bash colon . It is a built-in utility which simply exits with 0. In the other words …
In a shell script, file descriptor 0 stands for stdin , file descriptor 1 stands for stdout , and file descriptor 2 stands for stderr . In addition, programmers can open , close , or duplicate file descriptors with the exec built-in command and the I/O redirection operator: Syntax Description exec $fd< "${filepath}" Open …
In Javascript, we can add a property to an object with: obj . property = value ; However, sometimes we would like to have fine-grained control over properties. With Object.defineProperty() , we can decide: Descriptor Purpose Default value Property value undefined writable Whether the property can be assigned false get Getter of the …
NPM package manager plays an important role in Node.js ecosystem. Every serious Javascript developers should learn how to create a package with npm . In this post, I am going to cover several important npm commands. Initialize a NPM Package To start a project, we have to create package.json …
Under some scenarios, we would like to push a message from an HTTP server to clients. For example, in a group messaging application, whenever a user sends a message to the server, the server has to push such message to everyone. Since 2001, several techniques have been proposed. Eventually, WebSocket …
Ctrl-P plug-in allows us to open files with fuzzy names or regular expression matches. It boosts my productivity at lot! I am glad to know about this plug-in and I would like to share my experience with you. Installation If you are managing Vim plug-ins with Vundle [1] , you can …
Recently, I am curious about this code snippet: class Test ( object ): def __init__ (): pass Why do we have to extend or inherit from object type? There are no differences with or without (object) in Python 3. But there are significant differences in Python 2. If a class inherits (either directly …
Grunt is a task runner for Javascript development. Grunt automates the process to bundle, transpile, uglify, and compress the Javascript source code. This post would like to give a quick guide to Grunt . Installation Our first step is to create a package.json . We will need a package.json to …
Javascript is a prototype-based object-oriented programming language. Unlike the conventional class-based object-oriented programming languages (e.g. C++ or Java), which ask programmers to write a class and then instantiate several similar objects from the class, Javascript adopts a different approach. In the world of Javascript, we have to craft a …
It is easy to write a hello world program in Node.js: console . log ( "Hello world!" ) However, due to the asynchronous nature of Javascript, reading inputs and writing outputs are less straight-forward. We have to pass the callback functions or register event listeners. First Attempt For example, to read some …
It is common to organize the code in several modules when we are developing Javascript applications. In Node.js ecosystem, we can import a module with the require() function and export symbols by adding them to the module.exports object. On the other hand, ES2015 adds import statements and export …
ECMAScript 2015 (also known as ES2015 or informally ES6) is the latest standard for JavaScript. It has been released for a while. However, V8 , the JavaScript engine for Node.js , has only limited ES2015 support. As of writing, according to ECMAScript 6 compatibility table , the feature coverage of each Javascript …
I would like to launch ssh-agent and add my private key at the beginning of my shell script and stop it before leaving the shell script. How do I guarantee that ssh-agent will be shutted down properly? What will happen if the user press Ctrl-C or even kill the shell …
Several months ago, I wrote a post to describe how to setup an autossh daemon with upstart . Since Ubuntu 15.04 has switched to systemd , I would like to do the same with systemd . I will give a brief introduction to systemd in this post. Systemd Unit File Systemd services …
I have a clean Ubuntu 15.10 installation these days. However, I noticed that video thumbnails (or previews) do not show up in Gnome Nautilus : I prefer thumbnails to icons. Besides, I remember that Nautilus will generate a thumbnail for each video in Ubuntu 14.04. Thus, I took some …
GDB is a powerful debugger. Without a doubt, we can debug multi-threaded programs with gdb . In particular, we can switch between threads, inspect the stack, and dump the registers. In this post, I would like to start with the Dining Philosophers Problem , which was first coined by Edsger Dijkstra . Here …
Discourse is a new generation discussion forum. I found that Discourse is very suitable for personal note taking. One notable feature of Discourse is that the users can focus on conversations. Besides, it supports Markdown as the message markup language. This is the reason why I like it very much …
There are some files that shouldn't be tracked by Git at all. For example, the temporary files created by the text editors, the Python bytecode, and etc. How could we ignore those files? In the previous post , I have mentioned that we can create a .gitignore file and list the …
Although I have written Python for several years, I am still not very familiar with its idioms. In particular, I don't quite understand how to compare and sort the objects in Python. That's the reason why I am writing this article. The rest of this article consists of following sections …
I got an Android Nexus 7 (2013, Wi-Fi) device a short while ago. I attached the device to my computer and tried to list the devices with adb devices command. But, unfortunately, I got the following error message: $ adb devices List of devices attached ???????????? no permissions In the following of …
Recently, the Linux operating system on my laptop no longer boots. It seems that the boot sector for GRUB bootloader is corrupted. I tried to reinstall GRUB with an Ubuntu LiveCD; however, I have encountered some problem related to Btrfs file system (which is the file system for my root …
Code coverage is a metric to show the code being untested. It can be considered as a hint to add more test cases. When we are writing C/C++, the most notable code coverage testing tool is gcov , which is a GCC built-in coverage testing tool. Besides, we can collect …
Ctags is a source code indexing tool. With ctags , we can easily find the definitions of the classes, functions, and variables. According to my experiences, ctags can significantly reduce the time to browse the source code. In this post, I would like to give a brief introduction to ctags and …
In some circumstances, we would like to ignore the files (or directories) under the Git repository base directory. How could we do this? For example, assume that we have a Git repository with following files: out/bin/conv preprocessed/out/gen-case1.h preprocessed/out/gen-case2.h preprocessed/input.txt conv …
I used to download the large files with wget because I can simply resume the download tasks with -c option. This option will check the size of the output file, and download the rest of the file from the server. I can even restart the download task with a different …
C++11 introduced three new smart pointer class templates : std::unique_ptr , std::shared_ptr , and std::weak_ptr . These smart pointer class templates are designed to replace the old std::auto_ptr smart pointer, which is known to have some defect and deprecated now. In this post, I would like to give a …
Today I have encountered a problem: Given that there are multiple equivalent keys in an instance of std::multimap , how could we list all of the corresponding values? For example: #include <map> #include <iostream> int main () { std :: multimap < int , int > xs ; xs . insert ( std :: make_pair ( 1 , 12 )); xs . insert ( std …
Waliki is a simple wiki app for Django . We can write wiki contents with reStructuredText and the contents will be stored in a Git repository. In this post, I would like to introduce the instructions to install Waliki . Getting Started First, install the related Ubuntu packages: $ sudo apt-get install git …
The Python package manager pip is a tool to manage the installed site packages. With pip , we don't have to be worried about the package dependencies anymore. pip will download the required packages from Python Package Index automatically. Install Packages To download and install the packages from Python Package Index …
It's the end of 2014. It has been an amazing year with a lot of astonishing moments! This is my first year to work as a full-time software engineer . I have learned a lot from the real world software development, including the PMD, annaul planning, software schedule estimation, and etc …
It is well-known that Debian stable release is very stable , i.e. the packages are very old and well-tested. However, this become a problem to me. Since Git 1.9, we have to run the following command to silence a warning when we are running git push . $ git config --global …
How to count the number of trailing zeros of an integer? The simplest way is to use the built-in function __builtin_ctz() : uint64_t count ( uint64_t n ) { return __builtin_ctz ( n ); } What will happen if we don't have __builtin_ctz() ? If we have another built-in function __popcount() , which can compute the Hamming weight (the …
RISC-V is an instruction set architecture (ISA) released by UC Berkeley. Besides, a high performance, power efficient, and royalty-free open source implementation Rocket Chip is available. RISC-V was developed by Krste Asanović and David A. Patterson. In their technical report , they claimed that an open instruction set can benefit both …
Since I am sharing the network without public IP, I would like to maintain a SSH tunnel so that I can connect to my desktop from the remote site. After searching the web, I found that Autossh fits my needs. Autossh is a utility that can start and monitor the …
I came across the LLVM obfuscator today. It is a code obfuscator working mostly on LLVM IR level. This means that most LLVM supported target platforms are supported by the LLVM obfuscator as well. Also, I have also read an article which mentioned how to disassemble and deobfuscate the binaries …
It is a well-known idiom to define a virtual destructor for the classes with virtual functions. If we don't define a virtual destructor, then the base class destructor will be invoked when you are deleting the object through the base class pointer even if the object is an instance of …
In this post, I would like to introduce the bugpoint command line tool. This is a automatic test case reduction tool which can help us generate minimal test case. As a compiler developer, the first step to debug is to create a minimal test case which can still reproduce the …
In the past, I didn't like to install the Vim plug-ins or new syntax highlight because all of the files were messed up in the .vim directory which makes it difficult to uninstall a plug-in. Recently, I have come across with Vim Vundle . It is a vim plug-in manager which …