Saturday, February 13, 2021

The script has an unsupported MIME type ('text/html').

ServiceWorker: The script has an unsupported MIME type (chrome-extension) 


The Error is showing because of the incorrect path and service worker is not accessible.

Path defined for js is not correct, might be you have taken relative path and this is vary on different pages.

Replacing:

'service-worker.js'

with:

'/service-worker.js' OR './service-worker.js'

in (navigator.serviceWorker.register('/service-worker.js')


The service worker file is not present at http://domain.com/service-worker.js so the server is returning index.html instead. Then the registration function has no idea of what to do with a index.html file and tells you that the MIME-type is not correct. 

A quick fix would be to copy the service-worker.js file to the public folder so that when you hit http://domain.com/service-worker.js you see the file in the browser. 

Remember to go to ChromeDev > Applications > ServiceWorkers and hit Unsubscribe. in order to remove the errored one. Remember also disable cache 

Thursday, February 4, 2021

Install Google Analytics to WordPress Without a Plugin

 

Install Google Analytics to WordPress Without a Plugin


In order for Google Analytics to start tracking your visitors, the tracking code mentioned above needs to be present on every page of your site you want to track user behavior on. Usually, that’s all of them. Here’s how you can achieve that manually.

Option A: Insert the Code Into header.php
One of the main ways to add the tracking code to your site is to insert it into your header. This way, it will load on every page.

Most standard themes have a header.php file that is responsible for outputting the site header section. So, you can simply input the Google Analytics code here.

However, when you make changes to theme files, be aware that it’s always best to do it in a child theme. Otherwise, they will get lost when you update your main theme. Child themes are super useful in general and you should definitely read up about them. Also, don’t forget to back up your WordPress site when making any changes like this.

Once you have created your child theme, simply copy the header.php from the main theme into it and start editing. You can do that directly in the WordPress back end via Appearance > Theme Editor.

add google analytics tracking code to wordpress header file via the theme editor Copy and paste the tracking code from Google Analytics into header.php right after the opening <head> tag.
Also, make sure the code is wrapped in <script>...</script> brackets! Otherwise, browsers won’t recognize it for what it is. That’s it! Now save and you are good.


Option B: Use functions.php
Another possibility to add Google Analytics to WordPress without a plugin is to use the functions file. You can do the same thing as we did above, however, instead of adding the tracking code to header.php directly, you insert it into the head section via a function.

To do so, simply edit your (child) theme’s functions.php file and add the following piece of code (but use your own measurement or tracking ID instead of ours):

function ns_google_analytics() { ?>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-B175YGY1T1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());


gtag('config', 'G-B175YGY1T1');
</script>
<?php
}


add_action( 'wp_head', 'ns_google_analytics', 10 );
Save, upload, and from that moment, Google Analytics should start tracking what’s going on on your site.

Wednesday, February 3, 2021

window.location.href not working - asp.net

 window.location.href not working


If we are calling function through a submit button. This may be the reason why the browser does not redirect. It will run the code in the function and then submit the page instead of redirect. 

In this case Either
1. change the type tag of your button to button
        2. you just need to add "return false;" at the bottom of your function

Sunday, January 31, 2021

Uncaught (in promise) TypeError: Failed to execute 'Cache' on 'addAll': Request failed

 Error in Service Worker.

Uncaught (in promise) TypeError: Failed to execute 'Cache' on 'addAll': Request failed.

Main cause of this is typo in one of the filenames/ OR file is not exists that had added to cached_urls. It did not match the name of the real file so I kept getting the error.

I Got this issue due to typo in the filename and found it by quickly setting cached_urls to an empty list and found that the error went away.

Monday, January 25, 2021

Advanced SEO - Separate URLs for Mobile and desktop applications

We can configure Separate URLs for Mobile and desktop applications

Annotations for desktop and mobile URLs

To help Google algorithms understand separate mobile URLs, we recommend using the following annotations:

  1. On the desktop page, add a rel="alternate" tag pointing to the corresponding mobile URL. This helps Googlebot discover the location of your site's mobile pages.
  2. On the mobile page, add a rel="canonical" tag pointing to the corresponding desktop URL.

google support two methods to have this annotation: in the HTML of the pages themselves and in sitemaps. For example, suppose that the desktop URL is http://example.com/page-1 and the corresponding mobile URL is http://m.example.com/page-1. The annotations in this example would be as follows.

Annotations in the HTML

On the desktop page (http://www.example.com/page-1), add the following annotation:

<link rel="alternate" media="only screen and (max-width: 640px)"
 
href="http://m.example.com/page-1">

On the mobile page (http://m.example.com/page-1), the required annotation should be:

<link rel="canonical" href="http://www.example.com/page-1">

This rel="canonical" tag on the mobile URL pointing to the desktop page is required.

Annotations in sitemaps

Google support including the rel="alternate" annotation for the desktop pages in sitemaps like this:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
 
<url>
   
<loc>http://www.example.com/page-1/</loc>
   
<xhtml:link rel="alternate" media="only screen and (max-width: 640px)"
   
href="http://m.example.com/page-1" />
 
</url>
</urlset>

The required rel="canonical" tag on the mobile URL should still be added to the mobile page's HTML.

Tuesday, January 19, 2021

Plesk - Upgrade the .net Framework to 4.7.2 OR 4.8

 Steps to Upgrade the .net Framework to 4.7.2 OR 4.8

1. First Download the .NET Framework from https://dotnet.microsoft.com/download/dotnet-framework 

2. Install on the Server.

3. Login to the Plesk and go to "Tools & Settings" > "Server Components" and refresh the components using the refresh button



4. After update, it will reflect in "Web Script" section at the server component page.


All done!!!

Tuesday, January 12, 2021

How to split column with delimiter into two columns in SQL Server Split

We can use Case and  CHARINDEX to split column with delimiter into two columns in SQL Server

select 
    case when CHARINDEX('_',name)>0 
         then SUBSTRING(name,1,CHARINDEX('_',name)-1) 
         else name end firstname, 
    CASE WHEN CHARINDEX('_',name)>0 
         THEN SUBSTRING(name,CHARINDEX('_',name)+1,len(name))  
         ELSE NULL END as lastname
from emp

you can use CASE command to control is last name available.


MS SQL Server:

Query 1:

declare @t table (id int, name  varchar(50))

insert into @t (id,name) values( 1    ,'abc_rao')
insert into @t (id,name) values( 2    ,'nani')
insert into @t (id,name) values( 3    ,'hari_babu')
insert into @t (id,name) values( 4    ,'kalibabu')
insert into @t (id,name) values( 5    ,'ab_tan')

select 
    case when CHARINDEX('_',name)>0 
         then SUBSTRING(name,1,CHARINDEX('_',name)-1) 
         else name end firstname, 
    CASE WHEN CHARINDEX('_',name)>0 
         THEN SUBSTRING(name,CHARINDEX('_',name)+1,len(name))  
         ELSE NULL END as lastname
from @t

Results:

| FIRSTNAME | LASTNAME |
|-----------|----------|
|       abc |      rao |
|      nani |   (null) |
|      hari |     babu |
|  kalibabu |   (null) |
|        ab |      tan |


Thursday, January 7, 2021

How to cancel your Zoom subscription or add-ons at anytime?

Cancel a Pro (paid) subscription
  • Sign in to the Zoom web portal.
  • Click Account Management, then click Billing.
  • Under the Current Plans tab, find the plan you want to cancel and click Cancel Subscription to stop your subscription's automatic renewal.
  • Confirm your request by selecting Cancel Subscription.
  • Choose why you would no longer like to renew your subscription.
  • Once complete, click Submit.
    Your plan status will now be updated to Canceled. You will still have use of your paid plan for the remainder of your subscription term.
  • (Optional) If you would no longer like to have the plan canceled, you will be able to reactivate your plan by selecting Reactivate Plan on the Current Plans page.
Note: If it says Contact Sales instead of Cancel Subscription, you will need to contact our sales team or your Account Executive to have the plan canceled

Tuesday, January 5, 2021

How to set up an HTTP/HTTPS redirect in IIS

In order to force a secure connection on our website, it is necessary to set up a certain HTTP/HTTPS redirection rule. This way, anyone who enters your site using a link like “domain.com” will be redirected to “https://domain.com” or “https://www.domain.com” (depending on your choice) making the traffic encrypted between the server and the client side.

Steps to setup an IIS HTTPS redirect:

  • Download and install the URL Rewrite module.
  • Open the IIS Manager console and select the website you would like to apply the redirection to in the left-side menu:
  • Double-click on the URL Rewrite icon.
  • Click Add Rule(s) in the right-side menu.
  • Select Blank Rule in the Inbound section, then press OK.
  • Enter any rule name you wish.
  • In the Match URL section:
    • Select Matches the Pattern in the Requested URL drop-down menu
    • Select Regular Expressions in the Using drop-down menu
    • Enter the following pattern in the Match URL section: (.*)
    • Check the Ignore case box
  • In the Conditions section, select Match all under the Logical Grouping drop-down menu and press Add.
  • In the prompted window:
    • Enter {HTTPS} as a condition input
    • Select Matches the Pattern from the drop-down menu
    • Enter ^OFF$ as a pattern
    • Press OK
  • In the Action section, select Redirect as the action type and specify the following for Redirect URL:

    https://{HTTP_HOST}{REQUEST_URI}
  • Un-check the Append query string box.
  • Select the Redirection Type of your choice. The whole Action section should look like this:
    NOTE: There are 4 redirect types of the redirect rule that can be selected in that menu:
    • Permanent (301) – preferable type in this case, which tells clients that the content of the site is permanently moved to the HTTPS version. Good for SEO, as it brings all the traffic to your HTTPS website making a positive effect on its ranking in search engines.
    • Found (302) – should be used only if you moved the content of certain pages to a new place *temporarily*. This way the SEO traffic goes in favour of the previous content’s location. This option is generally not recommended for a HTTP/HTTPS redirect.
    • See Other (303) – specific redirect type for GET requests. Not recommended for HTTP/HTTPS.
    • Temporary (307) – HTTP/1.1 successor of 302 redirect type. Not recommended for HTTP/HTTPS.
    OPTION 2: Specify the Redirect Rule as https://{HTTP_HOST}/{R:1} and check the Append query string box. The Action type is also to be set as Redirect.
  • Click on Apply on the right side of the Actions menu.


The IIS redirect can be checked by accessing your site via http:// specified in the URL. To make sure that your browser displays not the cached version of your site, you can use anonymous mode of the browser.

The rule is created in IIS, but the site is still not redirected to https:// Normally, the redirection rule gets written into the web.config file located in the document root directory of your website. If the redirection does not work for some reason, make sure that web.config exists and check if it contains the appropriate rule.

To do this, follow these steps:
  • In the sites list of IIS, right-click on your site. Choose the Explore option:
  • Explore will open the document root directory of the site. Check if the web.config file is there.
  • The web.config file must have the following code block

    <configuration>
     <system.webServer>
     <rewrite>
     <rules>
     <rule name="HTTPS force" enabled="true" stopProcessing="true">
     <match url="(.*)" />
     <conditions>
     <add input="{HTTPS}" pattern="^OFF$" />
     </conditions>
     <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
     </rule>
     </rules>
     </rewrite>
     </system.webServer>
    </configuration>


    Note: This is a default configuration. If you'd like to change it, you might need to check this server documentat
    ion
    .
  • If the web.config file is missing, you can create a new .txt file, put the aforementioned code there, save and then rename the file to web.config.

Sunday, December 13, 2020

Shopify - Add password protection to your online store

Add password protection to your online store

You can add password protection to your online store.

Steps:

  • From your Shopify admin, go to Online Store > Preferences.
  • Scroll to the Password protection area, and check Enable password.
  • In Password, enter the password that you'll give to the customers who you want to be able to access your online store. Don't use the same password that you use to log into your admin.
  • In Message for your visitors, enter the message that you want to show on the password page. If you don't want to show a message, then leave this field blank.
  • Click Save.

 

Edit your password page settings

You can edit the content that shows on your password page, such as the text, colors, and typography. 

  • From your Shopify admin, go to Online Store > Themes.
  • Find the theme that you want to edit and click Customize.
  • Select Password page from the top bar drop-down menu. If you don't see Password page in the menu, then you need to add password protection to your online store.
  • To edit the sections on the password page, do the following tasks
    •  Click Sections.
    • Click on the section that you want to edit. Most themes have header, content, and footer sections.
    • Make changes to the section settings.
    • Click Save.
  • To edit the theme settings for the password page, do the following tasks:
    • Click Theme settings.
    • Click on the settings category that you want to edit. Most themes have color, typography, social, and favicon settings.
    • Make changes to the theme settings.
    • Click Save.