Have a look at the attached example, it's an adaptation of the code from your link.
You should test it, I can't having no device.
Tested a similar code with B4PPC.
You should play with the ShakeThreshold variable to adapt the sensivitiy.
Using the variables JerkX, JerkY and JerkZ instead of Jerk you could have a test for each direction.
Hope this helps.
What do you want to do with the result ?
Best regards.