40 Tips for Happy Healthy Life - MUST READ & SHARE

Health

1. Drink plenty of water.

2. Eat breakfast like a king, lunch like a prince and dinner like a beggar.

3. Eat more foods that grow on trees and plants, and eat less food that is manufactured in plants.

4. Live with the 3 E’s — Energy, Enthusiasm, and Empathy.

5. Make time for prayer and reflection

6. Play more games.

7. Read more books than you did in 2012.

8. Sit in silence for at least 10 minutes each day.

9. Sleep for 7 hours.


Personality

10. Take a 10-30 minutes walk every day —- and while you walk, smile.

11. Don’t compare your life to others’. You have no idea what their journey is all about.

12. Don’t have negative thoughts or things you cannot control. Instead invest your energy in the positive present moment.

13. Don’t over do; keep your limits.

14. Don’t take yourself so seriously; no one else does.

15. Don’t waste your precious energy on gossip.

16. Dream more while you are awake.

17. Envy is a waste of time. You already have all you need.

18. Forget issues of the past. Don’t remind your partner with his/her mistakes of the past. That will ruin your present happiness.

19. Life is too short to waste time hating anyone. Don’t hate others.

20. Make peace with your past so it won’t spoil the present.

21. No one is in charge of your happiness except you.

22. Realize that life is a school and you are here to learn. Problems are simply part of the curriculum that appear and fade away like algebra class but the lessons you learn will last a lifetime.

23. Smile and laugh more.

24. You don’t have to win every argument. Agree to disagree.


Community

25. Call your family often.

26. Each day give something good to others.

27. Forgive everyone for everything.

28. Spend time with people over the age of 70 & under the age of 6.

29. Try to make at least three people smile each day.

30. What other people think of you is none of your business.

31. Your job won’t take care of you when you are sick. Your family and friends will. Stay in touch.


Pure unicode character smiley collection

Here is some collection of some pure unicode smiley characters.

Just select, copy paste and use anyone anywhere.


🍓 😹 💀 👌 📱 💻 💾 📺 📠 🔔 👃 ⛄ 💏 💑 🎃 👶 🎅 🎄 🎁 🎉 👂 👦 💅 👏 👫 💃 👶 💛 💙 💜 💚 💗 💓 💿 📀 💽 🎈 📞 🐵 🍁 💪 🙍 🌂 👌 💖 🐹 🎎 🎐 🎍 🐚 🎏 💝 🎓 👆 👇 💢 👊 💨 👐 👋 😺 😸 👅 😻 😽 💦🐻 🐷 💩 🐮 👀 👄 💋 💔 💘 🐟 👍 🐳 👎 👉 🐺 🐱 🐭 🐹 🐨 🐗 🍎 🍊 🍓 😹 💀 👌 📱 💻 💾 📺 📠 🔔 👃 ⛄ 💏 💑 🎃 👶 🎅 🎄 🎁 🎉 👂 👦 💅 👏 👫 💃 👶 💛 💙 💜 💚 💗 💓 💿 📀 💽 🎈 📞 🐵 🍁 💪 🙍 🌂 👌 💖 🐹 🎎 🎐 🎍 🐚 🎏 💝 🎓 👆 👇 💢 👊 💨 👐 👋 😺 😸 👅 😻 😽 💦📠 🔔 👃 ⛄ 💏 💑 🎃 👶 🎅 🎄 🎁 🎉 👂 👦 💅 👏 👫 💃 👶 💛 💙 💜 💚 💗 💓 💿 📀 💽 🎈 📞 🐵 🍁 💪 🙍 🌂 👌 💖 🐹 🎎 🎐 🎍 🐚 🎏 💝 🎓 👆 👇 💢 👊 💨 👐 👋 😺 😸 👅 😻 😽 💦🐻 🐷 💩 🐮 👀 👄 💋 💔 💘 🐟 👍 🐳 👎 👉 🐺 🐱 🐭 🐹 🐨 🐗 🍎 🍊 🍓 😹 💀 👌 📱 💻 💾 📺 📠 🔔 👃 ⛄ 💏 💑 🎃 👶 🎅 🎄 🎁 🎉 👂 👦 💅 👏 👫 💃 👶 💛 💙 💜 💚 💗 💓 💿 📀 💽 🎈 📞 🐵 🍁 💪 🙍 🌂 👌 💖 🐹 🎎 🎐 🎍 🐚 🎏 💝 🎓 👆 👇 💢 👊 💨 👐 👋 😺 😸 👅 😻 😽 💦🐻 🐷 💩 🐮 👀 👄 💋 💔 💘 🐟 👍 🐳 👎 👉 🐺 🐱 🐭 🐹 🐨 🐗 🍎 🍊 🍓 😹 💀 👌 📱 💻 💾 📺 📠 🔔 👃 ⛄ 💏 💑 🎃 👶 🎅 🎄 🎁 🎉 👂 👦 💅 👏 👫 💃 👶 💛 💙 💜 💚 💗 💓 💿 📀 💽 🎈 📞 

Javascript important code scripts


Browser window's position

var leftPos = (typeof window.screenLeft == "number") ?
 window.screenLeft : window.screenX;
var topPos = (typeof window.screenTop == "number") ?
 window.screenTop : window.screenY;

Browser window's size

var pageWidth = window.innerWidth,
pageHeight = window.innerHeight;
if (typeof pageWidth != "number"){
 if (document.compatMode == "CSS1Compat"){
  pageWidth = document.documentElement.clientWidth;
  pageHeight = document.documentElement.clientHeight;
 } else {
  pageWidth = document.body.clientWidth;
  pageHeight = document.body.clientHeight;
 }
}

Pop up opener

var exWin =window.open("http://www.example.com/"
   ,"exampleWindow"
   ,"height=400,width=400,top=10,left=10,resizable=yes");
 exWin.resizeTo(500,500);
 exWin.moveTo(100, 100);
 alert(wroxWin.opener == window);

Pre checking pop-up blocker

var blocked = false;
  try {
  var exWin = window.open("http://www.example.com", "_blank");
  if (exWin == null){
    blocked = true;
  }
  } catch (ex){
    blocked = true;
  }
  if (blocked){
    alert("The popup was blocked!");
  }

Avoid intervals; use timeouts

var num = 0;
  var max = 10;
  function incrementNumber() {
    num++;
    //if the max has not been reached, set another timeout
    if (num < max) {
  setTimeout(incrementNumber, 500);
    } else {
  alert("Done");
    }
  }
setTimeout(incrementNumber, 500);

Get query string arguments

function getQueryStringArgs(){
 //get query string without the initial ?
 var qs = (location.search.length > 0 ? location.search.substring(1) : ""),
        //object to hold data
        args = {},
  
        //get individual items
  items = qs.length ? qs.split("&") : [],
  item = null,
  name = null,
  value = null,
  
        //used in for loop
  i = 0,
  len = items.length;
  
  //assign each item onto the args object
  for (i=0; i < len; i++){
          item = items[i].split("=");
          name = decodeURIComponent(item[0]);
          value = decodeURIComponent(item[1]);
          if (name.length) {
            args[name] = value;
          }
        }
  return args;
}

To new location

location.assign("http://www.google.com/");

Diable back button

location.replace("http://www.google.com/");

Detect browser exit

window.onbeforeunload=function(e){return "Before Close";};

Replace All

String.prototype.replaceAll = function (find, replace) {
 var str = this;
 return str.replace(new RegExp(find.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), replace);
};

Number letter counts

If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.

If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?


NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters. The use of "and" when writing out numbers is in compliance with British usage.

Solution:


void Solution()
{
 Dictionary<int, string> numbers = new Dictionary<int, string>();
 numbers.Add(1, "one");
 numbers.Add(2, "two");
 numbers.Add(3, "three");
 numbers.Add(4, "four");
 numbers.Add(5, "five");
 numbers.Add(6, "six");
 numbers.Add(7, "seven");
 numbers.Add(8, "eight");
 numbers.Add(9, "nine");
 numbers.Add(10, "ten");
 numbers.Add(11, "eleven");
 numbers.Add(12, "twelve");
 numbers.Add(13, "thirteen");
 numbers.Add(14, "fourteen");
 numbers.Add(15, "fifteen");
 numbers.Add(16, "sixteen");
 numbers.Add(17, "seventeen");
 numbers.Add(18, "eighteen");
 numbers.Add(19, "nineteen");
 numbers.Add(20, "twenty");
 numbers.Add(30, "thirty");
 numbers.Add(40, "forty");
 numbers.Add(50, "fifty");
 numbers.Add(60, "sixty");
 numbers.Add(70, "seventy");
 numbers.Add(80, "eighty");
 numbers.Add(90, "ninety");
 numbers.Add(100, "hundred");
 numbers.Add(1000, "thousand");

 int sum = 0;
 for (int i = 1; i <= 20; i++)
 {
  sum += numbers[i].Length;
  Console.WriteLine(numbers[i] + " " + numbers[i].Length);
 }

 for (int i = 21; i < 100; i++)
 {
  int key = i / 10;
  if (i % 10 != 0)
   sum += numbers[key * 10].Length + numbers[i % 10].Length;
  else
   sum += numbers[key * 10].Length;
 }

 int sumTill1To99 = sum;

 for (int i = 101; i < 999; i = i + 100)
 {
  int key = i / 100;
  sum += numbers[key].Length + numbers[100].Length;
  sum += (numbers[key].Length + numbers[100].Length + "and".Length) * 99;
  sum = sum + sumTill1To99;

 }

 sum = sum + numbers[1].Length + numbers[1000].Length;
}

Lattice Paths Problem

Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.

How many such routes are there through a 20×20 grid?

Solution:

void Solution()
        {
            //Lattice Path Problem
            //The number of possible path at (i,j) = BinCoff(i+j,j)
            // So for 20x20 matrix it will be
            long x = BinomialCoefficient(40, 20);
        }

        static long BinomialCoefficient(long n, long k)
        {
            // return fact(n) / (fact(k) * fact(n - k));

            long divFactor = k > (n - k) ? k : (n - k);
            long restProd = 1;
            bool flag = true;
            long counter = 1;
            if (divFactor == k)
            {
                for (long i = 0; i < (n - k); i++)
                {
                    restProd = restProd * (k + 1 + i);
                    if (restProd % counter == 0 && flag)
                    {
                        restProd = restProd / counter;
                        //flag = false;
                        counter++;
                    }
                }
                return restProd;// / fact(n - k - counter);
            }
            else
            {
                for (long i = 0; i < k; i++)
                {
                    restProd = restProd * ((n - k) + 1 + i);
                }
                return restProd / fact(k);
            }


        }

        static long fact(long i)
        {
            if (i == 0)
                return 1;
            else
                return i * fact(i - 1);
        }

Highly divisible triangular number

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:

1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...

Let us list the factors of the first seven triangle numbers:

 1: 1
 3: 1,3
 6: 1,2,3,6
10: 1,2,5,10
15: 1,3,5,15
21: 1,3,7,21
28: 1,2,4,7,14,28

We can see that 28 is the first triangle number to have over five divisors.

What is the value of the first triangle number to have over five hundred divisors?

Solution:


void Solution()
        {
            int i = 1;
            int triangleNumber = 0;
            do
            {
                triangleNumber = i * (i + 1) / 2;
                i++;
            }
            while (NoOfDivisors(triangleNumber) <= 500);

            Console.WriteLine(triangleNumber);
        }

        static int NoOfDivisors(int num)
        {
            //Based on the formula, otherwise it will take infinite time
            //Let d(n) be the number of divisors for the natural number, n.
            //We begin by writing the number as a product of prime factors: n = paqbrc...
            //then the number of divisors, d(n) = (a+1)(b+1)(c+1)...

            int counter = 0;
            int totalCount = 1;
            bool flag = false;
            int tempNum = num;
            for (int i = 2; i <= num / 2; i++)
            {
                if (tempNum % i == 0)
                {
                    counter++;
                    tempNum = tempNum / i;
                    i--;
                    flag = true;
                    continue;

                }
                if (flag)
                {
                    totalCount = totalCount * (counter + 1);
                    counter = 0;
                    flag = false;
                }
                if (tempNum == 1)
                    break;
            }

            return totalCount;
        }

Largest product in a grid

In the 20×20 grid below, four numbers along a diagonal line have been marked in red.

08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48

The product of these numbers is 26 × 63 × 78 × 14 = 1788696.

What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid?

Solution :

void Solution()
        {
            int row = 20, col = 20;
            int[,] matrix = new int[,] {{08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08},
                                        {49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00},
                                        {81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65},
                                        {52,70,95,23,04,60,11,42,69,24,68,56,01,32,56,71,37,02,36,91},
                                        {22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80},
                                        {24,47,32,60,99,03,45,02,44,75,33,53,78,36,84,20,35,17,12,50},
                                        {32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70},
                                        {67,26,20,68,02,62,12,20,95,63,94,39,63,08,40,91,66,49,94,21},
                                        {24,55,58,05,66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72},
                                        {21,36,23,09,75,00,76,44,20,45,35,14,00,61,33,97,34,31,33,95},
                                        {78,17,53,28,22,75,31,67,15,94,03,80,04,62,16,14,09,53,56,92},
                                        {16,39,05,42,96,35,31,47,55,58,88,24,00,17,54,24,36,29,85,57},
                                        {86,56,00,48,35,71,89,07,05,44,44,37,44,60,21,58,51,54,17,58},
                                        {19,80,81,68,05,94,47,69,28,73,92,13,86,52,17,77,04,89,55,40},
                                        {04,52,08,83,97,35,99,16,07,97,57,32,16,26,26,79,33,27,98,66},
                                        {88,36,68,87,57,62,20,72,03,46,33,67,46,55,12,32,63,93,53,69},
                                        {04,42,16,73,38,25,39,11,24,94,72,18,08,46,29,32,40,62,76,36},
                                        {20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,04,36,16},
                                        {20,73,35,29,78,31,90,01,74,31,49,71,48,86,81,16,23,57,05,54},
                                        {01,70,54,71,83,51,54,69,16,92,33,48,61,43,52,01,89,19,67,48}};

            int prod = 1;
            int maxProd = 1;
            int maxAjd = 4;

            //Scanning RowWise Horizontally
            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < col - maxAjd + 1; j++)
                {
                    for (int k = 0; k < maxAjd; k++)
                    {
                        prod = prod * matrix[i, j + k];
                    }
                    if (maxProd < prod)
                        maxProd = prod;
                    prod = 1;
                }
            }

            //Scanning ColumnWise Vertically
            for (int i = 0; i < row - maxAjd + 1; i++)
            {
                for (int j = 0; j < col; j++)
                {
                    for (int k = 0; k < maxAjd; k++)
                    {
                        prod = prod * matrix[j, i + k];
                    }
                    if (maxProd < prod)
                        maxProd = prod;
                    prod = 1;
                }
            }

            //Scanning Backward Diagonally
            for (int i = 0; i < row - maxAjd + 1; i++)
            {
                for (int j = 0; j < col - maxAjd + 1; j++)
                {
                    for (int k = 0; k < maxAjd; k++)
                    {
                        prod = prod * matrix[i + k, j + k];
                    }
                    if (maxProd < prod)
                        maxProd = prod;
                    prod = 1;
                }
            }

            //Scanning Forward Diagonally
            for (int i = 0; i < row - maxAjd; i++)
            {
                for (int j = maxAjd - 1; j < col; j++)
                {
                    for (int k = 0; k < maxAjd; k++)
                    {
                        prod = prod * matrix[i + k, j - k];
                    }
                    if (maxProd < prod)
                        maxProd = prod;
                    prod = 1;
                }
            }
        }

Remote Debugging - Visual Studio

Introduction

We have been facing hurdles several times due to unavailability of environment where the software product is deployed. Sometimes, it becomes so much time consuming to find out the issue in our software product due to environment availability and thus we try to find out the issue by implementing regressive logging, capturing these logs and finding out the exact issue. This logging sometimes has to be repeated till we find out the exact root cause.

This article is for the developers and testers who have never used the Remote Debugging feature of Visual Studio. Through this article I will guide you how to debug from the code in your local machine in case you don't have the running product environment in your local system.

Suppose your product is deployed in a server The product may contains multiples modules and binaries as a part of it. Now suppose a user has reported an issue the is related to a Binary/Module. To find out the issue by code debugging, the Visual Studio has provided a great feature which is "Remote Debugging". Through remote debugging you will be able to generate the scenario from server end by using the product and debugging it through the local system where the code is.

The Remote Debugging Monitor (msvsmon.exe)

The Remote Debugging Monitor is a small application that allows you to debug the software component remotely. Before using the Remote Debugging Monitor, you must setup it in your server where the application is. Below are the steps to setup the Remote Debugging Monitor.

1) Download the Visual Studio 2010 Remote Debugging Monitor. Make sure to select the correct version according to the server configuration (32 bit or 64 bit).



2) Install Remote Debugging Monitor.


3) Go to the below mentioned path and execute msvsmon.exe.

For 64 bit Server : "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger\x64"
For 32 bit Server : "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger\x32"

4) Start the Remote Debugging Monitor.




5) GoTo the options menu and configure it as below.




6) Now the Remote Debugging Monitor is running with access to all users.


Debugging the application remotely

To debug any application or component of any application, follow the below steps mentioned:

  1. Copy the dll/exe and the pdb file from the debug folder of the CodeBase where the binaries are compiled.
  2. Paste these dlls/exes and the pdb file to the application deployment folder on the server.
  3. Now in case of Windows/Console application do the below steps:
    • Run the application on the server.
    • On the local machine, Open code in Visual Studio.
    • GoTo Debug from Menubar and select "Attach to Process..".
    • Look for the process of your application from the list and click OK.
  4. In case of Web application, follow the below steps:
    • Open the application through browser.
    • On the local machine, Open code in Visual Studio.
    • GoTo Debug from Menubar and select "Attach to Process..".
    • Select "w3wp.exe" and click Ok.
  5. Set the appropriate breakpoints in the code.
  6. Process the application and generate the scenario.
  7. The application remotely will hit the breakpoint due to Remote Debugging Monitor.

Points of Interest

There are other options as well which we can configure to restrict anonymous users to allow debugging through the tool. In some case, other elements like Firewall can restrict the remote debugging in-spite of the Remote Debugger Monitor service running. So, such concerns we have to take case in case of any issue.

Oracle DB Admin Important Queries

DB Lock status

select OS_USER_NAME os_user,
 PROCESS os_pid,
 ORACLE_USERNAME oracle_user,
 l.SID oracle_id,
 decode(TYPE,
  'MR', 'Media Recovery',
  'RT', 'Redo Thread',
  'UN', 'User Name',
  'TX', 'Transaction',
  'TM', 'DML',
  'UL', 'PL/SQL User Lock',
  'DX', 'Distributed Xaction',
  'CF', 'Control File',
  'IS', 'Instance State',
  'FS', 'File Set',
  'IR', 'Instance Recovery',
  'ST', 'Disk Space Transaction',
  'TS', 'Temp Segment',
  'IV', 'Library Cache Invalidation',
  'LS', 'Log Start or Switch',
  'RW', 'Row Wait',
  'SQ', 'Sequence Number',
  'TE', 'Extend Table',
  'TT', 'Temp Table', type) lock_type,
 decode(LMODE,
  0, 'None',
  1, 'Null',
  2, 'Row-S (SS)',
  3, 'Row-X (SX)',
  4, 'Share',
  5, 'S/Row-X (SSX)',
  6, 'Exclusive', lmode) lock_held,
 decode(REQUEST,
  0, 'None',
  1, 'Null',
  2, 'Row-S (SS)',
  3, 'Row-X (SX)',
  4, 'Share',
  5, 'S/Row-X (SSX)',
  6, 'Exclusive', request) lock_requested,
 decode(BLOCK,
  0, 'Not Blocking',
  1, 'Blocking',
  2, 'Global', block) status,
 OWNER,
 OBJECT_NAME
from v$locked_object lo,
 dba_objects do,
 v$lock l
where  lo.OBJECT_ID = do.OBJECT_ID
AND     l.SID = lo.SESSION_ID

Rows per block

SET PAUSE ON
SET PAUSE 'Press Return to Continue'
SET PAGESIZE 60
SET LINESIZE 300
COLUMN "Rows per Block" FORMAT 9999
 
SELECT
   count(*) as "Rows per Block"
FROM
   &&tabname
WHERE
   dbms_rowid.rowid_block_number(rowid) =
     (
     SELECT
        min(dbms_rowid.rowid_block_number(rowid))
     FROM &&tabname
     )

Execution plan

create table PLAN_TABLE (
        statement_id       varchar2(30),
        plan_id            number,
        timestamp          date,
        remarks            varchar2(4000),
        operation          varchar2(30),
        options            varchar2(255),
        object_node        varchar2(128),
        object_owner       varchar2(30),
        object_name        varchar2(30),
        object_alias       varchar2(65),
        object_instance    numeric,
        object_type        varchar2(30),
        optimizer          varchar2(255),
        search_columns     number,
        id                 numeric,
        parent_id          numeric,
        depth              numeric,
        position           numeric,
        cost               numeric,
        cardinality        numeric,
        bytes              numeric,
        other_tag          varchar2(255),
        partition_start    varchar2(255),
        partition_stop     varchar2(255),
        partition_id       numeric,
        other              long,
        distribution       varchar2(30),
        cpu_cost           numeric,
        io_cost            numeric,
        temp_space         numeric,
        access_predicates  varchar2(4000),
        filter_predicates  varchar2(4000),
        projection         varchar2(4000),
        time               numeric,
        qblock_name        varchar2(30)
);
commit




EXPLAIN PLAN
SET STATEMENT_ID= 'MY_FIRST_EXP'
FOR
<SQL QUERY for which execution plan needs to be generated>

SELECT * 
FROM   TABLE(DBMS_XPLAN.DISPLAY);

Active Sessions

SET LINESIZE 500
SET PAGESIZE 1000

COLUMN username FORMAT A15
COLUMN machine FORMAT A25
COLUMN logon_time FORMAT A20

SELECT NVL(s.username, '(oracle)') AS username,
       s.osuser,
       s.sid,
       s.serial#,
       p.spid,
       s.lockwait,
       s.status,
       s.module,
       s.machine,
       s.program,
       TO_CHAR(s.logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time,
       s.last_call_et AS last_call_et_secs
FROM   v$session s,
       v$process p
WHERE  s.paddr  = p.addr
AND    s.status = 'ACTIVE'
ORDER BY s.username, s.osuser;

SET PAGESIZE 14

Index Usage

SET VERIFY OFF
SET LINESIZE 200

SELECT table_name,
       index_name,
       used,
       start_monitoring,
       end_monitoring
FROM   v$object_usage
WHERE  table_name = UPPER('&1')
AND    index_name = DECODE(UPPER('&2'), 'ALL', index_name, UPPER('&2'));

Tablespaces

SET LINESIZE 200

SELECT tablespace_name,
       block_size,
       extent_management,
       allocation_type,
       segment_space_management,
       status
FROM   dba_tablespaces
ORDER BY tablespace_name;

Top Sessions

SET LINESIZE 500
SET PAGESIZE 1000
SET VERIFY OFF

COLUMN username FORMAT A15
COLUMN machine FORMAT A25
COLUMN logon_time FORMAT A20

SELECT NVL(a.username, '(oracle)') AS username,
       a.osuser,
       a.sid,
       a.serial#,
       c.value AS &1,
       a.lockwait,
       a.status,
       a.module,
       a.machine,
       a.program,
       TO_CHAR(a.logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time
FROM   v$session a,
       v$sesstat c,
       v$statname d
WHERE  a.sid        = c.sid
AND    c.statistic# = d.statistic#
AND    d.name       = DECODE(UPPER('&1'), 'READS', 'session logical reads',
                                          'EXECS', 'execute count',
                                          'CPU',   'CPU used by this session',
                                                   'CPU used by this session')
ORDER BY c.value DESC;

SET PAGESIZE 14

Top Sqls

SET LINESIZE 500
SET PAGESIZE 1000
SET VERIFY OFF

SELECT *
FROM   (SELECT Substr(a.sql_text,1,50) sql_text,
               Trunc(a.disk_reads/Decode(a.executions,0,1,a.executions)) reads_per_execution, 
               a.buffer_gets, 
               a.disk_reads, 
               a.executions, 
               a.sorts,
               a.address
        FROM   v$sqlarea a
        ORDER BY 2 DESC)
WHERE  rownum <= &&1;

SET PAGESIZE 14


.Net and Football. What?



If
you are new to programming or want to learn .net framework from rare basics, then this is the place for you. You are probably wondering about the title of this post ".Net and Football". Well, it seems funny, but I have chosen this because if you know one thing better, it's easy to know something else which is similar to the things you know.
Football is very popular game worldwide, and almost every child and teenager like it. OK, so let's begin playing football and learning .Net Framework.

To start playing football, you need to learn the rules and the ecosystem about it. Just as we need a football court to play football, we need .Net Framework to run our .Net program.

.Net Framework - The Football Court

A football court consist of a well spread grass, two goal posts, boundaries with some fixed length and width. Similarly, a .Net framework consists of a base container over which the following components are laid out:

Common Language Runtime (CLR)
The .Net Framework Class Library
Common Language Specification and Common Type System
Metadata

Common Language Runtime (CLR) - The Referee

We can visualize CLR as a referee of the match, who controls everything as the match progresses. He manages everything from goal count, goal by whom, penalties, giving or denying permission to play. Similarly, CLR Compiles application into the runtime, compile the IL code into native code, execute the code.

The CLR has the following features:

Manages memory
Memory allocation
Memory de-Allocation
Thread execution support
Code execution
Code safety verification
Compilation
Convert MSIL to Native Code
Code Security (granted permission to execute code. Code level, Folder level, Machine level)

The .Net framework class library - Things of play

Just like we require different things to play football for e.g. Hand gloves, football shoes, goal post stand etc., the .Net framework class library provides us different in-built functionalities to build a program.
.Net base class library consist of predefined reusable classes, interface and types. It also provides core programming features such as Reflection, File IO, XML, Collections etc. All the core classes interface and types can be used with any .NET Framework programming languages

CLS and CTS - Different teams, different cultures, one rule.

The two team in football might be from different countries speaking different language. So how can they communicate while playing football. Well, there is a common language that is flowing between these two teams which is the language of rules. Both team know the rules of the game very well. They know if one does a penalty, the other team have an advantage of penalty shoot-out. Similarly, there is a common set of language rules defined for all the language supported by .Net framework and that language set is called Common Language Specification (CLS).
In .NET, every Data Type is internally represented by a class or structure. All the classes and structures related to Data Types are collectively known as CTS.

.Net Assembly - The Player

The players themselves can be considered as Assemblies. A player is a unit of executing the play. Similarly, an assembly is a unit of execution of a program. Many assemblies work together to execute a program. However, unlike football, assembly can be one or many.

Assembly Metadata - Player's info (statistics, ranking etc.)

It is interesting to know about a player's carrier statistics, history, ranking etc. So these are the details that is associated with the player. Similarly, there are some additional details that are associated with the assembly itself, we call this information as metadata. This information includes description of the Assembly , datatypes and members with their declarations and implementations, references to other types and members, security permissions etc.

Copyright @ 2017

Code Review Check-list

Code review if one of the top software development stages in a software development process. Recently as technologies are growing, their architectures is a also growing from simpler to complex. A complex architecture is tough to maintain but it can be decomposed into simpler ones by following certain guidelines. Those guidelines are not covered in-depth here but certainly make their importance in the code review process. A code is reviewed to check if our code adhere to certain guidelines that are standard to modern code architecture specially object oriented code.

This check list is not a strict-to-follow thing but can be very helpful in a code review process.

Architectural/Design

Single Responsibility Principle

The idea that a class should have one and only one responsibility. You might want to apply the idea to methods as well

Open/Closes principle

If the language is object oriented, are the objects open for extension but closed for modification? What happens if we need to add another one of x?

Code duplication (DRY)

Don't Repeat Yourself is a common practice. One duplication is usually okay, but two are not.

Squint-Test Offences

If you squint your eyes, does the shape of this code look identical to other shapes? Are there patterns that might indicate other problems in the code structure?

The Boy Scout Rule

If you find code that's messy, don't just add a few lines and leave. Leave the code cleaner than you found it.

Potential Bugs

Are there off-by-one errors? Will the loops terminate the way we expect? Will they terminate at all?

Error Handling

Are errors handled gracefully and explicitly where necessary? Have custom errors been added? If so, are they useful?

Efficiency

If there's an algorithm in the code, is it using an efficient implementation? (e.g. iterating over a list of keys in a dictionary is an efficient way to locate a desired value.)

Style/Readability

Method names

Methods should have names that reveal the intent of the API while fitting into the idioms of your language and not using more text than is necessary (e.g. it's not "send_http_data" it's "post_twitter_status").

Variable names 

Foo, bar, e: these names are not useful for data structures. Be as verbose as you need (depending on the language). Expressive variable names make code easier to understand.

Function length

When a function is around 50 lines, you should consider cutting it into pieces.

Class length

300 lines is a reasonable maximum for class sizes, but under 100 lines is ideal.

File length

As the size of file goes up, discover-ability goes down. You might consider splitting any files over 1000 lines of code into smaller, more focused files.

Docstrings

For complex methods or those with longer list of arguments, is there a docstring explaining what each of the arguments does if it's not obvious?

Commented code

Sometimes you will want to remove any commented out lines.

Number of method arguments

Consider grouping methods and functions with three or more arguments in a different way.

Readability 

Is the code easier to understand? Do I have to pause frequently during the review to decipher it?


Communicating your review

Ask questions

How does this method work? If this requirement changes, what else would have to change? How could we make this more maintainable?

Complaint/reinforce good practice

One of the most important parts of the code review is to reward developers for growth and effort. Few things feel better than getting praise from the peer. Try to offer as many positive comments as possible.

Discuss in person for more detailed points.

On occasion, a recommended architectural change might be large enough that it's easier to discuss it in person rather than in the comments. Similarly, if discussing a point and it goes back and forth, try to pick it up in person and finish out the discussion.

Explain reasoning

It's often best both to ask if there is a better alternative and justify why a problem is worth fixing. Sometimes it can feel like the changes suggested can seem nit-picky without context or explanation.

Make it about the code, not the person

It's easy to take feedback from code reviews personally, especially if we take pride in our work. It's best to make discussions about the code rather than about the developer. It lowers resistance and it's not about the developer anyway. It's about improving the quality of the code.

Suggest importance of fixes

Try to offer many suggestions, not all of which need to be acted upon. Clarifying if an item is important to fix before it can be considered done is useful for both reviewer and the reviewee. It makes the result of a review clear and actionable.