Build Rsync for Android Yourself

To build rsync for Android you’ll need to have the Android NDK installed already.

Then clone the rsync for android source (e.g. from CyanogenMod LineageOS) …

… create the missing
jni/Application.mk
build file (e.g. from this Gist) and adapt it to your case

… and start the build with

You’ll find your self-build rsync in
obj/local/*/rsync
. 😀

Update 2017-10-06:

  • Updated sources from CyanogenMod to LineageOS.
  • Added links to Gist and Andoid NDK docs
  • Updated steps to work with up-to-date setups

If you get something like the following warnings and errors …

… you probably need to update
config.h
and change
/* #undef MAJOR_IN_SYSMACROS */
to
#define MAJOR_IN_SYSMACROS 1
.

Bottle Plugin Lifecycle

If you use Python‘s Bottle micro-framework there’ll be a time where you’ll want to add custom plugins. To get a better feeling on what code gets executed when, I created a minimal Bottle app with a test plugin that logs what code gets executed. I uesed it to test both global and route-specific plugins.

When Python loads the module you’ll see that the plugins’
__init__()
and
setup()
methods will be called immediately when they are installed on the app or applied to the route. This happens in the order they appear in the code. Then the app is started.

The first time a route is called Bottle executes the plugins’
apply()
methods. This happens in “reversed order” of installation (which makes sense for a nested callback chain). This means first the route-specific plugins get applied then the global ones. Their result is cached, i.e. only the inner/wrapped function is executed from here on out.

Then for every request the
apply()
method’s inner function is executed. This happens in the “original” order again.

Below you can see the code and example logs for two requests. You can also clone the Gist and do your own experiments.

Why Programming is Difficult

There are three other things that make programming difficult:

  • Fixing things that should not be broken
  • No time for learning things
  • Bad environment for programming

Let’s look at these things – these are all “time thieves”

Joe Armstrong explains what makes programming difficult.

Programming is terrible – Lessons learned from a life wasted

There are no words to describe this talk, just watch it!

Aktivieren Sie JavaScript um das Video zu sehen.
https://youtu.be/csyL9EC0S0c

Or maybe there are … those of the presenter himself: “A bad programmer talks about bad programming.”

Default Values for Boolean Options in Ruby

Let’s say you read settings from a YAML file and have some sort of settings object. Then you check if certain options are set with custom values or you have to set default/fall-back values on them. If you are dealing with Boolean options you have to be careful … as I had to find out myself.

Initially you would probably do something like the following to set a default value on a Boolean option:

Do you see the problem? What happens if the option was deliberately set to

false
? You would overwrite it because both cases
nil
(i.e. nothing set) and
false
would evaluate to
false
in the context of the
||=
operator and you would in both cases assign the right hand value (and overriding an explicit user choice in one case) … *ouch*.

So the correct solution is something like the following:

Just be careful … 😀

Render Rails assets to string

If you ever needed a way to render a Rails assets to a string, Hongli Lai from Phusion describes how. 🙂

I prepared a Gist wrapping it into a nice helper. 😀