Wednesday, August 3, 2022

SVG images from AWS Cloudfront downloading while opening in browser

 Why SVG  images from AWS Cloudfront downloading instead of opening opening?

 In S3 Bucket, by default SVG Image Content-type header is "application/octet-stream", so you need to change it to "image/svg+xml". 

Screen shot to change the content-type of SVG image at s3 bucket using the cloudberry Software.




Saturday, December 11, 2021

Mircosoft Windows - Creating a directory starting with a dot on windows

 You can create a folder using the Command Prompt with:

Step 1: Press Window + R to open "Run" Command

Step 2: Type cmd in the run window to open command prompt

Step 3: in the Command prompt, Go To Directory in which you wants to create folder, using Cd.. Command

Step 3: Use the Command  mkdir .well-known

Friday, December 3, 2021

SQL Server - Query for Possible bad Indexes

 --Possible bad Indexes (writes > reads)

SELECT  OBJECT_NAME(s.object_id) AS 'Table Name',sca.name  , i.name AS 'Index Name',

'DROP INDEX ' + i.name + ' ON ' + sca.name + '.' + OBJECT_NAME(s.object_id)  ,

        i.index_id, user_updates AS 'Total Writes',

        user_seeks + user_scans + user_lookups AS 'Total Reads',

        user_updates - ( user_seeks + user_scans + user_lookups ) AS 'Difference'

FROM    sys.dm_db_index_usage_stats AS s WITH ( NOLOCK )

        INNER JOIN sys.indexes AS i WITH ( NOLOCK ) ON s.object_id = i.object_id

                                                       AND i.index_id = s.index_id

INNER JOIN sys.tables AS t ON s.object_id = t.object_id

INNER JOIN sys.schemas As sca on t.schema_id = sca.schema_id

WHERE   OBJECTPROPERTY(s.object_id, 'IsUserTable') = 1

        AND s.database_id = DB_ID()

        AND user_updates > ( user_seeks + user_scans + user_lookups )

        AND i.index_id > 1

ORDER BY 'Difference' DESC,    'Total Writes' DESC,     'Total Reads' ASC ;

Monday, November 22, 2021

SQL Server - Drop indexes and stats

 

Query to get the 'drop query for Stats'


SELECT distinct 'DROP STATISTICS ' + sca.name + '.' + t.name + '.' + s.name
FROM sys.stats AS s
INNER JOIN sys.stats_columns AS sc
ON s.object_id = sc.object_id AND s.stats_id = sc.stats_id
INNER JOIN sys.columns AS c
ON sc.object_id = c.object_id AND c.column_id = sc.column_id
INNER JOIN sys.tables AS t
ON s.object_id = t.object_id
INNER JOIN sys.schemas As sca on t.schema_id = sca.schema_id
where s.name like '_dta_stat_%'


Query to get the 'drop query for Index'


SELECT distinct 'DROP INDEX ' + s.name + ' ON ' + sca.name + '.' + t.name
FROM sys.stats AS s
INNER JOIN sys.stats_columns AS sc
ON s.object_id = sc.object_id AND s.stats_id = sc.stats_id
INNER JOIN sys.columns AS c
ON sc.object_id = c.object_id AND c.column_id = sc.column_id
INNER JOIN sys.tables AS t
ON s.object_id = t.object_id
INNER JOIN sys.schemas As sca on t.schema_id = sca.schema_id
where s.name like '_dta_index_%'

SQL Server - Deleting the contents from log file

 You can shrink the log with the following Statements:

USE [MyDatabase]
GO
ALTER DATABASE [MyDatabase] SET RECOVERY SIMPLE WITH NO_WAIT
DBCC SHRINKFILE([MyDatabase_log], 1)
ALTER DATABASE [MyDatabase] SET RECOVERY FULL WITH NO_WAIT
GO
This snippet can be found on various sites in the net, but be aware that it's not a good practice to kill the log like this because of recovery. After doing this, you can only recover your database to the last full or full+incremental backup.

Monday, July 5, 2021

Remove 'Powered by Shopify' from your store

  1. From your Shopify admin, go to Online Store > Themes. 
  2. Find the theme that you want to edit, and then click Actions > Edit languages
  3. In the Filter translations box, type "powered"
  4. In the Powered by Shopify box, use the space bar on your keyboard to type a single space. You can repeat these steps for the Powered by Shopify HTML box, which appears on your store's "Opening soon" page if your store is password-protected. 
  5. Click Save.


Wednesday, June 23, 2021

Adding Cache-Control headers to Static Files in ASP.NET Core

 Implement Caching to Static files in the asp.net core

When you create a new ASP.NET Core project from the default template, you will find the StaticFileMiddleware is added early in the middleware pipeline, with a call to AddStaticFiles() in Startup.Configure():

Please replace the app.UseStaticFiles() from the below code:

public void Configure(IApplicationBuilder app)
{
    // logging and exception handler removed for clarity

    app.UseStaticFiles();

    app.UseMvc(routes =>
    {
        routes.MapRoute(
            name: "default",
            template: "{controller=Home}/{action=Index}/{id?}");
    });
}

to

using Microsoft.Net.Http.Headers;

app.UseStaticFiles(new StaticFileOptions
{
    OnPrepareResponse = ctx =>
    {
        const int durationInSeconds = 60 * 60 * 24 * 14;
        ctx.Context.Response.Headers[HeaderNames.CacheControl] =
            "public,max-age=" + durationInSeconds;
    }
});


This enables serving files from the wwwroot folder in your application. The default template contains a number of static files (site.cssbootstrap.cssbanner1.svg) which are all served by the middleware when running in development mode. It is these we wish to cache.

for more details - https://andrewlock.net/adding-cache-control-headers-to-static-files-in-asp-net-core/

Saturday, May 29, 2021

SEO for different countries

 

There are 3 options for SEO in different Countries:

1.       Country Code Top Level Domains (ccTLDs):

a.       A ccTLD (Country Code Top-level Domain) is a two-letter domain extension used primarily to identify an association of some kind to a specific country or territory. The first thing to do is you have to purchase a domain name whose extension should be your country domain such as .com which is global .http://co.uk for UNITED KINGDOM , .http://co.in for India , .ae for gulf etc. . Then you have to use Google webmaster geotargeting feature This tool allows you to set which country your website is targeted to.

b.       Automatically associated with the country they cover (.de to Germany)

c.       Starting SEO from scratch with no domain history and we need to start submitting website on Local search engine and directories 

d.       Focus on Local SEO to Boost traffic only from the targeting country 

e.       webhosting server is also matter, make sure that if you are targeting United Kingdom your website hosting server will be UK based.

f.        This strategy Increased costs of domain registration.

g.       SEO work on one site won’t benefit all sites, as they are all separate websites.

 

2.       Subdomains with Generic Top-Level Domains (gTLDs) or Country Names:

a.       Subdomain like Uk.domain.com, Us.domain.com

b.       this solution only works when the parent website is a .com domain.

c.       Has some connection to the current SEO authority of the main website, which can aid performance when launching in a new country

d.       SEO work on one site won’t benefit all sites, as they are all separate websites except domain authority

 

3.       Subdirectories with Generic TLDs (gTLDs) or country names

a.       Subdirectories like Domain.com/uk , domain.com/us

b.       SEO performed on one part of the domain will benefit all the country folders as it’s one site

c.       There is also the added inheritance of the authority of your original website so you aren’t starting from scratch when you go into a new market

d.       Links between countries are seen as internal links, not external ones, which helps your backlink profile as it will be made up predominantly of links from other people’s sites and not mainly from your own site

e.       In the search results, it’s not as obvious that the country subfolder is specifically for users in that country

f.        No automatic association in search to the target country

 

According to me, for the low budget 3 is the best option, so I want to choose this option. But if your budget is more than 1st option is defiantly better.


Google Merchant Feed for different countries with different currency.:

 

We need to submit the currency in the local currency of country of sale because

1.       One of the Google Shopping policies states that the price in your product feed needs to match the price on the landing page.

2.       Google has developed something called currency conversion. It will convert the price in your feed based on exchange rates from Google Finance and show these in your Shopping ads.

To support multiple currency support in the google AdSense, we need to upload the product with local currency and this price with currency should be same on the Landing page.

 

In the AdSense campaign, Currency conversion automatically converts the price in your product data to the currency of the new country of sale and displays both prices in your ads and free product listings. This makes your ads and listings understandable to users in other countries while allowing you to continue using your existing website and landing pages with minimal changes.

 

So, we will show the same currency & price on the Product landing page as we submit in the google Feed, but when customer lands on this page we will ask to change currency (show the currency of country by detecting the country).

 

 

Thursday, March 11, 2021

Background color not showing in print preview

 The Chrome CSS property -webkit-print-color-adjust: exact; works appropriately.

media print CSS in the body:

@media print {
body {-webkit-print-color-adjust: exact;}
}

503 This mail server requires authentication when attempting to send to a non-local e-mail address.

 Server error: '503 This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.'

and Error:

Your message did not reach some or all of the intended recipients.

      Subject: test

      Sent: 10-03-2021 15:15

The following recipient(s) cannot be reached:

 'example@domain.com' on 10-03-2021 15:15


This error occurs mostly in Windows system. The users can send emails to local domain systems but can’t send emails to external addresses. Why they do server sends this message: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. To resolve this error one should check the settings of the mail client or should contact the administrator for verification of address or domain are defined for the server or not.

Cause
  • SMTP server needs authentication for sending the mail to the external or non-local address. SMPT authentication and server are not configured by the email client.
  • Firewall or proxy software of the email doesn’t allow the SMTP authentication.
  • The email server may not match the settings of the server or have an incorrect credential configuration.
Symptoms
  • On Windows System, unable send mail through PHP scripts.
  • You will the following error while accessing the script of the web browser if you have defined ini_set ( ‘ display_error ’ , 1 );
SMTP server response: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.
  • Addresses in the local host are not be added to Whitelist of the Mail Server Settings. Mail Server Settings is available in the Tools & Settings.
  • The error specified above is seen in the Activity available in the Logs of the SMTP server.
Resolution

  1. Log on to the Plesk.
  2. In the Whitelist add the address of the local host.
Go to Tools & Settings >> Mail Server Settings >> White List >> Add Address: Check the following entries


mail1.png

Code:
CONFIG_TEXT: 127.0.0.1/32
::1/128
Mail will not be counted to Outgoing Mail Limit, when you add localhost address to the whitelist. If the address of the local host is not whitelisted, you need to add correct authentication credentials in the script of the mail. If this does not work, you should follow subsequent steps.
  • Connect the Plesk server through RDP.
  • In the Mail Enable option, launch MailEnable Management console. MailEnable is available in All Programs of Windows Start
  • Right click on the SMTP, which is in the MailEnable Management console and open the properties.

  • Move on to the Security tab in the SMTP Properties. Now disable the “Disable all catchalls” and “Authenticated senders must use the address from their post office” options and click on Apply button.
mail3.png

  • Select Denied relay rights option from Privileged IPs… available in the Relay tab. You can send emails through the server from a web page or web server. To do this you have to add the IP address of the users who can send the mail. Click Add button and enter the IP address of the user and click Close. Now click Ok button to save the changes.
mail4.png

  • At last, you have to restart the services of MailEnable SMTP Connector. To do this go to Servers >> localhost >> System >> Services Status in the MailEnable Management console. There you have to select the MailEnable SMTP Connector and then click Restart option.