Friday 31 July 2015

How to install node js? How to run a Node js on windows?


What is Node js?
A lot of the confusion for newcomers to Node is misunderstanding exactly what it is. The description on nodejs.org definitely doesn't help more.

An important thing to realize is that Nodejs is not a webserver. By itself it doesn't do anything. And It doesn't work like Apache. There is no config file where you point it to you HTML files. If you want it to be a HTTP server, you have to write an HTTP server (with the help of its built-in libraries). Node.js is just another way to execute code on your computer. It is very simply a JavaScript runtime.

Installing Node
Node.js is very easy to install. If you're using Windows or Mac, installers are available on the download page.
https://nodejs.org/#download

I've Installed Node, now what?

It's so easy. Here are the exact steps I just took to run the "Hello World" example found at http://nodejs.org/. This is a quick and non understable example. For a permanent installation you'd want to store the executable in a more reasonable place than the root directory and update your PATH to include its location.

Download the Windows executable here: http://nodejs.org/#download
Copy the file to C:\
Create C:\hello.js
Paste in the following content:
   var http = require('http');

var server = http.createServer(function(req, res) {
  res.writeHead(200);
  res.end('Hello This is my first node script. Thanks - Arpan Thakrar');
});
server.listen(8080);

console.log('Hey This is my first nodejs script. Thanks - Arpan Thakrar');


Save the file. And Go to the
Start -> Run... -> cmd
c:
C:>node hello.js

Output -:
Hey This is my first nodejs script. Thanks - Arpan Thakrar

Note-:
This is a basic of nodejs. This is not a full-featured HTTP server. It can't serve any HTML file or images. In fact, no matter what you request, it will return 'Hey This is my first nodejs script. Thanks - Arpan Thakrar'. However, you can run this and hit http://localhost:8080 in your browser and you'll see the text.

Hey This is my first nodejs script. Thanks - Arpan Thakrar

You might notice something a little different now. Your Node.js application no longer exits. This is because you created a server and your Node.js application will continue to run and respond to requests until you kill it yourself.

If you want this to be a full-featured web server, then you have to do that work. We will learn that in next post :)NJOY!!

That's it. This was done on Windows.

Wednesday 17 June 2015

How to increase import size in phpmyadmin in WAMP:-


how to increase maximum execution time in php, 
How to increase maximum execution time in php, 
How to change maximum execution time in phpmyadmin, 
phpmyadmin max execution time, phpmyadmin import file size, 
phpmyadmin import file size increase, 
Increase the import file size in phpmyadmin wamp, 
Phpmyadmin increase import file size

Solution 1):-
Please follow below settings in C:\wamp\bin\apache\apache2.2.8\bin\php.ini

Find:
post_max_size = 8M
max_execution_time = 30
upload_max_filesize = 2M
memory_limit = 8M
max_input_time = 60

Change to:
post_max_size = 750M
max_execution_time = 5000
upload_max_filesize = 750M
memory_limit = 1000M
max_input_time = 5000

Then restart your wamp to take effect

Solution 2):-
Add this to an htaccess file:
<IfModule mod_php5.c>
php_value post_max_size 200M
php_value max_execution_time 259200
php_value upload_max_filesize 200M
php_value memory_limit 300M
php_value max_input_time 259200
</IfModule>

Solution 3:-
If you don't have access of your php.ini or dont use htaccess file, you can use ini_set in your php file:
For example - ini_set('max_execution_time', 5000);

You can also refer http://forum.wampserver.com/read.php?2,45000 for more informaion

Saturday 13 June 2015

Non secure to Secure AJAX call in PHP with Maintaining Session Variables

Want to Non secure to Secure AJAX call in PHP and maintain session?


What is .htaccess file?
".htaccess is a configuration file for use on web servers running the Apache Web Server software.

When a .htaccess file is placed in a directory which is in turn 'loaded via the Apache Web Server', then the .htaccess file is detected and executed by the Apache Web Server software.

These .htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer."

------------------------------------------------

Write below code in .htaccess file.


SetEnvIf Origin "http(s)?://(www\.)?(yourdomainname.com)$" AccessControlAllowOrigin=$0
Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin

Header set Access-Control-Allow-Credentials true

-------------------------------------------------------------

In your jQuery AJAX call add below code,

xhrFields : { withCredentials : true }

Example,

$.ajax({ 
 type: 'POST',
url: http://www.yourdominname.com?test.php
data:  $('#formname').serialize(),
xhrFields : { withCredentials : true },
success: function(msg) 
}
});