Librehat's English Blog

Code can be lovely!

Install Terminus Font as A Normal User

For old Linux distributions, TrueType Fonts (TTF) are installed into $HOME/.fonts if not installed globally. As an even older practice, bitmap fonts (usually used in xterm or urxvt) installation is slightly different.

Here is my situation: - Red Hat Enterprise Linux 5 - No root priviledge - System reboots every week

As you may know, those now deprecated configuration methods are the only ways on this old system. To be honest, I never installed a bitmap font before because TTF is simply much better and eye-friendlier. But if we consider the rendering speed, of course bitmap is faster in most cases.

Anyway, take Terminus as an example since it's very popular (not my type of font). Download the latest source code from its project website and extract it. Then,

./configure --prefix=$HOME/.local
make install fontdir

Now these fonts should be installed into your home directory. Before they can be used, you need to type some commands:

xset +fp $HOME/.local/share/fonts/terminus
xset fp rehash

To preview the font, simply run xfontsel and change font family to terminus. You can also list all terminus fonts using xlsfonts | grep terminus.

You should be able to download the TTF type font of terminus, if that's the case, you need to copy them into $HOME/.fonts directory and run fc-cache -rv to refresh the cache.

Change your terminal font to a nice one before you get your eyes blind. :)

All about that GNIB Card

All non-EU people living in Ireland know how infamous the registration in GNIB is. Basically, one need to queue outside the buidling at 6~7 A.M. (and there's some people get there at 3 A.M.), then get a ticket when its door finally opens. In a peak season like recently, tickets run out at as early as 8:40 A.M.. Once you get the ticket, you'll need to wait for hours to be called to sumbit your documents, then wait for another hours to get your passport back along with a new GNIB card. The whole process generally takes one day, literally one day.

It's not over, you can't re-enter this country with just your GNIB card. You have to apply for a re-entry visa, which may be single-journey or multiple. Again, wait outside the buildling to get a ticket for re-entry visa application and spend half a day there (the visa office closes at 2 P.M. so you can't spend a whole day).

I don't know why on earth we need a GNIB card, even after living here for a year. A GNIB card is not a valid identity card, as stated on the card. But this non-ID card costs you 300 euro per year and is mandatory for any person staying in Ireland for long term (more than 90 days). Besides, you can't re-enter this country just by this card like UK's BRP. Maybe I'm not smart enough like Irish government staffs to understand the wisdom and find the hidden usages behind this card.

Anyway, it's inevitable to deal with this thing. I'm going to sum up some experiences I have, which should be useful for non-EU students staying in Republic of Ireland.

Read on →

Build GCC 5.2 on RHEL 6

To build GCC, we need other three components, GMP, MPC, and MPFR. And I found a lazy way to compile all of them together here. But because GMP, MPC, MPFR are compiled together with GCC, they're certainly not installed before the new GCC is installed. So we can't do make -k check to make a test after the compilation in this way. If you'd like to do a test, please go the traditional way, build and install them one by one seperately.

tar xf gcc-5.2.0.tar.bz2
tar xf gmp-6.0.0a.tar.xz
mv gmp-6.0.0 gcc-5.2.0/gmp
tar xf mpc-1.0.3.tar.gz
mv mpc-1.0.3 gcc-5.2.0/mpc
tar xf mpfr-3.1.3.tar.xz
mv mpfr-3.1.3 gcc-5.2.0/mpfr
mkdir gcc-5.2.0/gcc-build && cd gcc-5.2.0/gcc-build
# I don't have root privilege, so install to a subdir in my home directory
../configure --prefix=$HOME/gcc5 </span>
--disable-multilib </span>
--enable-languages=c,c++ </span>
--enable-libstdcxx-threads </span>
--enable-libstdcxx-time </span>
--enable-shared </span>
--enable-__cxa_atexit </span>
--disable-libunwind-exceptions </span>
--disable-libada </span>
--host x86_64-redhat-linux-gnu </span>
--build x86_64-redhat-linux-gnu </span>
# For clusters, you should request a compute node in slurm to do the compilation. Don't do these in head node
make -j4
make install

With --with-default-libstdcxx-abi=gcc4-compatible, we avoid recompiling all C++ libraries built using older GCC (prior to GCC 5.1). This ensures the default ABI is the old, GCC4-compatble one instead of the newly introduced CXX11 ABI. Check Configure - The GNU C++ Library for details.

Read on →

Use avconv to Convert Video Format

avconv is a utility that belongs to Libav project. Similar to its precedent ffmpeg, it supports lots of mainstream encoders and decoders. Here I just put some simple commands as a personal memo and a brief guide.

Install libav-tools via apt-get on your Debian/Ubuntu machines. Note on my Fedora laptop, there is no libav but only the original ffmpeg packages. The command-line options are fairly similar (sometimes even identical). In that case, you only need to substitute ffmpeg for avconv.

Read on →

Qt 5 Blueprints is Out

I have worked on this book, Qt 5 Blueprints, since last September. It turns out to be one of greatest experience in my life. :) Now, before the end of March, I'm glad to announce the publication of Qt 5 Blueprints!

I'm sure lots of people out there want to learn how to code in Qt/C++ and/or Qt Quick/QML. Now, you can buy this book directly from Packt Pub,, or, to start building truly cross-platform GUI applications. By cross-platform, I mean even mobile operating systems!

This book is for those developers who are familiar with C++ but not Qt. And because Qt is more like a C-style C++ framework, you don't need to be an expert of C++. Only basic C++ knowledge is required. Moreover, this book also covers QML application development! For more details, please refer to the book page on Packt Pub.

At last but never the least, if you find any mistakes in the book, please let me know (by contacting Packt Pub). And I'll do my best to provide following errata.

Force-Enable Hardware Acceleration in Firefox on Linux

Before any steps, let's check if GPU acceleration is already on.

  1. Open about:support in Firefox.
  2. Navigate to Graphics section.
  3. Check the GPU Accelerated Windows field.

If it's 1/1 or 1/2 or 2/2 or whatever, anyway, the first number must be greater than 0, then Firefox is already hardware accelerated. And you don't need to take following procedures to force-enable it. Otherwise, let's do a few modifications to force-enable the GPU acceleration in Firefox!

Read on →

Display Shutdown Dialog When Power Button Gets Clicked on ODROID-U3

In order to make your power button on ODROID-U3 work, you may have to install acpid at first. Otherwise, the power button won't even work.

I use latest Debian Wheezy on this board while MATE as the desktop environment. However, after installed acpid, the system is to shutdown immediately when I press the power button.

Let's see what acpid does when power button clicked, the contents of /etc/acpi/events/powerbtn-acpi-support are:

Read on →