How to setup / enable Directory index listing?

When a web browser is pointed to a directory on your website which does not have an index.html file in it, the files in that directory can be listed on a web page. That’s handy when you want to share a folder of downloads, documents or builds without making a web page for them. There are two ways to do it: upload a script such as Directory Lister, which gives you a nicer looking page, or turn on the web server’s own listing with one line in .htaccess. Both are covered below. ...

January 20, 2019 · 3 min · Harshvardhan Malpani

How to edit default python version for a linux user?

On older Linux servers such as CentOS 7, typing python still starts Python 2, even after you’ve installed a newer Python 3 yourself. If you want python to start your new version for your own user only, an alias in .bashrc is the simplest way. It doesn’t touch the system’s Python, which matters on CentOS 7 because yum depends on Python 2. Edit the bash profile and add an alias using the following code: ...

December 31, 2018 · 2 min · Harshvardhan Malpani

How to increase EBS storage block size on a running spot instance in AWS?

So, you created a aws group with a small ebs storage size and now that the site is in production, storage disk is full and it was mounted as root storage, now you are asking “MY AWS INSTANCE STORAGE IS FULL, WHAT TO DO?” or “How do I increase the EBS volume size of a running instance?” So, here is the simple solution: There are two commands which will help you ...

December 18, 2018 · 2 min · Harshvardhan Malpani

Removing extra digits after decimal and leave only two decimal places

I had a long list of numbers with too many digits after the decimal point and wanted to cut each one down to at most two decimal places. Any text editor with regular expression find and replace, such as Notepad++ or VS Code, can do it in one go with this pattern: ^(.*?\..?.?).*?$ Your first match group will leave the number with a maximum of 2 decimal digits. So find with ^(.*?\..?.?).*?$ and replace with \1. Turn on the editor’s regular expression mode first, and put one number on each line. ...

November 12, 2018 · 2 min · Harshvardhan Malpani

How to save Windows 10 Lockscreen wallpaper image in laptop?

The Windows 10 lock screen feature is called Spotlight, and you see new beautiful pictures on your Windows 10 machine whenever it is locked. Windows doesn’t offer a button to save them, but the pictures are already on your disk, and a few commands copy them somewhere you can use them. These pics are present in the Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy folder and don’t have file extensions, so they don’t show up as pictures. Probably Microsoft doesn’t want them to be indexed in your gallery. The folder is inside AppData, which Explorer hides by default, so the command line is the easiest way to get at them. ...

November 5, 2018 · 2 min · Harshvardhan Malpani

How to add colon separated hours in PHP using explode function twice?

Problem Statement Tracked hours for multiple days are available in HH:MM:SS format, separated by tabs. Add all the times to show the total hours worked/tracked. This is the format you get when you copy a row of time values out of a spreadsheet or a time-tracking report: the cells are pasted as one line with a tab between them. The values can’t be added as ordinary numbers, because 60 seconds make a minute and 60 minutes make an hour. The script below splits the string twice with explode(), first into days and then each day into hours, minutes and seconds, adds each part up separately and carries the overflow at the end. ...

September 6, 2018 · 3 min · Harshvardhan Malpani

Extracting names from given list of URLs (using regex)

I use this when I have a list of URLs and only need one part of each, here a person’s name that comes after ?= at the end of the URL. Instead of copying the names out one at a time, a regular expression in Notepad++ pulls them all out in one go. The same trick works for any list where the value you want follows a fixed marker. Let us extract the name from the URL https://www.google.com/name?=rajiv The name we want here is rajiv. ...

August 9, 2018 · 3 min · Harshvardhan Malpani

MySQL error 1449: The user specified as a definer does not exist

Why this error happens? Most of the times, reason is that your database dump through command line or PhpMyAdmin or even other libraries can have SQL’s Definer statements. Now, as per MySQL’s Official Documentation: The DEFINER clause specifies the MySQL account to be used when checking access privileges at routine execution time for routines that have the SQL SECURITY DEFINER characteristic. MySQL Reference Manual v8.0 In practice, every view, trigger, stored procedure, function and event remembers the MySQL account that created it: its definer, written as 'user'@'host'. A dump keeps those definers. When you import it on another server where that account doesn’t exist, for example a dump of the live database loaded onto your local machine, the objects still point at the missing account, and using them fails with error 1449, “The user specified as a definer (‘user’@‘host’) does not exist”. ...

July 28, 2018 · 3 min · Harshvardhan Malpani

Magento 2 all cli commands

This is the complete output of php bin/magento list on a Magento 2.2.4 store. I keep it here as a quick reference for everything the Magento command-line tool can do, without having to log in to a server to look it up. The list depends on the Magento version and the extensions installed, so run the same command in your own Magento root to see exactly what’s available there. [~/www]# php bin/magento list Magento CLI version 2.2.4 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: help Displays help for a command list Lists commands admin admin:user:create Creates an administrator admin:user:unlock Unlock Admin Account app app:config:dump Create dump of application app:config:import Import data from shared configuration files to appropriate data storage cache cache:clean Cleans cache type(s) cache:disable Disables cache type(s) cache:enable Enables cache type(s) cache:flush Flushes cache storage used by cache type(s) cache:status Checks cache status catalog catalog:images:resize Creates resized product images catalog:product:attributes:cleanup Removes unused product attributes. config config:sensitive:set Set sensitive configuration values config:set Change system configuration config:show Shows configuration value for given path. If path is not specified, all saved values will be shown cron cron:install Generates and installs crontab for current user cron:remove Removes tasks from crontab cron:run Runs jobs by schedule customer customer:hash:upgrade Upgrade customer's hash according to the latest algorithm deploy deploy:mode:set Set application mode. deploy:mode:show Displays current application mode. dev dev:di:info Provides information on Dependency Injection configuration for the Command. dev:profiler:disable Disable the profiler. dev:profiler:enable Enable the profiler. dev:query-log:disable Disable DB query logging dev:query-log:enable Enable DB query logging dev:source-theme:deploy Collects and publishes source files for theme. dev:template-hints:disable Disable frontend template hints. A cache flush might be required. dev:template-hints:enable Enable frontend template hints. A cache flush might be required. dev:tests:run Runs tests dev:urn-catalog:generate Generates the catalog of URNs to *.xsd mappings for the IDE to highlight xml. dev:xml:convert Converts XML file using XSL style sheets i18n i18n:collect-phrases Discovers phrases in the codebase i18n:pack Saves language package i18n:uninstall Uninstalls language packages import import:categories Run category importer script indexer indexer:info Shows allowed Indexers indexer:reindex Reindexes Data indexer:reset Resets indexer status to invalid indexer:set-mode Sets index mode type indexer:show-mode Shows Index Mode indexer:status Shows status of Indexer info info:adminuri Displays the Magento Admin URI info:backups:list Prints list of available backup files info:currency:list Displays the list of available currencies info:dependencies:show-framework Shows number of dependencies on Magento framework info:dependencies:show-modules Shows number of dependencies between modules info:dependencies:show-modules-circular Shows number of circular dependencies between modules info:language:list Displays the list of available language locales info:timezone:list Displays the list of available timezones maintenance maintenance:allow-ips Sets maintenance mode exempt IPs maintenance:disable Disables maintenance mode maintenance:enable Enables maintenance mode maintenance:status Displays maintenance mode status module module:disable Disables specified modules module:enable Enables specified modules module:status Displays status of modules module:uninstall Uninstalls modules installed by composer sampledata sampledata:deploy Deploy sample data modules sampledata:remove Remove all sample data packages from composer.json setup setup:backup Takes backup of Magento Application code base, media and database setup:config:set Creates or modifies the deployment configuration setup:cron:run Runs cron job scheduled for setup application setup:db-data:upgrade Installs and upgrades data in the DB setup:db-schema:upgrade Installs and upgrades the DB schema setup:db:status Checks if DB schema or data requires upgrade setup:di:compile Generates DI configuration and all missing classes that can be auto-generated setup:install Installs the Magento application setup:performance:generate-fixtures Generates fixtures setup:rollback Rolls back Magento Application codebase, media and database setup:static-content:deploy Deploys static view files setup:store-config:set Installs the store configuration. Deprecated since 2.2.0. Use config:set instead setup:uninstall Uninstalls the Magento application setup:upgrade Upgrades the Magento application, DB data, and schema store store:list Displays the list of stores store:website:list Displays the list of websites theme theme:uninstall Uninstalls theme varnish varnish:vcl:generate Generates Varnish VCL and echos it to the command line How to read the list The first line is the shell prompt and the command, run from the Magento root (~/www on that server). The second line shows the version of the CLI. Usage is the general form of every command: php bin/magento <command> [options] [arguments]. Options work with any command. The most useful are -v, -vv and -vvv for more detail when a command fails, -n to skip interactive questions when a command runs from a script, and --no-ansi to drop the colour codes when saving the output to a log file. Available commands are grouped by the word before the first colon, so cache:clean and cache:flush both sit under cache. The text on the right is the command’s own description. To see the arguments and options of a single command, run php bin/magento help cache:clean, or add --help to any command. Commands can also be shortened as long as the abbreviation matches only one command: php bin/magento c:f runs cache:flush. ...

July 27, 2018 · 7 min · Harshvardhan Malpani

RPM repo not found connection errors on Centos Redhat duplicate problems

These are the steps I use when yum update on CentOS or Red Hat fails because of duplicate packages or a damaged RPM database, plus two network fixes for when yum can’t reach its repositories at all. I wrote them in 2018 for CentOS 6 and 7, which use yum. yum -y update command failing The command line will show messages like: xxx is outdated and v abc will be installed but at the end it shows a duplicate binary, please remove the duplicate first. ...

July 24, 2018 · 3 min · Harshvardhan Malpani