1. Find Undefined Behavior with Clang UBSan

    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 …

    More

  2. 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 …

    More

  3. Python Property Decorator

    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 …

    More

  4. Experience with Atom Editor

    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 …

    More

  5. Colon Built-in in Bash

    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 …

    More

  6. Open and Close Files in Bash

    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 …

    More

  7. JavaScript Object.defineProperty()

    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 …

    More

  8. NPM Package Manager

    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 …

    More

  9. Flask and Socket.IO

    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 …

    More

Page 1 / 6 Next »