Execution sequence for interactive login shell scripts

./etc/profile

if ~/.bash_profile exists then

execute ~/.bash_profile

else if ~/.bash_login exists then

execute ~/.bash_login

else if  ~/.profile exists then

execute ~/.profile

fi

~/.bashrc  is not used in interactive scripts.

 

nJoy 😉

 

How to allow includes, Basic Auth from outside .htaccess

This .htaccess file does the following:

Allow SSI lines 1/2/3

Reauire Authenitcation for all outside except those from a particular IP the rest ..

Options +Includes      
AddType text/html .shtml .html
AddOutputFilter INCLUDES .shtml .html
AuthType Basic
AuthName “Password Required For INGG Monitor”
AuthUserFile /var/www/passwords/password.file
Require valid-user
Order deny,allow
Deny from all
Allow from 323.365.376.398
Satisfy any
Header set Access-Control-Allow-Origin “*”
~

 

you need to enable the headers module (mod_Headers)

In Ubuntu :

cd /etc/apache2/mods-enabled/

ln -s ../mods-available/headers.load headers.load 

nJoy 😉

 

Installing latest ImageMagick on Centos 6.3

When I needed ImageMagick on Centos the default installer came with a version some 400 verison back.

Installing the latest version was a bit wiry so here it goes:

 

wget “http://www.imagemagick.org/download/linux/CentOS/i386/ImageMagick-6.8.6-9.i386.rpm”

yum install bzip2-devel freetype-devel libjpeg-devel libpng-devel libtiff-devel giflib-devel zlib-devel ghostscript-devel djvulibre-devel libwmf-devel jasper-devel libtool-ltdl-devel libX11-devel libXext-devel libXt-devel lcms-devel libxml2-devel librsvg2-devel OpenEXR-devel

yum install fftw-3.2.1-3.1.el6

download libltdl3-1.4.3-9sls.i586.rpm

wget “ftp://ftp.pbone.net/mirror/ftp.rpmhelp.net/pub/releases/1.0-CURRENT/i586/RPMS/libltdl3-1.4.3-9sls.i586.rpm”

install it :

yum install libltdl3-1.4.3-9sls.i586.rpm

 

yum install ImageMagick-6.8.6-9.i386.rpm

 

Voila.

 

nJoy;

 

 

 

Node.js handling mysql disconnects.

You may lose the connection to a MySQL server due to network problems, the server timing you out, the server being restarted, or crashing. All of these events are considered fatal errors, and will have the err.code = 'PROTOCOL_CONNECTION_LOST'. See the Error Handling section for more information.

A good way to handle such unexpected disconnects is shown below:

 

var db_config = {
  host: 'localhost',
    user: 'root',
    password: '',
    database: 'example'
};

var connection;

function handleDisconnect() {
  connection = mysql.createConnection(db_config); // Recreate the connection, since
                                                  // the old one cannot be reused.

  connection.connect(function(err) {              // The server is either down
    if(err) {                                     // or restarting (takes a while sometimes).
      console.log('error when connecting to db:', err);
      setTimeout(handleDisconnect, 2000); // We introduce a delay before attempting to reconnect,
    }                                     // to avoid a hot loop, and to allow our node script to
  });                                     // process asynchronous requests in the meantime.
                                          // If you're also serving http, display a 503 error.
  connection.on('error', function(err) {
    console.log('db error', err);
    if(err.code === 'PROTOCOL_CONNECTION_LOST') { // Connection to the MySQL server is usually
      handleDisconnect();                         // lost due to either server restart, or a
    } else {                                      // connnection idle timeout (the wait_timeout
       throw err;                                 // server variable configures this)
    });
}

handleDisconnect();

As you can see in the example above, re-connecting a connection is done by establishing a new connection. Once terminated, an existing connection object cannot be re-connected by design.

With Pool, disconnected connections will be removed from the pool freeing up space for a new connection to be created on the next getConnection call.

svn fails to transmit data: Transmitting file data .

I had svn not committing to the repository. It would just stop at

Transmitting file data .

and would not budge.

upgrade , and committing another file on it’s own would work .

 

I sudo’ed as root and used chown user. on the folder where the working copy was and it sorted itself out.

So the issue must have been permissions.

Hope this helps someone else !

 

 

Vim auto align columns

Best trick ever i found on vim :

if you start with rough space, comma delimited files to align them just type in command :

 :%!column -t

AWESOME !!!
I love VIM

nJoy ;-)

Installing and configuring Postfix Ubuntu 10.04

Introduction

Postfix is the default Mail Transfer Agent (MTA) for Ubuntu. It is in Ubuntu’s main repository, which means that it receives security updates. This guide explains how to install and configure postfix and set it up as an SMTP server using a secure connection.

 

What is a Mail Transfer Agent

In other words, it’s a mail server not a mail client like Thunderbird, Evolution, Outlook, Eudora, or a web-based email service like Yahoo, GMail, Hotmail, Earthlink, Comcast, SBCGlobal.net, ATT.net etc…. If you worked for a company named Acme and owned acme.com, you could provide your employees with email addresses @acme.com. Employees could send and receive email through your computer, but not without your computer running all the time. If all your email addresses are at a domain (@gmail.com, @yahoo.com) you do not own (you don’t own Google) or do not host (acme.com) then you do not need this at all.

(more…)

Enable SSI on Apache2 under Ubuntu

Tested on:
– Ubuntu Linux 10.10 Maverick Meerkat (2010-11-21)
– Ubuntu Linux 7.10 Gutsy Gibbon
– Ubuntu Linux 6.06 Dapper Drake
– Ubuntu Linux 5.10 Breezy Badger

 

1)  Optional: Install the Apache2 httpd server if not already installed.

sudo apt-get install apache2

2) Create the following symlink.
sudo ln -s /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled

3) Open the /sites-available/default file and add the text with the yellow background.
sudo gedit /etc/apache2/sites-available/default

...
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews +Includes
AllowOverride None
Order allow,deny
allow from all
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</Directory>
...

4) Restart Apache2 and create a SSI test file (ssi-test.shtml) and save it in the directory /var/www/.

sudo apache2ctl restart

sudo vim /var/www/ssi.shtml

<html>
<head>
<title>SSI Page</title>

</head>
<body>
<!--#echo var="DATE_LOCAL" -->
</body>
</html>

5) Test SSI in your web browser.
http://localhost/ssi.shtml

If your browser displays the local date (eg Monday, 29-Jul-2013 14:32:58 BST), SSI would be working.

Yeah !!

nJoy 😉