Skip to content

How to set a unique and strong password for a site

It is becoming a challenge to set different/unique password for each of the websites for login purposes. Some times we end up having same password for most of the login accounts like an   email(gmail/yahoo/hotmail), office logins, bank logins, linked etc etc.

I found an interesting way of solving this issue:

{special-charater(s)}{Upper-Case-Letter(s)}{Login-site-Name}{Numeric-number-sequence}

example password for linked-in: $%Sundaylinkedin1245

example password for gmail: $%Sundaygmail1245

example password for a bank login: $%Sundaymybank1245

So in above examples though the password is unique it is but easy to remember as the text marked in bold is different (based on login site) and rest of the character will remain same.

Also it satisfies the condition of having a special-character, alpha-numeric, upper case; and most importantly it is unique for a given site.

Advertisements

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 class SendMail
{

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.