Wednesday, August 9, 2017

using Linq methods with caution - E.g FirstorDefault()

Don't use FirstorDefault() unless you are sure its valid/ verified in the business scenario. else you are going to introduce bugs in the code.

Saturday, April 15, 2017

Git tips

Set up Git

Removing non-repository files with git?


How do I discard unstaged changes in Git?

a)For a specific file use:
git checkout path/to/file/to/revert
b)For all unstaged files use:
git checkout -- .
Make sure to include the period at the end.
c)To check out specific files
git checkout -- cats.html index.html
git branch -a                                     -- lists all branches
git push origin :branchnamehere     -- to delete the remote branch(note semicolin before                                                                                    branchname)

git remote show origin                     -- checks for stale branches tracking origin
git remote prune origin                     -- to clean up deleted remote branches

git tag                                                           -- list all tags
git tag -a v0.1.2.3 -m "versioncomments"   -- add a new tag
git push --tags                                              -- to push new tags

git fetch      -- pulls down the history but does not merge

rebase vs Merge
Rule of thumb:
1. When pulling changes from origin/develop onto your local develop use rebase.
          git pull --rebase

2. When finishing a feature branch merge the changes back to develop.









Getting up to speed with StructureMap

Developer Basics


TDD rules : - 
  1. Isolate the Ugly Stuff
  2. Push, Don’t Pull (this post)
  3. Test small before testing big
  4. Avoid a long tail
  5. Favor composition over inheritance
  6. Go declarative whenever possible
  7. Don’t treat testing code like a second class citizen
  8. Isolate your unit tests, or suffer the consequences!
  9. The unit tests will break someday
  10. Unit tests shall be easy to setup
And the overriding “Zeroeth Law” is “If code is hard to test, change it.”


Wednesday, April 12, 2017

WebApi Notes


To return a custom response you can use new helper methods exposed through ApiController such as:
  • Ok
  • NotFound
  • Exception
  • Unauthorized
  • BadRequest
  • Conflict
  • Redirect
  • InvalidModelState


Monday, April 3, 2017

Angular 2 on Azure

A Good post to publish on to a Azure

An important change to note is
Node is present on webapp server but it would not return version number with the command.
but the good news is npm install command works well.


Issue 1:  404 errors in the site
Situation: providing access to api data folders on azure.
Solution : Ref:

Saturday, August 6, 2016

Setting up Angular 2..

You may head to Angular official guide to getting started but some things might be missing there which I covered here.

Q: Latest Node installed but not  the latest npm.
A:  npm updates itself to latest
If windows use
       npm install npm -g
Other use 
       sudo npm install npm -g


Q:install typing error
A: make sure you run npm as administrator and run below commands
  • Typings: npm install -g typings
  • Tsd: npm install -g tsd
and then use
npm run typings install
and below command in case your previous npm install failed
npm install

Q:unable to compile typescript code in Visual studio code
A: The TypeScript compiler does have to be manually installed using npm install -g typescript.



Sunday, July 17, 2016

SQL Hacks

1) make self admin sql express script. Just download and run the below script

2)SSRS Deployment Script

Friday, March 18, 2016

Angular 2 posts

1. The following are examples for the core fundamentals of Angular 2. Click the button to view each sample in a plunker. - from John Papa   (

Saturday, December 26, 2015

Grunt / Bower / NPM for Visual Studio

What is Grunt/ Gulp / NPM?
You may refer "An Introduction to Bower, Grunt and Gulp" Section at this article

NPM (Node package manager) is useful to manage UI packages.

How do i install them 
Follow the Steps in here

Opps! I  don't see gulp working 
If you get the below error

"Error:Failed to load   <your project location>\gulpfile.js"...
'gulp' is not recognized as an internal or external command, operable program or batch file."

Solution: We need to install gulp  --> which needs npm ( node package manger)

Step 1: Download & Install node.js in your the system.

Step 2:  Next Goto All Programs -> Node.js -> nodejs Command promt

Step 3:  run the below command to install gulp
npm install gulp -g

Note: you might face issues trying to install using npm if behind a proxy for which you may these solutions

Can I integrate it with my Online hosted Builds

Oh! Yes Have a look at here

Cant find .npmsrc
I ran npm config set <option> <value>, the file ~/.npmrc seemed to be created automatically, with the option & its value as the only non-commented-out line.

Thanks for visiting the post. 

Hope this helps you!

Thursday, August 8, 2013


1. How to align two elements on the same line without changing HTML

Using display:inline-block
#element1 {display:inline-block;margin-right:10px;} 
#element2 {display:inline-block;} 


Monday, July 22, 2013

Various options to store your SharePoint Solution’s Configuration Data.

The various options are : -
  1. Code
  2. web.config
  3. SharePoint List
  4. External Data Source
  5. Property Bag - 
  6. Hierarchical Object Store

1. - Good one with comparison. Do read the comments.

2. Hierarchical Object Store in SharePoint 2010 - more info on how to use the same.

Wednesday, July 3, 2013

Sharepoint 2010 Events

New Events in SharePoint Foundation 2010
Two new Add events have been provided for SharePoint lists – that is, for SPList objects:

In addition to these Add events, two Delete events have also been added to SharePoint lists:

New events on Sharepoint Sites

New Synchronous After Events
The default synchronization behavior is synchronous for before events and asynchronous for after events. Also available is a new property on the SPEventReceiverDefinition base class called Synchronization. This property has get and set methods to retrieve and set the SPEventReceiverSynchronization enumeration value. This enumeration provides a value called Default to support backward compatibility.

New Event Binding Functionality in SharePoint Foundation 2010
The ability to bind events at the scope of the site collection (SPSite), as well as giving you the ability to bind XML event receivers that are scoped to the individual site (SPWeb).

SPSite-Level Binding
   SharePoint Foundation 2010 supports an SPSite-level event receivers collection. Like other event receiver collections, this one accepts bindings from SPWebEventReceiver, SPListEventReceiver, and SPItemEventReceiver objects. All of these event types can be scoped to the site collection level (that is, SPSite). However, an SPEmailEventReceiver object does not work at the site collection level because the way that this object is implemented.

SharePoint Foundation 2010 supports binding XML event receivers at the scopes of both SPWeb and SPSite instances by using the <Receivers> tag. When a SharePoint Feature is scoped to the site collection level, a <Receivers> tag is potentially ambiguous. The tag can indicate either site-wide event binding or event binding for the top-level site. Note, however, that the default behavior is to scope to the site level. Therefore, when you scope a Feature to the site collection level, use the attribute named Scope to specify the intended scope.

SharePoint Foundation 2010 supports event binding based on the SPItemEventReceiver event receiver by using semantics of the ListTemplateId property. This approach creates an event receiver definition that is scoped to the list as the list is created. SP supports event binding that is based on the SPItemEventReceiver object in the XML of a specified content type.

SP provide the identity (ID) of the originating user and then let the event receiver implementer respond as appropriate.
SharePoint Foundation 2010 also introduces a new property called OriginatingUserToken on the SPEventPropertiesBase class that
returns the ID of the originating user.

 Event code should check for this user by ID, and, optionally, perform behaviors that can potentially cause unexpected effects by using an impersonated site collection with the token of that originating user.

In some scenarios, for example, when an active workflow has code that is running with elevated privileges, the code runs in the context of the system account. But in this scenario, when event receiver code needs to run with the credentials of the originating user, SharePoint Foundation 2010 allows you to undo the reversion using the above feature.

Redirect to URL in SharePoint Foundation 2010

Microsoft SharePoint Foundation 2010 now allows event receivers to provide a redirection URL to provide custom messages through the user interface (UI). The redirect URL feature works with all pre-event receiver types (such as SPWebEventReceiver, SPListEventReceiver, and SPItemEventReceiver) in cases where the action is being cancelled. To support the new user interfaces, SharePoint Foundation 2010 added the CancelWithRedirectUrl field to values in the SPEventReceiverStatus enumeration  (values -CancelNoError,    CancelWithError,    CancelWithRedirectUrl,    Continue ). CancelWithRedirectUrl allows you to specify a redirect URL for a Web browser UI. Use the URL that is specified by the RedirectUrl property of the SPEventPropertiesBase object to navigate to alternate pages. This URL should be a server-relative URL, and cannot contain ECMAScript (JavaScript, JScript).