Thursday, March 4, 2021
Saturday, November 7, 2020
Sql Query titbits
Generate Dates and hour between Date Range
DECLARE
@start DateTime = getdate() -1,
@end DateTime = getdate();
;
WITH Dates_CTE
AS (SELECT @start AS Dates
UNION ALL
SELECT Dateadd(hh, 1, Dates)
FROM Dates_CTE
WHERE Dates < @end)
SELECT DAY(dates),DATEPART(hour,Dates)
FROM Dates_CTE
OPTION (MAXRECURSION 0)
Got better queries? .. Add in comment .. Thanks
Wednesday, July 8, 2020
ef core tips
Debug code-first Entity Framework migration codes
Place this piece of code right above the migration you want to debug:
if (!System.Diagnostics.Debugger.IsAttached)
System.Diagnostics.Debugger.Launch();
More details / Ref : https://stackoverflow.com/a/52700520/193061
Thursday, July 2, 2020
Powershell TitBits
Replace all file names in a folder
Get-ChildItem -Filter “*ModelMap*” -Recurse | Rename-Item -NewName {$_.name -replace ‘ModelMap’ ,’ModelMapping’ }
Thursday, June 4, 2020
Java To C# mapping
Java C#
Map Dictionary
Set HashSet
Pair KeyValuePair
.map .Select
.collect .ToList()
.stream .AsEnumerable
LinkedHashSet <Need custom impl >
flatMap() SelectMany
format() String.format()
zip( .Zip(
joining() String.Join(
InstStream(1,100) Enumerable.Range(1, 100)
Function Func
.apply( .Invoke(
.isEmpty() .Any()
.size() .Count
.filter( .Where(
BiFunction Func
Monday, January 6, 2020
Addins for Software tools
SQL management addins
VS Code Addins
- Javascript/ Typescript
- Prettier
- using powershell
- d
Friday, January 3, 2020
RxJs Excellent posts
RxJs Excellent posts
RxJS Operators for Dummies: forkJoin, zip, combineLatest, withLatestFrom
https://scotch.io/tutorials/rxjs-operators-for-dummies-forkjoin-zip-combinelatest-withlatestfrom
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?
Ans:
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 filesgit checkout -- cats.html index.html
---------------------------------------------------------------------------------------------------------------------
git branch -a -- lists all branchesgit 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.
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.
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
Developer Basics
https://jeremydmiller.com/2014/11/07/strong_typed_configuration/
--------------------------------------------------------------------------------------
TDD rules : -
- Isolate the Ugly Stuff
- Push, Don’t Pull (this post)
- Test small before testing big
- Avoid a long tail
- Favor composition over inheritance
- Go declarative whenever possible
- Don’t treat testing code like a second class citizen
- Isolate your unit tests, or suffer the consequences!
- The unit tests will break someday
- Unit tests shall be easy to setup
ref: http://codebetter.com/jeremymiller/2006/03/09/jeremys-second-law-of-tdd-push-dont-pull/
--------------------------------------------------------------------------------------
Wednesday, April 12, 2017
WebApi Notes
In ASP.NET Web API 2
To return a custom response you can use new helper methods exposed through ApiController such as:
- Ok
- NotFound
- Exception
- Unauthorized
- BadRequest
- Conflict
- Redirect
- InvalidModelState
---------------------
13/11/2020 SignalR 2 (.net framework) Tip
You would be unable to connect to signalr 2 (.net version) running on your visual studio/localhost if the visual studio is not running as Admin.
Monday, April 3, 2017
Angular 2 on Azure
A Good post to publish on to a Azure
http://abusanad.net/2016/07/24/publish-angular-2-app-from-visual-studio-to-azure/#comment-8701
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.
Ref: https://blogs.msdn.microsoft.com/azureossds/2016/04/20/nodejs-and-npm-versions-on-azure-app-services/
Issue 1: 404 errors in the site
Situation: providing access to api data folders on azure.
Solution : Ref: https://blogs.msdn.microsoft.com/benjaminperkins/2014/09/01/the-webpage-cannot-be-found-404-when-accessing-a-file-on-azure-websites/
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.
https://angular.io/docs/ts/latest/quickstart.html
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
Ref: http://blog.npmjs.org/post/85484771375/how-to-install-npm
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
npm run typings install
and below command in case your previous npm install failednpm install
Ref: http://stackoverflow.com/questions/35449005/npm-start-is-not-working-for-angular-2-quickstart 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.Ref: http://stackoverflow.com/questions/31189875/does-vs-code-install-typescript-and-if-so-where
Q:
Sunday, July 17, 2016
SQL Hacks
1) make self admin sql express script. Just download and run the below script
https://gist.github.com/wadewegner/1677788
2)SSRS Deployment Script
http://www.sqlblogspot.com/2014/03/ssrs-deploymentcomplete-automation2012.html
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
http://a2-first-look.azurewebsites.net/ (http://jpapa.me/a2firstlook)
Saturday, December 26, 2015
Grunt / Bower / NPM for Visual Studio
What is Grunt/ Gulp / NPM?
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.ref:https://stackoverflow.com/questions/15536872/nodejs-npm-global-config-missing-on-windows
Thanks for visiting the post.
Hope this helps you!
Hope this helps you!
Thursday, August 8, 2013
HTML Tips
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;}
2.
Monday, July 22, 2013
Various options to store your SharePoint Solution’s Configuration Data.
The various options are : -
- Code
- web.config
- SharePoint List
- External Data Source
- Property Bag -
- Hierarchical Object Store
Ref:
1. http://blogs.msdn.com/b/zwsong/archive/2012/03/27/where-should-you-store-your-sharepoint-solution-s-configuration-data.aspx - 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
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).
Subscribe to:
Posts (Atom)
Devops links
Build Versioning in Azure DevOps Pipelines
-
Build Versioning in Azure DevOps Pipelines
-
For india 1) http://www.mustseeindia.com/<place you want to visit eg:vizag>
-
REf: http://www.nikhedonia.com/notebook/entry/efficient-paging-for-gridview/