Wednesday, May 27, 2020

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation generally happens when any of the following conditions are met:
The logical order of pages in an index do not match with the physical order present in the data file.
By deletion of existing rows or updating existing values of the indexed columns.
To check if your MS SQL Server contains fragmentation in your indexes, execute the below query.
	SELECT  OBJECT_NAME(ind.OBJECT_ID) AS TableName,ind.name AS IndexName
,indexstats.index_type_desc AS IndexType,
indexstats.avg_fragmentation_in_percent,page_count  ,  DB_NAME(database_id)
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats
INNER JOIN sys.indexes ind  
ON ind.object_id = indexstats.object_id
AND ind.index_id = indexstats.index_id
WHERE indexstats.avg_fragmentation_in_percent > 30
ORDER BY indexstats.avg_fragmentation_in_percent DESC
Generally any fragmentation between 10 to 30 percent is considered fine. If the result shows fragmentation more than 30% on indexes than you really need to fix this as it might be main root cause for affecting application performance or slowness.
The Index Fragmentation issue can be solved by,
If the fragmentation levels are low, than you can defragment the indexes.
If the fragmentation levels are high, then ideally you should rebuild the indexes.

Tuesday, May 26, 2020

Git : Remove cached files from Repository

While working on a GIT repo, many times we face a issue where we have previously included some files in GIT and now we want to remove the same files from GIT for some reason. Also if we add those files to git ignore file but still sometime they are not ignored by GIT.

This happens sometimes due to the cache on our working GIT repo. To solve this issue permanently we can run the below given commands sequentially and step by step in GIT Bash or any other window which supports git commands.
	git rm -r --cached .
git add .
git commit -am 'Cleared GIT Cache'

After executing the above commands sequentially and step by step the GIT cache will get clear and the files will get removed from GIT. Do consider taking a backup of source code in case you want to revert again back to original as it was.

XAMPP : Upgrade PHP and MySQL to latest Version

Many of us work on multiple projects and on long term projects also. While working condition may arise to upgrade PHP version for a project on your local development server. We just can't remove our old installation as it would also impact our old projects as old projects might be completely lost in this process.
A better way to handle this is that we might want to upgrade the existing XAMPP version to match the required PHP and MySQL version. This can be done by following the below steps.
  1. First of all take a backup of your existing htdocs and data folder (it is a subfolder of MySQL folder in XAMPP).
  2. In case you have made some changes in the configuration files like php.ini, httpd.config or any other files, than please take backup of those files also.
  3. Download the latest Version of XAMPP from their official website. (https://www.apachefriends.org/download.html)
  4. Now, reinstall the downgraded version and replace those folders with the old ones.
  5. After this replace the php.ini, httpd.config and other configuration files if you have taken backup.
With the above steps your PHP and MySQL Version will be upgraded to the latest version.

Monday, October 14, 2019

WordPress LearnDash Course Completion URL filter

If you want to set the completion URL as a custom one so that after completion of course user will be sent to this URL instead of the default LearnDash URL than can use the following available filter of LearnDash with WordPress.

 add_filter("learndash_course_completion_url", function($link, $course_id) {
//You can change the link here
return $link;
}, 5, 2);

You can set or change the priority of the filter execution as per your need or keep it as it is.

WordPress LearnDash Quiz Completion Hook

If you want to call a hook when a Quiz is completed in LearnDash using WordPress than you can do it in the following way.

 add_action("learndash_quiz_completed", function($data) {
//Called when quiz is completed
}, 5, 1);

You can adjust the priority of the function as per your need.  

WordPress LearnDash Topic Completion Hook

If you want to call a hook when a Topic is completed in LearnDash using WordPress than you can do it in the following way.

 add_action("learndash_topic_completed", function($data) {
//Called when topic is completed
}, 5, 1);

You can adjust the priority of the function as per your need.

WordPress LearnDash Lesson Completion Hook

If you want to call a hook when a Lesson is completed in LearnDash using WordPress than you can do it in the following way.

 add_action("learndash_lesson_completed", function($data) {
//Called when lesson is completed
}, 5, 1);

You can adjust the priority of the function as per your need.

WordPress LearnDash Course Completion Hook

If you want to call a hook when a course is completed in LearnDash using WordPress than you can do it in the following way.

 add_action("learndash_course_completed", function($data) {
//Called when course is completed
}, 5, 1);

You can adjust the priority of the function as per your need.

Tuesday, November 8, 2016

Create a Linux VM on Azure using the Portal

In this section we are going to see how to “Create a Linux VM on Azure using the Portal”.  We assume that you have an Azure Portal with a valid subscription. Follow the following steps to quickly create a “Linux Virtual Machine”.



  • Login into your Azure Portal with your portal credentials.
  • After logging you will be redirected to “Dashboard” of the Portal.
  • In the upper left corner you will find an option “New”.
  • Click on the “New” option.


  • After clicking on New you will find many options.
  • Click on the “Virtual Machines” Option.
  • Select “Ubuntu Server” from the Featured Apps and Select “Resource Manager”  as deployment model.

  • Click on the “Create” button.
  • On the Page will be displayed next Enter the following things.
  • A name for your “Virtual Machine”.
  • Admin Username
  • Set the Authentication type to “SSH
  • Select Existing “Resource Name” or add new.
  • After Entering all the required data click on the “Ok” button to continue.

  • The next step will be to “Select a Size”.
  • There will be multiple sizes displayed on the screen.
  • You can have a look the “Recommended” sizes by Azure.
  • Select the “DS1” Size from the Options as it will Install “ubuntu” on Premium SSD.
  • You can select other options also.
  • Please see below screenshot for more details.


  • The next option after this is the “Settings”.
  • There is no need to change or set any “Setting”.
  • It is recommend to leave the “Settings” as it is.
  • Just click “Ok” and the summary of the settings will be visible for review.
  • If all things are fine the “Confirm” the “Settings” by clicking on the “Ok” button.
  • Now the next step is to get the “Public” IP of the VM that we have just created.
  • Go to “Dashboard” of your portal.
  • Click on the “Network Interfaces” option.
  • In the “Network Interfaces” you will see the name of the VM that you just created.
  • Click on the VM and you see the Public IP Address.
  • Copy the Public IP Address. (Suppose your Public IP is 11.12.11.12)
  • Now SSH into the public IP using your SSH public key using the following command.
  • ssh -i ~/.ssh/azure_id_rsa ubuntu@11.12.11.12

That's all and your Linux VM is ready for use!

Magento 2 Contact Page With Google Map

In Magento 2 contact page is present and it can be enabled from the Admin section from the configuration options. The contact page shows a form and captcha. By default map is not available on the contact page in Magento 2.

In many cases users need to also show the shop address on the contact page with the help of an Google map. For this purpose this extension can be used.

Important Features of the Extension are as follows:

(1) Extension is very easy to install
(2) Text area option to enter any address in Admin
(3) Option to manage map height.
(4) Option to upload custom images for marker .
(5) Option to customize the page layout.
(6) Text field Option to enter latitude and longitude for the map marker.
(7) User can easily enable and disable this module.

This extension can be downloaded from the Magento Marketplace.

Please refer the following URL:  https://marketplace.magento.com/clarion-contact.html

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...