czwartek, 16 grudnia 2010

Running (with) Android

I'm running on a regular basis. Not a typical thing a geek would do, but at least it generates a lot of data in form of GPS traces for further processing. I'm keeping track of my running workouts with RunningAhead website [http://www.runningahead.com] and for a while I was also using their dedicated app for Android to record my exercises. However over time I found software called CardioTrainer[http://www.worksmartlabs.com/cardiotrainer/] much better as it gives me voice updates on my speed, distance, remaining distance etc., provides music (or podcasts in my case) playback. I couldn't though completely migrate to it from RunningAhead for two reasons: one, CardioTrainer does not support history import (well you can enter workout info manually, but that's only overall time and distance); two, RunningAhead website is so much better.
So for now, I'm recording tracks with CardioTrainer, than exporting gpx files and uploading them to RunningAhead. I've also just started my own little project to have a software that combines the best of the two plus gives some extra data crunching features that I'm missing now...

środa, 15 grudnia 2010

Passing array as a parameter to Perl subroutine

In Perl if you pass an array as a parameter to a subroutine like this: 
someroutine(@arg1, $arg2);
Then inside the routine you would expect the following to be the way to get the parameter values:
(@arg1in, $arg2in) = @_;
but that doesn't work as the @arg1in get assigned the entire content of the @_; A solution to that is passing an array reference instead so the call would look like that:
someroutine(\@arg1, $arg2);
Then inside after doing this:
($arg1in, $arg2in) = @_;
you can refer to the array as @{$arg1in}  or to its elements like ${$arg1in}[1].
See also: http://www.cs.cf.ac.uk/Dave/PERL/node61.html