Trick to hide email address smartly on a webpage to stop spam

Protecting emails from spam is a tough task. Scraping email addresses is a common trick for getting huge lists of working emails from a search engine, but how do we stop it? Here is one of the ways to hide your email address from being scraped. Simple harvesters download the HTML of a page and look for anything shaped like name@domain. The trick is to never put the address in the HTML in that shape. The two halves go into attributes of an element, and CSS puts them back together on screen, so visitors see the full address while the page source never contains it. ...

June 15, 2018 · 2 min · Harshvardhan Malpani

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry Magento 2

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry means MySQL refused to write a row because another row already has the same value in a column, or combination of columns, that has to be unique. The full message names the duplicated value and the key, which tells you which table to look at. These queries deal with duplicates in catalog_product_entity_int, the table where Magento 2 stores integer product attributes such as status, visibility and dropdown values. Each row there is one value: the product (entity_id), the attribute (attribute_id), the store view (store_id, 0 for the default), the value itself, and its own ID, value_id. Normally a unique key allows only one row per product, attribute and store view. If the table has ended up with duplicate rows anyway, for example after a data migration or a bad import while that key was missing, adding the unique key back fails with this error until the duplicates are gone. ...

May 29, 2018 · 3 min · Harshvardhan Malpani

Bulk Add Custom Attribute Options in Magento 1

This is the Magento 1 version of my browser-console trick for adding lots of options to a dropdown attribute at once. Typing values one by one into the options table gets slow when there are dozens of them, so the script clicks Add Option and fills in the value for every item in a list. Steps: In the Magento 1 admin, go to Catalog > Attributes > Manage Attributes, open the attribute and switch to the Manage Label / Options tab. Open the browser console (Ctrl + Shift + J in Chrome, Cmd + Option + J on a Mac). Edit the mimim array so it holds your values, paste the script and press Enter. Check the new rows, then click Save Attribute. Nothing is saved until you do. jQuery is required. The Magento 1 admin is built on the Prototype library and doesn’t load jQuery itself, so this only works if jQuery is already on the page, for example because an extension adds it to the admin. That’s also why the script starts with jQuery.noConflict(): Prototype uses $, so the script keeps jQuery under the name $jq and leaves $ to Prototype. ...

May 16, 2018 · 2 min · Harshvardhan Malpani

Magento 2 – How to manage multi domain website store setup URLs

When one Magento 2 installation runs several websites or store views on different domains, the address of each one is stored in the database. Before changing anything, and whenever a domain redirects somewhere it shouldn’t, I run this query to see all of them in one place: select * from `core_config_data` where path like 'web/%' What it shows Every row is a saved setting from the Web section of Stores > Configuration. The columns to look at are: ...

April 3, 2018 · 2 min · Harshvardhan Malpani

[SOLVED] Magento 2 Error: A technical problem with the server created an error. Try again to continue what you were doing. If the problem persists, try again later.

Sometimes debugging on Magento can be annoying, specially if something just arises out of the blue, not while you are actually writing a code. This is something that occurs on the Magento admin panel. The admin page sends requests to the server in the background (AJAX), and when one of them fails or comes back with something the page can’t read, Magento shows this generic popup instead of the real error. So the message itself tells you very little. Before trying the fixes below, look at var/log/exception.log and var/log/system.log, and open your browser’s developer tools to see the failing request and its response in the Network tab. ...

March 15, 2018 · 3 min · Harshvardhan Malpani

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: ...

March 9, 2018 · 13 min · Harshvardhan Malpani

Receiving money in India | Why PayPal sucks and What are the charges?

So Why is Paypal bad? No, In theory It is not bad. It is an easy mode of payment transfer when comes to my international clients. But being an Indian citizen, why I never prefer Paypal as payment mode. Let us take a look. So, I am going to explain it with an example of payment that I received from United Kingdom. My client sent me 103.60 GBP which at the time of transaction was equivalent to 9334.35 INR. ...

March 3, 2018 · 3 min · Harshvardhan Malpani

How to tweak Magento 2 for two letter search in fulltext mode

The problem: Magento 2 won’t return any search results if the search token is 2 letters in length. Searches for sizes like “XL”, short brand names or model codes come back empty, even though matching products exist. This happens when Magento uses MySQL as its search engine. The search then relies on MySQL full-text indexes, and MySQL leaves short words out of those indexes: InnoDB skips words shorter than 3 characters by default, and MyISAM skips words shorter than 4. A two-letter word never makes it into the index, so it can’t be found. ...

March 2, 2018 · 3 min · Harshvardhan Malpani

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

Sometimes a batch of files needs uppercase names while the extension stays lowercase, for example when another system expects ABC123.jpg rather than abc123.jpg or ABC123.JPG. Renaming them one by one is tedious, so I use a short bash loop. Use this simple code in the bash shell. The following code will change all xxx.jpg files to XXX.jpg in the current working directory, so cd into the folder first. 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 it works for i in *.jpg; do loops over every file ending in .jpg in the current folder, with one file name in $i on each pass. The match is case-sensitive, so .JPG files are skipped. ext=${i##*.} is bash parameter expansion. ##*. removes the longest part of the name that ends in a dot, leaving only the extension, so photo.v2.jpg gives jpg. basename "$i" ".$ext" prints the file name with the extension removed. tr '[a-z]' '[A-Z]' turns every lowercase letter into uppercase, and .$ext puts the original extension back on the end. photo_01.jpg becomes PHOTO_01.jpg. if [ "$i" != "$name" ] skips files whose names are already uppercase. Without it, mv would complain that the source and the destination are the same file. mv $i $name does the rename. To rename other files, change *.jpg to *.png, *.pdf or any other pattern. The extension is worked out from each file name, so nothing else needs to change. To check what the loop will do before it renames anything, replace mv with echo mv; it then prints each rename instead of running it. ...

February 28, 2018 · 2 min · Harshvardhan Malpani

Chain CA Root Bundle for Let’sEncrypt SSL

When you install an SSL certificate by hand, for example in cPanel’s SSL/TLS manager or on a server where you copy the files yourself, you need three things: the certificate, its private key, and the “CA bundle” (also called the chain). The bundle holds the intermediate certificates that link your certificate to a root certificate that browsers trust. Leave it out and some browsers, Android devices and tools like curl report the certificate as untrusted, even though it’s valid. This is the bundle I used for Let’s Encrypt certificates in 2018. ...

February 26, 2018 · 3 min · Harshvardhan Malpani