When managing a MongoDB server, encountering issues with the service can be frustrating. One such issue is the code=exited, status=48 error, which indicates that the MongoDB service failed to start due to the port 27017 being already in use. This comprehensive guide will help you understand the root cause of this error and provide step-by-step instructions to resolve it. Understanding the Error...
Bulk Resize and Compress Images with Python and Pillow
As a web developer, I have come across websites that performed very poorly in terms of loading speed. The main reason being they had too many unoptimized images. Generally, images have to be optimized through resizing and compression to save bandwidth both for the webserver and viewer. Thanks to advancements in image compression, we now have image formats such as webp which require very less...
How to Generate Unique Slug in Laravel
Those coming from WordPress will be very much familiar with the term slug. For those who are new, Slug is the part of the URL that comes after the domain name. The slug provides a unique identity to any page on a website. On content management systems like WordPress, the slug is automatically generated from the title. Slugs play an important role in search engine optimization. A well-optimized...
How to Disable CSRF protection on specific Routes in Laravel
Laravel is built with security in mind and hence it comes with a lot of built-in security features. One of these major security features is cross-site request forgery (CSRF) protection. The csrf vulnerability allows anyone to imitate forms on a site and make forged requests to modify or retrieve data. Laravel generates a csrf token for every user session. Using the csrf token, laravel can...
How to Host Multiple Websites on a Nginx Server
I have been using Nginx as the preferred web server for most of my web projects. It is very efficient than apache, which I used initially for my projects. It didn’t take long to find out the limitations of apache as the traffic grew. After spending some time researching solutions, eventually, I came across Nginx. Its performance and efficiency simply amazed me. If we compare two separate...
Web Scraping with Python and Beautifulsoup for Beginners
Python with the beautifulsoup library makes it very easy for beginners to scrape data from any HTML website. I have been using the request library with python to scrape data from multiple websites. It works like a charm every time unless you encounter a website that renders the front end with javascript. Data scraping helps to collect data from websites. There are various free and paid tools to...
How to Skip Elements in Xpath
Recently I came across a situation where I had to skip the first li tag from a list of li tags. This is where the position() function in xpath came to my help. Using the position() function, you can specify the number of elements you want to skip both from the beginning or ending of a list of elements. Even a combination of both. The position function returns a number equal to the context...
Upgrade WordPress to PHP 7.4 on Apache running on Ubuntu
WordPress now displays a “PHP update required” warning on the dashboard if the PHP installation is not up to date. I saw the same warning in the WordPress dashboard for one of my sites. The site has been running PHP 7.2 for more than a year and it was only recently i saw the warning for the first time. Coincidentally, the site had also been down in performance for a few months. So I...
Decrease WordPress page load time by reducing number of comments per page.
Recently I started receiving notifications in the google webmaster tools dashboard regarding slow loading time of some of the pages on my blog. The blog was running on WordPress on a Ubuntu with Apache as the server. On my end, most pages were loading fine with a average loading time of 2-3 seconds. In order to increase the performance, I switched the web server from Apache to Nginx. It did bring...
How to fix Incorrect Table Definition error in Laravel
SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key If you faced the above error in Laravel, I will show you the reason why it happened and how it will be fixed. The “Incorrect table definition” error can occur in Laravel due to many issues. I came across this error when I ran the php...