Wednesday, 24 April 2019

Build Habits which you want to continue as Lifestyle!

Today if you check any social networking site (Facebook, Instagram, etc.) there are tons of accounts which pretend to be something which they are not, and most of us gets fooled by their appearance and want to start doing some thing these people are doing for example starting a morning routine. A morning routing is a thing which a person do once after he wakes up and that time of the morning usually qualifies as the 'Self time' because there is no disturbance at that time of any kind, If you manage to wake up at 5AM then there are good chances that your neighbourhood will be asleep and you can work on something which is important to you and you like to get finished. There are lots of such videos out there which make you follow such routines and habits but the only thing is they don't last longer. The problem I see with this approach is 'Anything which doesn't comes from within you, will not be able to mould you'.

The Habits as I mentioned in the title, should be chosen wisely. Simply picking up a habit that doesn't even align with your work schedule or the goal which you have is not going to help you in any manner. you should think twice or even few more times if you feel its required before picking any habit as they have a negative impact on you when you don't follow through.

The habit should be chosen with all the awareness that you want to really change that aspect of your life to something better. There is a nice book by Author named Charles Duhigg Book is "The Power of Habit". If you really feel you have to changes something I suggest you to read that book.

Any habit worked upon seriously for a long duration throughout lifetime becomes a lifestyle. A few examples are:
  • A habit of brushing your teeth at night daily in a long run is a lifestyle you live by.
  • Waking up early to spend some time peacefully with your self is a lifestyle.
  • Reading daily before going to bed is a good habit or a lifestyle if pursued for long time.
  • Eating healthy food is a good habit but a proud lifestyle when you say I have not eaten any shit food in last 5 years.
  • Walking 10k steps everyday.
  • Going to gym 4-5-6 days a week is a habit and a lifestyle to follow. 
  • Writing a Journal.
what kind of  habit lifestyle do you care to build?

Tuesday, 2 April 2019

Scheduling meetings like a Pro!

It is a Sunday evening and a meeting reminder pops up on your mobile screen. It's damn annoying, but I have seen people doing it all the time. They schedule a recurring meeting without considering your weekend and that makes me go crazy. It's my day off, that meeting reminder popping on my mobile screen is the last thing I want to see.

This post is dedicated to those dummies who have certainly got promoted because of their hair greying but don't for sure know how to schedule a meeting.

For Office 365.

click 'New' on top left corner -> Calendar Event.





2. Fill in all the details you need. (Location, Title etc)
The title should be meaningful, something like 'Let's meet' doesn't make any sense if you are sending that invite to 5-10-20 people in your organisation. It has to make sense. Remember to cross-check your spelling because it is going to be there in the calendar for some time. You don't want to be wrong in that.
while adding people make sure you want them as an optional attendee or required one. Scheduling assistant can help you in determining whether the person you are inviting is available at that time.








Now the most important thing, making a meeting recurring without disturbing people at their weekend.




You can select 'Every workday' or select 'Other' from the dropdown if you want the meeting to occur on a specific day.






For MS Outlook.

Goto Home ->  Meeting. (Opens a popup dialogue)





Clicking on Appointment in the Meeting popup will open one more popup to help you schedule the appointment.

Recurring appointment - Daily.



Recurring Appointment - Weekly. It provides you with the option to select your weekdays.






Which Software/Application/Platform do you use to schedule meetings?

Thursday, 5 July 2018

.NET Standard: What it is and how to use


What really is dot net standard?  

Let me try to put it in simple words. We used to use different BCL's for different frameworks and remembering it is a tough job. So Microsoft once again has come up with a solution to help developers to put a little less load on on the brain to remember the API's. They have replaced all the BCL's with a common one which they are calling as .net Standard. 

.Net Standard 2.0 has around 32,000 API's. You can download the list from here or you can check it here at GitHub.

.Net Standard replaces Portable Class Libraries (PCLs) as the tool for building .NET libraries that work everywhere 


How to use it? 

If you have .net core installed on your machine you can start working on .net Standard just by creating a Class Library. Yes, the old Class library is now Class Library for .net standard. 






For those who understand pictures better or would like to read less. 


Above pictures are taken from a slide of Immo Landwerth. 

The table below can be used as the reference for writing a class library using the standard.

If you are choosing a version for writing .net standard, you should consider a trade-off which is the 
higher the version of .net standard more apis are available. Lower the version, more platforms have already implemented it.

You can follow .net standard on GitHub 

Below are the list of API's added newly in .net standard 2.0

Namespace
#APIs
Microsoft.Win32.SafeHandles 22
System 1,366
System.CodeDom.Compiler 46
System.Collections 335
System.Collections.Generic 23
System.Collections.ObjectModel 1
System.Collections.Specialized 281
System.ComponentModel 1,843
System.ComponentModel.Design 565
System.ComponentModel.Design.Serialization 155
System.Configuration.Assemblies 13
System.Data 1,587
System.Data.Common 907
System.Data.SqlTypes 971
System.Diagnostics 826
System.Diagnostics.CodeAnalysis 2
System.Diagnostics.Contracts 89
System.Diagnostics.SymbolStore 146
System.Diagnostics.Tracing 2
System.Drawing 520
System.Dynamic 226
System.Globalization 217
System.IO 309
System.IO.Compression 8
System.IO.IsolatedStorage 134
System.IO.MemoryMappedFiles 66
System.IO.Pipes 125
System.Linq 366
System.Linq.Expressions 50
System.Net 1,360
System.Net.Cache 52
System.Net.Http.Headers 20
System.Net.Mail 289
System.Net.Mime 75
System.Net.NetworkInformation 696
System.Net.Security 194
System.Net.Sockets 168
System.Net.WebSockets 188
System.Numerics 1
System.Reflection 403
System.Reflection.Emit 3
System.Resources 91
System.Runtime 12
System.Runtime.CompilerServices 190
System.Runtime.ConstrainedExecution 22
System.Runtime.ExceptionServices 6
System.Runtime.InteropServices 106
System.Runtime.InteropServices.ComTypes 15
System.Runtime.Serialization 486
System.Runtime.Serialization.Formatters 13
System.Runtime.Serialization.Formatters.Binary 23
System.Runtime.Serialization.Json 80
System.Runtime.Versioning 33
System.Security 124
System.Security.Authentication 11
System.Security.Authentication.ExtendedProtection 36
System.Security.Claims 206
System.Security.Cryptography 575
System.Security.Cryptography.X509Certificates 76
System.Security.Permissions 88
System.Security.Principal 41
System.Text 83
System.Text.RegularExpressions 31
System.Threading 330
System.Threading.Tasks 66
System.Timers 39
System.Transactions 223
System.Web 32
System.Xml 1,362
System.Xml.Linq 7
System.Xml.Resolvers 25
System.Xml.Schema 967
System.Xml.Serialization 943
System.Xml.XPath 261
System.Xml.Xsl 140

Thursday, 28 September 2017

Filter Attributes in MVC

An action filter is an attribute that can be applied to an Action or the controller.

Types of filters in MVC:

1.Authorization filters
2.Action filters
3.Result filters
4.Exception filters


Filters in MVC execute in the same order as mentioned above.

Authorization filters always execute before action filters and exception filters always execute at last.
The base class for all action filters is the FilterAttribute class which is in System.Web.Mvc namespace
The base class which is ActionFilterAttribute has the following methods which we can override:
· OnActionExecuting – This method is called before a controller action is executed.
· OnActionExecuted – This method is called after a controller action is executed.
· OnResultExecuting – This method is called before a controller action result is executed.
· OnResultExecuted – This method is called after a controller action result is executed.

Tuesday, 23 May 2017

Async and Sessionless controller in Asp.net MVC

I know it's very late and both the concepts are released long back.

Nov 2010 Microsoft released MVC3 RC in which provided a feature for Controller class to be free from session state was provided. Here is a link to Scott Gu's blog releasing same

Scott tells while answering a question on the post: Session state is designed so that only one request from a particular user/session occurs at a time. So if you have a page that has multiple AJAX callbacks happening at once they will be processed in serial fashion on the server. Going session-less means that they would execute in parallel.


Attribute Name is SessionState and it takes Enum of type SessionStateBehaviour which has the following members:

  • Default
  • Disabled
  • ReadOnly
  • Required

Usage:     [SessionState(SessionStateBehavior.Disabled)]

In case you opt to use SessionState attribute TempData and other session related thing won't work as mentioned in a small demo on Dot net curry.

Sessionless Controllers specifies the type of Session support you want for your class. On the other hand, as the name suggests Async Controllers let us perform operations without making the thread wait for completing the operation.

This is a nice blog by an MVP about calling the web services using Normal, Async and Sessionless manner.

Async controllers are deprecated in MVC4 and they are implemented using Task class.  The new model for asynchronous methods is called the Task-based Asynchronous Pattern (TAP), More can be read here about it.

Hope it helps.

Tuesday, 16 May 2017

Difference between Tier and Layers

During an interview this question was asked and I was pretty sure that what ever layers we create in our code (Presentation, BLL, DLL etc) are the tiers but I was wrong.
An answer on stack overflow sums it up very well.
layer = a part of your code, if your application is a cake, this is a slice.
tier = a physical machine, a server.

Scott Hanselman also have a nice blog post on same. He says:
a "Tier" is a unit of deployment, while a "Layer" is a logical separation of responsibility within code.  You may say you have a "3-tier" system, but be running it on one laptop.  You may say your have a "3-layer" system, but have only ASP.NET pages that talk to a database. 

and then he explains about what should be there in your Presentation, BLL and DLL and what should not be there.


Sunday, 23 April 2017

Iqueryable vs Ienumerable a comparison.

There is always a doubt in developers mind regarding usage of IQueryable and IEnumerable.

IQueryable extends IEnumerable. IQueryable should be used while working with remote databases. 

Well, here are some facts which can help resolving your doubt and can strengthen your decision-making as which one to use.






Some important points about Ienumberable<T>
  • It's read-only.
  • Iterates only in forward direction.
  • Doesn't supports adding or removing objects.
  • It's a base interface for any generic collection
When to use IEnumberable:
  • Working with read-only collection
  • Need to read objects in the forward direction.
  • Want to iterate collection using for-each.



Some important points about IQueryable<T>
  • It implements IEnumerable so the results can be iterated using for-each.
  • Best suited for querying against the remote data source.
When to use IQueryable
  • your data source is queryable.
  • Data needs to be applied 
  • The deferred way is needed to load the data.





IEnumerable
IQueryable
Namespace
System.Collections Namespace
System.Linq Namespace
Derives from
No base interface
Derives from IEnumerable
Supported
Supported
Not Supported
Supported
How does it work
While querying data from the database, IEnumerable executes a select query on the server side, load data in-memory on the client side and then filter data. Hence does more work and becomes slow.
While querying data from the database, IQueryable executes a select query on the server side with all filters. Hence does less work and becomes fast.
Suitable for
LINQ to Object and LINQ to XML queries
LINQ to SQL queries
Custom Query
Doesn’t support
Supports using CreateQuery and Execute methods
Extension method
parameter
Extension methods supported in IEnumerable takes functional objects.
Extension methods supported in IEnumerable takes expression objects, i.e., expression tree.
When to use
When querying data from in-memory collections like ListArray, etc.
When querying data from out-memory (like remote database, service) collections.
Best Uses
In-memory traversal
Paging
Table from code project