How to Leverage Browser Caching via .htaccess
Leveraging browser caching through the .htaccess file is an effective way to improve website performance by instructing the user’s browser to cache static resources. This reduces the number of requests made to the server, as the browser can retrieve cached files instead. To leverage browser caching, follow these steps: Open your preferred text editor and […]
how can I add comments to a batch file?
The REM statement This is the most common way to write comments. Any line in your bat-file that starts with REM is completely ignored by the command-processor. REM This bat-file moves all files in C:Incoming to C:ToProcess REM Written by Nikunj Kansara REM 05/01/2003 Double Colons Alternatively you can replace the word REM by two […]
How to display HTML tags as plain text in browser using php
Show HTML tags in browser we can use htmlspecialchars() <?php $new = htmlspecialchars(“<a href=’test’>Test</a>”, ENT_QUOTES); echo $new; // <a href='test'>Test</a> ?>
How to install pear mail in ubuntu
pear install Net_SMTP sudo /etc/init.d/sendmail start sudo /etc/init.d/apache2 restart
Configure SMTP mail on apache server in ubuntu
sudo apt-get install php-pear sudo pear install Mail_Mime sudo apt-get install sendmail sudo /etc/init.d/sendmail start sudo /etc/init.d/apache2 restart
Hide Div using Javascript
To hide a div element using JavaScript, you can set its style. Display property to “none“. Here’s an example: <!DOCTYPE html> <html> <head> <title>Hide a div with JavaScript</title> <script> function hideDiv() { var divElement = document.getElementById(“myDiv”); divElement.style.display = “none”; } </script> </head><body> <div id=”myDiv”> <p>This is the content of my div element.</p> </div> <button onclick=”hideDiv()”>Hide […]
Node.js Response.WriteHead function
Up until now all we’ve been sending into the writeHead function is the status code. However, it can take additional parameters like ‘Content-Length’, ‘Content-Type’. var http = require(‘http’); var fs = require(‘fs’); http.createServer(function(request, response) { response.writeHead(200, {‘Content-Type’: ‘text/html’} ); fs.readFile(‘index.html’, function(err, contents) { response.write(contents); response.end(); }); }).listen(8080);
Node.js Read File from Server
Now, showing you how to create an HTTP non-blocking server and how to read a file of the non-blocking filesystem. var http = require(‘http’); var fs = require(‘fs’); http.createServer(function(request, response) { response.writeHead(200); fs.readFile(‘index.html’, function(err, contents) { response.write(contents); response.end(); }); }).listen(8080); Generate Request curl http://localhost:8080
node.js Convert Blocking
Everyone don’t knows why important to write non-blocking programs in Node.js. Here is some code using non-blocking function “readFile()“ Read the contents of ‘index.html’ and log them to the console. var fs = require(‘fs’); fs.readFile(‘index.html’, function(err, contents){ console.log(contents); });
Create User in Mysql
CREATE USER ‘monty’@’localhost’ IDENTIFIED BY ‘some_pass’; GRANT ALL PRIVILEGES ON *.* TO ‘monty’@’localhost’ WITH GRANT OPTION;