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