CentOS 7 – issues while using certbot

On CentOS 7 you can face issues related to pyOpenSSL version while running certbot (https://certbot.eff.org/).

ImportError: ‘pyOpenSSL’ module missing required functionality. Try upgrading to v0.14 or newer.

If you can’t force CentOS 7 to use more recent version of this package, try this:

> cd ~
> mkdir virtualenv
> cd virtualenv
> virtualenv --no-site-packages -p /usr/bin/python2.7 certbot
> . ~/virtualenv/certbot/bin/activate
> pip install certbot
> pip install --upgrade setuptools
> pip install --upgrade pyOpenSSL
> pip install ipaddress
> pip install enum34
> pip install cffi
> certbot --version
certbot 0.24.0

Connecting to already running Docker container

> docker ps
abcdef123456        image_name
> docker exec -it abcdef123456 /bin/bash

Calling C code from Python via Cython

If you need more information what Cython is, take a look here: http://cython.readthedocs.io/.

This sample, is a simple “Hello world” code for macOS based installation of Python and Cython.

First step is to get Cython for your platform. You can use pip to achieve that

# Installation of Cython at macOS
# I prefer to use Virtualenv contrary to OS based installation
# If you need more info about Virtualenv, take a look here
# https://virtualenv.pypa.io/

> virtualenv venv
> source venv/bin/activate
> pip install Cython

After you are done with that, you can create sample code. We will call method in C that accepts one argument – char * – and prints the string on stdout.

/* hello.c */
#include <stdio.h>

void f(char *str) {
      printf("str: %s\n", str);

Next thing we need is a Cython based wrapper for the code we want to call

''' hello_caller.pyx '''

cdef extern from "hello.c":
  void f(char *)

    take a look here for details about different Cython declarations

cpdef hello_world(str):

Last thing we need is a setup.py script for Cython that will perform the build

''' setup.py '''
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

sourcefiles = ['hello_caller.pyx']
ext_modules = [Extension("hello_caller",
                          sourcefiles )]

  name = 'Hello world',
  cmdclass = {'build_ext': build_ext},
  ext_modules = ext_modules

After everything is set up, we can build everything

> python setup.py build_ext --inplace

and, eventually, we can call C code from Python code

''' script.py '''

import hello_caller

message = "Hello world"

by running

> python ./script.py
str: Hello world

How to get info which release of CentOS was installed

> cat /etc/centos-release
> cat /etc/redhat-release

The Art of Quitting

Do you want to avoid these awkward moments when you want to do something inside editor but you have no idea how to do it?

Do you want to look like a pro while working with random people?

Do you remember last time you have asked your colleague

– How do I quit this thing?

Don’t you worry no more! Read the best selling leaflet “The Art of Quitting” and act like a pro. Quit editor, you don’t know, and keep your poker face

– Hey, as we are already here, let me start [vim/emacs/nano/pico]

Surviving in Java’s world

JNI Cookbook – Appendix B

uDocker – when there is no root around

Docker (at some point) requires root privileges. However, it’s not always the case you have them. And then, you need to go via sys admin ;)

source: When Sysadmin lends a hand – CommitStrip

If you have found yourself in a situation like this, consider using either uDocker or Singularity.

Using uDocker, you can run image without root privileges at all.

“- Look mum, no root!”

– Anonymous Sysadmin

> curl https://raw.githubusercontent.com/indigo-dc/udocker/devel/udocker.py > udocker.py
> chmod a+rx udocker.py
> ./udocker.py run hello-world
Downloading layer: sha256:9bb5a5d4561a5511fa7f80718617e67cf2ed2e6cdcd02e31be111a8d0ac4d6b7
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Warning: check container content: 74d3a6a7-72d2-3615-a1d2-f46ef8811a70
Warning: non-existing user will be created

 *                                                                            *
 *               STARTING 74d3a6a7-72d2-3615-a1d2-f46ef8811a70                *
 *                                                                            *
 executing: hello

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

For more examples and ideas, visit:

Ansible Container and time out
during the process of storing large image files

If you have encountered the issue related to time out (during the build process of images while using ansible-container), take a look here:

Reproducing the issue (macOS)

$ python2.7 -m ensurepip --default-pip
$ sudo pip install virtualenv
$ virtualenv venv
$ source venv/bin/activate
$ pip install ansible
$ pip install ansible-container[docker]
$ pip install docker==2.7.0

Clone the repo and build image

$ git clone https://github.com/mkowsiak/ansible-with-big-file.git
$ cd ansible-with-big-file
$ ansible-container build --no-cache
# at some point, you will get ReadTimeout (timeout=60) - it is coming from conductor
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 642, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 515, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: UnixHTTPConnectionPool(host='localhost', port=None): 
     Read timed out. (read timeout=60)
Conductor terminated. Cleaning up.

How to fix the issue?

git clone https://github.com/ansible/ansible-container.git
cd ansible-container
pip install -e .[docker]
# Modify file: ansible-container/container/docker/templates/conductor-local-dockerfile.j2
echo "" >> \
# Create image. This time, using custom conductor
cd ansible-with-big-file
ansible-container build --no-cache

Polycom RealPresence Desktop – they can see me, but I can’t see them!

If you encounter this kind of problems, make sure to check port forwarding on your router. Recently, it happened to me that router decided to remove all the port forwarding I have set up in the past. Just make sure to have this list of forwards configured.

You can read more about configuring Polycom with your DSL router here: Polycom m100 and router configuration for correct port forwarding (NAT) – no audio, no video.

Docker and memory settings

If you encounter this kind of issue

g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.

Make sure to provide way more memory for your Docker

macOS, Time Machine and Docker

Recently, I have found that it is a definitely good idea to call

sudo tmutil addexclusion -p $HOME/Library/Containers/com.docker.docker

if you have Time Machine and you play with Docker a lot.

This command is definitely worth running.

Ansible and ‘Error while fetching server API version’

If you are getting this error

'Error while fetching server API version: {0}'.format(e)
DockerException: Error while fetching server API version: 
   ('Connection aborted.', error(2, 'No such file or directory'))

you should know that all you need is a Docker that is running ;)

I love this kind of errors :)

How to solve missing javah in Java 10 – ugly way

In Java 10, there is no longer javah tool. It means, that you can’t extract information regarding native interfaces easily. It’s not that simple to generate header files based on compiled – class – files.

If you desperately need to process lots of class files, you can alway hack through using javap tool. You can create “reduced” source files that will be more than enough for javac to generate headers. It’s not ideal, but in case of “it should be on my desk in 10 minutes” like tasks, it can be your day saver.

Have fun!


# FIRST_ARG - full class name (with package)
# Note! I have a strong assumption that:
#  - native method is declared inside class that is part of package
#  - native method is not declared inside class that is inner class
# SECOND_ARG - class path

CLASS_NAME=`javap -cp $2 $1 | \
  grep -v "Compiled from" | \
  grep "public class" | \
  cut -f3 -d" " | \
  awk -F"." '{ print $NF }'`

PACKAGE_NAME=`javap -cp $2 $1 |i \
  grep -v "Compiled from" | \
  grep "public class" | \
  cut -f3 -d" " | \
  sed s/\.${CLASS_NAME}$//`

DIR_NAME=`echo $PACKAGE_NAME | sed 's|\.|/|g'`
mkdir -p java_jni/${DIR_NAME}


# There are lots of strong assumptions here !!
echo "package ${PACKAGE_NAME};" > ${JAVA_FILE}
echo "public class ${CLASS_NAME} {" >> ${JAVA_FILE}
javap -cp $2 $1 | grep "native" >> ${JAVA_FILE}
echo "}" >> ${JAVA_FILE}

# Now, we can generate header
mkdir -p c_header
javac -h c_header ${JAVA_FILE}

Java 10 and JNI Cookbook updates

Eventually, the time for updates has come. I had to update all the codes (Makefiles, to be precise) to get JNI Cookbook samples working with most recent releases of the tool chain.


Java 10 and first surprise with JNI

Well, you will be surprised with Java 10 and JNI. They have warned – that’s true, but it escalated quickly ;)

> javah -jni -d c -cp target recipeNo001.HelloWorld
javah: No such file or directory

you have to switch to javac and use it’s new feature of generating JNI headers directly from java files instead of class files

> javac -h c -d target java/recipeNo001/HelloWorld.java

In fact, the whole process is much simpler now as you don’t need intermediate step with javah.

There is one more issue here. New approach not always mean better one. It looks like this change may affect people who don’t have access to source codes: Generate JNI header files for class files in JDK 10. You can get it, sort of, fixed by decompiling class files: How to solve missing javah in Java 10 – ugly way

Formatting Java code

In the past I was using Eclipse as a tool for Java formatting. Eclipse allows you to call formatter from CLI which makes it super convenient to format lots of files easily. You can find description here.

But, I think that Eclipse’s time approached. I have found something called: Google Java Format. It’s very handy when it comes to quick formatting of the code. Take a look here.

/* PassLong.java */
package recipeNo004;

public class PassLong {

        /* This is the native method we want to call */
             public static native void displayLong(long value);

        /* Inside static block we will load shared library */
  static {

  public static void main(String[] args) {
/* This message will help you determine whether
                                LD_LIBRARY_PATH is correctly set
      println("library: "
                        + System.getProperty(

                long value = 1234;

                /* Call to shared library */
    PassLong.displayLong(         value        );

All you have to do, is to call it like this:

java -jar google-java-format-1.5-all-deps.jar  PassLong.java

and here you go. Nicely formatted, beautiful, Java code.

/* PassLong.java */
package recipeNo004;

public class PassLong {

  /* This is the native method we want to call */
  public static native void displayLong(long value);

  /* Inside static block we will load shared library */
  static {

  public static void main(String[] args) {
    /* This message will help you determine whether
    		LD_LIBRARY_PATH is correctly set
    System.out.println("library: " + System.getProperty("java.library.path"));

    long value = 1234;

    /* Call to shared library */

Screen Flow vs. ffmpeg – converting to animated GIF

From time to time, I need to generate animated GIF. Mostly in cases when I want to share some info on web page or when I want to show some actions to the users. Usually, few steps that has to be done to achieve something. Like “-Click here, click there, here you go. It’s all set”.

Screen Flow is my screen casting weapon of choice. It does job exactly as I need. However, there is one drawback. Whenever I export movies to GIF, they are huge. Take a look below.

I have this simple, short, mp4 movie

And here is GIF made with Screen Flow

frame rate – 15
rgb – 8bits
length – 8 sec

While here, I have another one, made using ffpmeg

frame rate – 15
rgb – 8bits
length – 8 sec

ffmpeg -i movie.mp4 -pix_fmt rgb8 -r 15 image.gif

Of course, you can generate Screen Flow like GIF as well. It’s just a matter of generating palette before proceeding with GIF creation

ffmpeg -y -i movie.mp4 -vf palettegen palette.png
ffmpeg -y -i movie.mp4 -i palette.png -filter_complex paletteuse -r 15 image.gif

Now, if you can sacrifice quality a little bit, I think it’s worth adding ffmpeg into the process and save few bytes in size.

If you want to know how to compile ffpmeg for macOS, take a look here: Awesomenauts and strange issues with exporting replays

– Animation was made based on new game from Animata Design: CHUCHEL

Chuchel – new game from Animata Design

If you are fan of point and click games you can’t miss this one – CHUCHEL.

This is yet another game from well know Animata Design. These guys are the ones behind Smorost, Machinarium, and Botanicula (just to mention few). All these games have few, common, attributes: surrealistic sense of humour, great sound tracks (made by DVA and Floex) and really, really, nice graphics.

If you were fan of games like Goblins, Leisure Suit Lary, King’s Quest this one is something you should show to your kids. No doubt!

There are few things about this game that make it really worth buying.

1. You need just one mouse button during gameplay. You can use mouse like this one:

2. Interaction is super simple – just point and click

3. All messages are presented as pictures – you don’t have to know foreign language. Well, in fact you don’t have to know !any! language.

4. Graphics is really appealing

We have spent (so far) just one hour playing it, and it was fun.

So, if you like games like Machinarium, Botanicula, make sure you won’t miss this one.

And the soundtrack, even though you can feel it is game related, still sounds well. Unfortunately, I think it’s not yet available at DVA’s page on bandcamp, but it is still worth paying for. I have listened to it already twice. It’s quite similar to Botanicula’s one but, at the same time, different!

You have two options to get the game: Steam, and HumbleBundle. I, personally, prefer buying from HumbleBundle – you get it DRM free and you get Steam key anyway.

Now, let me be 100% clear here. If you are a grown up who likes surrealistic games, nice soundtracks and (in addition to that) you have kids ~8 years old – this one is for you.

On the other hand, if you are Counter Strike fan, I guess you will not enjoy this game that much ;)

Anyway, take a look at short gameplay below.

I, personally, like it ;)

Awesomenauts and strange issues
with exporting replays

While exporting gameplay from Awesomenauts, you may experience issues related to architecture used during ffmpeg compilation. Awesomenauts come with precompiled ffmpeg version, but it looks like something went wrong. The results are horrible. No exporting inside macOS High Sierra. It looks like Awesomenauts are distributed with incorrectly built tool (in fact, libs).

dyld: Library not loaded: @loader_path/../../Frameworks/libavdevice.dylib
  Referenced from: ../Library/Application Support/.../ffmpeg-lgpl/./ffmpeg_mac
  Reason: no suitable image found.  Did find:
	.../Steam/..../Frameworks/libavdevice.dylib: mach-o, but wrong architecture
	.../Steam/..../Frameworks/libavdevice.dylib: stat() failed with errno=1
Abort trap: 6

However, there is a rescue. You can compile ffmpeg by yourself!

All you have to do is: clone sources from git, compile the stuff and put symbolic link inside Awesomenauts application. Pretty easy, isn’t it? Just take a look below.

# getting sources
mkdir -p $HOME/opt/src
mkdir -p $HOME/opt/shared
cd $HOME/opt/src
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg

# configure and make ffmpeg
cd $HOME/opt/src/ffmpeg
./configure --disable-x86asm --prefix=$HOME/opt/shared
make; make install

# create symbolic link
cd $HOME/Library/Application Support/Steam\

# make sure to make a backup
mv ffmpeg_mac ffmpeg_mac~
ln -s $HOME/opt/shared/bin/ffmpeg ffmpeg_mac

# make sure it works
./ffmpeg_mac -version
ffmpeg version N-90232-g0645698ecc Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)

Now, you can export gameplay movie directly from Awesomenauts application ;) Now. Let’s take a look at this sweet, Ayla’s, triple kill ;)

Happy sharing!

NX server shutdown

sudo /Applications/NoMachine.app/Contents/Frameworks/bin/nxserver.bin --shutdown
sudo /Applications/NoMachine.app/Contents/Frameworks/bin/nxserver.bin --startmode manual