Posts

Generic SQL Script to get table name and table count

 SELECT       QUOTENAME(SCHEMA_NAME(sOBJ.schema_id)) + '.' + QUOTENAME(sOBJ.name) AS [TableName]       , SUM(sPTN.Rows) AS [RowCount] FROM        sys.objects AS sOBJ       INNER JOIN sys.partitions AS sPTN             ON sOBJ.object_id = sPTN.object_id WHERE       sOBJ.type = 'U'       AND sOBJ.is_ms_shipped = 0x0       AND index_id < 2 -- 0:Heap, 1:Clustered GROUP BY        sOBJ.schema_id       , sOBJ.name ORDER BY [TableName] GO

Reduce DB Backup size

Reduce DB Backup size BACKUP DATABASE [dbname] TO DISK = 'path\dbname_date.bak' with COMPRESSION , STATS = 5

Disable TLS 1.0 and 1.1 in the server level

Image
Disable TLS 1.0 and TLS 1.1 at server level

Load Balancer Setup to fetch right URL of the application

Load Balancer Setup to fetch right URL of the application (without the port of the individual servers) < add key = " aspnet:UseHostHeaderForRequestUrl " value = " true " />

SQL Server - Execute big script files from the command line

SQL Server - Execute big script files from the command line sqlcmd -S <<ServerName>> -d "<<DB Name>>" -i "C:/script.sql"

SQL Server Extract User Roles and Build queries

Need to export all users and it's object-level permissions at one go? then execute the below to generate the Queries for creating the users and granting permissions at one go. Courtesy:  https://dba.stackexchange.com DECLARE     @sql VARCHAR(2048)     ,@sort INT DECLARE tmp CURSOR FOR /*********************************************/ /*********   DB CONTEXT STATEMENT    *********/ /*********************************************/ SELECT '-- [-- DB CONTEXT --] --' AS [-- SQL STATEMENTS --],         1 AS [-- RESULT ORDER HOLDER --] UNION SELECT  'USE' + SPACE(1) + QUOTENAME(DB_NAME()) AS [-- SQL STATEMENTS --],         1 AS [-- RESULT ORDER HOLDER --] UNION SELECT '' AS [-- SQL STATEMENTS --],         2 AS [-- RESULT ORDER HOLDER --] UNION /*********************************************/ /*********     DB USER CREATION      *...

Microsoft Graph - An Interesting Read

Image
Overview Microsoft Graph exposes REST APIs and client libraries to access data on the following: Azure Active Directory Office 365 services: SharePoint, OneDrive, Outlook/Exchange, Microsoft Teams, OneNote, Planner, and Excel Enterprise Mobility and Security services: Identity Manager, Intune, Advanced Threat Analytics, and Advanced Threat Protection. Windows 10 services: activities and devices Education https://developer.microsoft.com/en-us/graph/graph-explorer Graph Explorer https://developer.microsoft.com/en-us/graph/graph-explorer Quick Start https://developer.microsoft.com/en-us/graph/quick-start Develop Microsoft Graph https://docs.microsoft.com/en-us/graph/auth-overview Microsoft API and reference catalogue  https://msdn.microsoft.com/library

Github - Branch Protection

Image
Github - To protect the branch from developers to commit directly, we can use the Brach Protection Rules. By doing this no one can check in the code directly to the brach and developers need to raise a pull request and then someone review and then merge the code to the restricted branch. This option will enforce all the code committed are reviewed by someone.

SQL Server - Update Statistics

sp_updatestats;

Bypass SSL Check

To bypass the SSL certificate check for your local development environments, you can use this ServicePointManager.ServerCertificateValidationCallback +=                 (sender, certificate, chain, sslPolicyErrors) => true;

RESTful APIs Best Practices

Image
REST Security Cheat Sheet https://www.owasp.org/index.php/REST_Security_Cheat_Sheet

API - Framework Level Exception Handling

Image
The Exception handing at the framework level in API has been implemented in all the three API’s . please don’t use any try-catch block inside the API methods until it’s needed specifically.  When Global hander has been introduced to handle the exceptions. The framework will automatically handle the exceptions.

Agile Development with Automated Deployments

For most of the projects, we follow Agile Process and we may need to do frequent deployments to the SIT Environments to move things faster. In our project also we had the same requirement and we found that manual deployments using FTP takes more time (around 45 mins to 60 mins) so we have planned to do automated deployments to move things faster. Automated deployments take around 3 minutes. Here we are showcasing the effort saved after we have automated our deployment process. Manual Deployments: -           Switch to the deploy branch -           Publish the code and zip it -           Use FTP to transfer the files to the server -           Backup database -           Backup last deploy package -       ...

How to remove Git from a Project/Folder including sub-folders.

How to remove Git from a Project/Folder including subfolders? Use the below command in the route directory rm -rf .git

Setting up IIS for auto redirection

Image
IIS Options to setup auto-redirection.

Code Review - Strightly Follow It..

Image
Project starting from scratch should parallelly start reviewing the code. The power of code review can only be seen, when you start reviewing the code for your team members. If you are starting the code review for the first time, then be ready with many shocks. Then you will realise why you haven't started the code review process way earlier? Project age is 3 months and very early in the development stage, still completed the 100 code review for the project. How happy you feel when your code is clean and refactored from its childhood days... :-) Update: After a year, we have almost 600+ pull request raised. This means the contribution and code quality has been improved. Also, thanks to ReSharper :-)

.NET Standard

.NET implementation support .NET Standard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0 .NET Core 1.0 1.0 1.0 1.0 1.0 1.0 1.0 2.0 .NET Framework 1 4.5 4.5 4.5.1 4.6 4.6.1 4.6.1 4.6.1 4.6.1 Mono 4.6 4.6 4.6 4.6 4.6 4.6 4.6 5.4 Xamarin.iOS 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.14 Xamarin.Mac 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.8 Xamarin.Android 7.0 7.0 7.0 7.0 7.0 7.0 7.0 8.0 Universal Windows Platform 10.0 10.0 10.0 10.0 10.0 10.0.16299 10.0.16299 10.0.16299 Windows 8.0 8.0 8.1 Windows Phone 8.1 8.1 8.1 Windows Phone Silverlight 8.0

How to find Microsoft .NET "CORE" Framework Version Installed?

Image
How to find Microsoft .NET "CORE" Framework Version Installed? Press  Windows  +  R Type  cmd On the command prompt, type  dotnet --version If the  .NET Core  is installed, we should not get any error in the above steps.

Gulp Setup - Local Environment

Install npm check the version using npm -v Install node check the version using node -v Install Gulp -> npm install -g gulp-cli check the version using gulp -v Validation 1. npm list --depth=0

Tips on improving SEO

Tips on improving SEO           404ing internal links: update or remove links to Javascript, CSS files identified           PageSpeed Insights: Improve the average page speed score           Multiple H1s: Remove H1 associated with a page.           HTTP canonical: update canonical links sitewide to reference HTTPS pages - not HTTP           Robots.txt: add default robots.txt file           XML sitemap: Export and schedule for daily publication an XML sitemap or register with google tag manager frequently.           Use a 301 redirect to force site-wide HTTPS resolution           In the case of HTTPS, use a 301 redirect to force URLs to resolve with www. Prepended (currently getting no response).           Broken redirects need to be mapped individually ...

Preventing Cross-Site Request Forgery (XSRF/CSRF) Attacks in ASP.NET Core

MSDN blog to explain on Preventing Cross-Site Request Forgery Attacks in dot net core. https://docs.microsoft.com/en-us/aspnet/core/security/anti-request-forgery

Setting up Github with Git Bash

1)            Create an account on Github https://github.com/ 2)            Install Gitbash from following URL: https://git-scm.com/downloads 3)            Set up Github repositories: Go to start -> all programs -> git -> Open ‘Git bash’ On Command prompt: Step 1:            git config --global user.name "YOUR NAME"          Step 2: git config --global user.email "YOUR EMAIL ADDRESS" Step 3: Generate new SSH Keys as follows: Enter following command: ssh-keygen -t rsa -b 4096 -C "email@example.com" Press Enter Message displayed: Created directory '/p/.ssh'. Step 4: Create a passphrase: Enter your passphrase. ( it can be different than your password) Note: While setting pass phrase, the cursor doesn’t mov...

Performance Guide for Visual Studio in ReSharper

Nice blog from Resharper to explain the step by step guide to improve the Performace when we use ReSharper with Visual Studio. Most of our team members who are using the VM's from offshore will be benefiting from this Performance Improvements quide. Performance Guide for Visual Studio in ReSharper 2017.3

Don't use target="_blank" for your hyper links

Don't use target="_blank" for your hyper links instead use this rel="noopener noreferrer"

Entity Framework Migration Best Practices

1.       Introduction Like code is flown into version control system our database scripts will also be flown into the version control system and upgrading and downgrading the system should be straightforward. Before starting the Migration: Every developer should have their own local database for development. They can’t use the shared database for development. -          Steps for Migration Enable Migration This is one-time activity per team. Mostly the team lead when setting up the project will be doing this process. Add-Migration For every new migration activity, we will be using this command to start the migration. Update-Migration After the changes are done and the changes are ready to push to the database. We will use this Update-Migration to push the changes to the database. 2.      Workflow When using migration for a single person it will seem less and easy to use and wo...

Multi-Tenant Data Architecture

Image
Multi-tenancy Models When any application planned to roll out for multiple regions/countries/clients then multi-tenancy model comes into picture. This can be classified into four models as below -        Separate Application Separate Database -        One Shared Application and Separate Database -        One Shared Application and Shared Database (Separate Schema) -        One Shared Application and Shared Database (Same Schema) These models are differentiated based on whether the data is isolated or shared. The difference between the shared data and the isolated data is a continuum with many variations that are possible. Sample Application URL for different implementations. Tenant Name URL Tenant 1 Tenant1.domainname.com Tenant 2 Tenant2.domainnam...