Coder's notes

For your infomation

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.

Using Emacs for Python development

  1. Install Emacs version 24+
  2. Install elpy by following the guideline here
  3. Use only white space => Add this to ~/.emacs
    (add-hook 'python-mode-hook
    (lambda ()
    (setq-default indent-tabs-mode nil)
    (setq-default tab-width 4)
    (setq-default python-indent 4)))
  4. Convert tab to space by pressing (Meta = Alt key or ESC key) Meta+x, type untabify then press Enter.

Building LÖVE engine on Fedora 20

Download the source code from this website (Other downloads \ LÖVE source):

Version 0.9.2 direct link:

Install required packages (with root permission)

yum install -y freetype-devel glibc-devel libmpg123-devel libmodplug-devel physfs-devel mesa-libGL-devel openal-soft-devel DevIL-devel libvorbis-devel SDL2-devel libmng-devel libtiff-devel lua-devel gcc-c++ libtool luajit-devel

Assuming that you have saved love-0.9.2-linux-src.tar.gz in folder ~/Downloads/, you can try:

cd ~/Downloads
tar -xvf love-0.9.2-linux-src.tar.gz
cd love-0.9.2

If everything is ok, you will see love binary file in the ~/Downloads/love-0.9.2/src directory. Try to run it by:

cd src

If you see a splash screen like this you know that you have compiled LÖVE successfully.
Screenshot from 2015-09-01 16:29:13

Please comment if you have trouble following this tutorial.

Install Python3 and NLTK on Windows 8 using pip

  • Download Python 3 from here
  • Open command prompt and run
    c:\Python34\Scripts\pip3 install nltk
  • Then start Python 3.4 by running
    Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (In
    tel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
  • Now you are ready to work with NLTK.

Blog at

Up ↑