Out of memory Cent OS Linux: unicode_start hang issue: Solved

My Cent OS 5.6 RHEL based virtual machine has suddenly became very slow ..almost died :-( after few min I saw a message on console related to “Out of memory“, after doing a bit analysis and search I found that this is a known issue and also reported in redhat bug tracker (obviously got resolved in upstream versions).
Reason: Problem is that setting BASH_ENV=~/.bashrc runs /etc/profile, which sources /etc/profile.d/lang.sh. If TERM=linux, lang.sh runs /bin/unicode_start sending the whole process into an infinite loop.

I found two solutions (as of now)

1. Open vi /etc/sysconfig/i18n this file contains a reference to unicode (UTF-8). We have take out all the references to UTF-8)

Code before:

LANG="en_US.UTF-8"
SUPPORTED="en_US.UTF-8:en_US:en"
SYSFONT="latarcyrheb-sun16"

Code after:

LANG="en_US"
SUPPORTED="en_US:en"
SYSFONT="latarcyrheb-sun16"

2. Another solution is to change the shell from “bash” to “sh” in unicode_start script
We need to open the vi /bin/unicode_start and from first line change “#!/bin/bash” to “#!/bin/sh“.

References: https://bugzilla.redhat.com/show_bug.cgi?id=622981

YAPC::EU 2013 Slides

See this link for the slides of talks given by Perl guru Jonathan Worthington in recently held YAPC Europe. Here is the brief list of talks:

All the talks are good but I personally liked the talk on Concurrency, Parallelism and Asynchrony  in which he explains about Perl 6 thread system. 

In future, I wish to attend some of these talks.

Enjoy the slides.

 

Source:

http://6guts.wordpress.com/2013/08/17/yapceu-2013-slides/

 

 

CSS based page numbering in PDF creation

I frequently use PDF engine for generating PDF of multiple web pages a kind of book. Though you can use engine specific switch to insert page number(s) but if you want beautiful CSS based numbering then below code can be used. Just paste the code in a .CSS file and link to your html pages.

/* Page number at the bottom of page */

@page {

  @bottom-center {

    content: "Page " counter(page) " of " counter(pages);

    font-style: italic;

    color: green

    }

  }

WEBDAV authentication for Office docunments on SSL enabled sites

As explained in my post related to the Webdav authentication issue using IE for Office documents on Windows 7, I found that the fix will not work for SSL enabled sites. To support HTTPS you will have to add the following lines in /etc/httpd/conf.d/ssl.conf file.

<VirtualHost>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(OPTIONS|PROPFIND)$ [NC]
RewriteRule ^.*$ – [F,L]
</VirtualHost>
Restart httpd

To generate an SSL certificate you can use OpenSSL library

Head First book Perl

Some months back I have purchased 4th edition of Camel book, Programming Perl. I am liking the book and at present focusing on Chapter 6 on Unicode. Well, I was just wondering if the experts in the Perl community have plans to write a Perl book in the Head First series. Well, the obvious answer could be that we already have excellent books then why we need this? But I personally feel that Head First books have quite delightful way of teaching which can shorten learning time. May be this can help in attracting more guys to take a dip in the Perl world in a short time and later one can pick the Camel book and others.

I don’t know if someone had already started writing? But just a thought.

Thanks

PostgreSQL useful tips

I am posting some of the PostgreSQL commands which I use frequently.

Create a new database name testdb

# createdb <dbname>
e.g:

# createdb testdb

Remove a PostgreSQL database
# dropdb <dbname>
e.g:

# dropdb testdb

Backing up a PostgreSQL database

# su - postgres
# pg_dump --blob -Fc testdb -f /var/lib/pgsql/backups/testdb_backup

Restoring PostgreSQL database from back up dump

# pg_restore --dbname=testdb /var/lib/pgsql/backups/testdb_backup

Writing query output to a CSV file:

# \o 'tmp/logs/query_out_dump.csv'

After this operation all the query results will be stored in a CSV file.
Using console again for query output:

# \o

For more on pg_dump and pg_restore pl. check the documentation

Solving the authentication problem while opening Office documents hosted on Apache in IE8/IE9 on Windows 7

We were facing a problem in IE 8/9 on Windows 7 while accessing  Office 2007/ Office 2010 documents hosted on apache/Cent OS 4.6. After some analysis I found the reason and finally ended in a fix. See below my findings and solution. Hope this helps:

The main issue is with the Microsoft’s way of implementing Webdav protocol for accessing web content through Microsoft Web Client. When we click on a Office document then web client  sends HTTP /1.1 OPTIONS Request header to server to check the WebDav communication (My server doesn’t have WebDav). In response Apache return 200 OK Response header to Web Client which results in prompting the authentication screen by Windows 7.  Well you have option in IE to pass the authentication login automatically but that would be security breach as you will be exposing your machine authentication to internet so I would not prefer that. Best way is to configure Apache to reject these request. This is how i have solved. These changes needs to be done in httpd.conf file in /etc/httpd/conf folder (Cent OS 4.6)

# One way to doing it – Deny access based on request method

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(OPTIONS|PROPFIND)$ [NC]
RewriteRule ^.*$ - [F,L]

# Another way to implementing – Deny acess based on user agent (Vista and Windows 7 used same user agent with different version so this Regx shall work for both

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^Microsoft-WebDAV-MiniRedir
RewriteRule ^.*$ - [F,L]

Explanation on Flags:

1. [F] flag causes the server to return a 403 Forbidden status code to the client.

2. Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive manner. That is, it doesn’t care whether letters appear as upper-case or lower-case in the matched URI.

3. The [L] flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed. This corresponds to the last command in Perl.

 Some References:

Microsoft knowledge article on authentication requests from office documents 

Apache mod_rewrite rule documentaion

fiddler tool for debugging HTTP requests