Just another WordPress.com weblog

Install Ruby on Rails
1. Install Dependencies
$ sudo apt-get install ruby ruby-dev zlib1g-dev libsqlite3-dev sqlite3

2. Install Rails without documentations of gem files

$ sudo gem install rails –no-ri –no-rdoc

Note : Missing dependency of ruby-env or zlib1g-dev will result in following error :

ERROR: Error installing rails:
ERROR: Failed to build gem native extension.

/usr/bin/ruby2.1 extconf.rb

If anybody is facing such an issue while installing, please look into the log file of a specific gem where you encountered the problem and install the specific dependency package for that gem

Install rails without documentation for gems by default
1. find out gemrc file in your system
$ strace gem source 2>&1 | grep gemrc
stat(“/etc/gemrc”, 0x7fffe6f7dcd0) = -1 ENOENT (No such file or directory)
stat(“/home/selva/.gemrc”, 0x7fffe6f7ddb0) = -1 ENOENT (No such file or directory)
2. $ vim ~/.gemrc – add below line to this file :
gem: –no-documen

After you have created your rails application and you are facing the issue like “rails server autodetect’ could not find a javascript runtime” while starting your application’s rails server (bin/rails server), You can either install therubyracer gem which is commented in your Gemfile or You can install node.js by using this link :


Download the the repository key with:

curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -

Then setup the repository:

$ sudo sh -c "echo deb https://deb.nodesource.com/iojs_1.x vivid main \
> /etc/apt/sources.list.d/nodesource.list"
$ sudo apt-get update
$ sudo apt-get install iojs


echo ‘<pre>’;

class EmailTemplates {
private $inputString;

function __construct() {
$this->inputString = file_get_contents(‘message3.txt’);  //Read File and convert into string

public function parseEmailContent() {

//Finding “From:” word and getting the whole line.

$fromPattern = “/From\:(.*)/im”;  //Where  i = case insensitive, m = string matching found multiple times
preg_match_all($fromPattern, $inputStr, $fromAddress);   //Match founded will be stored in first index and result will be returned to second index of resulting array variable. preg_match_all stores all matched values into array.
$fromPattern = “/To\:(.*)/im”;
preg_match_all($fromPattern, $inputStr, $fromAddress);
$messagePattern = “/\”([^\”]+)\”/”;  //Finding  Email body messages within Double Quotes.
preg_match_all($messagePattern, $inputStr, $bodyMessage);

$emailTpl = new EmailTemplates();


Email Contents File : message.txt

From: mine@gmail.com
To: myfriend@gmail.com

“sdjfdsfhsodn asdfsdlfdsfd;
sdfhdsiofdsfdsfihds sdifjdsofjn sd dsifjdsofn sdoifodsjifsdjfjdslfd”


From: Mine <mine@gmail.com>
To: My Friend <myfriend@gmail.com>

“sdjfdsfhsodn ouef sncks ahcnkl9isdio90q2
sdfhdsiofdsfdsfihds sdifjdsofjn sd dsifjdsofn sdoifodsjifsdjfjdslfd”



echo “<pre>”;
$numArray = array(11,1,9,4,13,47,5,15,2,7);
echo “Input Value : “;

$n = count($numArray);
$result = sortArray($numArray, $n);
echo “Output Value : “;

function sortArray($unsortedArr, $n) {
$len = count($unsortedArr);
for($i = 0; $i < $len-1; $i++) {
if($unsortedArr[$i+1] < $unsortedArr[$i]) {
$unsortedArr[$i+1] ^= $unsortedArr[$i] ^= $unsortedArr[$i+1] ^= $unsortedArr[$i];   //Swapping Array index values
#    print_r($unsortedArr);
$n = $n-1;
if($n > 0) {
return sortArray($unsortedArr, $n);
} else {
return $unsortedArr;



Today i started to learn python cgi. In the begining, i had to know the network concepts like how data are transferred over the network. I got clear idea about TCP/IP(Transmission Control Protocol/Internet Protocol), that is, It is a rule to be followed for transferring data over internet. First data are divided into small packets and packed with relevant information and IP assigns destination address to each packets

Now all packets are no need to follow the same path. Router will direct the packets to manage data traffics over internet to reach its destination.

And there are different type of HTTP requests GET, POST, PUT, CONNECT, TRACE, DELETE, HEAD, OPTIONS.

CGI – Common Gateway Interface

It is external program to a web server which process the client requests and return respective results.
CGI Concept and Processing Steps :
1. Client sends requests
2. Server receives requests
3. Contacting external program called CGI script
4. CGI script process client data and returns the result to server
5. Server serves response to Client

It can be written in Ruby, Python, PHP, Perl. CGI mostly uses GET and POST.

I got tired to configure the apache server to make working python file. Finally, i succeeded to work with python cgi.

These are all the steps which i did,

First i created folders /var/www/python/cgi-bin/ and changed folder permission

as $ sudo chmod -R 777 /var/www/python

Then i created this test file to check in the browser and saved it as index.py in cgi-bin folder

print “Content-Type: text/plain\n\n”
print ‘python works’

And i added the cgi-bin directory path in /etc/apache2/httpd.conf file as follows:

<Directory “/var/www/python/cgi-bin”>
    Options ExecCGI
    Order allow,deny
    Allow from all

<Directory “/var/www/python/cgi-bin”>
    Options All

          If cgi-bin directory path is not set, apache will throw 403 Forbidden error, that means, either you dont have enough permission or this folder is not having 777 permission. Next is, restarting apache server sudo /etc/init.d/apache2 restart to reflect the changes in server.

               Now i tested the index.py file, It downloaded the python file instead of opening in browser. This is where i got stuck to go ahead. I googled and tried to fix the solution. After struggling more than one hour, i found that browser is not recognized the the cgi script file.

        It means that some configuration is missing for setting up MIME type in apache server.  The actual file to be configured is mime.conf in /etc/apache2/mods-enabled/mime.conf. I just uncomment this line

AddHandler cgi-script .cgi

and add .py at the end of this line to look like

AddHandler cgi-script .cgi .py

Now restart your server $ sudo /etc/init.d/apache2 restart and run the index.py file in browser.


FATAL ERROR: MODx Setup cannot continue.

To use PHP 5.3.0+, you must set the date.timezone setting in your php.ini. Please do set it to a proper timezone before proceeding. A list can be found here

Read the rest of this entry »

As i mentioned before about my project using pygtk and glade, it is now been completed.

Project Description :
This application is applicable to retail business. You can import your Product details in your business into the database. It has different modules User Management, Product Management, create stock details, Billing, Report automation and Production and Sales report etc.,

It provides stocks details and sold product details and Report Automation on the daily basis. User can be created by admin with some restriction. Product can be added to database by admin.

I hosted my project in code.google.com : http://code.google.com/p/py-retail/

Here is screenshots :

Python 2.7 Vs Python 3.1

Date : 06/02/2011

Place : KanchiLUG Meet

I explained some new features added which was been lacking in Python 2.7 to the Python 3.1 at KanchiLug weekly meet. I gave the demo using both Python 2.7 Interpreter and Python 3.1 Interpreter about those features such as output of divisonal operator, file object creation, dictionary’s ordered list, Indentation exceptional error, format specifier etc., To know more details of the new features in Python 3.1, use this link New Python 3.1 Features

Booming GNU/Linux,

செல்வமணி.  ச

Tag Cloud