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 …
-
-
Manage Chroot Environments with Schroot
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 …
-
Build qemu-user-static from source code
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 … -
Find Undefined Behavior with Clang UBSan
Two weeks ago, I came across an interesting bug. The
convert()
function below returns0x80000001
whenp
points to0x01
,0x00
,0x00
,0x80
, but the expected return value is0x00000001
instead.int32_t convert(const uint8_t *restrict p) { uint32_t x = ( p[0] + 256 * p[1] + 256 * 256 * p …
-
POSIX Shared Memory
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 …
-
Full-text Search with Django and PostgreSQL
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 …
-
Introduction to qemu-debootstrap
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 withqemu-aarch64
:$ qemu-aarch64 /path/to/static-executable
However, running a dynamically linked executable requires more efforts. To run a …
-
Django ORM and Updating Counters
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 …
-
Connect to Freenode with Irssi through SSL and SASL
-
Python Property Decorator
Page 1 / 7 Next »