How to generate a Zookeeper root password (superDigest) using standard unix tools

You may want to generate a Zookeeper superDigest without making use of the built-in

org.apache.zookeeper.server.auth.DigestAuthenticationProvider

class if, for example, you’re using configuration management tools such as Puppet or Chef and normally generate authentication values outside of the environment where they’ll be used.

The Zookeeper documentation on this is vague at best, and I eventually had to resort to reading the source code for this function, which for some reason includes the “super:” prefix in the digest. This can be seen in the source code responsible for the generation of the digest:

 static public String generateDigest(String idPassword)
         throws NoSuchAlgorithmException {
     String parts[] = idPassword.split(":", 2);
     byte digest[] = MessageDigest.getInstance("SHA1").digest(
     idPassword.getBytes());
     return parts[0] + ":" + base64Encode(digest);
 }

The function clearly splits the input (in the format “super:password”) into two sections, then promptly ignores that array and uses the full input for the digest directly following that.

For example, if your password is “hunter2”, you need to do the following to generate a functioning digest:

$ echo -n "super:hunter2" | openssl sha1 -binary | base64
V1o6/gHR24bI2f+NOZanWPgr+eg=

And then when you lauch Zookeeper, you would use the following in addition to the standard command line:

-Dzookeeper.DigestAuthenticationProvider.superDigest=super:V1o6/gHR24bI2f+NOZanWPgr+eg=

Took me a while to figure out that my original attempts weren’t working because I didn’t include “super:” in the password.

 

How to export your Runtastic “Sleep Better” data on Android

Sleep Better with Runtastic is a well-polished sleep tracking app for Android and iOS that I’ve been using for the past year or so without issue. Unfortunately I found out a few days ago that Runtastic does not sync your sleep session data with their servers, which means that you lose everything if you uninstall the app or get a new phone. Having no export function also means that you are limited to the app’s visualisation and statistics features.

I started digging for a solution and soon found that the app stores its database at the following location (access to this directory requires root):

/data/data/com.runtastic.android.sleepbetter.lite/databases/sleep_db

This turns out to be a sqlite database that you can view with any compatble program (I used DB Browser for SQLite) and from there you can easily export the data in each table as a CSV file.

sqlite

As an example of what you can do with the data, I made a scatterplot of the number of hours I slept against my sleep efficiency:

sleep

If only companies would make it easier to access your own data.