Friday, December 13, 2019

Sample SQL script to delete messages in Service Broker Queue manually

SQL Script:

declare @ch uniqueidentifier
while(1=1)
begin
    select top 1 @ch = conversation_handle from [dbo].[YourQueueName]
    if (@@ROWCOUNT = 0)
    break
    end conversation @ch with cleanup
end

[Solved] AxoCover code coverage fails after upgrading the Visual Studio


Error Message:

No results, this could be for a number of reasons. The most common reasons are:
1) missing PDBs for the assemblies that match the filter please review the
output file and refer to the Usage guide (Usage.rtf) about filters.
2) the profiler may not be registered correctly, please refer to the Usage
guide and the -register switch.
Test execution finished.

Solution:
  1. Go to the directory where AxoCover is installed. You can locate this by running a long test (e.g. thread sleep, and open the file location of the AxoCover.Host-*.exe from the task manager. For example for me it is: C:\Users\venkat\AppData\Local\Microsoft\VisualStudio\15.0_6d93d79f\Extensions\pfu3q5ow.kny\
  2. Then navigate to OpenCover\x86 or x64 depending on what platform your tests are running
  3. Open CMD with admin right
  4. Enter: regsvr32 /i OpenCover.Profiler.dll
  5. You will get a dialog that DLL is registered.

Now your coverage will run again.

Tuesday, November 12, 2019

Link to Download latest version of Visual Studio 2019

Visual Studio 2019 is a Full-featured integrated development environment (IDE) for Android, iOS, Windows, web, and cloud.

Click a button below to download latest version of Visual Studio 2019,

Community:
    Powerful IDE, free for students, open-source contributors, and individuals, open-source contributors, and individuals.

Download Free Visual Studio Community 2019
Professional
    Professional IDE best suited to small teams

Download 90 days Trial Visual Studio Professional 2019
Enterprise:
    Scalable, end-to-end solution for teams of any size.

Download 90 days Trial Visual Studio Enterprise 2019

Link to Download latest version of Visual Studio 2017

Visual Studio 2017 comes in three different editions. Which are,

  1. Visual Studio Community 2017
  2. Visual Studio Professional 2017
  3. Visual Studio Enterprise 2017

You can install multiple editions of Visual Studio 2017 side-by-side.

Click a button below to download the latest version of Visual Studio 2017:

Community:
    Powerful IDE, free for students, open-source contributors, and individuals, open-source contributors, and individuals.

Click here to download Visual Studio Community 2017

Professional:
    Professional IDE best suited to small teams.

Click here to download Visual Studio Professional 2017

Enterprise:
    Scalable, end-to-end solution for teams of any size.

Click here to download Visual Studio Enterprise 2017

(Solved) This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".

IIS Error Message:

This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".

Solution:
  1. Click "Start button"
  2. in the search box, enter "Turn windows features on or off"
  3. in the features window, Click: "Internet Information Services"
  4. Click: "World Wide Web Services"
  5. Click: "Application Development Features"
  6. Check (enable) the features.
It should be working now.

Friday, September 6, 2019

Sample C# program to print left rotation of an array

Here is a sample C# program to print the left rotation of an array to k times very Quickly. This program succeeded all test cases in HackerRank challenge.

Program :
static public void Main ()
{
    int[] arr = {1, 4, 5, 6, 2};

    int length = arr.Length;
    int k = 2;

    LeftRotate(arr, length, k);
}
static void LeftRotate(int[] arr, int length, int k)
{
    for (int i = k; i < k + length; i++)
    {
        Console.Write(arr[i % length] + " ");
    }
}

Output :
5 6 2 1 4

Friday, August 2, 2019

COCKROACH THEORY By Google CEO Sundar Pichai - A beautiful way to understand LIFE

The cockroach theory for SELF-DEVELOPMENT:

At a restaurant, a cockroach suddenly flew from somewhere and sat on a lady. She started screaming out of fear. With a panic stricken face and trembling voice, she started jumping, with both her hands desperately trying to get rid of the cockroach. Her reaction was contagious, as everyone in her group also got panicky. The lady finally managed to push the cockroach away but ...it landed on another lady in the group. Now, it was the turn of the other lady in the group to continue the drama. The waiter rushed forward to their rescue. In the relay of throwing, the cockroach next fell upon the waiter.


The waiter stood firm, composed himself and observed the behaviour of the cockroach on his shirt. When he was confident enough, he grabbed it with his fingers and threw it out of the restaurant. Sipping my coffee and watching the amusement, the antenna of my mind picked up a few thoughts and started wondering, was the cockroach responsible for their histrionic behaviour? If so, then why was the waiter not disturbed?

He handled it near to perfection, without any chaos.

It is not the cockroach, but the inability of those people to handle the disturbance caused by the cockroach, that disturbed the ladies.

I realized that, it is not the shouting of my father or my boss or my wife that disturbs me, but it's my inability to handle the disturbances caused by their shouting that disturbs me.

It's not the traffic jams on the road that disturbs me, but my inability to handle the disturbance caused by the traffic jam that disturbs me.

More than the problem, it's my reaction to the problem that creates chaos in my life.

Lessons learnt from the story:

I understood, I should not react in life. I should always respond.

The women reacted, whereas the waiter responded.

Reactions are always instinctive whereas responses are always well thought of.

“Person who is Happy is not because everything is Right in his Life.
He is Happy because his Attitude Towards Everything in his Life is Right..!”

Sunday, July 21, 2019

10 Advice from Warren Buffet for Young People Who Want to Be Rich

Warren Buffet became a millionaire in 1960 at the age of 30 and ever since then, He has been one of the richest people in the world. Over the years he has given various advice to young people about how they can be rich and successful.



Advice No. 1. “I will tell you how to become rich. Close the doors. Be fearful when others are greedy. Be greedy when others are fearful.”

Advice No. 2. “No matter how great the talent or efforts, some things just take time. You can’t produce a baby in one month by getting nine women pregnant”.

Advice No. 3. “It’s better to hang out with people better than you. Pick out associates whose behavior is better than yours and you’ll drift in that direction.”

Advice No. 4. “You won’t keep control of your time, unless you can say ‘no.’ You can’t let other people set your agenda in life.”

Advice No. 5. “You don’t have to be smarter than the rest. You have to be more disciplined than the rest.”

Advice No. 6. “Risk comes from not knowing what you’re doing.”

Advice No. 7. “The chains of habit are too light to be felt until they are too heavy to be broken.”

Advice No. 8. “Enjoy your work and work for whom you admire.“

Advice No. 9. “You can’t buy what is popular and do well.”

Advice No. 10. “Never invest in a business you cannot understand.”

Thursday, June 13, 2019

Sample program to create custom SVG Marker with Label for Google Map Api

Here is a sample program to create custom SVG Marker for Google Map Api. The marker will look like shown in the below image. You can change the color of the marker by passing the color as the parameter for the pinSymbol function.
HTML :
<div id="map_canvas" style="height: 400px; width: 100%;">
CSS :
html, body, #map_canvas {
    height: 500px;
    width: 500px;
    margin: 0px;
    padding: 0px
}
JAVASCRIPT :
function initializeMap() {
 var center = new google.maps.LatLng(30.5, -98.35);;
  var markerLatLng = new google.maps.LatLng(30.5, -98.35);

    var map = new google.maps.Map(document.getElementById('map_canvas'), {
        zoom: 12,
        center: center,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var marker = new google.maps.Marker({
        position: markerLatLng,
        map: map,
        draggable: true,
        raiseOnDrag: true,
        label: { text: 'WXYZ', color: '#fff', fontSize: '12px' },
        icon: pinSymbol('green')
    });
}

function pinSymbol(color) {
    return {
        path: 'M 0,0 C -2,-20 -10,-22 -10,-30 A 10,10 0 1,1 10,-30 C 10,-22 2,-20 0,0 z',
        fillColor: color,
        fillOpacity: 1,
        strokeColor: '#000',
        strokeWeight: 2,
        scale: 2,
        labelOrigin: new google.maps.Point(0, -30)
    };
}
OUTPUT IMAGE :

Sample C# program to find the Permutation of a given string

The below C# program is used to print all the possible way to arrange the characters in the given string. Also known as Permutation.

Program :
using System;
public class Permutation
{
    public void Permute(string inputString, int startIndex, int endIndex)
    {
        if (startIndex == endIndex)
            Console.WriteLine(inputString);
        else
        {
            for (int i = startIndex; i <= endIndex; i++)
            {
                inputString = Swap(inputString, startIndex, i);
                Permute(inputString, startIndex + 1, endIndex);
                inputString = Swap(inputString, startIndex, i);
            }
        }
    }

    private string Swap(string a, int i, int j)
    {
        char temp;
        char[] arr = a.ToCharArray();
        temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;

        return new string(arr);
    }
}

class Program
{
    static void Main(string[] args)
    {
        string inputString = "ABC";
        Permutation p = new Permutation();
        p.Permute(inputString, 0, inputString.Length - 1);

        Console.ReadLine();
    }
}


Output :

ABC
ACB
BAC
BCA
CBA
CAB

Wednesday, June 5, 2019

Add or ignore where conditions in SQL Server query based on a flag

Assume you want to select data from SQL Server based on a condition. But the condition should be considered only if another condition satisfies else it should return all data. How would you do that. Here is a sample program to achieve the solution.

declare @flagAll = 1;

Select *
from Students S
where @flagAll = 1
or S.Department = 'CSE'
In this example if the @flagAll is set to 1, then the first condition will be satisfied so the second condition will not be executed as it is OR condition, so all data will be returned. Else if @flagAll = 0 then the first condition will be failed, as it is OR condition the second condition S.Department = 'CSE' will be considered and all CSE department Student data will be returned.

If you have alternate solution, Kindly post as comment.