December 2016
« Mar    




Android and integrated ZXing

By Bart | March 25, 2016

If you want to use ZXing for barcode reading, but do not want your customer to install a third party app. Or if you just can’t because the Android device you are using cannot connect to the Play store (as is the case with many wearables), there is an extremely easy way to use the ZXing scanner in your app, using Android Studio. No need to download anything, install libraries, compile entire code trees:

To embed the library, add these two lines to your app.gradle:

dependencies {
    compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
    compile ''

Then, to initiate a scan, call this in your Activity:

new IntentIntegrator(this).initiateScan();

Finally, you use this code to receive the result:

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
   if (requestCode == 0) {
      if (resultCode == RESULT_OK) {
         String contents = intent.getStringExtra("SCAN_RESULT");
         String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
         // Handle successful scan
      } else if (resultCode == RESULT_CANCELED) {
         // Handle cancel

Topics: Geekstuff, Snack | Geen reacties »

Android websnack: ADB doesn’t recognise device

By Bart | December 14, 2015

If you have set your phone to debugging, but adb doesn’t recognise it, try switching the way it connects to the PC. I found that using “Charge Only”, or “MTP” caused the debugging to not work. Putting it on “PTP” made it work.

Topics: Opinie | Geen reacties »

Linux GUI development: A Sorry State Of Affairs

By Bart | November 21, 2015

Every now and then, I check the state of affairs in Linux GUI development (well …. the last time was six years ago). For the last few years I have been developing on all kinds of different platforms, Windows .NET, Android, Web. All these platforms are a breeze to develop in, my favourite for quick application development being C#.NET. And because I have been working in C#.NET a lot lately, I decided to see how the GUI development in Linux holds up to that in 2015.

Defining the needs

Obviously, before we can start developing, we will be needing tools. For my research I decided to only install tools that are readily available in my distribution’s repository, so a simple sudo dnf install <tool> gets me where I want to be.

There are some other important things we need to lay down as well:

These demands aren’t too much to ask for, as they are available on other platforms already (the UI editor of Visual Studio is great and my first Android app took me 30 minutes between installing the IDE to having it on my phone).

I will be rating each tool I find, bearing in mind I’d give Visual Studio 2010 9/10 and Android Studio 8.5/10.


We start with an oldie and hopefully goodie. Anjuta has been the tool I have been using to create some applications in the distant past. It was OK then, but in my last tests it crashed a lot on me. Let’s see what we got now. I will be using Anjuta 3.16.0.

Installing was a breeze, I thought. Until I actually started it up and tried to create a UI application (using GTK+ and C), it immediately complained about missing packages. After having these installed, I hit the “Run” button, only to see it was missing even more! I didn’t want to go more into it; this is already taking too long. I don’t want to search the internet for these kind of simple things. It should Just Work.

I should mention though that the included UI builder (Glade) is quite OK.

Rating: 5/10, native, didn’t work “out of the box”, decent UI builder

Python with wxWidgets

This one was a little harder to setup. I had to download the IDE (I used LiClipse) but I think standard Eclipse from the repository, together with the PyDev plugin would work as well. Getting wxWidgets/WxPython installed was a little search-and-install away.

Creating an app is all about coding, I didn’t find a UI builder of any kind. Looking at the documentation, it looks like I have to code my UI.

Rating: 5/10, not native, fairly easy to set up, no UI builder


This looks promising! Installing is only a simple dnf install monodevelop and it starts quickly. Four clicks later, I have boiler plate code and a clear project layout. This feels quite at home for Visual Studio developers. It only needed one extra package installed (gtk-sharp2), but that was only one `sudo dnf install` away. Within a few minutes, I was happily programming away and I actually created a simple “Hello World” app in under 30 minutes. It still had some bugs and some things are a little awkward, but this is the best until now.

Rating: 7/10, not native, really easy to set up, decent UI builder


The install is from a download, no package available in the repository. Installing worked, but I couldn’t even start a simple command line project, because some plugins weren’t enabled. Couldn’t enable them either.

Rating: 4/10, not native, couldn’t even start a simple Java project


GUI development in Linux is still buggy and hard to set up. It needs a lot of boiler plate code or handcrafted code to create user interfaces. Your best bet is to use one of the cross-platform tools, such as Mono or WxWidgets.

Note that this isn’t about getting these tools to work. It is about getting it to work fast and easy. Developers want to get developing on their own projects, we don’t want to spend time hunting down libraries, fixing configuration files or installing software. And the competition (e.g. Visual Studio, Android Studio) gives us that, those tools are the reference.

Topics: Opinie | Geen reacties »

Query SQLite database from unrooted Android device

By Bart | October 22, 2014

To quickly test your SQLite database while developing an Android app, it can be useful to use the sqlite3 command line command to query the database. However, it is not easy to get to the SQLite file: you cannot just download it from your device, nor can you mount the right directory to your development machine.

Luckily, the handy adb shell comes to the rescue. There is no copy possibility easy to the external card or whatever, only cat. To get the file onto your computer, use these two steps:

~$ adb shell "run-as <package> \
           cat /data/data/<package>/databases/<database>" > \
~$ adb pull /sdcard/<database>

where <package> is the package name of your app, as found in the AndroidManifest.xml (the package attribute in the manifest (root) tag. <database> is the database name you used in the constructor of your SQLiteOpenHelper.

Update it seems that not all devices support this method (starting from Android 5.0?), so there is another way to do it: first allow full read access to the file and then pull directly:

~$ adb shell "run-as <package> \
           chmod 666 /data/data/<package>/databases/<database>"
~$ adb pull /data/data/<package>databases/<database>

then, you use sqlite3 to query anything from there:

~$ sqlite3 <database>
sqlite> select * from <table>;

Topics: Geekstuff, Snack | Geen reacties »

Updated WordPress thanks to mqTranslate

By Bart | September 15, 2014

The last months, qTranslate was blocking my updates, because it gave me the message it will break my site. Too bad, the developer/maintainer of qTranslate seems to have abandoned his project, or he couldn’t find the time anymore. Luckily, thanks to the open-source-ness of the plugin, some brave souls have picked up the duty of forking and continuing the plugin, under the name mqTranslate. This made it possible to update again! So, I am fully upgraded to 4.0 with all plugins updated. The update was seamless and all settings were imported with no effort.

Thanks, Qian Qin for a great plugin, and thanks to the mqTranslate team for continuing it!

Topics: Opinie | Geen reacties »

Python Snack: How to log only error to stdout in CherryPy

By Bart | April 24, 2014

Started working with Python, which is extremely easy and a joy to work in. It also has great libraries and tools you can use. So, also started using CherryPy to power the XML API I am working on. While debugging it throws out a lot of messages on stdout, of which the access messages I don’t want. Googling and playing around I found this quick way to disable the access logging in stdout:

    import logging
    import cherrypy

    cherrypy.log.screen = False
    cherrypy.log.error_file = ""

Topics: Geekstuff, Snack | Geen reacties »

How to ditch PHP, part 2: diving into Python

By Bart | December 14, 2013

Case Study

In part 1 we defined our limits and the requirements needed to replace PHP. We gave Python a first look and found out it is quite easy to use it in Apache. To get a good feeling of what Python can do and how to build a Real World site, I decided to use our Beers website as a case study. It is a simple website where we post beers we tasted around the world, including photos and reviews. It works with a simple database and administration possibilities.  The goal is to re-implement the site in Python and transfer all existing data into it.


Researching Python and web applications quickly puts you on the road of web application frameworks, something I really haven’t used in PHP. Maybe that’s one of the reason of all my bad PHP habits. The de facto Python framework standard seems to be Django. And a nice warm bath it is. It installs like a breeze (as simple as an apt-get install python-django) and has great documentation. I am on part three of its good tutorial now and I am getting a feeling of the joy of using both Python and the Django framework. There are a few things to consider though:

I have used CakePHP before as a framework in PHP, but it didn’t give me the same feeling as Django does. This can of course be because of me. But after running through the tutorial and trying to wrap my head around its workings, Django makes me want to continue with it, CakePHP made me want to put it away. Django gives me the feeling I am still in control, because it hides all the standard stuff behind (highly customisable) admin pages. The actual web application has to be written completely by you. Django includes full MVC support (database connections are seamless, no need to write any SQL) and a template system. Using the shell you can even load and edit the data in real time. In short, Python with Django lets you create apps, not write the same stuff over and over again. It is not really about the language yet, I hope I can get to that in the next part.

Topics: Geekstuff, Opinie | Geen reacties »

How to ditch PHP, part 1: Introduction

By Bart | December 7, 2013


Yes, you read it correctly. After years (approximately 13) of using PHP as my go-to tool for web development, I decided to ditch it. It was becoming more and more of a nuisance and when I got more into C# and Java development lately, PHP started to really feel like a incoherent mess. I read some extra resources about it and the Bad Things I experience are not only experienced by others, no, the PHP mess is even bigger. So I decided to ditch it completely. The first thing of course that pops in your mind is: what next? Which language fits the needs that were filled by using PHP? So I wrote up a little list of features this other language should have for the best transition:

  1. Good templating. I always use Smarty when I program in PHP (that is, I do now, in the past I have written a lot of bad echo "" code).
  2. Good database support. For now, MySQL will do, but I am in the process of ditching that as well, in favor of PostgreSQL. I still want to be able to use my current databases.
  3. Apache integration. I cannot afford to run a specialized application engine on our servers. Many sites still use PHP (like this one). It has all to be combined.
  4. Good library availability. To make real-world applications, XML support, XLS/PDF generation, image generation, etc is mandatory.
  5. Good documentation / community to go to to find stuff out or ask questions when I am stuck. (This is one of the good things of PHP; the documentation is good and there are many people out there that can help you.)

I put this all in a question on Stack Overflow, but also found out, as I already should have known, that these kinds of questions are not a good fit for the site. Thankfully the remarks gave me enough to start digging a little further. Two languages that immediately pop to mind are Python and Ruby. So let’s start with those.

First Stop: Python

Installing / configuring

In my PHP-minded mind, I started to think mod_python was the way to go, but I immediately get reminded that mod_wsgi is a better fit. So I set upon installing and configuring that, which is quite a breeze on Ubuntu. It is right there in the repositories so no need to compile anything. Apache accepted the module easily and configuring it to run an example worked right away. So: installing Python in my Apache server: +1. Now it is time to get up to speed with my Python, which will take some time. Next post, I’ll see if I can get a simple database connection going.

Topics: Geekstuff, Opinie | Geen reacties »

Bart on safety

By Bart | September 24, 2013

When we launched Snøg Avalanche Buddy, we also decided to post the app on some winter sports forums. The reactions we got there were mixed, but mainly very negative. Part of the negativity was aimed at the safety of the app. In one case we were even threatened, that we were putting people in danger. The whole thing gave me the insight that people aren’t thinking thoroughly enough about ski safety in particular and safety in general. Thinking about it, I found out that safety is a three step process of Prevention, Protection and Emergency Response. In this post I will explain what I mean with that. After that, I will talk about ski safety and try to put Snøg’s safety properties into perspective.

What is safety?

100% safety does not exist. Nowhere ever. Even if you have a helmet, seatbelt and super-brakes, there is always the chance of lightning hitting your car and turning it into a fire ball. So, talking about safety basically means talking about risk. How do you treat risks, how do we try to lower them and what do we do if stuff happens anyway? Let’s first define risk. Risk is the product of the chance of something unfortunate to happen and the damage it creates when it does happen. So, dying of a meteor impact is a low risk (low chance, high damage), dying of the common fever is a low risk (high chance, low damage), dying in a car wreck is a reasonable high risk (moderate chance, high damage). We try to control the higher risks, either by lowering the chance of bad things happening, or by lowering the damage if it happens. And this is exactly where the three steps come in.


In the first step, it is all about lowering the chances of bad things to happen. This is by far the most important factor in safety. In fact, it is so important, people have been calling it primary safety measures. Prevention basically means staying out of harm’s way. In the ubiquitous car analogy, this means for example not getting into your car, when road or weather conditions are bad. Or driving defensively. There is a lot of technology going on in prevention of accidents.

Examples of prevention measures: good brakes, not running red lights, holding the rail when climbing the stairs, etc.


The second step is about lowering the effects of an accident, may it happen even after all our prevention efforts. We call these secondary safety measures. It is all about, well, protecting yourself. Often, these measures are the only ones called safety measures and people completely forget the primary measures.

Examples of protection measures: helmets, seat belts, knee protectors, roll cages, etc.

Emergency Response

Okay, so now we were really unlucky. We tried to lower the chances, lower the damage and still we got in an accident. Our last line of defense is emergency response. This is all about getting you as fast as possible into a safe spot again. In our car analogy, think of a system called OnStar that is available in the US. That system will call 911 when it detects an accident.

Examples of emergency response measures: the fire department’s jaws-of-life, always being able to call 112, etc.

Now, what about skiing?

The three steps of safety of course also apply to ski safety and a whole industry is created around ski safety.

In all the discussions on all the forums, many people fail to see the big picture. They buy an avalanche beacon, (mostly) wear a helmet and think they are untouchable. If you do that, think about this: only 30% of people with a beacon are saved from an avalanche. Besides that, the largest risk of an avalanche is not being buried, but hitting a tree or rock. Beacons are your last line of defense, not your first.

And remember: “the mountain doesn’t know you’re an expert“.


Many of these insights were inspired / taken from Bruce Schneier’s blog, even though he mainly talks about security and terrorism. The ideas on risks are basically the same though.

Topics: Opinie | Geen reacties »

N reasons why “N reasons why” and “how to become successful” lists are useless

By Bart | August 19, 2013

  1. They oversimplify things, you can not pack a successful business / career / interview in 10 simple rules. If you could, everyone would be successful and not everyone is; hence they are nonsense.
  2. They are basically adverts, they often end in “Dude McDudeson is the author of ‘Be Branson overnight’ or some other business nonsense tripe.
  3. They are not true, most of the time a list like “10 reasons why Branson is successful”, will help you nothing, because there are a zillion other reasons not mentioned in the list. Most notably luck, correct timing and hard work.
  4. Do not try to learn from the big guys, as a three-person business with a yearly turnover of 150k€, it is stupid to try to learn from the big guys. Try to learn from the successful little guys. They are in your own neighborhood, get inspired there, not on LinkedIn from Jobs and Gates.
  5. They often don’t apply to you. Every business is different. Rules that made some people successful can be detrimental to your situation.
  6. They are backwards-looking. For every success out there, there are thousands of failures. Of course the successful ones did something right, but it is hard to put your finger on it. The first person to correctly predict a success has yet to be born.

Bart Friederichs is the author of this blog and an entrepreneur in the Netherlands. He has not published any books at all.

Topics: Opinie | Geen reacties »

« Voorgaande Artikelen