Tuesday, February 23, 2010

Installing Ruby on Linux

This post talks about the installation , of ruby on debian and rpm based systems.

On debian systems:
On debian systems , the default package manager is the aptitude package manager.
Ex: Ubuntu , debian , Sedux etc ..

Command to install:
[]$sudo apt-get install ruby1.9.1-full

On RPM based systems:
The default package manager is the RPM -> Red Hat Packager manager.

Refer to this link : http://www.linuxweblog.com/ruby-on-rails-install

Posted By:
Jayanthi GM(Course Instructor , Java , PESIT)
Prashanth Raghu (Student Assistant)

Interactive online ruby Interpreter

Hi guys today , the web is being revolutionised , by technologies , such as PHP and Ruby . To try out ruby , on your browser ,


http://tryruby.org/

An interesting fact not to be missed , Ruby was developed by the Japanese.

Posted By:
Jayanthi GM(Course Instructor , Java , PESIT)
Prashanth Raghu(Student Assistant)

Most popular programming language

Hi everyone , in this age of web it is not surprising to note that more and more programmers are tending towards , web programming technologies.
A sample survey by develeperiq.in , shows the following result as of 23/02/2010.

  • Java -- 5702 votes
  • C/C++ -- 41053 votes
  • PHP -- 55398 votes
  • C# -- 3167 votes
  • VB -- 33841 votes
  • Python -- 5319 votes

Nice change , swing towards web programming languages.

Posted By:
Jayanthi GM(Course Instructor Java , PESIT)
Prashanth Raghu (Student Assistant)

Sunday, February 21, 2010

It is a mobile story -> Google's Android

When google comes up with a new product , it always has it's own distinct flavour and substance . Here is an article about the acquisition aspect of google.

We all know or have definitely heard about the Android, the mobile OS of google.
The one fact , we need to learn is that , Android Inc. was a small firm working in mobile OS , and was acquired by Google in 2005. Google , later went on to make the open mobile alliance , consisting of 47 companies , from hardware , software and telecommunication streams .

Android applications ,are developed in Java , through the libraries provided by Google.

So here we go , something in favour of start up's.

Posted by,
Jayanthi GM(Course Instructor , Java ,PESIT)
Prashanth R (Student Assistant)

The Sun finally sets down OOOracle

Today , as I script this page ,  I am internally feeling a sense of voidness . One of my favorite companies , none other than sun microsystems , has been acquired by the software giant , Oracle . The link sun.com , no longer leads you to the sun.com website , we are familiar to , but to oracle's page , which indicates the merger of the giants . Let us hope , Oracle keeps up it's promise , and maintains the standards and quality , provided by sun , for such a long time.

We miss you , may the sun never set upon you.

Posted by,
Jayanthi GM(Course Instructor , Java PESIT)
Prashanth Raghu ( Student Assistant )

Saturday, February 20, 2010

MultiHeaded python - Threading in python

Hi guys , as a student of multicore programming , I was just curious about threading facilities in higher level programming languages like python . So just revoking on the idea , I did find a good small ping application , using python.

Here is the source code : try it and make the changes to suite your local network.
I have made a comment , which shall help you .

original source : http://www.wellho.net/solutions/python-python-threads-a-first-example.html


import os
import re
import time
import sys
from threading import Thread

class testit(Thread):
   def __init__ (self,ip):
      Thread.__init__(self)
      self.ip = ip
      self.status = -1
   def run(self):
      pingaling = os.popen("ping -q -c2 "+self.ip,"r")
      while 1:
        line = pingaling.readline()
        if not line: break
        igot = re.findall(testit.lifeline,line)
        if igot:
           self.status = int(igot[0])

testit.lifeline = re.compile(r"(\d) received")
report = ("No response","Partial Response","Alive")

print time.ctime()

pinglist = []

for host in range(1,4): # Change the IP range here
   ip = "192.168.1."+str(host)
   current = testit(ip)
   pinglist.append(current)
   current.start()

for pingle in pinglist:
   pingle.join()
   print "Status from ",pingle.ip,"is",report[pingle.status]

print time.ctime()

 Posted by :
  Jayanthi GM (Course Instructor for Java , PESIT )
  Prashanth Raghu ( Student Assistant )

Wednesday, February 17, 2010

Core dumping of runtime allocated memory

Hello Folks , today we are going to demonstrate a simple application , which can generate the core dump of the memory allocated to objects at runtime.

Below is illustrated a simple c++ program , along with a trial run of the output try it and a fair analysis yields the fact about allocation of memory to the objects at runtime .

As an enhancement  , we can compile the program twice into 2 object files , and then run them simultaneously on two terminals , with considerable delay to affix the illustrated concept .

// The program is to be tested in any Linux environment
// We have tested the program in Fedora core 12

#define MARKERSIZE 5
#define BEGMARKER "" set it to
#define ENDMARKER "
" set it to
#include
#include
#include
#include
#include
#include


using namespace std;

class A
{
    char beginA[MARKERSIZE];
    int i;
    char b;
    char endA[MARKERSIZE];

public:
    A() : i(0xabcd), b('X')
    {
        std::cout << "CTOR" << std::endl;
        strcpy(beginA,BEGMARKER);
        strcpy(endA,ENDMARKER);
    }

    ~A()
    {
        std::cout << "DTOR" << std::endl;
    }

    void displayme()
    {
        printf("ADDR BEG = %p\n",beginA);
        printf("ADDR I = %p\n", &i);
        printf("ADDR B = %p\n", &b);
        printf("ADDR END = %p\n",endA);
    }
};


int main()
{
    for(int i=0 ; i<10 ; ++i)
    {
        A *a = new A();
        a->displayme();
        //delete a; remove this comment in the second run .
    }
        
       //send a SIGSEGV signal to generate core
    pid_t pid = getpid();
    kill(pid,11);
}

Trial Run :

ADDR BEG = 0x8fca008
ADDR I = 0x8fca010
ADDR B = 0x8fca014
ADDR END = 0x8fca015
CTOR
ADDR BEG = 0x8fca020
ADDR I = 0x8fca028
ADDR B = 0x8fca02c
ADDR END = 0x8fca02d
CTOR
ADDR BEG = 0x8fca038
ADDR I = 0x8fca040
ADDR B = 0x8fca044
ADDR END = 0x8fca045
CTOR
ADDR BEG = 0x8fca050
ADDR I = 0x8fca058
ADDR B = 0x8fca05c
ADDR END = 0x8fca05d
CTOR
ADDR BEG = 0x8fca068
ADDR I = 0x8fca070
ADDR B = 0x8fca074
ADDR END = 0x8fca075
CTOR
ADDR BEG = 0x8fca080
ADDR I = 0x8fca088
ADDR B = 0x8fca08c
ADDR END = 0x8fca08d
CTOR
ADDR BEG = 0x8fca098
ADDR I = 0x8fca0a0
ADDR B = 0x8fca0a4
ADDR END = 0x8fca0a5
CTOR
ADDR BEG = 0x8fca0b0
ADDR I = 0x8fca0b8
ADDR B = 0x8fca0bc
ADDR END = 0x8fca0bd
CTOR
ADDR BEG = 0x8fca0c8
ADDR I = 0x8fca0d0
ADDR B = 0x8fca0d4
ADDR END = 0x8fca0d5
CTOR
ADDR BEG = 0x8fca0e0
ADDR I = 0x8fca0e8
ADDR B = 0x8fca0ec
ADDR END = 0x8fca0ed
ADDR BEG = 0x8fca008
ADDR I = 0x8fca010
ADDR B = 0x8fca014
ADDR END = 0x8fca015
CTOR
ADDR BEG = 0x8fca020
ADDR I = 0x8fca028
ADDR B = 0x8fca02c
ADDR END = 0x8fca02d
CTOR
ADDR BEG = 0x8fca038
ADDR I = 0x8fca040
ADDR B = 0x8fca044
ADDR END = 0x8fca045
CTOR
ADDR BEG = 0x8fca050
ADDR I = 0x8fca058
ADDR B = 0x8fca05c
ADDR END = 0x8fca05d
CTOR
ADDR BEG = 0x8fca068
ADDR I = 0x8fca070
ADDR B = 0x8fca074
ADDR END = 0x8fca075
CTOR
ADDR BEG = 0x8fca080
ADDR I = 0x8fca088
ADDR B = 0x8fca08c
ADDR END = 0x8fca08d
CTOR
ADDR BEG = 0x8fca098
ADDR I = 0x8fca0a0
ADDR B = 0x8fca0a4
ADDR END = 0x8fca0a5
CTOR
ADDR BEG = 0x8fca0b0
ADDR I = 0x8fca0b8
ADDR B = 0x8fca0bc
ADDR END = 0x8fca0bd
CTOR
ADDR BEG = 0x8fca0c8
ADDR I = 0x8fca0d0
ADDR B = 0x8fca0d4
ADDR END = 0x8fca0d5
CTOR
ADDR BEG = 0x8fca0e0
ADDR I = 0x8fca0e8
ADDR B = 0x8fca0ec
ADDR END = 0x8fca0ed

A prerequisite b4 we run the program ,
run the following command:

[]#ulimit -l unlimited

to set the core dump size to unlimited .

Original Article at :http://cprogrammers.blogspot.com/2009/02/c-heap-marker-to-detect-memory-leaks.html

Authored by :

Jayanthi GM ( Course Instructor for Java ,PESIT )
Prashanth Raghu ( Student Assitant )