Saturday, January 30, 2016

Words of wisdom from a fellow amateur athlete to another

One of my fellow amateur athlete friend asked me advice for improving health and endurance.  Here's all that told.

Before I repeat my narration, here is a disclaimer.
  • The views and opinions expressed in this article are those of my own and do not necessarily reflect the official positions of the individuals I consider to be my Gurus, or of anyone else.
  • I am getting along in years, what I mention here seems appropriate for my age.  When taken AS-IS, it may not be appropriate for your age.
  • These tidbits are jumbled.  Please do not apply them in this sequence.
  • Folks interested in what exactly is applicable for them should do some self study around what I say here.
  • Do I follow all that I preach?  No!  But who said I am preaching.  Certainly I am not.  This is a dialog between a fellow amateur athlete and another.  Read on if you are still interested.

Regular jogging or running will not get you rid of your upper tummy.  It is certainly helpful for reducing fats from your overall body.  And also fats from your lower tummy.  For reducing upper tummy you must do those specific exercises.

Long distance running does not guarantee reducing your weight.  You may be surprised to see your weight will more-or-less remain the same even when you are regular with long distance running, even for a year or more.  Be aware that you are slowly replacing fats in your body with muscles.  Nevertheless, I like what Rujuta Divekar said - Never let the weighing scale tell you how to feel about yourself today! ;)   She summed it all very well in one line.

Do not expect results in a few days.  Or in a couple of months.  Be patient.  You must be consistent for a longer period of time.  A year or so.  When you will compare your health and endurance with how it was a year ago or a couple of years ago, you will be surprised to see the changes!

This is a misconception - eating less will reduce your weight.
We should eat in proper quantities.  What matters more is what we eat.  And how we eat our meals.  And does our daily routine have enough physical activities for consuming what we intake.

We should have sumptuous breakfast.  For breakfast we should have food that is relatively difficult to digest.  Such as dry fruits and eggs.  Fruits should be eaten in the breakfast.  Fruits should not be eaten during dinner or after dinner.

We should have lunch in normal portion.  Lunch should be smaller than breakfast.

Dinner should be smaller than lunch.  For dinner we should have rice.  Chapatis, bread etc. (that are made of wheat) are good for lunch.  These are golden words from Rujuta Divekar in one of her articles - Put rice on your plate: Eat rice, especially for dinner. Easy on your stomach, rice promotes the growth of gut-friendly bacteria, has fat-burning and anti-anxiety properties and also allows for better assimilation of Vitamin D. And remember, we need ‘optimum fibre’, not ‘high fibre’, so choose hand-pounded or single-polished white rice over brown rice.

I avoid to sleep right after dinner.  So we have dinner around 8 PM.  A margin of two hours between dinner and sleep is needed for food to digest properly.

What should you eat for breakfast and for lunch and for dinner?  I try to follow this formula I learned from Rujuta Divekar - do not eat food for which you see a lot of advertisements.  Eat food that your grandmother recognizes.

We should not fluctuate our sleep pattern.  It affects our workouts and our health.  For years I "adjusted" my sleep durations and timings.  Being aware, now I attempt to be consistent.

If you are working in a night shift, I say you are killing your health on a slow track.  You should quit and get a regular shift job, even if it is a less paid.

We should avoid all electronic screens after dinner or for three hours before going to sleep.  No laptops, no smartphones, no TV.  Because watching these screens tricks our body to believe that daytime is still going on.  So our body does not recognize it is now night and time to sleep.  I do not remember from where I learned this.

I said no TV!  Am I nuts?  Gee, this is different topic altogether.  Our home has no TV.   Okay, we do have a TV, but no satellite dish connection.  We only have a DVD player attached.  So we rarely watch TV.  For years.  I know it is difficult to start.  But try it.  You will thank me.

Okay, back to our original subject.  Cross training really helps.  What is this cross training?  Cross training is sometimes doing a workout that is not your main workout.  It is effective for improving fitness performance in our main sport.  It provides time to muscles in our body for recovering.  We use different sets of muscles for different activities.  After a workout, we should provide enough rest to muscles.  So for a futsal player, cross training could be slow running, sprints, circuit training, stretching and flexibility routine, all once a week.  May be swimming and cycling.  There is no universal formula that suits all.  You should experiment and find what suits you.  Do consider your age and your daily routine.  I tend to incline towards training less rather than over-training and sometimes acquiring injuries out of it.

These days my week consists of one slow and easy run, one hill run, and one game of futsal.  Sometimes hiking instead of futsal.  During weeks when I do a long run, I skip futsal and hiking.  So if you ask - what is the primary sport for me and what are the cross trainings?  I wonder as well.  I am an amateur athlete.  I keep switching between futsal, long distance running, and hiking.  This is what suits me.  Our original aim is to stay healthy, have endurance, and have fun while doing it.  So why to keep pushing with workouts that do not suit?  I must be missing some benefits that I would get if I add more variety, say swimming or cycling or badminton or tennis.  Okay.  I follow my objective in my own way.  You find your objective and apply your own way to it.  Right, one size does not fit all.  Everyone loves their own tune and plays their own fiddle in whatever way they like.

Should you run on a treadmill or on roads?  If you are going to start jogging or running, in the beginning you should use a treadmill.  If you are consistent, you would come to a point where you would want to go out and run on roads or in gardens.  I personally prefer running in gardens instead of on roads.  I know almost all long distance runners hate to run in loops.  I have no trouble running thirty loops in a garden.  I happily keep the count.

If you are beginning jogging or running, which running shoes should you buy?  I say don't get into a habit of spending big money.  For a 3 km run or jog, your existing sports shoes are good enough!  Consider buying sports shoes only after you become consistent with running.  Consistent here is a period of at least six months.  Before that period, if your existing sports shoes give way, you'd buy running shoes anyway :-)
Now I am an amateur long distance runner for more than three years.  These days I have a pairs of Merrell Men's Trail Glove Black and Crimson Gore-Tex Running Shoes and a pair of Merrell Men's Allout Fuse Carbon and Lantern Running Shoes.  Both pairs are UK size 9.5  This size fits me perfectly.  I'd repeat what I have read - please don't be loyal to a brand.  Buy and use what suits you.

And what device should one use for tracking the runs or workouts?  I have no suggestion in this case.  I am a free runner.  I do not use any tracking device.  I listen to my body.  And my body listens to me.

I found this excellent wikihow article - How to Begin Running

Another fantastic article I found in Merrell blog is - 11 Things the Mountain Teaches You

We should drink plenty of water.  Particularly during first half of the day.  I avoid drinking too much water during evenings.

Should we have energy drinks instead of water?  If you are referring to canned high energy drinks that are sold besides alcohol, holy s__t, no.  If you are referring to Enerzal or sports drinks such as Gatorade, then you are on the right track.  Enerzal or Gatorade replenishes what is lost from the body in a workout, quantities of potassium and sodium.  In my opinion, having Enerzal or a sports drink before, during, and after a workout does help.
Someday I want to follow what I have learned from Rujuta Divekar - go natural - replace Enerzal and Gatorade with natural tender coconut water and cold pressed sugarcane juice.  Today I am not there yet.

From a day prior to a marathon, I start drinking Enerzal or Gatorade instead of water.  Like carb-loading, I do salt-loading.
Yep, buying more Gatorade liquid required more money.  So I have bought packs of Gatorade powder.  Gatorade powder from one pouch makes one bottle of Gatorade liquid.  This is cheaper than buying Gatorade liquid.  Sometimes I want it strong so I put powder from two pouches in one Gatorade bottle.  And I do like to experiment.   Once I bought Nesquik chocolate flavored powder from Amazon for my daughter.  The seller sent pineapple flavored powder instead.  My daughter hated the pineapple flavor from the moment we opened the packaging.  I liked it as a replacement of Gatorade.  So I kept it for myself.  Not just me, everyone in my weekend futsal club enjoyed the taste.

After a workout (such as a game of football, running, jogging, swimming, cycling) we should have some food within 30 minutes.  Our body needs it.  Not eating for a long time after a workout is bad.  Thank you Rajas Borwankar for this useful advice.

Before a workout, we should have one or two bananas followed by a sip or two of water or Enerzal or a sports drink such as Gatorade.  Doing a workout with empty stomach is not good.  Bananas contain magnesium, bananas are available all year, and they are relatively cheap.  So bananas are good to have before a workout.
But bananas are difficult to carry on a sports trip or on a hiking.  I carry a jar of mixed dry fruits instead.  Expensive than bananas, but are easy to carry and good source of energy.

I do not buy sports energy bars that are available in the market.  They are expensive.  For me, most of them are tasteless and hard to swallow.  With same money we could buy plenty of bananas.  Or a good amount of dry fruits.

I do not buy the packets of mixed dry fruits from stores.  They are relatively expensive.  And you don't get to choose what exactly you want.  I prepare my own trail mix.  I learned this from the Merrell blog.  I prepare a mix of cashews, dried berries, walnuts, etc.  Sometimes I mix brazil nuts, hazelnuts etc.  Depends on how much money I want to spend.

If you are past your prime age, say you are 35 or more, your body needs more rest to recover after workouts.  Every alternate day is a rest day for me.  You don't agree?  All right, you do what suits you.

Should you do workouts in the mornings or in the evenings?  I say mornings.  Are you concerned of burning out from the morning workout and then lacking energy for the rest of the day?  I'd say the equation you have right now is not in balance for you.  Why not try reducing your workout.  If your daily routine leaves you with no choice other than a evening workout, okay, an evening workout is better than no workout.

What if I decide to ride cycle to my workplace?  Oh, if you are living in a city that is cycle-friendly, (such as Mainz, Germany) this is an excellent choice.  All Indian cities today are not at all cycle-friendly.  Air pollution levels are also alarming in Indian cities.  I live in Pune, India.  I never want to take the heavy risk.

Over the years, certain lifestyle trends evolved for me and my family.  As per our capacity of understanding the world around, we made our choices.  Choices that we thought would improve our health and endurance.  This article is more-or-less a narration of some of them.  Oh yeah, The Architect said correctly, the problem is choice.  In one discussion Neo asked The Oracle, "But if you already know, how can I make a choice?"  The Oracle replied, "Because you didn't come here to make the choice. You've already made it. You're here to try to understand why you made it."

Last important advice - we should help our fellow amateur athletes in whatever ways we could.  I learned this from Michael Francis of The Pune marathoners Club.  Michael, thanks a zillion for all you do in Pune.  We are indebted to you.
Gee, you happen to be a professional athlete?  So you have slightly different goals.  You know what role you are in.  And yes we all know - what goes around, comes around.  :-)

Tuesday, July 7, 2015

How do I extract files from ISO

I had created .iso file.  Then I wanted to check if a particular file is included in this image.

In the Windows world, a third party software is required to do this.  Linux has built-in support to do this.

I created a directory in which to mount the image.
mkdir /mnt/iso-check/

Then mount the .iso file.
mount -o loop  /disk1/iso/SONAS-  /mnt/iso-check/

Now I could traverse to /mnt/iso-check/ and check that the required file is in there or not.

After I am done with whatever I was looking for, I unmounted the image.
umount /mnt/iso-check

Monday, April 21, 2014

How do I calculate sum of a column of numbers

I executed a command at a Linux machine, and it produced a long output.  I did the filtering, and now I have a column of numbers.  Now, how do I calculate sum of these numbers?  If you have awk available at your machine, here's how to do it.

$ your_long_list_of_command | awk '{ sum+=$1 } END { print sum}'

Wednesday, January 5, 2011

Sorting techniques in Perl

Check out this SlideShare Presentation:

Thursday, September 2, 2010

Validating numbers in a perl script

This morning one of my perlish friends asked me for help. He had a regular expression that was used for validating a string which contained numbers. The regex was failing and he wanted to know how to fix it. The strings he had were "12.3%", "1.25%" and similar. Numbers in it came from disk space usage, in percentages varying from 0% to 100% Similar to what we see in the output of df command.
And he wanted to extract the numeric part of it, to be used in numeric calculations.

His regex was not taking into account that these numbers could have "optional" parts. They could be "100%", "12%", "0.8%", "0%" and so on. Here is the regex I gave him.

[root@sonash5 tmp]# perl -e '$str = "1.23%"; print "matches" if ($str =~ m/^((\d{1,3})?(\.\d+)?)\s*%$/); print ", and the match is $1 \n"'
matches, and the match is 1.23
[root@sonash5 tmp]#

Are you thinking, why not just remove the % character from end of the string and use the rest of it as numeric entity?

That's a bad idea. What if some machine gives you "75 %"? Or even "75", assuming that they are percentages? And the string obtained could even be " 34.5%", resulting in the numeric calculations go wrong. When those string are coming from a source that you don't know, or may vary based on the operating system and the hardware and other things, it is a good idea to validate the string for the numeric pattern that you are looking for. And if the pattern is found, extract it and use it further.

Tuesday, May 25, 2010

How do I I find doubled words in a file

Noticed that mistake in the title? Or missed it? Here's how to catch those in your text files.

perl -nl -e 'print if m/\b(\w+)\s+\1/' filename

Instead if the whole line, you just want to see the line number and the word that is doubled?

perl -nl -e 'print "$. : $1" if m/\b(\w+)\s+\1/' filename

And you want to correct these?

perl -pi -e 's/\b(\w+)\s+\1/\1/g' filename

Friday, May 21, 2010

How do I get difference between two dates that are in yyyy-mm-dd format

A few days ago one of my friends asked me - How to get the difference in terms of number of days from two dates stored in yyyy-mm-dd format. I was in a hurry and told him how to go about, but couldn't show him the exact steps.

Yesterday I posed this questions to the interns in our company, thinking they would benefit from solving it. I told them to read the date values from shell environment variables, and use the programming language /tools of their choice to prepare the solution.

One guy wrote a neat C code to get the answer. He had to maintain a data structure to store how many days are present in all the months of the year, and also a function to find if the given year is a leap year or not. That resulted in the code growing to about 100 lines.

I asked them if they could think of some other approach, and if they were aware of how time is maintained in UNIX systems.

A perl script that uses package Time::Local makes the task easier to accomplish.

use strict;
use warnings;
use Time::Local;

my $date1 = $ENV{'date1'};
my $date2 = $ENV{'date2'};

my @date1_breakup = split(/-/, $date1);
my @date2_breakup = split(/-/, $date2);

my $date1_unix = timelocal(0, 0, 0, $date1_breakup[2], $date1_breakup[1], $date1_breakup[0]);
my $date2_unix = timelocal(0, 0, 0, $date2_breakup[2], $date2_breakup[1], $date2_breakup[0]);

my $diffSeconds = $date2_unix - $date1_unix;
my $diffDays = $diffSeconds / (60 * 60 * 24);
print "difference in days : $diffDays\n";

A plain simple bourne shell script can also do the job for us, if the date command supports -d option.

date1_unix=`date -d $date1 +%s`
date2_unix=`date -d $date2 +%s`
diff=`expr $date2_unix - $date1_unix`
diff_days=`expr $diff / 86400` # Number of seconds in a day are 86400
echo $diff_days

yogeshs@yogesh-laptop:~/temp$ export date1=2010-04-22
yogeshs@yogesh-laptop:~/temp$ export date2=2010-05-23
yogeshs@yogesh-laptop:~/temp$ ./

Here's what happened inside the shell script.
yogeshs@yogesh-laptop:~/temp$ sh -x
+ date -d 2010-04-22 +%s
+ date1_unix=1271874600
+ date -d 2010-05-23 +%s
+ date2_unix=1274553000
+ expr 1274553000 - 1271874600
+ diff=2678400
+ expr 2678400 / 86400
+ diff_days=31
+ echo 31

You still want to see how this is done using C? Do let me know and I'll share that piece of code with you.