Understanding Linting, getting started with ESLint for Node.js development with IDE Visual Studio Code
Node.js , Javascript , Uncategorized / May 25, 2020

Node.js application developers usually come across the requirement to adhere to linting rules during the development phase. In this article we will understand the importance of following linting rules and how to set up ESLint with Node.js. We will also see how to easily identify and fix linting errors with Visual Studio Code.     Linting Linting is static code analysis, which helps to identify errors, coding style issues, insecure code, etc during the development phase. Linter is a tool that helps to identify lining errors while writing code. Linting is done during the phase of writing the code. Static code analysis is a method of debugging by examining source code before a program is run. Linting helps to improve code quality, provide better structure, speed up the overall development process by flagging potential errors early.   Linting JavaScript/TypeScript source code with Node.js Identifying linting errors in JavaScript code is done using the linting tool ESLint. If you are using TypeScript TSLint is used.   Linting Rules Linting rules are the rules which are enforced on the source code by the linter. For example, to enforce that the length of a single line of code not to exceed 140 characters max-len rule…

Changing permalink settings, throwing 404 error in localhost? Solution for Ubuntu with Apache
Wordpress , PHP / May 18, 2020

Changing the permalink settings from plane to other options like Month and name/Other can cause a 404 error while you are running your WordPress in Ubuntu with Apache localhost.  This error can be quite annoying and here are the changes you should make to get rid of this error. To change permalink navigate to settings->permalinks.     We are running your WordPress site from folder /var/www/html/testfolder/wptest     Step 1 – Enable mode rewrite in Apache

Provides a rule-based rewriting engine to rewrite requested URLs on the fly. Now after enabling, restart  Apache

          Step 2 – Modify the Apache Config file Apache config file is  etc/apache2/apache2.conf. Open the file using the following command.

Find the following lines in the config file

replace this with the following. The AllowOverride ride is changed to All and require is changed to all granted.

AllowOverride directive is used to allow the use of a. htaccess within the webserver to allow overriding of the Apache config on a per-directory basis. Require provides a variety of different ways to allow or deny access to a resource.           Step 3 – Restart Apache…

Create a beating heart icon using font-awesome, JQuery and CSS animations.
css , SASS , Snippets / May 9, 2020

This code snippet helps you in creating a simple beating heart icon using font-awesome, JQuery, and CSS animation The scale() CSS function defines a transformation that resizes an element on the 2D plane. Modify this code to add more effects

   

Modify wpDiscuz plugin, limit registered user to comment once and limit number of comments, in a post
Uncategorized / May 7, 2020

  Navigate to  wp-content/plugins/wpdiscuz/templates/comment/comment-form.php Find line

Put the following condition to limit the number of user comments to one and limit total comments.

Read more about the functions used here https://truetocode.com/disable-wordpress-comment-box-on-reaching-a-specific-number-of-comments-or-if-user-already-posted-a-comment/

Disable WordPress comment box, on reaching a specific number of comments or if user already posted specific number of comments.
Wordpress , PHP / May 6, 2020

Imagine a use case in which the comment box has to be disabled On reaching a specific number of comments in WordPress post If the user already posted a comment For applying these conditions, the following data are needed Number of comments in a post Number of comments of a User in a WordPress Post   Obtain the number of comments in a WordPress Post To obtain the number of comments in a post, the following built-in function  get_comments_number, can be used.

    Obtain  the number of comments of a User in a WordPress Post To obtain the number of comments in a post, by the logged-in user, the following built-in function  get_comments, can be used.

  Navigate to the themes folder, comment_form  function in comments.php usually outputs the comment form. A condition has to be applied before calling this function.

  On using plugins, this might not work depending on the plugin For more information read the following documentation for built-in functions https://developer.wordpress.org/reference/functions/get_comments_number/   https://developer.wordpress.org/reference/functions/get_comments/ This approach helps in preventing spam comments.

Share this page in social media platforms