Sunday, July 29, 2018

When you actually meet your Achchhe Din

Recently my parents visited my city Pune and we went for a holy trip to Shirdi, Shani Shingnapur, Nashik,Triambakeshwar and Mumbai. I will tell you about the instances where I felt that these days were actually my Achchhe Din. So my parents landed at Pune airport at around 0430 hours early in the morning. I booked an OLA cab for them as they themselves asked me not to come for pickup. So now-a-days these cab services have been given a pick-up zone at the airport so to get pickup people need to go to these points like Ola have Ola pickup zone. So asking my parents to search for such zone was not a good idea in early morning in their first time visit. So I booked this cab and called the driver. I asked him that you should pick my parents from arrivals gate. Firstly he hesitated but then I requested him and he accepted. In 15 minutes my parents were at my door. So this was the beginning.
So sometimes these cab services actually do us a favor.
My parents enjoyed the day in Pune. Then in evening we had a planned journey to Shirdi. We were all set. But I got a call that the bus which we booked is cancelled. My parents asked me what next? So with in 5-6 minutes I could book another bus and our planned journey remain a planned journey. So obstacles come but if they get handled well then it is your achchha din.
We left for Shirdi from Pune at around 2355 Hrs. We reached Shirdi at around 0415 Hrs. We got fresh fast and then reached temple. The weather was calm and we got chance to get Darshan of Sai Baba with easy. So the other times I visited Shirdi twice, I saw huge crowd. But this time it has been very easy. After that we went to Shani Shinganpur. We reached back Shirdi at around 1230 Hrs. 
We went to a restaurant for lunch.There I met with a miracle. It was raining cats and dogs. After having lunch I rushed to wash basin to wash my hands. This wash basin was outside the restaurant in open space. So in between there is a gate having a shutter. So while I was going this shutter was up. But when I ran back, somebody just pulled this shutter down because of rain. I was running with speed to save me from water. I could not pay attention to this shutter going down and my head collided with the shutter with a loud sound. 7-8 people ran to see what happened. I thought I am gone. I thought there will be lot of blood on my head. But when I touched it, there was nothing except a little bit pain. I stood still for some time. But this passed as a miracle. My parents who were sitting on other side did realize something happened there but when I reached there I could manage not to tell them that it happened with me. so It was the most achchhe din event for me.
After that we reached Triambakeshwar to pay a visit to Jyotirlinga. We thought to stay in a specific hotel but in evening we could not book it because it was full. So a person came to us and shown a hotel just adjacent to it. We lived there for a night and in the morning we reached to that specific hotel(Gajanan Maharaj Sansthan) where we planned to live in and we got the room. Just to enjoy the moment we lived there for a day near to nature in showerish rains. We had to extend Triambak journey by one day but it has been awesome. This tells us a point that go to few places but live them fully.

Me with my parents
Then our last day trip was to visit Mumbai. We visited 4-5 places comfortably including Siddhi Vinayak Temple, Mahalakshmi Temple and Gateway of India. Though these days and moments are not extra-ordinary. We all of us get few such days in our lives after sometime. But when things go as per your expectation. They execute smoothly. You can call them your Achchhe Din. Hope you like this experience of mine. May you all the readers get frequent Achchhe Din in your lives. One thing you must learn from this is be little cautious  roaming and running at new places, miracles does not happen every time.

My other articles that might interest you are given below:

Wednesday, July 11, 2018

Fastest way to develop a calculator C# - string expression to mathematical expression

Fastest way to develop a calculator C# - string expression to mathematical expression

Friends today I will tell you something very amazing. The easiest and fastest way to create a calculator in C#. You would have earlier created calculator by adding two textbox on form where you can enter two numbers and then operator buttons to calculate the result. For example you entered 5 in textbox1 and 7 in textbox2 then if you click on multiply button on the form you get the result as 35. Similar you can design other operator buttons like add, subtract and division and they will work in similar way. The only issue with this kind of calculator is that you can have only 2 operands and one operator in a expression. With this kind of calculator it is difficult to do huge calculations.
C# Technical Tips and Tricks
Fastest way to develop a calculator in C# language. Convert string expression into mathematical expression.
So the solution to this issue is to have a calculator which can compute the value of an expression. So here the concept of an expression calculator arises. Many of you would be aware of expression calculator where in one textbox you will enter full expression 5+6-2*1 and then when you will click on calculate it will show the result 9. So it is good for large and small calculations both. It is far better and most used calculator.
Now coming to its implementation:
Traditional approach will be to write a huge program:
1. You will parse whole string in terms of operands and operators.
2. You will remember their sequences.
3. You will have to remember the BODMAS implementation works correctly as you yourself are creating this calculator from scratch.
4. It will surely take atleast 4 hours if you are doing it for first time.

Now I will tell you the tricky way of doing this. You can create a calculator with in 5 minutes though we will definitely use some already defined functions. But I assure you that you can bring the result of any string expression. You don't have to parse anything.

So lets assume you have a textbox with ID Textbox1 to enter the expression. Then a Calculate button and a result Textbox2 to show the result.
So you can do this as follows. In your code behind file write
using System.Data;
//On button click you have to write these lines
DataTable dt = new DataTable();

//that's it. You have implemented your calculator with help of Compute method available in System.Data.
Try this and let me know if you face any issue. If it sounds interesting to you then definitely share it with your programmer friends. #FrandsCodeKarLo #Hahaha

Other important links to explore

datatable compute c#, CSharp Tips and Tricks, create calculator in C#, develop c# calculator

Monday, July 9, 2018

Convert to two decimal places C# Round to 2 decimal places

Convert to two decimal places C# Round to 2 decimal places

There are various methods or you can say ways available to round a number to two decimal places. When we store values in our database, Our main concern is to have a good precision so for that the numbers are stored with lots of decimal places. There can be 6 decimal digits, 8 decimal digits, 10 decimal digits and more.

Convert to two decimal places C#

The main concern arises when we need to show such values on front end platforms to the end customers. They might not be interested in so much digits after decimal. So today we will learn various ways in which we can convert / round such number to two decimal places.
Things that also matter here is how are you receiving it at your end.
If you are receiving it as string you can do it as follows.
string decimalNumber = "15.45000000";
string newDecimal= Math.Round(Convert.ToDecimal(decimalNumber, 2).ToString(CultureInfo.InvariantCulture);
// Output of newDecimal 15.45
So in the process above we are actually converting string to decimal and then we are rounding it off to two decimal places.

Now Suppose rounding of this string is not a big concern. Your main concern is just to represent it in the form of string with two decimal places then there is another technique you can use so 
string decimalNumber = "15.45000000";
string newDecimal=decimalNumber.ToString("#.##");
//Output here also will be similar 15.45
The only concern is if number is 0 then output will be "" means an Empty string.
You can resolve this by using this trick
string newDecimal=decimalNumber.ToString("0.##");
So using this trick you can very well change the presentation of the numeric string but here rouding off is not happening as it was happening in the first method.

For this you can also use
string newDecimal=decimalNumber.ToString("F");

Now I will tell you techniques where you already have a decimal number. The only thing you need is to round off to two decimal places.
for example decimal x = 45.66300005;
decimal newDecimal = Math.Round(x,2, MidpointRounding.AwayFromZero);
//Output 45.66

So there are lot of ways and technique that you can use to reach your requirement. I am sure one of this definitely benefit you. Tell me in comments which one did you use. You can also left your appreciations in comment section :)

Other important links to explore

round off to 2 decimal places c#, c# 2 decimal places without rounding, c# round up to 2 decimal places, string format 2 decimal places c#, convert.todecimal c# 2 decimal places

Sunday, July 8, 2018

Indore is actually the cleanest city of India

First of all, I welcome you on my blog. This is my first post. So I thank you for your time.
Recently I had a chance to visit Indore which is located in heart state of India Madhya Pradesh. I was very excited because I was visiting Indore for a great cause. I was invited by Google for a Google Search Conference which was held in Indore Marriott. I reached Indore one day before the conference so that I can explore Indore.
So I had heard a lot about cleanliness of Indore after the Clean India Campaign started. Indore came first in Clean India Survey conducted by Government of India. So I thought I will actually like to verify it today whether Indore is really that clean. On my way when I entered Indore roads were really very clean. That was the first instance where I realized that Indore is little different than other cities.

Roads were very clean and lot of trees have been planted on roadsides. And it does not end here. I reached my hotel in Vijay Nagar around 10 AM. After getting fresh, I went for a breakfast of Poha-Jalebi near Bombay Hospital. I found out people are little more responsible be it shop keepers or consumer. Every shop no matter what they sell is having dustbins.
You can find public toilets on roadside and they are maintained and kept clean. Their slogan is not just Clean Indore Green Indore but "Indore Rahega Number One". In afternoon around 1230 I left for Ujjain. When I entered in Bus I saw a dustbin. I was amazed to see that. If there will be a dustbin inside and people have a little bit of common sense, why they will throw garbage outside the bus. So that arrangement is just awesome. I explore the area around Indore railway station, Madhumilan Cinema, Palasia and lot many other places on my way to hotel. Places are clean and lot of cleanliness slogan you will find out throughout the city.
new lot of cleaning equipment lined up 
So it is not just the administrative effort but it also shows how responsible people of Indore are. I am really impressed. In the evening I visited Treasure Island Mall, Chhappan. Chhappan is just an amazing place for the foodies out there. If you love food then you will definitely love this place. This place is having all varieties of food with a delicious and yummy taste. I am very selective when it comes to my food. But I liked the food. I ate at Madhuram, Vijay Chaat Bhandar and Pushpak Pav Bhaji. Lot of people visit this place but the place is still very clean. You will not see littering in-spite of so much crowd.
standee in Indore
I really liked this lighted structure which says I Love Indore. There is lot I can write but keeping it short, I want to conclude Indore is actually very clean city of India. Indoris should be proud of this and it has really changed my perceptions about Indore. Being a Delhiite, I do give opinions but this opinion is now proven.In the last,I thank friends I met in Indore who made this exploration really thorough and memorable. Hope you like my experience. I will love your comments below.

Some other important links