How to transpose an array in PHP with irregular subarray size?

Transposing an array means turning its rows into columns: the first item of every sub-array becomes the first row, the second items become the second row, and so on. This is handy for CSV-style data where each sub-array is one column (a heading followed by its values) and the columns have different lengths, as in the test code below. A plain nested loop then leaves gaps in the shorter rows: a row can have keys 0 and 2 but no 1, and something like fputcsv(), which ignores keys, would shift the values into the wrong columns. This function fills those gaps with null, so every row of the result has one slot per original sub-array. ...

March 5, 2019 · 3 min · Harshvardhan Malpani

SQL Notes

These are my notes on MySQL statements I keep reaching for when creating and changing tables by hand. They cover creating a table with a foreign key, adding, changing and removing a column, and the key and auto-increment definitions that phpMyAdmin writes into an export. The examples use two tables. emp holds employees, each with a unique emp_code. clients holds clients, each linked to the employee who looks after it. ...

February 18, 2019 · 3 min · Harshvardhan Malpani

How to fix Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI error in SSH?

Put this in your bash profile and run source ~/.bashrc alias composer="/opt/cpanel/ea-php71/root/usr/bin/php /opt/cpanel/composer/bin/composer" As Composer is now available via WHM you can use this to find it: which composer This returned path “/opt/cpanel/composer/bin/composer” for me. If this returns nothing then disregard the rest of this answer, as Composer is not available to you at system level. You can now use php-cli to call this with Composer’s absolute path: php-cli /opt/cpanel/composer/bin/composer install php-cli /opt/cpanel/composer/bin/composer update php-cli /opt/cpanel/composer/bin/composer require whatever/example You may however need to alias php-cli if your system claims this isn’t found. It very much depends how PHP has been deployed on the WHM server. Learn how to fix PHP CLI error. You can do this by adding a user alias to the end of your “.bashrc” or “.bash_profile” file as follows: ...

February 12, 2019 · 1 min · Harshvardhan Malpani

How to switch your DNS to Google DNS or Cloudflare DNS on Windows 10?

So, this is the scenario. You are using some local ISP which has its own DNS server fulfilling your DNS requests but to speed things up and not rely upon a DNS server which is updated less frequently. For that purpose,we can switch our computer’s DNS to some other public DNS like Google’s or Cloudflare DNS. Step 1: Right click the Network Icon in your task bar. Right Click the network icon in taskbar ...

February 10, 2019 · 1 min · Harshvardhan Malpani
Google cloudconnect

What happened to googleforwork.com? Welcome the new cloudconnect.goog domain

Google for Work was the name Google used for its business products from 2014 until 2016, when the apps became G Suite and Google for Work itself was folded into Google Cloud. Its old domain stayed around for a while after that. This is a short note from February 2019 on where it went. So GoogleforWork.com is now being redirected to cloud.google.com, and the same applies to its subdomain connect.googleforwork.com. The campaigns that used to run on the Google for Work community pages are now hosted at www.cloudconnect.goog. ...

February 7, 2019 · 1 min · Harshvardhan Malpani

Testing Configuration for Paytm Gateway Plugin India

Paytm Payment Gateway Testing Data Online payment solutions for all your transactions by Paytm Woocommerce Plugin Download the plugin here: https://github.com/Paytm-Payments/Paytm_Woocommerce_Kit Enable/Disable Enable/Disable Enable Paytm Payments. Title Title Paytm This controls the title which the user sees during checkout. Description Description The best payment gateway provider in India for e-payment through credit card, debit card & netbanking. This controls the description which the user sees during checkout. Merchant Identifier Merchant Identifier Merchant Id Provided by Paytm ...

February 7, 2019 · 2 min · Harshvardhan Malpani

What are Customer Relationship Management (CRM) Software?

What Is CRM? CRM, also known as Customer Relationship Management can be understand as the software which was developed to improve the customer services and to make the customer services much more efficient. CRM Software act as the single tools which has the ability to bring your sales, marketing, customer support services at one place and helps you to manage them at one single platform. Who uses a CRM system? CRM System can be easily customized and changed by the different Organisations and companies according to their needs and requirements. The CRM software can be used by the any business types and size for increasing their sales, marketing, and customer support services i.e, Small Scale Startups, Large Organizations, Real-estate, Healthcare, Insurance and the list goes on and on…. ...

February 6, 2019 · 5 min · Harshvardhan Malpani

How to customize Magento 2 Maintenance mode page?

When a Magento 2 store is in maintenance mode, which you switch on with php bin/magento maintenance:enable before an upgrade or a deployment, visitors get Magento’s built-in “Service Temporarily Unavailable” page. It’s plain and says nothing about your store. You can replace its content with your own message, a way to contact you, and your analytics code. Edit the file pub/errors/default/503.phtml and put the following code in it: <?php /** * How to edit and customize code of Magento 2 Maintenance 503 Page * Add analytics if any * Replace <COMPANY NAME> with your Organization Name */ ?> <!doctype html> <title>Site Maintenance</title> <style> body { text-align: center; padding: 150px; } h1 { font-size: 50px; } body { font: 20px Helvetica, sans-serif; color: #333; } article { display: block; text-align: left; width: 650px; margin: 0 auto; } a { color: #dc8100; text-decoration: none; } a:hover { color: #333; text-decoration: none; } </style> <article> <h1>We&rsquo;ll be back soon!</h1> <div> <p>Sorry for the inconvenience but we&rsquo;re performing some maintenance at the moment. If you need to you can always <a href="mailto:abcd@COMPANY NAME">contact us</a>, otherwise we&rsquo;ll be back online shortly!</p> <p>&mdash; Team COMPANY NAME</p> </div> </article> What to change The PHP comment at the top is just notes. As it says, you can paste your analytics snippet into the page if you want to see how many visitors arrive during the downtime. The <style> block centres the page with 150px of padding, sets a 50px heading and 20px Helvetica text in dark grey, makes the article a 650px column in the middle, and colours links orange. Change the colours and fonts to match your store. The message is inside <article>. Replace abcd@COMPANY NAME in the mailto: link with your real support email address, and COMPANY NAME with your store’s name. &rsquo; is a curly apostrophe and &mdash; is a long dash. How Magento uses this file Magento sends the maintenance page with the HTTP status code 503, which tells search engines the downtime is temporary. ...

February 4, 2019 · 3 min · Harshvardhan Malpani

SSL certification setup: Cloudflare.

This article will guide you to set your SSL certification using Cloudflare. Cloudflare is an internet security company which provides content delivery network service. You can get free SSL certification as well as paid one from Cloudflare. A breif discussion on SSL certification and https redirection. So, Let’s start the process. Steps: Step1 Signup and Login to cloudflare. There you will get an option to add your site url. Do it and proceed. ...

February 1, 2019 · 2 min · Harshvardhan Malpani

Different types of MySQL Storage Engines Compared

Every MySQL table is handled by a storage engine: the part of the server that decides how rows are stored on disk (or in memory), how they’re indexed and locked, and whether transactions are supported. You choose the engine per table with ENGINE= in CREATE TABLE, and tables in the same database can use different engines. I put together the chart below to compare the five engines I come across most: MyISAM, Memory, InnoDB, Archive and NDB. The data comes from the storage engine feature summary in the MySQL 8.0 reference manual, linked at the bottom. ...

January 30, 2019 · 3 min · Harshvardhan Malpani