Coder's notes

For your infomation

Android jargon

  • Android SDK: A toolkits to compile source code to make Android applications. There are many versions of SDK, and sample source code for one version SDK may not work on another.
  • Emulators: The virtual devices that run on your machine for testing our apps. In order to run we need to download Android OS images (different CPU architectures, Android OS versions, etc.). This sounds simple but may causes a lot of trouble. The ARM images are really slow, and some of the x86 or x86_64 images do not work on some machines. On my Windows laptop, the Lollipop 5.0 images without Google APIs do not work, but the one with do. Some others caused a random OpenGL errors which I had no idea why. It seems that I have less problem on my Fedora computer.
  • Android Studio: An Integrated Development Environment for developing Android apps. The source code created from its templates may not work on all SDK. For example, Android 3.1.4 default templates don’t work with the default SDK version (SDK 28) as of today.
  • Gradle: A build automation system with dependency management, kind of a combination of Apache Ant and Maven.
  • Activities: Kind of UI forms for Android
  • Views: Kind of UI controls (buttons, textboxes, etc.)

Random notes on UML – 2018

  • The latest UML specification version is 2.5.1, which was released on December 2017.
  • The original opensource StarUML project (version 1) was abandoned by the authors, and redeveloped from scratch as a commercial software StarUML 2 . Although you can use it in trial mode as long as you want, it is no longer open-source.
  • Some others forked the abandoned original project and made it into WhiteStarUML. It is still being updated as of today.

Using Android x86_64 emulator

emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure Intel HAXM is properly installed and usable.

If you encounter this error message when starting Android emulator, please check the following:

    1. BIOS settings
      1. Intel® Virtualization Technology is enabled
      2. Secure boot is enabled ⇐ this is important!
    2. Intel x86 Emulator Accelerator has been installed (Android Studio > Tools > SDK Manager > Android SDK > SDK Tools)
    3. Run haxm_check.exe to make sure that HAXM is working properly (which can be found at C:\Users\[account_name]\AppData\Local\Android\Sdk\extras\intel\Hardware_Accelerated_Execution_Manager\).
    4. Verify that HAXM is running by running the following command in the terminal:
      sc query intelhaxm
    5. Try to run emulator from command line to see if there is any other hidden error (emulator.exe can be found at C:\Users\[account_name]\AppData\Local\Android\Sdk\emulator\):
      emulator -avd [device_name]



That’s it! We hope that this post helps you in some ways. Have a nice day.

Android SDK – Android Studio – Cannot create virtual devices on Fedora 26

I encountered an annoying error when I was trying to create a virtual device in AVD Manager. Looking at idea.log file (which located at ~/.AndroidStudio2.3/system/log) I found this

ERROR - ard.ConsolidatedProgressStep$1 - Unable to run mksdcard SDK tool. Unable to run mksdcard SDK tool.

and this

WARN - vdmanager.AvdManagerConnection - /home/user/Android/Sdk/emulator/mksdcard: error while loading shared libraries: cannot open shared object file: No such file or directory 
WARN - vdmanager.AvdManagerConnection - Failed to create the SD card. 
WARN - vdmanager.AvdManagerConnection - Failed to create sdcard in the AVD folder. 

This is strange because I’m pretty sure that I do have libgcc installed.

ldconfig -p | grep libgcc (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/

but mksdcard couldn’t run

ldd ~/Android/Sdk/emulator/mksdcard (0xf77a9000) => not found => /lib/ (0xf75a2000)
/lib/ (0xf77ab000)

It turned out that mksdcard use the 32-bit version of libgcc. So I fixed this by installing the 32-bit version of libgcc.

dnf install -y libgcc.i686

I’ll leave it here, just in case it also happens to you. Happy coding everyone.

GNU Build System demystified

How do we install packages from source? This is what many of us chant everyday.

make install

Have you ever wondered how people wrote thousand of lines of configuration scripts? Actually these scripts are not written by hand in most cases, but generated by a suite called “autotools” from GNU Build System. You can read more about it here:

TL; DR: You don’t write those scripts. You generate them by using + + source code autoconf + automake  ready-to-distribute source package

We start with the source code of an application. Let’s call it main.c

To compile this application using GCC, we do

gcc main.c -o uberapp

This will compile the application and produce a binary file called uberapp. This works for small projects but when they grow bigger, we need to look into make files, which automates the build process for us so we can just type “make” and it will do the rest.

Trouble is when we compile our applications on different platforms, we need to adjust our make files to make sure that they still work. That’s why we need “configure” scripts.  They check current environment and adjust configuration to adapt the source code accordingly.

Make files and configure scripts can be very complicated, but most projects are similar. They have some source files, that need to be compiled into some binary files. In order to do that, we need to check if required build tools or some libraries are available, et cetera. GNU has developed a process to build their products so end users can just type out the command

./configure && make && make install

to install anything. The process of writing configure and make scripts can be automated too. Configure scripts can be generated using autoconf and Makefile can be generated using automake.

In general, we need and to generate build script. Your uberapp project directory should look like this

With these three files main.c,, in the same project directory, we call


to generate configure script and


to generate Makefile (If you see error message, when calling automake, try to use automake –add-missing instead). From here we know what to do 🙂

Bonus #1: Use –prefix with configure script to install an application some where else (e.g. your home directory).

./configure --prefix ~/tmp/local
make && make install
ls ~/tmp/local

That’s it. Have a nice day.

Using webmode with Emacs

Want better HTML editing features for Emacs? Not happy with Jinja template editing in Emacs? Try this and you won’t be disappointed.

Download web-mode.el from to your local folder (e.g. ~/.emacs.d/custom-modes).

mkdir ~/.emacs.d/custom-modes
wget -P ~/.emacs.d/custom-modes

Now open~/.emacs and add the following lines

(add-to-list 'load-path "~/.emacs.d/custom-modes")

(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))

;; Indentation for web-mode.el
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)

Restart Emacs. Now try to edit any HTML, CSS or Jinja template file 🙂

Using Python unittest and coverage (a quick and dirty tutorial)

Follow this tutorial here to create a unittest

Assuming that you have a folder like


You can run both tests by using

python3 -m unittest discover -s test

or a specific test

python3 -m unittest test.test_uberlib

To use coverage, first you need to install it (using pip)

pip install coverage

And then type

coverage run --source mypackage --branch -m unittest discover -s test

Note: --source mypackage means only the source code in mypackage folder will be covered, --branch is for measuring branch coverage. Read more here.

To see coverage report, use:

coverage report

If you fancy HTML based report, use this and a report will be generated into a folder named htmlcov in your project folder. Open index.html inside the folder to see the report

coverage html

That’s it. It’s pretty cool eh?

Setting up Python development environment without superuser permissions

  1. Compile Python from source
    1. Download Python source code from E.g.:
      Unpack Python and compile it to our local folder
      tar -xvf Python-3.4.3.tgz
      cd Python-3.4.3
      ./configure --prefix=/home/user/bin/python --enable-unicode=utf8
      make && make install
  2. Install virtualenv locally
    1. Now you should have this folder ~/bin/python. Execute this to make sure Python have been installed properly
      ~/bin/python/bin/python --version
    2. Install virtualenv using local pip version (If you use Python 2.x, change pip to pip2
      ~/bin/python/bin/pip3 install virtualenv
    3. Create a virtualenv (e.g. ~/myp3)
      ~/bin/python/bin/virtualenv -p ~/bin/python/bin/python myp3
    4. Activate the virtualenv (make sure you have a space between the dot and the tilde.
      . ~/myp3/bin/activate
    5. That’s it. Now you should be able to build CPython packages. For example, try to install mecab-python3 which requires to have access to python.h
      pip3 install mecab-python3
  3. Lorem ipsum!

Raspberry Pi – All about wireless connection

Turn Raspberry Pi to be an Access Point [reference link]

Connect Raspberry Pi to a WiFi network:

  1. Method 1(via command line) [reference link]
    • sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
    • Edit the file so it looks like this:
      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      ssid=”Your Wifi Network Name Here”
      pairwise=CCMP TKIP
      group=CCMP TKIP
      psk=”Your Wifi Password Goes Here”
    • If the WiFi network has no password, edit /etc/wpa_supplicant/wpa_supplicant.conf as follow
      ssid="YOUR NETWORK SSID"
    • Then restart the network:
      $ sudo /etc/init.d/networking restart
      Reboot RPI if necessary
  2. Method 2 (via GUI):
    • $ startx
    • Look for the WiFi network available and connect with the same way as in normal PC.

Blog at

Up ↑