Sunday 29 December 2013

Sending Mail using PHP

Recently, I was trying to send mails using php script
I found out a couple of alternatives to get the work done.
There are a lot of good sites sharing this information. I am just sharing the steps  I took to get the job done.
I have used "Mail:factory " to send the mail. Again there a lot of options here, I have just used the most convenient one for me. Others are free to try and post
any options they can find.

Here goes nothing,

<?php
require_once "Mail.php";

 $from = "from where you want";

 $to = "send to your friend";
 $subject = "Testing No Reply! Pl. Ignore";
 $body = "Hi,\n\nTesting No Reply Functioning?";

 $host = "smtp server address";
 $port = "25"; #commonly 25 please check the port you are using

 $username = "USERNAME";
 $password = "PASSWORD";

 $headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     'port' => $port,
     'auth' => true,
     'username' => $username,
     'password' => $password));

 $mail = $smtp->send($to, $headers, $body);

 if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
  } else {
   echo("<p>Message successfully sent!</p>");
  }
?>



As you might have guessed, you will have to install "mail" for this to work For this we will install "pear" The simple command is (for linux : apt or yum)
sudo apt-get install php-pear
Once we are done with pear installation we will install the mail application
pear install mail
If you get a message saying "no such package" then please check the internet connection. If you need to set the proxy for pear package then please use
pear config-set http_proxy
 http://username:password@your_proxy_server:port
Note: The whole command is a to be used in a single line. Please do not press the return key

This should pretty much to the trick.

I received a lot of help from Nitin Dalvi with regards to the script
The code block highlighting method can be found at the following link http://mateenmoosa.wordpress.com/2011/08/09/blogger-code-block/

Sunday 25 August 2013

Growing Up -- Credit

Credit can mean  a lot of things. Most would be happy it reflected in their in bank statements but here I am referring to something called "Shabaski".

From our childhood we are trained to get credit for the things we do.
I am using the word trained because I believe no one is born with this idea. We gradually pick it up.
Let's look at this example.
A ten year old child is asked to pick up something from the floor and put it in the dustbin.
The child does this task ( Let us assume for the example the child actually listens in this case).
After successfully completing the task the gets a pat on his back.

This small thing develops in a habit. As the child grows this behaviour is repeated quite a few times.
Now the child is accustomed to this and every time he does something he looks into the eyes of the parents expecting a pat or may be a chocolate or may be pocket money depending on the age of the child.

Instead as he grows the pat's on his back tend to decrease. Something that was once considered very good suddenly seems to have lost its value.
Then he starts rationalizing in the wrong way (as we often do).

He first thinks, his task was not seen and may be if he repeats he will get the expected result.
Sometimes it works sometimes it doesn't. As time goes by this approach also changes.
Then he begins to wonder why the significance of his work is not being taken into account.
The task may be actually quite small and routine but for him it is the biggest thing there is.
Then he starts thinking if he is undervalued and so on and so forth.

The problem is we all think this way. Everyone wants appreciation for the work they do and there is nothing wrong in getting some appreciation. But as we grow we should realize we are doing certain things because we want to do them. So appreciation by others surely feels good but in no way does it help in enhancing or degrading the value of the work.
Rather should I say when we realize such things we start growing up.

Saturday 6 July 2013

RSSI and Throughput for MIMO

Throughput and RSSI are two of the most mysterious entities of the AP measurement world.
For Throughput measurement is an issue and for RSSI the interpretation of the measured value is a cause of concern. They vary from device to device and from one environment to other. This makes it almost impossible to define a standard set of values. For you define a standard then a room where the measurements are taken, the devices with which the measurements are taken including the wifi adapters and drivers and the exact same conditions have to be replicated.
The hardware can be duplicated but the environmental conditions, how do we create a mirror of these ?

If this was not complex for SISO systems we now have MIMO,  where complex ascends to a totally different level.
As per my understanding RSSI values are generally scaled values not raw power at the antenna. The way these values get scaled depends on the manufacturer of the card and varies with different manufacturers. For e.g. some may choose 10 levels to scale the received power, some may choose 100 levels to scale the received power. Based on the scaling the same number can mean a different value for each manufacturer. There's no specific standard for this. One reason is because RSSI is mostly used for internal calibration. So different scales imply different calibration, which is fine.

A general trend suggests with increasing distance, RSSI decreases and so does the throughput. However, this is not linear. In MIMO systems, RSSI determines whether a client (any laptop or phone) can connect to the AP in consideration. If the RSSI is so low that no signal is detected then it doesn't matter what technology we use, we don't get anything. The noise floor is generally considered to be around -96 dbm. Now, depending on your client's sensitivity the minimum RSSI level will be decided.

It would be our first guess that plotting RSSI vs Throughput will give a straight line. It holds if we have a SISO system and in MIMO if we have very few obstacles. But here comes the troublesome part. In MIMO if we go in the shadow zone of an obstacle the RSSI will most likely drop but the throughput might increase or decrease depending on the processing gains obtained by various paths.
So now how do we measure the actual throughput in an office like environment with different cubicles. If we try to plot the RSSI vs Throughput graph now we will see points all over the place. This does not give a very good picture as to how these quantities behave.

Now lets make things even more complicated. Let the environment change as  a function of time. Lets measure the RSSI and throughput at some fixed places. What we now expect(and if we are lucky we might get to see)  is a band of values. I shall leave the interpretation to a keen observer.

 

Sunday 3 February 2013

Why does a cat close its eyes when drinking milk?

We have a heard a lot of saying referring to a cat closing its eyes and drinking milk.
We compare it to people who feel the world stops looking just because they can not see
who is looking.
We also refer it to short sightedness.

But do we really think why the cat closes it's eyes when drinking food?

It is vulnerable when snacking to other creatures of  bigger size.
Mostly kids throwing stones or playing cricket, sometimes dogs and
sometimes adults when the cats sneaking into the house to have a drink.

Even so, the eyes are closed

There can be a simple explanation to it.

If the eyes were open the cat might get a squint.

It's face is so close to the bowl and the tongue is also small.
Trying to look at such close distances will be like trying to look at our nose to figure out how big it is.

In all fairness, even we don't look at out morsels when we are eating
We are too busy looking at the opposite person and pointing mistakes or too lost in out thoughts to notice our hands going to our mouth and food in our tummies.