InnoSetup Disable Select Destination Location

To disable InnoSetup “Select Destination Location” wizard page: Add this variable under [Setup] section: DisableDirPage=noDisableDirPage=no More information here: [Setup]: DisableDirPage

InnoSetup Disable Close of Applications

If you already handle the termination of your applications’s processes inside the CurStepChanged -> ssInstall then you may want to disable the display of the form “The following applications are using files that need to be updated by Setup”: To do so, just add this variable under [Setup] section: CloseApplications=noCloseApplications=no More information can be found […]

Node.js Execute a Unix Command

Use child_process.exec to execute a comand and fetch its output: var exec = require(‘child_process’).exec; var cmd = ‘id’;   exec(cmd, function(error, stdout, stderr) { console.log("Output: "+stdout); });var exec = require(‘child_process’).exec; var cmd = ‘id’; exec(cmd, function(error, stdout, stderr) { console.log("Output: "+stdout); }); Or you can use execFile() method: var execFile = require(‘child_process’).execFile;   execFile("/bin/ls", [‘-la’], […]

Node.js Cluster Module

Example Node.js cluster module usage: var cluster = require(‘cluster’); var http = require(‘http’); var numCPUs = require(‘os’).cpus().length;   if (cluster.isMaster) { // Fork workers. for (var i = 0; i < numCPUs; i++) { cluster.fork(); }   cluster.on(‘exit’, function(worker, code, signal) { console.log(‘worker ‘ + worker.process.pid + ‘ died’); }); } else { // Workers […]

Install Node.js on Debian 8 Jessie

Download this bash script to update the PPA and apt repos: curl -sL https://deb.nodesource.com/setup_7.x -o nodesource_setup.shcurl -sL https://deb.nodesource.com/setup_7.x -o nodesource_setup.sh * Replace 7.x with the last Node.js version Grant +x permissions to the bash script: chmod +x nodesource_setup.shchmod +x nodesource_setup.sh Run the bash script: bash nodesource_setup.shbash nodesource_setup.sh Now install Node.js (it contains also npm): apt-get […]

Basic usage of jQuery $.ajax

Example Form HTML code: <form id="foo"> <label for="bar">A bar</label> <input id="bar" name="bar" type="text" value="" />   <input type="submit" value="Send" /> </form><form id="foo"> <label for="bar">A bar</label> <input id="bar" name="bar" type="text" value="" /> <input type="submit" value="Send" /> </form> Javascript code: // Variable to hold request var request;   // Bind to the submit event of our form […]

Best PHP HTML\XML Parser Class

This is the fastest and simplest HTML parser class for PHP: https://github.com/Imangazaliev/DiDOM Here is an example usage: use DiDom\Document;   $document = new Document(‘http://www.news.com/’, true);   $posts = $document->find(‘.post’);   foreach($posts as $post) { echo $post->text(), "\n"; }use DiDom\Document; $document = new Document(‘http://www.news.com/’, true); $posts = $document->find(‘.post’); foreach($posts as $post) { echo $post->text(), "\n"; } […]

Bash: No space left on device

If you get this error on your Linux web server: -bash: No space left on device-bash: No space left on device That probably means you ran out of inodes, type this to check: df -idf -i If you see something like this: Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda2 1310720 1310720 0 100% /Filesystem […]

Bash Script to Delete PHP Session Files and Free Inodes

Use “df -i” command to view inodes usage: Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda2 1310720 1310720 0 100% /Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda2 1310720 1310720 0 100% / That means you ran out of inodes! Most probably PHP sessions are the issue. A quick command to delete all sess_* files […]

Regex Remove Blank Lines from Text in PHP

This regex will remove (preg_replace) all empty new lines from a text: $str = preg_replace(‘/^\n+|^[\t\s]*\n+/m’, ”, $str);$str = preg_replace(‘/^\n+|^[\t\s]*\n+/m’, ”, $str);