1. 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

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

  3. 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

  4. 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

  5. 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

  6. Vim Ctrl-P Plug-in

    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 …

    More

  7. Python New Style Class

    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 …

    More

  8. A Quick Guide to Grunt

    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 …

    More

  9. JavaScript Prototype and Object Oriented

    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 …

    More

  10. Read Lines from stdin in Node.js

    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 …

    More

« Prev Page 2 / 7 Next »