Understanding & Installing Node.js and NPM

We have been using client side/front end JavaScript to build dynamic pages where we embed the JavaScript code in HTML file, react to events and make AJAX calls for fetching data from the server.

Node.js allows you to write server side and networking applications with JavaScript.

Node.js is an open-source, cross-platform run-time environment that executes JavaScript code server-side. It is build on built on Chrome’s V8 JavaScript engine. It uses an asynchronous event-driven model and is designed for writing scalable internet applications, notably web servers.

Continue reading »

How to drop all tables in MySQL database

Once I faced a situation wherein I had no option to delete the database and was limited to use only the MySQL command line. I wasted a lot of time find and trying different ways to delete all tables in the database. So, I thought it will be worth sharing things that ultimately worked for me.

$ mysqldump -hHOSTNAME -uUSERNAME -pPASSWORD --add-drop-table --no-data DB_NAME | grep -e '^DROP \| FOREIGN_KEY_CHECKS' | mysql -hHOSTNAME -uUSERNAME -pPASSWORD DB_NAME;

Continue reading »

How to upload large files in PHP

By default PHP is configured to allow files upload of size upto 2M.

We need to adjust the following PHP configuration directives:

  1. upload_max_filesize: By default this value is 2M. We need to increase it to the maximum size of single file that we want to upload.
  2. post_max_size: It defines the maximum size of POST data that PHP will accept. This value should be greater than ‘upload_max_filesize’.
  3. memory_limit: This sets the amount of memory a PHP script is allowed to use during its execution. Set this to a value greater than ‘post_max_size’ so that PHP script can load and process the uploaded file.

Continue reading »

How to disable textarea resizing

If we add a simple textarea in a HTML form then we see that we can resize it by clicking on the bottom right corner of the textarea and dragging the mouse.

<textarea id="txt1" name="txt1" rows="5" cols="50"></textarea>

If we want to stop this resize then you have to just add a simple css as shown below.

textarea {
    resize: none;
}

Continue reading »

How to set up HTTP authentication with nginx

We will demonstrate you how to setup HTTP Authentication with Nginx on Ubuntu in this article. We are using Ubuntu 16.04.1 and have nginx version: nginx/1.10.0 installed in our machine.

“htpasswd” is used to create and update the files used to store usernames and password for basic authentication of HTTP users.

Following are the steps that we need to follow:

  1. apache2-utils
  2. Create username and password
  3. Update Nginx configuration
  4. Reload the Nginx Configuration

Continue reading »

How to temporarily disable Foreign Key Checks or Constraints in MySQL

While importing a database that has tables with foreign keys defined we get to see error “#1452 – Cannot add or update a child row: a foreign key constraint fails“.

Even while trying to delete some tables from such a database, we come across situation where we face foreign key constraint error: “#1217 – Cannot delete or update a parent row: a foreign key constraint fails

To avoid such errors first disable the foreign key checks, then do your job of importing the database or deleting the table and finally enable the foreign key checks.

Continue reading »

WinSCP: How to view the hidden files like .htaccess

WinSCP comes with a configuration setting that allows you to show or hide the hidden files . To view the hidden files, activate the setting by going to:

Options >> Preferences >> Panels

Select the “Show hidden files”  option under the common settings and click the “OK” button.

Continue reading »

How to restore mysql database from command line

We need to import database on local machine when setting up a live website locally or when we are transferring hosting from one service provider to another. Let’s see how we can import MySQL database dump from command line

Assuming that we have created the database say ‘mynewdb’ in which we have to import.

Run the following command

$ mysql -u username -ppassword mynewdb < dbbackupfile.sql

Continue reading »

How to backup mysql database from command line

It is necessary to take database backups at regular intervals to prevent loss of data. In this article we will see how we can backup mysql database using command line.

‘mysqldump’ command can be used to create backup of MySQL database as follows:

$ mysqldump -u username -ppassword dbname > dbname.sql

The above command assumes that you are running the ‘mysqldump’ command on the same server on which MySQL is installed.

Continue reading »

SOAP-ERROR: Parsing WSDL: Couldn’t load from … : failed to load external entity …

I had written some code using Magento API, it worked fine on my local machine but when I transferred the same code to my linux server I got the following error:

SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://mydomain.com/api/soap/?wsdl=1' : failed to load external entity "http://mydomain.com/api/soap/?wsdl=1"

When I opened the URL ‘http://mydomain.com/api/soap/?wsdl=1’ directlty in my browser, it displayed the wsdl file as expected.

Continue reading »

Back to top