Thursday, 26 July 2012

How does a search engine fetch answers to your queries ?

Ever wondered how does a search engine fetch answers to your queries in less than second? Google says it's a mixture of science, creativity, experimentation and cold, hard maths. This is how it works:

Thursday, 22 March 2012

Failure Breeds Success

Famous Personalities Who Failed At First
Business Gurus
1. Henry Ford
Ford is known for his innovative success but he failed five times before he founded the FORD Company. Henry Ford
2. R. H. Macy
Before the success of MACY, he failed in seven businesses and finally succeeded with his new store. R. H. Macy
3. Soichiro Honda
The billion-dollar business, that is Honda, started initially with a series of failures. He started making scooters of his own at home and spurred on by his neighbors, finally started his own business. Soichiro Honda
4. Bill Gates
Gates didn't seem like a shoe-in for success after dropping out of Harvard and starting a failed first business with Microsoft co-founder Paul Allen called Traf-O-Data. Bill Gates
5. Harland David Sanders
Sanders founded KFC and his famous secret chicken recipe was rejected 1,009 times before a restaurant accepted it. Harland David Sanders
6. Walt Disney
Walt Disney had a bit of a rough start and he was fired by a newspaper editor because, 'he lacked imagination and had no good ideas'. He kept plugging along, however, and eventually found a recipe for success that worked. Walt Disney
Scientists
7. Albert Einstein
Albert Einstein Einstein did not speak until he was four and did not read until he was seven, and his teachers and parents thought he was mentally handicapped, slow and anti-social. But he caught on pretty well in the end, winning the Nobel Prize and changing the face of modern physics.
8. Charles Darwin
Charles Darwin In his early years, Darwin gave up on having a medical career and considered as a lazy boy. Now, Darwin is well-known for his scientific studies.
9. Isaac Newton
Isaac Newton Newton was failed so many times in his school days and was sent off to Cambridge where he finally blossomed into the scholar we know today.
10. Thomas Edison
Thomas Edison Edison was fired for being unproductive In his early years. Even as an inventor, Edison made 1,000 unsuccessful attempts at inventing the light bulb.
11. Orville and Wilbur Wright
Orville and Wilbur Wright After numerous attempts at creating flying machines, several years of hard work, and tons of failed prototypes, the brothers finally created a plane.
Public Figures
12. Winston Churchill
This Nobel Prize-winning, twice-elected Prime Minster of the United Kingdom struggled in school and failed the sixth grade. After many years of political failures, finally became the Prime Minister at the ripe old age of 62. Winston Churchill
13. Abraham Lincoln
After Lincoln was failed many times in business and defeated in numerous runs, he became a greatest leader. Abraham Lincoln
14. Oprah Winfrey
Oprah faced a rough and abusive childhood as well as numerous career setbacks in her life to become one of the most iconic faces on TV. Oprah Winfrey
Writers and Artists
15. Steven Spielberg
Steven Spielberg Spielberg's name was rejected from the University of Southern California School of Theater, Film and Television three times. Thirty-five years after starting his degree, Spielberg returned to school in 2002 to finally complete his work and earn his BA.
16. J. K. Rowling
J. K. Rowling Rowling may be rolling in a lot of Harry Potter dough today, but before she published the series of novels she was nearly penniless, severely depressed, divorced, trying to raise a child on her own while attending school and writing a novel.
Athletes
17. Michael Jordan
Most people wouldn't believe that a man often lauded as the best basketball player of all time was actually cut from his high school basketball team. 'I have failed over and over and over again in my life. And that is why I succeed.' Michael Jordan

Wednesday, 29 February 2012

Find it difficult to focus on work after lunch?

Do you always feel like grabbing a snooze after lunch? These simple tips will help you stay at your sharpest even after your meal.

Why do you feel tired after lunch?

There could be a variety of factors causing you to feel sleepy after lunch:
  • What you eat plays an important part in deciding your energy levels. While some foods can boost your energy, others can zap it out. Junk food, sugary food or fatty food will make you feel lethargic and sleepy. These foods increase your blood sugar causing your body to release more insulin. This in turn triggers tryptophan, a kind of amino acid, known for its role in producing brain messengers or neurotransmitters related to sleep and relaxation.
  • Have you been getting adequate rest? It may seem obvious but if you’ve been having stressful and sleepless nights, you’re bound to feel sleepy during the day. Try getting at least 6 -7 hours of sleep every day.
  • If you have been eating healthy and are getting adequate sleep, you could be suffering from an illness. Sometimes, low fitness levels or some underlying disease could be responsible for draining you out. Your doctor should be able to detect this easily.

Tips to feel energetic after lunch

  • Watch what you eat: Junk food is a strict no no. Stick to a low carbohydrate and high protein diet. In simple terms, it means potatoes, white rice and pasta are out and sprouts, beans and cabbage are in. Keep your meal portions small as large meals require more effort to digest.
  • Save the alcohol for the weekend: Even if it’s an office party and you can have a glass of wine or beer, if you are expected to get back and work, it’s preferable to stay off the alcohol.
  • Take a little walk after lunch: Walk off your drowsiness by taking in some fresh air. Apart from getting rid of your lethargy, it’s a good way to include some activity in your daily schedule. Especially if your job involves sitting in one place.
  • Minimise your caffeine intake: I know coffee seems like a great perk-me-up, but the more coffee you consume, the more immune you get to its effects. Switch to water. Many people don’t feel thirsty in an air conditioned office and end up dehydrating their bodies.
  • Make sure you have breakfast: One cannot stress enough, the importance of having breakfast. Studies show that people who have a healthy breakfast are mentally and physically more active than those who skip it.
It may be hard to believe that such simple changes in your lifestyle can magnify your energy levels drastically. Try them out !

Monday, 30 January 2012

HOW TO SURVIVE A HEART ATTACK WHEN ALONE

Let's say it's 6.15pm and you're going home (alone of course),
after an unusually hard day on the job. You're really tired, upset and frustrated. Suddenly you start experiencing severe pain in your chest that starts to drag out into your arm and up into your jaw. You are only about five miles from the hospital nearest your home. Unfortunately you don't know if you'll be able to make it that far. You have been trained in CPR, but the guy that taught the course did not tell you how to perform it on yourself..!!

NOW HOW TO SURVIVE A HEART ATTACK WHEN ALONE..

Since many people are alone when they suffer a heart attack, without help, the person whose heart is beating improperly and who begins to feel faint, has only about 10 seconds left before losing consciousness.
However, these victims can help themselves by coughing repeatedly and very vigorously.
A deep breath should be taken before each cough, and the cough must be deep and prolonged, as when producing sputum from deep inside the chest.
A breath and a cough must be repeated about every two seconds without let-up until help arrives, or until the heart is felt to be beating normally again.
Deep breaths get oxygen into the lungs and coughing movements squeeze the heart and keep the blood circulating.
The squeezing pressure on the heart also helps it regain normal rhythm. In this way, heart attack victims can get to a hospital.

Sunday, 29 January 2012

How to Store or Save and Read Image in SQL Server table

How to Store or Save Image in SQL Server table

To store an image in to sql server, you need to read image file into a byte array. Once you have image data in byte array, you can easity store this image data in sql server using sql parameters. Following code explains you how to do this.

        private void cmdSave_Click(object sender, EventArgs e)
{
    try
    {
        //Read Image Bytes into a byte array
        byte[] imageData = ReadFile(txtImagePath.Text);

        //Initialize SQL Server Connection
        SqlConnection CN = new SqlConnection(txtConnectionString.Text);

        //Set insert query
        string qry = "insert into ImagesStore (OriginalPath,ImageData) _
                                    values(@OriginalPath, @ImageData)";

        //Initialize SqlCommand object for insert.
        SqlCommand SqlCom = new SqlCommand(qry, CN);

        //We are passing Original Image Path and
        //Image byte data as sql parameters.
        SqlCom.Parameters.Add(new SqlParameter("@OriginalPath",
                                    (object)txtImagePath.Text));
                                   
        SqlCom.Parameters.Add(new SqlParameter("@ImageData",
                                            (object)imageData));

        //Open connection and execute insert query.
        CN.Open();
        SqlCom.ExecuteNonQuery();
        CN.Close();

        //Close form and return to list or images.
        this.Close();
    }
   Following code explains how to read image file in to a byte array.

       
    //Open file into a filestream and
    //read data in a byte array.
    byte[] ReadFile(string sPath)
    {
        //Initialize byte array with a null value initially.
        byte[] data = null;

        //Use FileInfo object to get file size.
        FileInfo fInfo = new FileInfo(sPath);
        long numBytes = fInfo.Length;

        //Open FileStream to read file
        FileStream fStream = new FileStream(sPath, FileMode.Open,
                                                FileAccess.Read);

        //Use BinaryReader to read file stream into byte array.
        BinaryReader br = new BinaryReader(fStream);

        //When you use BinaryReader, you need to
        //supply number of bytes to read from file.
        //In this case we want to read entire file.
        //So supplying total number of bytes.
        data = br.ReadBytes((int)numBytes);
        return data;
    }

How to read image data bytes from SQL Server table

To read images from SQL Server, prepare a dataset first which will hold data from SQL Server table. Bind this dataset with a gridview control on form.

    void GetImagesFromDatabase()
    {
        try
        {
            //Initialize SQL Server connection.
            SqlConnection CN = new SqlConnection(txtConnectionString.Text);

            //Initialize SQL adapter.
            SqlDataAdapter ADAP = new SqlDataAdapter("Select * from ImagesStore", CN);

            //Initialize Dataset.
            DataSet DS = new DataSet();

            //Fill dataset with ImagesStore table.
            ADAP.Fill(DS, "ImagesStore");

            //Fill Grid with dataset.
            dataGridView1.DataSource = DS.Tables["ImagesStore"];
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }

   Once you have image data in grid, get image data from grid cell. Alternatively you can also get image data from Dataset table cell.

            //Store image to a local file.
            pictureBox1.Image.Save("c:\test_picture.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
           If you want you can extend this code to save image from Picture Box to a local image file.

    //Store image to a local file.    pictureBox1.Image.Save("c:\test_picture.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);Points of Interest
If you see frmImageStore in design mode, I have placed picturebox1 into a panel. This panel's AutoScroll property is set to True and SizeMode property of PictureBox1 is set to True. This allows picturebox to resize itself to the size of original picture. When picturebox's size is more than Panel1's size, scrollbars becomes active for Panel.