How to stop SPAM in gmail account permanently? A guide to creating filters in Google Mail [no third party app]

SPAM, don’t we hate it when our inbox is full of credit card offers, insurance policies and billions of pounds that some rich dude left for you in his will? Everyone wants to get rid of them but somehow, some stupid website out there keeps leaking on our email address and we keep receiving stupid junk emails.

We all know that SPAM or Junk Email means unsolicited messages that you receive by email. But here is a fun fact:

Spam is named after Spam luncheon meat by way of a Monty Python sketch in which Spam in the sketch is ubiquitous, unavoidable and repetitive.

Go to Latest update of this article

UPDATE
The new filter guide is on https://github.com/harshvardhanmalpani/Spam-List
You can directly use the file filter_import_for_gmail.xml from github repository and add filters.
———

let us get started with the guide, Please be aware that this guide will remove and block the SPAM addresses permanently.

Step 1: Log in to your Gmail account

Step 2: Go to Settings

Gmail settings

Step 3: Under Filters and Blocked Addresses, Click on Create a new filter

Step 4: In the new FROM field, enter the Email addresses you want to block separated with

" OR "
quotations not required, just [space]OR[space]

and finally click Create filter with this search

Step 5: Check Delete it and Never send it to spam and Save the filter by choosing Create filter


Ready to import gmail filters now available

download here

file contents:

<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
<title>Mail Filters</title>
<id>
tag:mail.google.com,2008:filters:1536425906073,1536425906073,1536425906074,1536425906074,1536425906075,1536425906075,1536425906075,1536425906076,1536425906076</id><updated>2018-09-08T22:28:26Z</updated><author>
<name>Harshvardhan Malpani</name>
<email>[email protected]</email>
</author><entry><category term='filter'></category>
<title>Mail Filter</title>
<id>tag:mail.google.com,2008:filter:1536425906073</id><updated>2018-09-08T22:28:26Z</updated><content></content><apps:property name='from' value='[email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected]'/><apps:property name='shouldTrash' value='true'/>
<apps:property name='shouldNeverSpam' value='true'/>
<apps:property name='sizeOperator' value='s_sl'/>
<apps:property name='sizeUnit' value='s_smb'/> </entry><entry><category term='filter'></category>
<title>Mail Filter</title>
<id>tag:mail.google.com,2008:filter:1536425906073</id><updated>2018-09-08T22:28:26Z</updated><content></content><apps:property name='from' value='[email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected]'/><apps:property name='shouldTrash' value='true'/>
<apps:property name='shouldNeverSpam' value='true'/>
<apps:property name='sizeOperator' value='s_sl'/>
<apps:property name='sizeUnit' value='s_smb'/> </entry><entry><category term='filter'></category>
<title>Mail Filter</title>
<id>tag:mail.google.com,2008:filter:1536425906074</id><updated>2018-09-08T22:28:26Z</updated><content></content><apps:property name='from' value='[email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected]'/><apps:property name='shouldTrash' value='true'/>
<apps:property name='shouldNeverSpam' value='true'/>
<apps:property name='sizeOperator' value='s_sl'/>
<apps:property name='sizeUnit' value='s_smb'/> </entry><entry><category term='filter'></category>
<title>Mail Filter</title>
<id>tag:mail.google.com,2008:filter:1536425906074</id><updated>2018-09-08T22:28:26Z</updated><content></content><apps:property name='from' value='[email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected]best.top OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected]'/><apps:property name='shouldTrash' value='true'/>
<apps:property name='shouldNeverSpam' value='true'/>
<apps:property name='sizeOperator' value='s_sl'/>
<apps:property name='sizeUnit' value='s_smb'/> </entry><entry><category term='filter'></category>
<title>Mail Filter</title>
<id>tag:mail.google.com,2008:filter:1536425906075</id><updated>2018-09-08T22:28:26Z</updated><content></content><apps:property name='from' value='[email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected]'/><apps:property name='shouldTrash' value='true'/>
<apps:property name='shouldNeverSpam' value='true'/>
<apps:property name='sizeOperator' value='s_sl'/>
<apps:property name='sizeUnit' value='s_smb'/> </entry><entry><category term='filter'></category>
<title>Mail Filter</title>
<id>tag:mail.google.com,2008:filter:1536425906075</id><updated>2018-09-08T22:28:26Z</updated><content></content><apps:property name='from' value='[email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR n[email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected]'/><apps:property name='shouldTrash' value='true'/>
<apps:property name='shouldNeverSpam' value='true'/>
<apps:property name='sizeOperator' value='s_sl'/>
<apps:property name='sizeUnit' value='s_smb'/> </entry><entry><category term='filter'></category>
<title>Mail Filter</title>
<id>tag:mail.google.com,2008:filter:1536425906075</id><updated>2018-09-08T22:28:26Z</updated><content></content><apps:property name='from' value='[email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected]'/><apps:property name='shouldTrash' value='true'/>
<apps:property name='shouldNeverSpam' value='true'/>
<apps:property name='sizeOperator' value='s_sl'/>
<apps:property name='sizeUnit' value='s_smb'/> </entry><entry><category term='filter'></category>
<title>Mail Filter</title>
<id>tag:mail.google.com,2008:filter:1536425906076</id><updated>2018-09-08T22:28:26Z</updated><content></content><apps:property name='from' value='[email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR t[email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR va.loan.#[email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected] OR [email protected]'/><apps:property name='shouldTrash' value='true'/>
<apps:property name='shouldNeverSpam' value='true'/>
<apps:property name='sizeOperator' value='s_sl'/>
<apps:property name='sizeUnit' value='s_smb'/> </entry><entry><category term='filter'></category>
<title>Mail Filter</title>
<id>tag:mail.google.com,2008:filter:1536425906076</id><updated>2018-09-08T22:28:26Z</updated><content></content><apps:property name='from' value='[email protected]'/><apps:property name='shouldTrash' value='true'/>
<apps:property name='shouldNeverSpam' value='true'/>
<apps:property name='sizeOperator' value='s_sl'/>
<apps:property name='sizeUnit' value='s_smb'/> </entry></feed>

Some of the spam email addresses in my filter list:

Note: You might have to create multiple filters because one search can not contain more than 1000 characters

Whole list of spammers

[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]toya.com
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
miklejackrijq[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]p1.com
[email protected]
[email protected]
[email protected]
va.loan.#[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

September Update

Latest way to be followed for SPAM blocking is as follows:

Do NOT follow both the procedures, only one of these is enough

Step 1: Log in to your Gmail account

Step 2: Go to Settings

Gmail settings

Step 3: Delete all previous filters if any, and then click on Import Filters

Click on Import Filters

Step 4: Upload the xml file that you downloaded from here: Link to filters in xml
choose xml file to import

Step 5: Click on open file and then you will see that all filters are loaded. Make sure you tick Apply new filters to existing email. and then click on Create Filters

Create Filters

Step 6: There is no step 6, wait and watch. All those filters will get created and will make you rid of SPAM

Linux Bash – How to change all filenames to uppercase leaving the file extension unchanged

use this simple code in bash shell. The following code will change all xxx.jpg files to XXX.jpg in any particular working directory.

for i in *.jpg; do 
ext=${i##*.}; 
name=$(basename "$i" ".$ext" | tr '[a-z]' '[A-Z]').$ext; 
if [ "$i" != "$name" ] 
then 
mv $i $name;
fi
done;

How to update Magento community edition using CLI

composer require magento/product-community-edition 2.2.6 --no-update
composer update
rm -rf var/di var/generation var/cache var/view_preprocessed generated/*
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento indexer:reindex
php bin/magento deploy:mode:set production

if you receive any errors post installation, try this hard fix

rm -rf app/code/Magento/ var/* vendor/*
chmod 777 -R *
composer update && composer install
php -f bin/magento setup:static-content:deploy
find . -type d -exec chmod 775 {}
find . -type f -exec chmod 660 {}
chmod u+x bin/magento
bin/magento maintenance:disable
bin/magento cache:clean

CORS policy for subdomains – htaccess – apache server

Works for Magento 2.2x

Cross-Origin Resource Sharing header for Access-Control-Allow-Origin for Subdomains

SetEnvIf Origin "^(.*\.yourdomain\.com)$" OSD=$1
Header set Access-Control-Allow-Origin "%{OSD}e" env=OSD
Header set Access-Control-Allow-Methods: "*"
Header set Access-Control-Allow-Headers: "*"

or a general format for simple copy paste:

SetEnvIf Origin "^(.*)$" OSD=$1
Header set Access-Control-Allow-Origin "%{OSD}e" env=OSD
Header set Access-Control-Allow-Methods: "*"
Header set Access-Control-Allow-Headers: "*"

How to manage Magento 2 product attribute values options using console

This is an update to my previous script which was used to add custom product attribute values using backend –
Add values to product attribute

Read the previous^ part to get introduction about how it works. you will have to use browser console (ctrl + shift +j in Google chrome)

First of all initialize the array mimim with the final set of values you want to see in backend. The script then automatically removes the extra options first(values which are not in mimim but in present in backend), then it adds the remaining values from mimim (which are in mimim but not at backend)

$jq=new jQuery.noConflict();
var mimim=["Abalone",
"Titanium Druzy",
"Tourmaline",
"Turquoise",
"Yellow Zircon",
"Light Blue Druzy"];
var trans=[];var o=0;
$jq('#manage-options-panel tbody tr td:nth-child(3) input').each(
function(a,b){
//if(a>10)return false;
//alert(b.value);
trans.push(b.value);
if($jq.inArray(b.value,mimim)==-1){ o++;$jq('#delete_button_'+b.name.slice(14,-4)).click(); trans.pop();}
});
alert(o+" items removed");
$jq.each(mimim,function(a,b){
//console.log($jq('#manage-options-panel tbody tr td:nth-child(3) input').val());
if($jq.inArray(b,trans)==-1){
$jq('#add_new_option_button').click();
$jq('#manage-options-panel tbody tr:last-child td:nth-child(3) input').val(b);
}
});

Insert Indian States in Magento Database

Connect to your server’s database using mysql cli or phpmyadmin and use the following query

INSERT INTO `directory_country_region` VALUES 
(NULL,"IN","AP","Andhra Pradesh"),
(NULL,"IN","AR","Arunachal Pradesh"),
(NULL,"IN","AS","Assam"),
(NULL,"IN","BR","Bihar"),
(NULL,"IN","CG","Chhattisgarh"),
(NULL,"IN","GA","Goa"),
(NULL,"IN","GJ","Gujarat"),
(NULL,"IN","HR","Haryana"),
(NULL,"IN","HP","Himachal Pradesh"),
(NULL,"IN","JK","Jammu and Kashmir"),
(NULL,"IN","JH","Jharkhand"),
(NULL,"IN","KA","Karnataka"),
(NULL,"IN","KL","Kerala"),
(NULL,"IN","MP","Madhya Pradesh"),
(NULL,"IN","MH","Maharashtra"),
(NULL,"IN","MN","Manipur"),
(NULL,"IN","ML","Meghalaya"),
(NULL,"IN","MZ","Mizoram"),
(NULL,"IN","NL","Nagaland"),
(NULL,"IN","OD","Odisha"),
(NULL,"IN","PB","Punjab"),
(NULL,"IN","RJ","Rajasthan"),
(NULL,"IN","SK","Sikkim"),
(NULL,"IN","TN","Tamil Nadu"),
(NULL,"IN","TL","Telangana"),
(NULL,"IN","TR","Tripura"),
(NULL,"IN","UK","Uttarakhand"),
(NULL,"IN","UP","Uttar Pradesh"),
(NULL,"IN","WB","West Bengal"),
(NULL,"IN","AN","Andaman and Nicobar Islands"),
(NULL,"IN","CH","Chandigarh"),
(NULL,"IN","DH","Dadra and Nagar Haveli"),
(NULL,"IN","DD","Daman and Diu"),
(NULL,"IN","DL","Delhi"),
(NULL,"IN","LD","Lakshadweep"),
(NULL,"IN","PY","Puducherry");

How to create Magento 2 category programmatically?

Use this code:

<?php
use \Magento\Framework\App\Bootstrap;
echo 'code by harshvardhanmalpani';
include('./app/bootstrap.php');
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
function createCategory($a='',$b=2,$c=true,$d='',$e='',$f='',$g='') {
global $objectManager;
$category = $objectManager->get('\Magento\Catalog\Model\CategoryFactory')->create();
$category->setName($a);
$category->setParentId($b); // 1: root category.
$category->setIsActive($c);
$category->setCustomAttributes([
'description' => $d,
'meta_title' => $e,
'meta_keywords' => $f,
'meta_description' => $g,
]);
$objectManager->get('\Magento\Catalog\Api\CategoryRepositoryInterface')->save($category);
}
createCategory("Abc");
createCategory("Xyz",4,false,"description","m title");
?>

How to secure a folder by whitelisting one IP using HTACCESS and denying all others

The process involves matching all requests for an IP, if the IP does not match redirect all secured directory requests.

RewriteCond %{REMOTE_ADDR} !^120\.120\.120\.120
RewriteRule ^admin/.* - [L,R=403] 
RewriteCond %{REMOTE_ADDR} ^120\.120\.120\.120
RewriteRule ^admin$ - [L,R=403]

If you want to control this IP using a script, you can add 2 lines

###CUSTOM RULES###
# your rules will appear here using php script
###CUSTOM RULES###

Now add a script, say happy.php
and use the following code:

$htaccess = file_get_contents('.htaccess');
$ip= str_replace(".","\.",$_SERVER['REMOTE_ADDR']);
$rules="RewriteCond %{REMOTE_ADDR} !^".$ip."
RewriteRule ^admin/.* - [L,R=403]
RewriteCond %{REMOTE_ADDR} !^".$ip."
RewriteRule ^admin$ - [L,R=403]";
$problem="###CUSTOM RULES###\r\n".$rules.
"\r\n###CUSTOM RULES###";
#please copy the next line carefully, no extra spaces or new lines
$solution=preg_replace('/###CUSTOM RULES###.*?###CUSTOM RULES###/sm',$problem,$htaccess);
file_put_contents('.htaccess', $solution);

you can also specify your error page for specific http code: 403
ErrorDocument 403 /er.htm

Magento 2.1x Cron Jobs

Cron Jobs
Add through cPanel/WHM

Time interval – 10 minutes -> */10 * * * *

Replace ^username^ with user dir

php /home/^username^/public_html/bin/magento cron:run >/dev/null 2>&amp;1
php /home/^username^/public_html/update/cron.php >/dev/null 2>&amp;1
php /home/^username^/public_html/bin/magento setup:cron:run >/dev/null 2>&amp;1

Using Crontab editor in Terminal

Use command crontab -e

*/10 * * * * php /home/^USERNAME AND PATH^/public_html/bin/magento cron:run >/dev/null 2>&amp;1
*/15 * * * * php /home/^USERNAME AND PATH^/public_html/bin/magento indexer:reindex >/dev/null 2>&amp;1

How to unlike all Facebook pages from your profile and Clean your newsfeed

Hello humans, I have tried to keep this tutorial simple and detailed. Please proceed with caution.

The following tutorial and the procedure will unlike pages you have liked from your profile, Please be clear about that the fact that the code provided here is clean and does not intend to do any harm to your Facebook account.

Note – This code uses jQuery library in its original form. So you do not need to be scared while using this “scary” looking code.

Continue reading “How to unlike all Facebook pages from your profile and Clean your newsfeed”