Posted on Leave a comment

Fix SQL Error: GROUP BY incompatible with sql_mode=only_full_group_by

MySQL 5.7.5+ changed the GROUP BY behavior. So in this and future versions GROUP BY would not work in same way as it used to be before.

So to make GROUP BY feature working like before follow these details:

Note: First of all to follow these steps you must need to have root access to your server.

If you want to disable error sql_mode=only_full_group_by  permanently then do those steps:

  1. sudo nano /etc/mysql/my.cnf
    
  2. Add this to the end of the file
    [mysqld]
    sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
    
  3. sudo service mysql restart  to restart MySQL

This will disable ONLY_FULL_GROUP_BY for ALL users

Posted on Leave a comment

PHP: How to fix Image rotation issue in img tag because of EXIF

Photos captured by some smartphones especially iPhones are automatically rotated when we use it in <img> tag which is mostly not acceptable as we don’t need such unwanted rotation. This happens because of EXIF Data stored in that image. But we can easily fix it using PHP by following these steps:

function autorotate($src)
{
// check if extension exists or not
if(extension_loaded('imagick'))
{
    try
    {       
        $image= new Imagick($src);
        switch ($image->getImageOrientation()) {
        case Imagick::ORIENTATION_TOPLEFT:
            break;
        case Imagick::ORIENTATION_TOPRIGHT:
            $image->flopImage();
            break;
        case Imagick::ORIENTATION_BOTTOMRIGHT:
            $image->rotateImage("#000", 180);
            break;
        case Imagick::ORIENTATION_BOTTOMLEFT:
            $image->flopImage();
            $image->rotateImage("#000", 180);
            break;
        case Imagick::ORIENTATION_LEFTTOP:
            $image->flopImage();
            $image->rotateImage("#000", -90);
            break;
        case Imagick::ORIENTATION_RIGHTTOP:
            $image->rotateImage("#000", 90);
            break;
        case Imagick::ORIENTATION_RIGHTBOTTOM:
            $image->flopImage();
            $image->rotateImage("#000", 90);
            break;
        case Imagick::ORIENTATION_LEFTBOTTOM:
            $image->rotateImage("#000", -90);
            break;
        default: // Invalid orientation
            break;
      }
      $image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);

      $image->stripImage(); // if you want to get rid of all EXIF data
        $image->writeImage();
        $image->clear();
        $image->destroy();
      return $image;

    }
    catch(Exception $e) {
        return 'Exception caught: ',  $e->getMessage(), "\n";
    }  
  }
  else
  {
      return "Imagick extension is not installed.";
  }
}
  

// now run autorotate() function with source of file as parameter
autorotate('my_img.jpg');

Or you can also fix it with just one line if you have root access to your linux server. Just run following shell command:

convert image.jpg -auto-orient output.jpg

 

Posted on Leave a comment

Best Websites to Learn Programming in Free

  1. https://frontendmasters.com/
  2. https://www.class-central.com
  3. http://www.udacity.com
  4. http://www.freecodeamp.com
  5. https://codecademy.com
  6. https://mva.microsoft.com/
  7. https://github.com/open-source-society/computer-science
  8. https://www.khanacademy.org
  9. https://www.safaribooksonline.com/ ( One Month Free Trial )
  10. http://edx.org
  11. http://coursera.org
  12. http://udemy.com
  13. https://www.skillshare.com/
  14. https://thenewboston.com/videos.php
  15. https://angularfirebase.com/
  16. http://w3schools.com
  17. https://www.airpair.com/
  18. https://egghead.io
  19. http://tutsplus.com
  20. https://www.pluralsight.com/browse/software-development ( 10 Days Free Trial )
  21. https://hackr.io
  22. https://academy.fossbytes.com/
  23. https://www.codeschool.com
  24. http://www.learnvern.com/
  25. http://www.lynda.com (10 Days Free Trial)
  26. https://www.datacamp.com
  27. https://alison.com/
  28. http://programming-motherfucker.com/become.html
  29. https://itpro.tv/PAID

  30. https://www.cbtnuggets.com
  31. https://linuxacademy.comAWS (Amazon Web Services)
  32. https://www.youtube.com/watch?v=BDBvHOaaKHo&list=PLv2a_5pNAko0Mijc6mnv04xeOut443Wnk
  33. https://linuxacademy.com/ (AWS and other cloud solutions )
  34. https://coursehunters.net/
  35. https://scrimba.com/
Posted on Leave a comment

How to remove index.php from codeigniter in UBUNTU?

This tutorial will show you that how to remove index.php from codeigniter in UBUNTU or how to enable url rewriting.

Step 1 :

Add this in htaccess file

<IfModule mod_rewrite.c>
  RewriteEngine On
  #RewriteBase /

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
</IfModule>

Step 2 :

Remove index.php in codeigniter config

$config['index_page'] = '';

Step 3 :

Allow overriding htaccess in Apache Configuration (Command)

sudo nano /etc/apache2/apache2.conf

and edit the file & change to

AllowOverride All

for www folder

Step 4 :

Enabled apache mod rewrite (Command)

sudo a2enmod rewrite

Step 5 :

Restart Apache (Command)

sudo /etc/init.d/apache2 restart

Source