shithub: rcfitness

Download patch

ref: 414b63b4a1d2359de630cada38233c74dfe868f1
author: rodri <[email protected]>
date: Fri Dec 25 06:01:02 EST 2020

initial release.

--- /dev/null
+++ b/21dec2020
@@ -1,0 +1,13 @@
+#exercise,reps,sets
+biceps,10,5
+shoulders,10,5
+back,10,5
+forearms,50,5
+crunch abs,15,4
+leg abs (reverse crunch),15,2
+corkskrew abs,15,0
+rocky abs (dragon flag),15,1
+russian abs,15,2
+push-ups,10,6
+glutes,20,2
+calves,50,1
--- /dev/null
+++ b/bmr
@@ -1,0 +1,3 @@
+# 66 + 6.23*lbs + 12.7*inch + 6.8*years
+66 + 6.23*176.36 + 12.7*68.89 - 6.8*23
+1883.2258
--- /dev/null
+++ b/exercises
@@ -1,0 +1,39 @@
+biceps
+	dumbbell lifts with your hands facing upward.
+shoulders
+	dumbbell wing lifts.
+back
+	dumbbell wing lifts with your hands facing up (thumbs out) and
+	your back leaned to the front, slightly bending your knees
+	forward.
+forearms
+	single dumbbell lift with your arms stretched forward.
+crunch abs
+	classical ab workout.  put your hands either over the pecs or
+	besides your head.
+leg abs (reverse crunch)
+	legs straight without touching the floor, then crunch them up
+	until your knees almost touch your pecs.
+corkskrew abs
+	sit with your legs above the ground and your hands on the
+	floor by the side, then pull your knees in to one side, then
+	push out, then the other side.
+rocky abs (dragon flag)
+	based on the workout rocky does in Rocky IV. legs straight
+	without touching the floor, core tight, then bring them all
+	the way up along with the core until the only part of your
+	body on the ground are your shoulders and hands.
+russian abs
+	sit with your legs straight above the ground, then twist your
+	core trying to touch the floor on each side.  you can also
+	bend your knees a bit.
+push-ups
+	classical ones (hands besides the pecs or above) focused on
+	arms and pecs (by placing your hands further away or closer).
+glutes
+	stand up, then raise one leg straight up to the back, then the
+	other, while keeping your back straight and facing forward.
+calves
+	while holding a couple of dumbbells, bend your knees slightly
+	forward and begin raising your toes from the ground, standing
+	on the tips, then back down.
--- /dev/null
+++ b/readme.md
@@ -1,0 +1,3 @@
+# rcfitness
+
+Rc tools for fitness tracking
--- /dev/null
+++ b/workout
@@ -1,0 +1,107 @@
+#!/bin/rc
+rfork en
+
+exercises=()
+session=()
+reps=()
+sets=()
+wdir=$home/lib/fitness
+today=`{date | awk '{print $3 tolower($2) $6}'}
+
+. <{<$wdir/exercises awk '/^[^	]/ {print "exercises=($exercises ''"$0"'')"}'}
+
+fn isnumber{
+	! ~ `{echo $1 | awk '/^[0-9]+$/'} ''
+}
+
+fn printexers{
+	for(i in `{seq 1 $#exercises})
+		echo $i':'	$exercises($i)
+}
+
+fn printsession{
+	showreps=$1
+	showsets=$2
+	for(i in `{seq 1 $#session}){
+		echo -n $i':'	$exercises($session($i))
+		if(~ $showreps 1 && ! ~ $#reps 0){
+			echo -n ' '[$reps($i)^x
+			if(~ $showsets 1 && ! ~ $#sets 0)
+				echo -n $sets($i)
+			echo -n ]
+		}
+		echo
+	}
+}
+
+fn plansession{
+	session=()
+	e=()
+	while(! ~ $e w){
+		echo program your workout session (a to add all, w to begin):
+		printexers | mc
+		e=`{read}
+		if(isnumber $e && test $e -ge 1 && test $e -le $#exercises)
+			session=($session $e)
+		if not if(~ $e a){
+			session=`{seq 1 $#exercises}
+			e=w
+		}
+	}
+
+	printsession | mc
+	echo -n is this all right?' '
+	ready=`{read}
+
+	if(~ $ready y)
+		setupreps
+	if not
+		plansession
+}
+
+fn setupreps{
+	reps=()
+	for(i in `{seq 1 $#session}){
+		r=()
+		while(! isnumber $r){
+			echo -n how many reps for $exercises($session($i))?' '
+			r=`{read}
+		}
+		reps=($reps $r)
+	}
+
+	printsession 1 | mc
+	echo -n is this all right?' '
+	ready=`{read}
+
+	if(~ $ready y)
+		start
+	if not
+		setupreps
+}
+
+fn mkreport{
+	echo '#'exercise,reps,sets >$wdir/$today
+	for(i in `{seq 1 $#session})
+		echo $exercises($session($i))^,^$reps($i)^,^$sets($i) >>$wdir/$today
+}
+
+fn start{
+	# initialize the set array
+	for(i in `{seq 1 $#session})
+		sets=($sets 0)
+
+	while(! ~ $e q){
+		printsession 1 1 | mc
+		e=`{read}
+		if(isnumber $e && test $e -ge 1 && test $e -le $#session){
+			lo=`{echo $e-1 | bc}
+			hi=`{echo $e+1 | bc}
+			sets=($sets(1-$lo) `{echo $sets($e)+1 | bc} $sets($hi-))
+		}
+	}
+
+	mkreport
+}
+
+plansession