Latest Questions and Answers

What is the difference between "==" and "is" in python?

In python == checks equality of the value but "is" checks memory. You can refer to below example to understand it better: a = [1,2,3] b = [1,2,3] a == b returns true because all values are same in both the lists. a is b returns false because a and b are two different objects in memory. clone = b b is clone returns true because clone and b point to the same memory. I hope you understand n... (more)

Could not find module "@angular-devkit/build-angular" in angular?

If you face above issue while executing the ng serve  command, you can install the package as dev dependency. This is introduced in latest version of Angular 6.0.

 npm install --save-dev @angular-devkit/build-angular  

I faced the same issue and it resolved my problem and hope it will resolve your's too.

How to start with Angular Js?

First of all I would like to introduce about Angularjs and Angular. First version of angularjs is called as Angularjs but later versions are called only Angular so this is the difference. To start with Angular, you must have node.js installed in your system that should be Node.js 10.9.0 or later version and you can get the latest version from You also need to have installed npm ... (more)

Expected response code 250 but got code “535”, with message "535-5.7.8 Username and Password not accepted?

If you are getting the above issue while setting up google / gmail SMTP server. You need to follow below steps it will surely solve your problem. I had also faced this issue and following the below steps resolved my problem and mail getting started to come in my inbox. 1- You need to enable 2 step verification in your google account setting  URL: 2... (more)

How to get unlimited child categories in structured format using recursion in PHP?

We can get all child categories in PHP using recursion. Follow below example for better understanding: public function get_child($product_categories) {     $cat = array();     if(count($product_categories) > 0)     {         foreach($product_categories as $val)         {             $cat[$val['category_id']]['id'] = $val['category_id'];           ... (more)

How to select an element with class and loop through each one in JavaScript?

We can select any element of webpage using document.querySelector  and loop through each element having same class with forEach  function. Follow below example to understand it better:     flag = 0;     idtochoose = '';     document.querySelector('.ty-shipping-options__method input').forEach(function(node) {         console.log(;         i... (more)

How to create range slider using jQuery?

Range is something we frequently use it in websites for the purpose of filtering records like products in ecommerce webistes. Anybody can integrate it using jQuery range slider by including a jquery.js, jquery-ui.js and jquery-ui.css.  There is an example below of few lines which will guide you how to use it easily:       jQuery Range Slider             $( function() {   ... (more)

How to use multi select field?

I would like to share with you guys that using a multi select field is very simple easy to integrate within forms or nay where in web page. You can refer to the below shared URL from where you can see multiple types of multi select fields which you can use as per your need: You can click on downloads button and you will see three... (more)

How to integrate an API in Django?

I suppose you are aware of django, and files. So, I'm going to show you how to use python inbuilt client to integrate API in file. How to import the package and use it, please see below example: #### #### import requests def testapi(request):     response = requests.get("")     response = response.json()     c... (more)

How to add defer to Enqueued JavaScript Files in WordPress?

To apply defer on javascripts included by wordpress plugins, custom included javascripts using enqueue hook of wordpress. Suppose you have included below files as an example and how to apply defer on these files: function custom_load_these_here_scripts() {     wp_enqueue_script('cycle', get_template_directory_uri() . '/js/cycle.js');     wp_enqueue_script('magn... (more)

How to set, unset and get cookie in jQuery?

You can set, get and delete cookie in jQuery using a jquery plugin. This plugin is very useful, easy to use in any website and get the requirement done without any hassle. Follow below steps and your are good to go: 1- Include the below library in the file and use as below mentioned. 2- Usage: Create session cookie: $.cookie('name', 'value'); Create expiring cookie, 7 days f... (more)

How to create a project in Django?

Please find below steps to proceed work on Django, debug code and troubleshoot problems etc. $django-admin startproject mysqlweb $python startapp polls $pip install mysqlclient (for python3, when using mysql database with django) Some of these applications make use of at least one database table, though, so we need to c... (more)

How to manage common sections in Django?

To overcome the above shared problem, we use "Custom template tags" feature of Django. It is one of the great feature to handle common section which gets display in base.html template and be available in all templates those are using base template. Suppose there is a section to display about text in sidebar and you want to write code once and use it in all templates without calling it in all views... (more)

Latest Interview Questions and Answers of PHP, jQuery, MySql and HTML/CSS?

Please find below the Latest interview questions and answers: jQuery: 1- What is event capturing and bubbling? 2- What does Bind and Call function do? 3- What is the difference between $(document).ready and $(window).load, and which one loads faster? 4- What is Closures in js? 5- What does Cache argument do in ajax? MySql: 1- What is Primary key and Candidate key with difference? 2- H... (more)

How to debug in Django?

To start debugging in django while doing development you will need to follow below steps and get to go: 1- $pip install django_extensions Now include in under INSTALLED_APPS as 'django_extensions'. 2- $pip install werkzeug You have set all required things for debugging, just need to write below statement where you want to debug: 3- assert False, latest_poll_list   It wil... (more)

How to connect with MySql database and execute query in Python?

You can connect with MySql database in Python using mysql connector python. You will need to install it first using below command and import it in your program. Refer to below example how to install and execute sql queries. pip install mysql-connector-python Example: import mysql.connector from mysql.connector import Error try:     cn = mysql.connector.connect(host='localhost',datab... (more)

How to connect django with MySql database?

Django comes with sqlite as database backend but you can use any of the database as per your need. To use MySql as database in django you will need to do some modification in file in DATABASES dictionary, refer to below line of code to proceed easily: By default you will see below code: DATABASES = {     'default': {         'ENGINE': 'django.db.backends.sq... (more)

Some example of small logical programs in Python?

##Write a Python program to get the difference between a given number and 17, if the number is greater than 17 return double the absolute difference. def get_difference(n):   if n < 17:     return 17 - n   else:     return (n - 17)*2 diff1 = get_difference(15) diff2 = get_difference(20) print(diff1) print(diff2) ########################### ##Write a Python program to calculate the sum of ... (more)

How to calculate number of days between two dates in Python?

You can use datetime module to get number of days between two dates, refer to below example to get the result:

from datetime import date

start = date(2019, 5, 1)  //Put start date
end   = date(2019, 5, 10) // Put end date

number_of_days = end - start

How to print a paragraph in Python?

We can get the same format as below using print function in Python:

  A string that you "don't" have to escape 
  is a ............. multi-line 
  heredoc string -----------------> example

How to change the label of wordpress login screen?

Yes you can change the wordpress login screen label like username of email address to only email address as per your choice. We have login_head action and gettext filter using combination of these hook we can modify the label. Please follow the below example for better understanding:    //Modify login label function login_screen() {     add_filter( 'gettext', 'modify_label', ... (more)

How to print a calendar of month from a year in python?

You can get a python program below which will take two arguments year (eg. 2019) and month (eg. 6) in integer format and will display complete calendar of the month from that year you will enter from console. import calendar year = int(input("Please enter year:")) month = int(input("Please enter month:")) print(calendar.month(year, month))   Just paste the above code in a python file and ex... (more)

How to add a confirm password field in woocommerce checkout form?

Presumed, you have enabled the registration setting from admin panel and password field can be seen on checkout form. Now, you need an additional confirm password field in the form, you can use below hooks to add and it will work completely fine: add_filter( 'woocommerce_checkout_fields' , 'confirm_password_field', 10, 1 ); function confirm_password_field( $fields ) {     if ( g... (more)

How to get woocommerce orders by user id in wordpress?

You can get same solution by using woocommerce built in functions. But this is the way which is independent of the woocommerce versions. Just paste the below function and get all orders made by a particular user by just providing user id. If you check the sql query, you will realize how many tables are involved to fetch the orders and how the records are stored into database. So it is also usefu... (more)

How to access raw password and username before login in Wordpress?

We can get and access raw password and username using wordpress action hook "wp_authenticate". You can get a better understanding referring the below example: function access_credential($username, $password ) {   if (!empty($username) && !empty($password)) {     // You can code here as per requirement   } } add_action('wp_authenticate', 'access_credential', 30, 2);... (more)

How to reorder the woocommerce checkout form fields?

Woocommerce is one of very popular plugin to create ecommerce plate form in wordpress. Developing a website in woocommece requires less time, effort and cost until any customization is made. We can get a plenty of built in themes with attractive designs and features. But sometime we don't go with readymade themes instead we ask designer to create design and get the web pages ready in bootstr... (more)

How to replace broken image with default one in website?

We can solve this problem by using jQuery. There is an event "error" which we can use to solve the problem of broken images in website. It is called when element doesn't properly. You can understand it better by referring below example and implement in your website. function handleImgError(){ if(this.alt=="author") this.src = " (more)

How to share password in email?

Sometime we need to share a password. Directly sharing it in email is not a good practice, we should share it using some other medium so I'm going to share one of the best way to share it. Go to the below website and put your password and apply some rules like how many days after it will expire and how many times it should be viewed, after that it will expire. Website URL: https://ppusher... (more)

What are Pre-requisites to build a chatbot using NLP?

If anybody is willing to build a chatbot in python, there are some topics you need to be aware about first then it will make your journey easy. You should have knowledge of scikit library and NLTK is assumed. If you are a new in this field you still need to read about it and its resources. Using NLP programmers can structure knowledge to perform tasks such as automatic summarization, translation... (more)

How to customize the alert in JavaScript or jQuery?

We can customize the alert box by using a library that is sweet alert. It is easy to use and has a nice effect which anybody can use in their websites to get different look. First include the library and then use below syntaxes. There are different ways to use and get alert boxes: swal("Hello World") If you pass two arguments then first will be the model's title and other one as a alert b... (more)

What is the meaning of __name__ == "__main__" in Python?

When a file executes it sets some special variables and __name__ is one of them. __name__ is set as "__main__" if it is getting executed directly. But if the file has been imported then it stores the filename suppose. For example: if __name__ == "__main__":     print("Executed directly", __name__ ) else     print("Import executed", __name__ ) ### On execution of directly _... (more)

How to calculate date interval between two dates in MySql?

I'm going to share how to calculate the date intervals between two dates like calculating 1 month before, two weeks before etc. You can do this using "DATE_SUB" mysql function. Find the below example to get proper understanding, it is an example of getting all medicines which are going to expire in next two weeks: $sql = "SELECT * FROM `products` p WHERE CURRENT_TIMESTAMP >=  DATE_SUB(FROM_... (more)

How to get records from certain offset up to the end of result set in MySql?

To get the all records from a specific offset up to the end of the result set, use the below MySql query and will solve your problem. The query retrieves all rows from the 95th row to the last: SELECT * FROM tbl LIMIT 94,18446744073709551615; You would be thinking why this large number has been specified but it is mentioned in MySql official document. Actually it is larger than the length of i... (more)

Why unitegallery images are zoomed bydefault?

Many people would have faced the zoom issue while using the unitgallery. Images get zoomed by default and image quality gets poor. You can solve this problem by setting up the below options and everything will be alright. 

slider_zoom_max_ratio: 2, 
slider_scale_mode: "fit", 
slider_zoom_step: 1.2 

How to integrate SOAP API using curl in PHP?

Yes. We can integrate a SOAP API using curl in php. I can make you understand by giving an example so that you can understand well. SOAP is its own protocol which uses XML to make requests and it is more secure that REST API. I will explain about SOAP in different section, let us see how we can make SOAP request using curl. Please check the below example to integrate any of the SOAP API and will... (more)

How to load CSS files asynchronously in WordPress?

A website developed in wordpress has a problem of speed. To speed up the website speed we use some cache plugin, optimize the js, css and image files. Optimizing these stuffs gives a good result and we see some improvement in speed no doubt. Here what i'm going to share is about loading js and css files asynchronously with the help of some scripts. It will give you a huge improvements in websi... (more)

How to use debugging JavaScript in Chrome DevTools?

Many time we work on JavaScript and resolve bugs debugging with console.log. It solves the problem but takes much time. To debug code quickly and solve the problems, we should use Chrome DevTools which is very powerful and convenient to solve the JavaScript in very less time. Please refer to the below URL where it has elaborated clearly in video and text format illustrating it using images. https... (more)

What is NLP?

NLP stands for Natural Programming Language. NLP belongs to one of the branch of Artificial Intelligence. It is used to build a system which understand, manipulate and respond to human in his natural language. NLP is being used in many areas like Google translation, auto suggest in grammatical mistakes etc. If you are using Python, there is a very powerful library used to build such a system tha... (more)

How to setup an Apache web server for PHP?

To setup an Apache web server, you need to run the below commands step by step and you will get the server ready to execute PHP and host any website developed in PHP. This is not a very difficult to make ready the server just you need to focus on what you are doing. Get start doing practice and it will become usual approach and many additional things you will know about setting up the web ser... (more)

How to install free SSL on Digital Ocean virtual server or Droplet?

  If you want to install free SSL on digital ocean droplet which already has been created and setup the Linux server by installing Apache. First go to terminal or putty and login into virtual server. Now, run below commands step by step: 1- Run update command to update all packages if any:  sudo apt-get update 2- sudo apt-get install apache2 3- sudo add-apt-repository ppa:ce... (more)

Get MySql Query to show messages, username of a chat?

Suppose there are two tables `chat` and `users`. `chat` have four columns id, sender, receiver and message and `users` have two columns id and name. chat:   users:   SELECT as sender, as receiver, c.message FROM `chat` as c LEFT JOIN `users` as u1 ON c.sender = LEFT JOIN `users` as u2 ON c.receiver =   In the result you will get sende... (more)

Python ORM with SqlAlchemy?

An ORM is Object Relational Mapper which maps with relational database management system to objects. ORM is not dependent on database which is going to be used and gives different objects to access the database to retrieve, insert and manipulate the records. Here we are going to use SqlAlchemy ORM in Python. To communicate with database, we just use ORM along with Python objects and classes. Her... (more)

How to check whether an image exists or not from image path?

To check image existence you can use below function. You just need to pas the image URL in this function and it will return true or false, this way you can identify and show image based on it's existence. //Check whether image exists or not function UR_exists($url){         if (@getimagesize($url)) {         return true;     } else {         return false;     } }... (more)

How to save Arabic in MySql database?

To save an Arabic text into your MySql database table, you first check the table column is set to "utf8" or not. If not, switch to table structure tab of phpmyadmin and click change under action column, here you will see a column "Collation" and choose "utf8_general_ci" from utf8 group and save. Now if you will save any Arabic string in this column it will save properly as it should be. Pleas... (more)

How to validate a date that can't be greater than current date?

Get the jQuery code below to check a date that can't be greater than current date:   $('.ty-dob input').change(function(){                      dob          = $(this).val();          var current_date = new Date();     var arrDate = dob.split("/");     var dob = new Date(arrDate[2], arrDate[1]-1, arrDate[0]);          /*console.log(arrDate);     cons... (more)

How to activate API access in CS Cart?

Cs cart comes with some basic APIs already created like fetch products, get cart contents and some more. You can create your own APIs that can communicate with database get ready to be connected with your mobile application. To access/enable APIs you need to follow below steps: API access is activated/disabled on a per-user basis. To activate cs cart API access for a user: 1- Got to the... (more)

How to connect python with MySQL database?

Before using mysql, you need to install mysql.connector module. Use the below command to install it: $ sudo apt-get install python3-mysql.connector Above example is for python3 and same can be used for python2 also. Get a quick reference with an example below: import mysql.connector cn = mysql.connector.connect(user='root', password='admin@123',                     ... (more)

How to disable keypress or restrict to write in a html input element in jQuery?

If we want to disable writing in a field using jQuery we can do this by writing below code. Actually sometime we don't want anybody to edit information written in a html input element but want that field populated with some default text then use the below line code to do this: $(document).ready(function(){                  //Disable address edit on checkout page         $(".... (more)

How to make a carousel vertical?

You can solve this problem by using a css technique and get the slides vertically rotate. I'm giving you an example and try to make you understand how you can get your problem resolved, below are some code snippets of thumbnails:                 /********* CSS ***********/ .owl-carousel{    transform: rotate(90deg);    width: 270px;     margi... (more)

How to setup a cs cart website on local machine?

It is a very simple step to setup it on local machine. You just need to backup complete website from cpanel with database and extact the zip file on your localhost root (WWW) folder. Now find the file name config.local.php on root of your extracted zip folder. Open up the file in any editor and find the line of code where you can see database name, user and host as below: // Database connectio... (more)