examples/adapt: unify adaption code