A docker compose to try out Matomo

A while ago I was looking for a free alternative to Google Analytics for a side project of mine.

I tried Countly but it uses MongoDB which I could not make it work easily for an ARM 32bit, to try it with on my Raspberry Pi 3.

So I stumble upon Matomo (ex Piwik).
It uses MySQL which can easily run on the Raspberry.

However I could not find a simple Docker to try it out.

So I wrote a docker compose for Matomo, you can find it on my github: https://github.com/manhluong/matomo_docker

Just clone the repo, then run:

docker-compose -f x86/docker-compose.yml --project-director ./matomo up

And you will see the service coming up.

At that point if you go to http://localhost:8080/ you should see the initial Matomo setup screen:

To try on an arm v7 32 bit architecture (the Raspberry Pi 3), just run the docker-compose contained in the other folder:

docker-compose -f arm32v7/docker-compose.yml --project-director ./matomo up

Continue reading

Building Dart 2 SDK for ARMv6 using Docker and CircleCI

Previously I wrote about building the Dart SDK for ARMv6, so that I could use Dart on a Raspberry Pi Zero.

The problem at the time was that I could build only version 1.24 of the SDK, while Dart 2 has been around for a while now.

I managed to build the latest version of Dart (2.0.0-dev.55.0) too.

I could run Aqueduct and the Flutter tools with that.

I used Docker again but this time I also wanted to play around with CircleCI, mainly to have a more powerful setup during the build process.

You can find everything in my repo: https://github.com/manhluong/dart_sdk_build_raspberry_pi_dockerfile

A zip file containing the binaries is in the output folder: https://github.com/manhluong/dart_sdk_build_raspberry_pi_dockerfile/tree/master/output

Continue reading

Building the dart sdk for armv6 via Docker

Given the rising popularity of Flutter I wanted to play around with the underlying language and it’s sdk, Dart.

More specifically I wanted to use Dart on my Raspberry Pi Zero.

The official binaries of Dart VM / SDK support only ArmV7 which means Raspberry Pi 2 onward, as the Zero is ArmV6.

In the Dart Github there are some instructions on how to build the sdk, also for the Raspberry Pi 1, but those instructions seems to be outdated and they doesn’t cover my preferred Linux distribution, Archlinux.

Continue reading

React Native for Android: yet another Context

If you have to inject / create a React Native module into your Android Activity (that does not extend the default React Native Activity), please beware that the Activity lifecycle is not tied to the React Context lifecycle used to create the RN module.

So you have to be careful to retrieve it at the right moment, bearing in mind that a developer can hot reload (pressing double R on the simulator), causing the creation of a new React Context.

Also, the framework gives you a way to listen to the lifecycle of the topmost React Native Acitivity, so that you don’t need to hold a reference to it.

To show how to solve these things, I wrote a short example that you can find here.

Please bear in mind that the Javascript part is very dumb. The main point is the Native / Java (yeah, no Kotlin yet for me) part.

Here is what the running app look like:

React Native for Android example

Continue reading

Adafruit PiTFT 2.4″ touchscreen on a Raspberry Pi Zero with Archlinux

While ago I bought the Adafruit PiTFT 2.4″ touchscreen HAT and I wanted to use it with my Rapsberry Pi Zero.

Unfortunately, it seems that Adafruit supports only the Raspian distribution while my favourite distro is Archlinux.

However, I managed to get the screen to work under Archlinux too:

Continue reading

Change locale in an Espresso test

You can change the locale programmatically in an Espresso test too.

Here you can find a quick example I wrote.

The key part is to restart the Activity after you have set the new Locale.

Of course you can also set the flag of ActivityTestRule to manually re-launch the Activity so that you launch it after you set the new Locale.

Just ensure you have a new Activity after you change Locale.

Bear in mind that to change the locale taking into account all the deprecations and sdk versions is more complex than the code I wrote in my example. Read more here.

Android Searchview and the magnifying icon

Just a quick note about the android.support.v7.widget.SearchView.

Normally the widget has the magnifying on the left side if expanded. So if you do something like this:

SearchView searchView =
   (SearchView) findViewById(R.id.search_view);
searchView.setIconifiedByDefault(false);
searchView.setIconified(false);

We will end up with something like this:

Android Searchview standard

If we need to manipulate the magnifying icon, we need a reference to that View:

ImageView searchViewIcon =
   (ImageView)searchView.findViewById(android.support.v7.appcompat.R.id.search_mag_icon);

After that just retrieve the parent ViewGroup. It is, at least today, a LinearLayout, so just remove the View and add it again to have it at the end / right side of the SearchView.

ViewGroup linearLayoutSearchView =
   (ViewGroup) searchViewIcon.getParent();
linearLayoutSearchView.removeView(searchViewIcon);
linearLayoutSearchView.addView(searchViewIcon);

So we have something like this:

Android Searchview right

Of course, it is a standard View, so if we need to remove it altogether, just set its properties accordingly (from here):

searchViewIcon.setAdjustViewBounds(true);
searchViewIcon.setMaxWidth(0);
searchViewIcon.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
searchViewIcon.setImageDrawable(null);

Jira issue filters used as notifications

Using Atlassian Jira, it is very useful to have notifications for issues, created or edited, of your projects.

Unfortunately, to enable custom notifications, you have to create a notification scheme and only an administrator can do that.

Jira, however, offers you the ability to save searches, called filters and the results can be delivered by email through subscriptions.

With the right filter and the right subscription you can set Jira to notify you via email if and only if issues of your projects are creted or edited, without clogging your inbox.

Continue reading