Snippets.page

Code snippets, tips, how-tos

Category: Dev

  • Create a new MySQL user from the command line

    Create and add a user to a MySQL database using the command line. Run MySQL Open MySQL using the below command. The username should be your root user or an admin user with access for creating other users. Create a database and a user Create a new database (if required) and create a new user. […]

    Read more

  • Start WSL cron in a hidden window

    Enable cron to run without asking for password Normally running sudo service cron start in WSL will ask for the sudo password. This is an issue when we want to run cron from the script below. To fix this, we need to enable cron service to run without asking for the password by adding it […]

    Read more

  • Align second line of bullet points in CSS

    HTML aligns the lines after the first line flush with the bullet point (the dot) instead of the text. You can fix this with the class below. text-indent property applies only to the first line of a text-block. So we first “pull” the first-line back along with the dot. Then we push the entire text-block […]

    Read more

  • Highlight the current post’s tags in WordPress

    List all tags in a bulleted list and highlight only the current post’s tags. Highlight the current post’s tags using CSS The idea is to show all the tags used on the site and then add a CSS class to the tags that are used in the current post. This class can then be styled […]

    Read more

  • Fix PHP executable not set in VSCode when running XAMPP on Linux

    This is a fix for the following error when opening PHP files in VSCode or VSCodium: Cannot validate since no PHP executable is set. Use the setting ‘php.validate.executablePath’ to configure the PHP executable. This error means that VSCode does not know how to validate the contents of a PHP file and can’t show errors in […]

    Read more

  • Change the file upload size in NGINX

    When you have a PHP-based website like WordPress running on NGINX, you would typically change the maximum file upload size in PHP settings e.g., in php.ini file or similar. NGINX web server also has it’s own configuration where you can set the max upload size server-wide. This is set in the .conf file using the […]

    Read more

  • Get a Let’s Encrypt SSL certificate for your domain

    Install a free SSL certificate and serve your site with “https”. Let’s Encrypt provides free SSL certificates and with the help of the installation tool called Certbot, you can easily enable an HTTPS certificate for your website. These instructions are for users running either Nginx or Apache on Ubuntu server and have access to the […]

    Read more

  • Set MySQL password from the command line

    If your MySQL root user’s password is currently empty (not set) and you want to add one to disable access without password, use the following commands. Open MySQL my entering the below in your command line: Here, mysql.user is the database which has the list of all the MySQL users. So the command breaks down […]

    Read more