Search This Blog

Sunday, April 15, 2018

Why NOT to Use var and Instead Use let or const in JavaScript

Consider the following example code:


You can note that the value of var a has changed due to the assignment within the block scope of the if statement, while the value of let b & const c value have remained unaffected.

So, the way let & const works is the way most programming languages work.

var is kind of weird, it’s one of the things a lot of people didn’t like about JavaScript. It causes security risk and confusion and hence it’s better to avoid it.

Friday, April 6, 2018

Why You Shouldn't Be Using mysqli_fetch_array()?

While researching as to why not to use mysqli_fetch_array(), and instead use mysqli_fetch_row() or mysqli_fetch_assoc(), I ran into this old post, which well explains the reason. The test results for each of these functions may not be as per contemporary test case, but it will still give you a good idea as to why mysqli_fetch_array() shouldn't be used

Benchmark on a table with 38567 rows:

mysql_fetch_array
MYSQL_BOTH: 6.01940000057 secs
MYSQL_NUM: 3.22173595428 secs
MYSQL_ASSOC: 3.92950594425 secs

mysql_fetch_row: 2.35096800327 secs
mysql_fetch_assoc: 2.92349803448 secs

As you can see, it's twice as efficient to fetch either an array or a hash, rather than getting both.  It's even faster to use fetch_row rather than passing fetch_array MYSQL_NUM, or fetch_assoc rather than fetch_array MYSQL_ASSOC.

Don't fetch BOTH unless you really need them, and most of the time you don't.

SOURCE: http://bit.ly/2qaSyFr

Saturday, March 17, 2018

[SOLVED] - Could not open input file: bin/magento in localhost and Magento 2x

If you are getting this error 'Could not open input file: bin/magento' while trying to run certain magento commands in your terminal in localhost, then you can try this solution which worked for me.

I ran into this issue, because I'd accessed the root directory of my Magento installation from my terminal. Everything was working fine until now. I then deleted my Magento installation, created a new folder with the same name as the deleted folder. Now remaining in the same terminal window, without changing path or closing the terminal, I was trying to run the magento shell commands. This was the reason I was running into the above error.

To solve this issue, I simply closed my terminal, opened it again, checked into the root directory of my magento installation, and now the commands were running fine.

Also check, while at the Terminal, you are inside the Root Directory of your Magento Installation, else you will get this ERROR again.

[Solved] - Install PHP 7.0, PHP 7.1 or PHP 7.2 in Ubuntu 14.04

After trying a couple of packages, settings and configuration, the solution below is finally what worked for me:

1. Update your PPA repository with the  PHP 7x package sources:

 sudo add-apt-repository ppa:ondrej/php
Press enter to confirm. If you come across any error then you will need to install the python-software-properties first as shown below:

NOTE: The above PPA is a co-installable one, meaning you can install PHP 5.5, PHP 5.6 or PHP 7.0 as per your requirement, and both your old and new versions of PHP can co-exist without you having to remove the old version.
 sudo apt-get update  
 sudo apt-get install python-software-properties  

2. Update

Once again update your packages:
 sudo apt-get update  

3. Install PHP 7.x and its relevant mods:

For PHP7.0: sudo apt-get install php7.0 php7.1-mbstring php7.0-mcrypt php7.0-mysql php7.0-xml php7.0-curl php7.0-intl php7.0-soap php7.0-zip php7.0-gd
For PHP7.1: sudo apt-get install php7.1
For PHP7.2: sudo apt-get install php7.2

4. Disable PHP 5.5 or 5.6:

Now this step is very important else you won't be able to use PHP 5.6. Even when you check your PHP version, it will still display as PHP 5.5. Follow the step below to disable PHP 5.5.

 sudo a2dismod php5
 or
sudo a2dismod php5.6

5. Enable PHP 7.x:

Note: Replace x with 0, 1 or 2, depending upon the version you want to install
 sudo a2enmod php7.x  

6. Restart Apache web server:

 sudo service apache2 restart  

Note: New location of php.ini file in PHP 5.6:

The location of php.ini fie is changed from PHP 5.6 onwards, unlike PHP 5.5 where it used to be located at '/etc/php5/apache2/php.ini'; the new location is at '/etc/php/7.x/apache2'

Tuesday, March 13, 2018

[SOLVED]-Remove AppImage Desktop Integration


To remove the desktop integration for your AppImage, follow the instruction below:

Since an AppImage is not "installed", you don't need to "uninstall" it. Just delete the AppImage file and the application is gone. Additionally you may want to remove menu entry by deleting the desktop file from $HOME/.local/share/applications/.

Source:
  1. How can I uninstall an AppImage?
  2. How To Use AppImage in Linux [Complete Guide]
  3. AppImage Website

Top Magento Hosting:

Top 5 Posts (Weekly)