Archive for the ‘Code’ Category

Hou, a simple toolkit for Node.js

For the purpose of providing a web service to a Node.js project to users, we may require a small middleware to start an HTTP service to handle the HTTP requests.

Read more

Increase the maximum upload file size for WordPress

The default file upload size is 2M.

If we are supposed to increase the size, a few update would be required.

Read more

Find all the Chinese characters in TextMate

If we wish to find all the Chinese characters in our TextMate, a simple way is use our regex.

Read more

SVMlight format

SVMlight is an implementation of Support Vector Machines (SVMs) in C. The author Thorsten Joachims designed a special input format to represent training/test data. It is also widely used by a lot of other programs.

Here is a brief introduction of the input format.

Read more

SSH port forwarding

SSH port forwarding is a mechanism in SSH for tunneling application ports from the client machine to the server machine, or vice versa.

If we wish to visit a port in remote but behind the firewall, we can use SSH port forwarding to bind that port into local.

Read more

A Cheat Sheet Regarding to System Maintenance

This post lists a few examples to check the status of your system in macOS and Linux

Read more

Invoke sudo access to one user/group without password

sudo allows a system administrator to delegate authority to give certain users—or groups of users—the ability to run commands as root or another user while providing an audit trail of the commands and their arguments. It plays a vital role in user controlling. Read more

How to synchronize your customized keymap

In general, we can click File->Export Settings to export your configuration from one application belong to another belong to JetBrain. If we have multiple workspace distributed in our laptop and PC in our lab, we can even use some plugin like Settings Repository to synchronize the configurations automatically. Read more

Normalize the cache directory for bazel

According to the doc from the official doc

The outputRoot directory is ~/.cache/bazel. (Unless $TEST_TMPDIR is set, as in a test of bazel itself, in which case this directory is used instead.)

However, if you are in a macOS, it is not true. Read more

Three Approaches to Pass Uncertain Number of Variables in C++

Sometimes, we are supposed to accept uncertain number of arguments in C++.

In this post, I am going to introduce 3 ways to implement it, so that you can pick up one of them which is most fit for you in current situation.

Read more

SIGR: Yet Another Simple SIGnal manageR

Signal plays an important role in communication with POSIX system.

For example, what if our code been killed, interrupted, hung on? Generally, the operation system (I am talking about BSD, Unix-like, POSIX system, same in the follow but will omitted), will not really "KILL" it, it will just send a kill signal with id to this process, the this process will process this signal later.

Here is a table to describe the id to default action.

Read more

shared_ptr, unique_ptr and weak_ptr

shared_ptr, unique_ptr and weak_ptr are three useful smart pointers that holds a reference which will help us managing our pointers easier.

Read more

Multilib version problems found in CentOS

Recently, when I ran "yum update" for some update, which will get an error as follow:

--> Processing Dependency: libstdc++.so.6 for package: pcre-8.32-17.el7.i686
---> Package zlib.i686 0:1.2.7-17.el7 will be installed
--> Running transaction check
---> Package libcap-ng.i686 0:0.7.5-4.el7 will be installed
---> Package libstdc++.i686 0:4.8.5-16.el7 will be installed
--> Finished Dependency Resolution
Error:  Multilib version problems found. This often means that the root
       cause is something else and multilib version checking is just
       pointing out that there is a problem. Eg.:

         1. You have an upgrade for libstdc++ which is missing some
            dependency that another package requires. Yum is trying to
            solve this by installing an older version of libstdc++ of the
            different architecture. If you exclude the bad architecture
            yum will tell you what the root cause is (which package
            requires what). You can try redoing the upgrade with
            --exclude libstdc++.otherarch ... this should give you an error
            message showing the root cause of the problem.

         2. You have multiple architectures of libstdc++ installed, but
            yum can only see an upgrade for one of those architectures.
            If you don't want/need both architectures anymore then you
            can remove the one with the missing update and everything
            will work.

         3. You have duplicate versions of libstdc++ installed already.
            You can use "yum check" to get yum show these errors.

       ...you can also use --setopt=protected_multilib=false to remove
       this checking, however this is almost never the correct thing to
       do as something else is very likely to go wrong (often causing
       much more problems).

       Protected multilib versions: libstdc++-4.8.5-16.el7.i686 != libstdc++-4.8.5-11.el7.x86_64
Error: Protected multilib versions: libgcc-4.8.5-16.el7.i686 != libgcc-4.8.5-11.el7.x86_64
Error: Protected multilib versions: pcre-8.32-17.el7.i686 != pcre-8.32-15.el7_2.1.x86_64
Error: Protected multilib versions: elfutils-libelf-0.168-8.el7.i686 != elfutils-libelf-0.166-2.el7.x86_64
Error: Protected multilib versions: libcap-2.22-9.el7.i686 != libcap-2.22-8.el7.x86_64
Error: Protected multilib versions: libdb-5.3.21-20.el7.i686 != libdb-5.3.21-19.el7.x86_64
Error: Protected multilib versions: libgcrypt-1.5.3-14.el7.i686 != libgcrypt-1.5.3-13.el7_3.1.x86_64
Error: Protected multilib versions: elfutils-libs-0.168-8.el7.i686 != elfutils-libs-0.166-2.el7.x86_64
Error: Protected multilib versions: nss-softokn-freebl-3.28.3-8.el7_4.i686 != nss-softokn-freebl-3.16.2.3-14.4.el7.x86_64
Error: Protected multilib versions: libselinux-2.5-11.el7.i686 != libselinux-2.5-6.el7.x86_64

Read more