28. April 2014

Gradle and build systems for C language – slides

Slides available in formats: PDFSlideShare

Source code: GitHub/georgik

10. April 2014

Debian Heartbleed openssl bug remains even after upgrade of openssl package

If you’re using Debian and you want to get rid of Hearbleed bug then it’s not sufficient to upgrade openssl package.

The really important package is libssl1.0.0:

apt-get install libssl1.0.0

It will restart all services which depends on this package.

4. April 2014

Debian – Tomcat 7 is not serving https after upgrade

I made upgrade of Tomcat7 server on Linux Debian.

Tomcat stopped serving https. Port was open, no strange message in log, but it was not possible to connect from browser.

Here is configuration of https connector:

Connector port="8443" SSLEnabled="true" 
 maxThreads="150" scheme="https" secure="true"
 clientAuth="false" sslProtocol="TLSv1"

Long story short. Old version of Tomcat7 was using keystore from file /etc/tomcat7/keystore, but new version expects /etc/tomcat7/keystore.jks.

Simple fix:

cd /etc/tomcat7
ln -s keystore keystore.jks

Restart Tomcat. 🙂

22. March 2014

Kivy – buildozer android debug failed with libstdc++.so.6: cannot open shared object file

Kivy is awesome library for developing GUI applications in Python.

It’s possible to build same application for desktop, Android or iOS. It’s something like Cordova/PhoneGap for JavaScript.

I was following Kivy crash course 2: Building an android apk tutorial recorded by Alexander Taylor.

I was trying to build application on Linux Debian for Android:

buildozer android debug

Build failed with quite strange message:

[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] Found 1 AIDL files.
     [aidl] Compiling 1 AIDL files.
     [aidl] /home/georgik/.buildozer/android/platform/android-sdk-21/platform-tools/aidl: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory


assets/private.mp3: /home/georgik/idea/kivytest/.buildozer/android/app/sitecustomize.pyo
Traceback (most recent call last):
  File "build.py", line 431, in 
  File "build.py", line 346, in make_package
    subprocess.check_call([ANT, arg])
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ant', 'debug']' returned non-zero exit status 1

The reason of this problem is not so obvious.

My operating system is 64bit, but Android build system requires 32 bit version of stdc++ library.

Fix is very easy. Just install lib32stdc++6 package 🙂

apt-get install lib32stdc++6

If build is still failing, because of other missing libraries, then you can use online Debian package search to find missing dependencies: https://www.debian.org/distrib/packages

Other missing 32bit libraries are often libz, libncurses5:

apt-get install lib32z1 lib32ncurses5

12. January 2014

How to convert Geocaching GPX file to WPT for OziExplorer

The goal is simple: convert GPX file from Geocaching.com to WPT file for Ozi Explorer and keep correct encoding of Slovak, Czech and German special characters.
Install GPSBabel and iconv. Store following script to file convert-gpx2wpt:


if [ -z "$2" ]; then
    echo "Specify input and output file"
    exit 1


iconv -c -f utf8 -t cp1250 < "$INPUT_FILE" > "$TEMP_FILE"
gpsbabel -i gpx -f "$INPUT_FILE" -o ozi,pack -F "$OUTPUT_FILE"

How to use:

chmod a+x convert-gpx2wpt
./convert-gpx2wpt input-file.gpx output-file.wpt

More info: http://www.gpsbabel.org/htmldoc-1.4.4/fmt_ozi.html

You can also use online service for conversion (there is limit on file size): http://www.gpsvisualizer.com/gpsbabel/

17. December 2013

Debian – upgrade from Apache 2.2 to 2.4 – Starting web server: apache2 failed!

Debian maintainers changed default Apache from version 2.2 to 2.4. Not a big deal?

I was just upgrading one package and it had dependency on whole new Apache. I said yes to upgrade, because I had no bigger issues with Apache upgrade in past.

Wohoo. This upgrade was very funny, because Apache 2.4 was not able to start due to conflicting configurations. The coolest part was that Subversion stopped working, but that’s different story.

The problematic part was that Apache failed to start with nice message:

[FAIL] Starting web server: apache2 failed!
[warn] The apache2 instance did not start within 20 seconds. Please read the log files to discover problems ... (warning)

I checked the log file /var/log/apache2/error.log, but there was no hint what went wrong.

Apache was working even though startup script reported error. 🙂

After a while I found that there were some important changes in /etc/apache2/apache2.conf. I compared this file with /etc/apache2/apache2.conf.dpkg.dist.

It was necessary to update following lines in apache2.conf:

Mutex file:${APACHE_LOCK_DIR} default
#LockFile /var/lock/apache2/accept.lock - disable this, old value

Then it was possible to start Apache without problem:

[ ok ] Restarting web server: apache2.

26. November 2013

There is more to C 2013 – slides

Slides available in formats: PDFSlideShare

12. August 2013

IntelliJ Idea support for Bash scripting

Unix users write scripts in their favorite editor. That’s ok, but when you have bigger project then power of IDE could help you. E.g. when editing project based on mix of Python, Bash and Java.

There is very useful plugin for IDEA known as BashSupport.

It will give you syntax highlight, code hinting and CTRL+Click is working the same way like in other programming languages. Very handy.

Here is example:


How to install this plugin?

File -> Settings. Search for word Plugins. Click Browse repository. Type BashSupport to search field. Right click on plugin name and choose install. restart Idea.


Enjoy 🙂

Note: This plugin works also on Windows, you need to configure just path to bash (e.g. Bash from Cygwin).

11. July 2013

W2k8 in KVM is not able to reach network

I found interesting issue while testing W2k8 with KVM. I used bridged network with br0 interface.

<interface type='bridge'>
 <mac address='52:54:00:...'/>
 <source bridge='br0'/>
 <model type='e1000' />

Windows server was not able to reach network. Network card was on-line, but ping was not working and network was not reachable.

Then I found PilotJLR’s solution. I just removed line with model type=’e1000′:

<interface type='bridge'>
 <mac address='52:54:00:...'/>
 <source bridge='br0'/>

Then I redefined virtual machine and start it again:

virsh define virtual.xml
virsh start virtual

2. June 2013

Configure Nginx with uWSGI to serve Pootle

It’s quite easy to set up Pootle. Just follow the manual – Quickstart.

virtualenv /var/www/pootle/env/
 source /var/www/pootle/env/bin/activate
 (env) $ pip install pootle
 (env) $ pootle init
 (env) $ pootle syncdb --noinput
 (env) $ pootle initdb

You can start Pootle with default CherryPy server. In order to boost performance it is necessary to use more powerfull server.

Let’s take intermediate step and serve Pootle by uWSGI.

First of all you’ll need to create wsgi.py file, because this file is missing in default Pootle installation. File: /var/www/pootle/wsgi.py

import os

# this part is only required when running from checkout instead of an install
    import sys
    ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
    sys.path.insert(0, ROOT_DIR) # Top level directory
    import syspath_override
except ImportError:
    # not running from checkout

# comment the above lines if running from install

os.environ['DJANGO_SETTINGS_MODULE'] = 'pootle.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

You can start uWSGI server by following command:

uwsgi --socket --chdir /var/www/pootle/lib/python2.7/site-packages/pootle --wsgi-file wsgi.py --master --virtualenv /var/www/pootle/ --http ":9090"

This will create uWSGI server and you can test it by connecting to http://localhost:9090

Let’s take further step and configure Nginx to server Pootle. We can modify previous command, because we do not need to server it as http at port 9090:

uwsgi --socket --chdir /var/www/pootle/lib/python2.7/site-packages/pootle --wsgi-file wsgi.py --master --virtualenv /var/www/pootle/

Create webroot directory where you will put static assets, just to avoid information leackage. Store there symlinks to assets and static files.

mkdir /var/www/pootle/webroot
ln -s /var/www/pootle/lib/python2.7/site-packages/pootle/assets /var/www/pootle/webroot/
ln -s /var/www/pootle/lib/python2.7/site-packages/pootle/static /var/www/pootle/webroot/

Store configuration to /etc/nginx/sites-available and create symlink to /etc/nginx/sites-enabled. Configuration of site:

upstream emperor {

server {
  listen 80;
  server_name pootle.sinusgear.com;
  root /var/www/pootle/webroot;

  access_log /var/log/nginx/pootle.sinusgear.com_access.log;
  error_log /var/log/nginx/pootle.sinusgear.com_error.log;

  location / {
    location ~* ^.+\.$ {
      root /var/www/pootle/webroot/static/styles;
      expires 30d;
    try_files $uri @django;

  location @django {
    root /var/www/pootle;
    include uwsgi_params;
    uwsgi_param UWSGI_FASTROUTER_KEY $host;
    uwsgi_pass emperor;

  location = /robots.txt {
    root /var/www/pootle/webroot/static/;
    access_log off;

  location ~* ^.+\.py$ {
    return 404;

Reload Nginx and Pootle should be much faster 🙂

I recommend book Mastering Nginx. You can learn there much more about Nginx configuration.

  • Where’s the fish?

  • Translations

  • Further info

  • Twitter

    Follow @jurajmichalek on twitter.

  • Comments

  • Tags

  • Topics