How Many Calories Do You Burn In A Day?
Good health comes from maintaining balanced body weight which needs to be proportionate to ones height, age and gender. My current IT computer job doesn’t give me anytime to maintain so called good BMI (Body Mass Index); as my work hours starts from 8:30AM and ends at 9PM on a typical weekday. Moreover it is not an excuse to say that I don’t have time so decided to do some strenuous work-outs which includes walking and cycling daily. So my schedule includes walking for 1 hr and cycling for 20-30mins everyday; which is nothing but 500 calories/day.
I found below BMR calculation very good and taken from one of the blogs.
Knowing your basal metabolic rate (BMR) is the key to knowing how many calories you should, or shouldn’t eat in a day. Simply put, your BMR is the minimum amount of calories your body requires on a daily basis to complete its basic
functions (i.e. breathing, sleeping keeping your heart beating or regulating your internal temperature). Your BMR is dependent upon your age, height, and weight and gender. If you’ve noticed that every year, it becomes harder to eat whatever you want and stay slim, then, you may have discovered that your BMR decreases as you age. The good news is that a regular routine of cardiovascular exercise (walking, jogging, swimming, aerobics, etc) can increase your BMR.
Once you know your BMR, then you can determine your Total Daily Caloric Expenditure by adding to that number, the number of calories used (i.e. energy burned) in your physical activity and the energy burned in digesting your food … yes digesting your food is work and uses caloric energy.
Once you have estimated your total daily caloric expenditure, you can more accurately calculate how many calories you can afford to eat (i.e. your daily calorie budget) and how much exercise you need to do every day to maintain, gain or lose weight to meet your healthy weight goals.
Basic Daily Caloric Expenditure Calculation
1 – Estimating your BMR
Calculating your BMR can be a very scientific process, but here is a quick “back of the envelope” sort of calculation which gives a good estimate.
BMR = your body weight (in pounds) multiplied by 10.
Example: 186 pounds x 10 calories/pound = 1,860 calories
Another more accurate way of calculating your BMR is called the Harris-Benedict Formula This formula takes into consideration your gender and age along with your weight. Visit http://en.wikipedia.org/wiki/Basal_metabolic_rate for the formula.
Alternatively, you can visit this site for an online BMR Calculator that takes your age, weight and gender into account. http://www.bmi-calculator.net/bmr-calculator/
2. Next factor in Calories Used in Physical Activity
Multiply your BMR by the appropriate activity level factor, as follows:
Physical Activity Calories = (BMR x Activity Level):
* Sedentary: 20% (Sitting most of the day)
* Lightly Active: 37.5% (Walking here and there; daily chores)
* Moderately Active: 40% (Constantly moving around; daily exercise)
* Very Active: 50% (Heavy exercise for prolonged periods of time, such as training for a sport)
Example: 1,860 calories x 0.20 = 372 calories for a sedentary person.
3 – Next Factor in The Calories Used During Digestion
Calories used during digestion, are estimated at 10% for the general population..
Digestion Calories = (BMR + activity level ) x 10%:
Example: (1860 + 372 calories) x 0.10 = 223 calories
4. Total Daily Caloric Expenditure = (BMR Calories + Physical Activity Calories + Digestion Calories)
Therefore, in order to maintain my current weight I burn an average of 2,455 calories every day to support my body’s most basic needs, activity level and digestion of food.
Now that I know my daily caloric expenditure, I can figure out how many calories I need to reduce in my diet in order to reach my weight loss goal.
Keep in mind that one pound of fat is equal to 3,500 calories. Therefore as a general rule of thumb, to loose 1 pound per week, I must take in a negative 500 calories a day or negative 3,500 calories per week. I can reduce the calories by a combination of eating less and exercising more to lose weight. So you see it’s pretty simple, if the total number of calories burned is more then the calories consumed it will lead to weight loss.
My goal is to lose 20 pounds over the next 4 months; that’s approximately 1.25 pounds (~4,000 calories) of fat in per week or 570 fewer calories each day.
MS Windows Inbuilt Keyboard
Very good piece of info………….
An alternative keyboard in Windows In case your keyboard or some keys stop working Microsoft provides you with an alternative way to type in using the mouse To work this tool go to
Start menu -> Select Run -> Type in OSK ->Press OK
A keyboard will appear that you can use both in Arabic and English
And to switch between Arabic and English just press the Shift key and choose the letter. This is helpful when the keyboard or part of your keys are not working.
Issue of Loading Invoker Servlet in Tomcat 6.0
I did some reading on Tomcat Invoker Servlet documentation and usage; and this all started when trying to fix an issue that I encountered when running a web application on tomcat from Eclipse IDE.
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.SecurityException: Servlet of class org.apache.catalina.servlets.InvokerServlet is privileged and cannot be loaded by this web application
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1145)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
… 6 more
I spent a good amount of time figuring out this exception by checking CATALINA_HOME/conf/server.xml and CATALINA_HOME/conf/web.xml configuration files in tomcat. But the real culprit lies in CATALINA_HOME/conf/context.xml where the problem comes when privelges of Context is undefined.
1. context.xml: Context privileged=”true” reloadable=”true” and
2. Also this file may need to be copied to {Eclipse_Workspace}\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf directory.
After making these changes the web app can be started on tomcat server from Eclipse IDE; and this time Invoker Servlet Exception should disappear.
Taken from Apache documentation: The default servlet-invoking servlet for most web applications, used to serve requests to servlets that have not been registered in the web application deployment descriptor.
So an invoker servlet can be used for teaching or testing purposes esp used to perform quick testing of servlet class by copying into the /classes directory of the web app.
In a nut shell, it is a dirty way of deploying servlets in mass. The proper way to deploy servlets is to configure each and every servlet in the application’s configuration file. This is tedious and problematic esp when developing or testing of servlets on fly.
Suppose that we have a context “test” with document base of “/home/xxx/workspace”, and we have created a servlet called “ServletTest.class”. With the Invoker Servlet enabled, we could simply drop our servlet into the application’s “WEB-INF/classes” (i.e., “/home/xxx/workspace/WEB-INF/classes/ServletTest.class”). Users can request this servlet via URL http://hostname:8080/test/servlet/ServletTest. In other words, the URL path “servlet” is mapped to “WEB-INF\classes”.
So the quick fix is to check the Context priveleges in context.xml and if that doesn’t work then copy the $CATALINA_HOME/conf/context.xml to the above specified location.
Windows 7 – 3Dimentional View
Recently I moved to Windows 7 OS and observed few good things about it. The best thing though is undoubtedly its 3-Dimentional view of running applications windows. For this you need to press Windows key along with tab key to get this view on Windows 7.
3D view remembers me of Jonathan Schwartz “Project Looking Glass” presentation; Sun dreamt about it and finally it is the M$ that implemented it.
Send Email from Java
Good small Java class which will send email from java.; and trying to save this content in my blog for future reference.
SendMail.java:
import java.io.*;
import java.net.InetAddress;
import java.net.Socket;{
public SendMail()
{
}
public static void main(String args[])
{
SendMail sm = new SendMail();
try
{
String smtpServer = args[0];
String sender = args[1];
String recipient = args[2];
String subject = args[3];
BufferedReader content = new BufferedReader(new InputStreamReader(new FileInputStream(args[4])));
sm.sendMail(smtpServer, sender, recipient, subject, content);
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void sendMail(String smtpServer, String sender, String recipient, String subject, BufferedReader content)
{
try
{
Socket s = new Socket(smtpServer, 25);
out = new PrintWriter(s.getOutputStream());
in = new BufferedReader(new InputStreamReader(s.getInputStream()));
String hostName = InetAddress.getLocalHost().getHostName();
receive();
send("HELO " + hostName);
receive();
send("MAIL FROM: ");
receive();
send("RCPT TO: ");
receive();
send("DATA");
receive();
send("Subject: " + subject + "\n");
for(String line = content.readLine(); line != null; line = content.readLine())
send(line);
send(".");
receive();
s.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
public void send(String s)
throws IOException
{
System.out.println(s);
out.print(s);
out.print("\r\n");
out.flush();
}
public void receive()
throws IOException
{
String line = in.readLine();
if(line != null)
System.out.println(line);
}
private BufferedReader in;
private PrintWriter out;
}
#!/bin/sh
mail-server="bedge1-mail1.Central.XXX.COM"
TO="abc@xxx.com"
FROM="bsk@xxx.com"
SUB="Test Mail"
LOGFILE="EmailData"
$JAVA SendMail ${mail-server} $TO $FROM $SUB $LOGFILE
Code Snippets
Listing out some code snippets:
1. Short 2 liner code which will give the highest number of an array.
public int guessWhat( int arr[] )
{
for( int i = 0, x= 0; i < arr.length; i++ )
x = x < arr[i] ? arr[i] : x;
return x;
}
2. Find the port occupied by the process or process-id.
pid=SOME_PROCESS_ID
netstat -nlp | grep $pid | awk ‘{print $4}’ | cut -f2 -d:
3. List all the ports occupied in a linux/solaris machine
netstat -nlp | grep tcp | awk ‘{print $4}‘ | cut -f2 -d:
4. jfind utility which will search for class file (s) from jar files in a given directory.
user@sqindia$ sh jfind directory-name class1 class2 ……
jfind.sh
#!/bin/sh
out=”";
c=”0″;
jarDir=$1;
if [ ! -x ${jarDir} ] ; then echo “Directory or File $jarDir does not exit.”; exit 1; fi
shift 1;
cls=$*;
ss=$#;
tf=”`echo “$*” | sed -e ‘s/ /\\\\|/g’`”;
for i in `find $jarDir -name “*.jar” -print`
do
out=`jar -tvf $i | grep -w ${tf}* | awk ‘{print $8}’`;
if [ "$out" != "" ] ; then
c=”1″;
echo;
echo “————————-”;
echo “Jar file: ‘${i}’ “;
out1=`echo $out | sed -e ‘s/ /\\\\n/g’`;
echo -e $out1;
echo “————————-”;
fi
done
if [ "$c" = "0" ]; then
echo “The classname ‘$cls’ cannot be found.”;
fi
Output:
[bala@cepheusvir16 ~]$ jfind $JAVA_HOME/jre/lib BootstrapServer StubEntry BadPaddingException
————————-
Jar file: ‘/usr/local/java/jre/lib/jce.jar’
javax/crypto/BadPaddingException.class
————————-
————————-
Jar file: ‘/usr/local/java/jre/lib/rt.jar’
com/sun/corba/se/impl/util/StubEntry.class
com/sun/corba/se/internal/CosNaming/BootstrapServer.class
————————-
Jfind is a very cool utility which will help in searching for class file(s) from huge jar-file repository.
5. Automate interactive script using expect
#!/usr/local/bin/expect -f #
spawn ssh
expect “password:”
send xxxxx\n
interact
put employees.lst
put student.lst
echo “Transfer complete”
bye
7. On Solaris you can create a read-only version of any directory by adding something like this to /etc/auto_direct:
/var/rot -ro,fstype=lofs :/var/tmp
Then you can go to /var/rot to read what’s in /var/tmp, but you can’t write anything.
Command List for Windows and Unix
Important UNIX and Windows commands for use.
Quite an old collection and some commands can be irrelevant now and for some commands expecting MKS tool kit or Cygwin on Windows.
1) To know the Ethernet and other Ip address details:
> ipconfig /all —- for Windows Desktop
> ifconfig -a —- for Solaris and Linux Desktop
2)To check the protocol and N/W statistics
> netstat -rn
3) To know whether a system is alive and know its ip-address:
> ping -s host-name for Solari/Linux workstations
> ping hostname for Windows workstations
4) Find a file/directory in command line
> find (./dir-name) -name “hello.java”
> find (./dir-name) -name “hello.java” -print
> find (./dir-name) -type d –> This will list the fully qualified directory name inside dir-name name.
5)Remote login to a machine
> rlogin hostname/ipaddress in Win/Solaris/Linux
6)Telnet into a machine(Windows)
> telnet hostname/ipaddress
7) Information of Threads for a particular Process
ps -LP “process-id”
8)To mount a file system in Linux
U shd be at the point of sqindia/export
$ for i in 1 2 3 4 5 6 7 8 9
> do
> mkdir disk0$i
> mount sqindia.india.sun.com:/export/disk0$i disk0$i
>done
9)Find the disk space in Solaris
df -k will show total space mounted
du -k shows the space used
10)To create a Symbolic link
ln -s oldfilename(from what) slinkname(to here)
11)To Set CLASSPATH variable in Solaris and Linux
ksh> set CLASSPATH=classpath1:classpath2:classpath3:.
ksh> export CLASSPATH
ksh> export CLASSPATH=classpath1:classpath2:classpath3:.
In Windows:-
ksh> set CLASSPATH=classpath1;classpath2;.
12) To set the Path variable
ksh / sh > setenv PATH path1:path2:path3:$path:. ****In Solaris and Linux
> export PATH
> setenv PATH=path1;path2;path3;%path%;. ****In Windows
13)To find the processor configuration
> psrinfo -v ——- In Solaris
> prtconf
> prtconf -v
> eeprom
14)Find the system diagnostic info to find the error log
> dmesg — In Solaris
15)Find the patches that have been installed
showrev -p — In Solaris
16)To find the audio and videocards
$ sndconfig —-In Solaris for Sound cards
else check this file etc/modules.conf
17) Command to find whether a system supports which bit kernel
$ getconf HW_CPU_SUPP_BITS /// In Solaris and Linux
$ getconf KERNEL_BITS or: $ file /stand/vmunix
18) Command to find whether running 32 bit or 64 bit processor
$ isainfo
19) Command to recursively change the permissions of a directory
$ chmod -Rf 722 dir-name
20) Again few more points on system configuration
/usr/sbin/psrinfo
/usr/sbin/prtconf
RAM: prtconf | grep -i mem
CPU: mpstat
or
/usr/platform/`uname -m`/sbin/prtdiag
Try /usr/platform/`uname -m`/sbin/prtdiag. This will give you the amount of memory installed and speed and number of processors.
The command “prtconf” does it. If you want more and better details get sysinfo off the network.
dmesg | egrep ‘cpu|mem’
21) Get CPU, RAM and other etc info in Solaris and Linux
cat /proc/cpuinfo
22) ipcs – report inter-process communication facilities status
23) vmstat – reports virtual memory statistics regarding kernel thread, virtual memory, disk, trap, and CPU activity.
24) prstat – report active process statistics
25) /etc/logindevperm file help to set the drivers of the devices in the solaris environment.
26) mdb – modular debugger: The mdb utility is an extensible utility for low-level debugging and editing of the live operating system, operating system crash dumps, user processes, user process core dumps, and object files. For a more detailed description of mdb features, refer to the manual, Solaris Modular Debugger Guide.
27) kstat – disply kernel statistics: The kstat utility examines the available kernel statistics, or kstats, on the system and reports those statistics which match the criteria specified on the command line. Each matching statistic is printed with its module, instance, and name fields, as well as its actual value.
28) ptree – help to print the process in a tree hierarchical format.
29) mpstat – report per-processor or per-processor-set statistics
30) umask – get or set the file mode creation mask
31) rctladm – display or modify global state of system resource controls
32) arp – address resolution display and control
33) fmdump – fault management log viewer: The fmdump utility can be used to display the contents of any of the log files associated with the Solaris Fault Manager, fmd(1M). The Fault Manager runs in the background on each Solaris system. It receives telemetry information relating to problems detected by the system software, diagnoses these problems, and initiates proactive self-healing activities such as disabling faulty components.
34) dbx usage manual and commands :
%> dbx /java/jdk/latest/binaries/solaris/bin/java
(dbx) dbxenv rtc_inherit on # command needed for the leak checking to follow the fork/exec of child processes, which java does.
….
….
(dbx) check -leaks
….
….
(dbx) run -version
….
….
(dbx) cont
35) awk – pattern scanning and processing language
ls -l | awk ‘{print $2}’
36) sed – stream editor
>cat file
I have three dogs and two cats
>sed -e ‘s/dog/elephant/g’ -e ‘s/cat/tiger/g’ file
I have three elephants and two tigers
37) dump – dump selected parts of an object file
The dump utility dumps selected parts of each of its object file arguments.
The dump utility is best suited for use in shell scripts, whereas the elfdump(1) command is recommended for more human-readable output.
38) elfdump – dump selected parts of an object file
The elfdump utility symbolically dumps selected parts of the specified object file(s). The options allow specific portions of the file to be displayed.
The elfdump utility is similar in function to the dump(1) utility, which offers an older and less user-friendly interface than elfdump, although dump may be more appropriate for certain uses such as in shell scripts.
Archive files, produced by ar(1), can also be inspected with elfdump. In this case each object within the archive is processed using the options supplied.
39) ypcat hosts
ypcat helps to print all the hosts with its ipaddress in the local domain.
ypcat hosts | grep timetone
Prints the ipaddress and hostname of the timetone server.
40) /usr/ucb/ps -auxwww | grep java
This command should get you the whole command line for the running JVM including the memory settings.
41) ldd – list dynamic dependencies of executable files or shared objects
ldd /usr/lib/libc.so
libm.so.2 => /lib/libm.so.2
/platform/SUNW,Sun-Blade-1000/lib/libc_psr.so.1
42) nm – print name list of an object file
ldd /usr/lib/libc.so
libm.so.2 => /lib/libm.so.2
/platform/SUNW,Sun-Blade-1000/lib/libc_psr.so.1
nm /platform/SUNW,Sun-Blade-1000/lib/libc_psr.so.1 | grep memset
43) logname – command on Windows
Which gets you the current user-name.
$logname
Administrator
44) Remove tailing CTRL M characters from each line
In vi, do a :%s/^M//g
linux/solaris: dos2unix
Java Code on sqlplus
Trying something new. This blog page gives steps to write, compile and execute a piece of java code on sqlplus. So if you are lonely with no java compiler sqlplus got the answer to your java code.
Here it is.
Step-1: Write Java code by following below sql syntax.
ops@sqindia:/opt/10g > create or replace and compile java source
named “ABC”
2 as
3 import java.util.*;
4 import java.text.*;
5 public class ABC
6 {
7 static public void java_get_timezone( String[] p_timezone )
8 {
9 Date d = new Date();
10 DateFormat df2 = new SimpleDateFormat( “z” );
11
12 df2.setTimeZone( TimeZone.getDefault() );
13 p_timezone[0] = df2.format(d);
14 }
15 }
16 /
Java created
Step-2: Create a SQL procedure get_timezone which will create a java instance and call the particular method.
ops@sqindia:/opt/10g > create or replace
2 procedure get_timezone( p_timezone out varchar2 )
3 as language java
4 name ‘ABC.java_get_timezone( java.lang.String[] )’;
5 /
Procedure created.
3. Anonymous block to invoke the above created procedure.
ops@sqindia:/opt/10g > declare
2 tz varchar(25);
3 begin
4 get_timezone( tz );
5 dbms_output.put_line( tz );
6 end;
7 /
IST
Quite amazing; this facility really helps when you have only sqlplus in hand to validate a piece of java code.
Wisdom Education Trust
Straight from the inspiring note of Mr APJ Abdul Kalam “If I am authorized, I will remove the word impossible”. Yes I personally like this statement very much; nothing is impossible in this world. But I think only a healthy mind with good education will help an individual in handling the some thing called impossible.
In this context let me introduce a trust that is started by my old college mates. Which they call it “The Wisdom Education Trust” or WET in short. A non-profitable trust formed by 6 guys with great vision and working towards promoting the education in rural villages. The trust is started in January 2007 and main motto of this trust is to provide money, guidance to up lift the poor & intelligent students. The motto of the service says that “Education is the most powerful weapon in the entire universe.”. This is the second year for the WET after a very enriching success the last year; where in the last year the community found 15-20 deserving students. Provided them scholarships which basically includes paying tuition fees, providing books, giving guidance etc.
Deeply motivated by the fact recently I joined the trust and the process of finding deserving students is as follows:
1. Schools authorities send some nominations of students who are smart & intelligent but very poor.
2. The student data is checked & thoroughly verified.
3. Then a final list is prepared out of them who definitely require scholarships or economical support.
4. Funds are raised from friends to meet the current year requirements.
The domain for the WET is registered and found as http://www.wet-mission.com .
Wishing good luck for WET.
Boring evenings with out IPL
After the breath taking action for 45 days the Indian premier League (IPL) ended on Sunday 01 June and Rajasthan Royals emerged as the Winners of the tournament. As everybody knows that IPL is the cricket form of the English Premier League (EPL) and the UEFA Champions League; popular Soccer tournaments. The IPL is a very big hit in the cricketing world which brought lot of action, drama and money. A typical 20-20 game will last only for 3-3.5 hrs; which instilled non-stop and scintillating action to the game and to its enthusiasts.
I think the 20-20 version of cricket is really a great invention and it is threatening the popularity of one day format of the game. This made the first version of the IPL a big success and it left over good memories to cherish. The 20-20 will help in attracting the Europeans and Americans to the cricketing world; also help in globalizing the game.
Regarding the grand final of the tournament it was really electrifying till the last ball of the match. Each team fought to their skin and tried their level best to win. The match brought us the memory of the ICC Twenty20 world cup final between India & Pakisthan; where India emerged victorious of the world cup in the last over of the match. At one point of time I thought that the Chennai Super Kings upsets the Rajasthan Team. But Rajasthan’s winning consistency has paid off and emerged as winners of the tournament. The inspirational & legendary leg spinner Shane Warne lead the Rajasthan team; he didn’t lose his spin rhythm despite of his retirement from Cricket. And not the least the Chennai Super Kings skipper Dhoni need a special applause for his captaincy and he proved himself again as the Mr Cool & Composed of the cricketing world.
Evenings are great with IPL in full flow with atleast one match everyday and the tournament really was part of the evening plan. Anxiously waiting for next version of IPL in 2009.
