Monday, October 08, 2012

Exploring Pyreverse UML

Installing pylint for python came with an extra package called pyreverse. This wonderful little package gave ability to create class diagrams from python code. Simply writing the following code produced the png files of class diagrams.

$pyreverse -o png * 

This would create png files which can be used for documentation as well as design review meeting. A very handy tool which won the day for us.

Monday, February 14, 2011

Getting Wireless Up on Ubuntu 10.10 DELL VOSTRO 1500

After long long hours of searching and head scratching the following two-step process helped in getting the wireless up and running on Dell Vostro

Step 1: Flash BIOS

Go to the link and flash the bios according to latest.
Simply download the file and install the program and reboot.
This would enable the wlan in Ubuntu.

Step 2: Update Driver
Update the wireless driver using the following command.
$ sudo apt-get update
$ sudo apt-get install bcmwl-kernel-source
This should be done and after a reboot the Wireless should be up and running.

Immense help for this was taken from here and here.

Twofolds Joy of using Ubuntu

Frequent inhibitors to migrating to Ubuntu are what if something goes wrong, where will my windows go, what if I don't get everything working and topmost is I have only one partition what to do now don't wish to risk any partition magicians. A quick fix to all this rests in using Windows-based Ubuntu Installer (Wubi). If something goes wrong you don't lose windows, hard disk space and top of all your patience with Linux-derivatives.

All it takes is the following simple steps

1. Go to the Ubuntu Windows Installer Link
2. Let the 1.4 MB or so file to download and then install click.
3. Then let the application take charge while it asks for minimal information like username and password.
4. Boom after a couple of restarts and long download (700+ MB)you will have a copy of Ubuntu lying alongside windows harmless.
5. If you encounter some hiccups then its best to go to the windows and ask around google and then apply the fixes. This is the fun part that such hiccups no longer are fatal.

Best of luck Happy Hunting Ubuntu

Monday, November 01, 2010

Ubuntu Update Manager's Proxy does not change when system proxy is changed

All efforts to change the Update Manager's proxy come to a grinding halt without any solution. The reason for this fallout is that the proxy is "hidden" at a very safe location. Ubuntu Update Manager's proxy does not change after changing the system-wide proxy or proxy of synaptic program. The reason is that it uses the apt-get's proxy settings. Which can be amended by looking at the /etc/apt/apt.conf file. This file contains the information about proxy servers.
Acquire::http::proxy "http://ProxyServerAddress:ProxyServerPort/";
Acquire::ftp::proxy "ftp://ProxyServerAddress: ProxyServerPort/";
This information can be amended to gain direct access to the internet or if the need is to change to a different proxy server. 

Saturday, October 30, 2010

The easiest SVN tutorial ever

Browsing through the Internet its extremely difficult to find  the subversion(svn) commands in an instance and be productive immediately. So here is the step by step list of instructions which can be followed to accomplish the most common tasks of svn.

We would use the project on Sourceforge named Dr. Java as an example.

If the project is already there and you wish to CHECKOUT some code to view here is the command.
$svn co drjava
Now if you wish to add new file to the svn repository the command is very simple. For example if you wish to add the text file readme.
$svn add README_TEXT
The above command will not add it to the server but add it to the schedule. If you wish to view current status of additions, deletions that are scheduled you could use the command
$svn status
And finally if you are satisfied simple do the following and the commit will be done meaning all the changes will now be part of the repository and a new version will be assigned. REMEMBER adding/ deleting/ changing code in a repository requires permissions. Therefore you might be prompted for passwords during the process.

$svn commit
This is all the information that you need to get past the basic svn commands and concentrate on your project.

Now that you have gone through one cycle it would be easier to use the following command to explore other features of svn.
$svn help

Tuesday, October 26, 2010

MySQL quickest way to look at databases

Looking for MySQL's administration tool is a task. Installing and configuring PHPMyAdmin would take Apache, php and then successful configuration. Then what to do to look at the tables, databases in the fastest possible way to look at tables and execute queries.
$ mysql -u username -p
the command will prompt for a password
mysql> Show databases;
mysql> show tables;
 The above two commands are extremely useful when one wants to look at the databases installed and tables in individual databases.

For example to look at users tables in database drupal the following commands will suffice.

mysql> use  drupal6;
mysql> select * from users;

These commands can be used in both Linux and Windows and are very handy and dont require much to do.

PHP Issue :: preg_split instead of explode function

If the need is to parse a string and extract the words. Then its advisable to use preg_split instead of using the explode function.

Code follows :
preg_split ("/\s+/",$textInput);
where the first argument is the regular expression for finding one or more spaces and the second argument is the input text.

This option works far better than the explode(" ", $textInput).

Tuesday, September 21, 2010

Judging the Joomla Jungle :: The Premier CMS

First experience of using a comprehensive Content Management System (CMS) was Drupal way back some years ago. Before that content management meant either using Front Page or direct FTP of the webpages. Despite "hearing" a lot of good reviews about Joomla never really got the time to explore it.

First Steps
The first steps towards installing Joomla in Linux are the usual for web servers. Install LAMP (Linux, Apache, MySQL and PHP).  After testing LAMP's successful installation proceed with the following.

Download Joomla from the website and follow the instructions given in INSTALL.PHP file in the main folder. Copying the instructions from the php file verbatim here. Copy the folder into www directory of Apache.

{verbatim copy starts}
First, you must create a new database for your Joomla! site e.g.

    $ mysqladmin -u db_user -p create Joomla
MySQL will prompt for the 'db_user' database password and then create the initial database files.  Next you must login and set the access database rights e.g.
    $ mysql -u db_user -p
Again, you will be asked for the 'db_user' database password.  At the MySQL prompt, enter following command:
        TO nobody@localhost IDENTIFIED BY 'password';
    'Joomla' is the name of your database
    'nobody@localhost' is the userid of your webserver MySQL account
    'password' is the password required to log in as the MySQL user

    If successful, MySQL will reply with
    Query OK, 0 rows affected
    to activate the new permissions you must enter the command
    flush privileges;
    and then enter '\q' to exit MySQL.
 Alternatively you can use your web control panel or phpMyAdmin to create a database for Joomla.

{verbatim copy ends}

So once the installation was complete simply go to the http://localhost/joomla (depending on where you stored the joomla in the apache directory. This would launch the web installer and answering a couple of simple questions results in the installation of Joomla.

Ooops where are my other databases !!!!
Having installed and worked on Joomla I realized that my other databases have been lost. Moreover the admin password has been lost. So I had to recover the  password again via the instruction given here. This glitch created  a lot of headache but finally after recovery of the admin password.

Using the CMS
The result of this installation procedure was a sleek joomla content management system. Its extremely easy to get started and actually use via the admin panel by going to the http://localhost/jooomla/administrator.
The whole website can be managed through a set of menus and control panel. There is the template manager which helps in installation of new templates as well as edit/ preview/ apply templates. The other important aspect is easy maintenance of posts. The CMS is nice although it takes time to figure out the whole concepts. In contrast to Drupal (which was really easy to manage via the web interface of admininstrator account) Joomla lacks a bit of such flexibility.

Next Steps
The next steps is installation of themes and extensions. In this regard the following seems attractive and worthy of exploration.
  • Financial Extensions
  • Site Analytics

Tuesday, August 17, 2010

Learning Probability via Octave

Probability is a subject which brings everyone sleepless nights. Octave, the MATLAB clone or for some MATLAB wanna-be . GNU Octave is a high-level language, primarily intended for numerical computations. The best way to learn octave is to take a difficult task (or goal) and then start using it.

Octave Basics
Octave can be installed using the following command in Ubuntu.
$ sudo apt-get install octave
Once installed octave can be invoked via the command.
$ octave
Its best to understand the modus operandi of Octave. Like lists are the primary data structures in LISP Language. In octave vectors are at the core.  Vectors are used to store information, manipulate information via vector algebra and display data still using 2D/3D graphics. Applications of octave are huge but we will use probability as a starting point and see how we can learn better probability using the computational and graphical features of octave.

Uniform Probability Distribution
Uncertainty of events can be modeled using concepts of probability. If a set of events is equally likely to occur then we say that the events have equal or uniform probability of happening.
The first step towards developing a mathematical model for probability is to map real-life events to random variables (in our case the random variables will take on values from real numbers). Thus we say that instead of using real-life events we will refer to values 1, 2, 3, 4, .... when talking about events (e.g., Sun rise, Sun Set etc.). Lets use the example of a dice having six faces each one marked with number 1, 2, 3, 4, 5 and 6 respectively. The events of getting a particular face after rolling the dice are getting face marked by either One, Two, Three, Four, Five or Six. Since we cannot say with certainty  which face will come up on  roll of  dice. We say that x which is a random variable which takes on values {1, 2, 3, 4, 5, 6} corresponding to the aforementioned events.
Now this information can be stored as a vector x = [1 2 3 4 5 6] and so lets see the corresponding command in octave by simply typing x=[1 2 3 4 5 6].
octave:1> x=[1 2 3 4 5 6]
x =

   1   2   3   4   5   6
The following values x = and followed by 1 2 3 4 5 6, shows the value stored in the vector x. This display can be avoided by placing a semi-colon (;) at the end of the command. Now that we have declared a variable named x with values lets see how octave stores it. This can be achieved anytime by writing the command whos on the command line of octave.
octave:2> whos
Variables in the current scope:

  Attr     Name        Size                         Bytes       Class
  ==== ====        ====                     =====  =====
                 ans         1x30                             30        char
                   x           1x6                               48        double
The size of variable x is 1x6 which means that its a vector (matrix) of size 1 row and 6 columns, with 48 bytes needed to store it while the class of variables in double.

Now lets see what is the probability of getting a particular face. Since all the faces of the dice have an equal probability of showing up hence the probability of getting a 1 is equal to the probability of getting 2, 3, 4, 5 or 6. Therefore in our model the probability given by p(x) = 1/6 {where 6 represents the total number of possibilities}. Now lets calculate the probability of the events using octave.
octave:3> px=1/6*ones(1,6)
px =

    0.16667    0.16667    0.16667    0.16667    0.16667    0.16667
Here in the above code we have used the function ones which helps to declare a vector of size 1x6 and initialize it with ones. We simply multiply it with 1/6 to get 0.16667 in all the elements. In order to check what is the probability of event 3 simply write the following command.
octave:4> px(3)
ans =  0.16667
Similarly for all the other events.  This was simple because we used the simplest possible probability model.

Normal Probability Distribution
Moving further lets move to a more "realistic" probability model. Normal Probability Distribution is a very practical to model most situations. Special thanks to Guillaume Riflet's website for the equations in this article.
 f(x) = \tfrac{1}{\sqrt{2\pi\sigma^2}}\; e^{ -\frac{(x-\mu)^2}{2\sigma^2} }
Trying out this equation in octave gives the following resulting. Now using the same number of events x=[1 2 3 4 5 6]. The mean (mu)=3.5 and variance(sigma)=1.
octave:5> mu=3.5; sigma=1;
octave:6>  fx=(1/sqrt(2*pi*sigma^2)*exp(-(x-mu).^2/(2*sigma^2)));
fx =

   0.017528   0.129518   0.352065   0.352065   0.129518   0.017528
Since the mean was selected to be 3.5 therefore we can see that the probability of 3 and 4 are maximum here while the probability decreases as we move away from 3.5 on either side. Now this is the classical "bell shaped" or Gaussian  curve. This does not look clear because we took only 6 data points to plot the curve we can improve the points by using the following code and the resulting graph is shown.
octave:8> x=[1:0.1:6];
octave:9>  fx=(1/sqrt(2*pi*sigma^2)*exp(-(x-mu).^2/(2*sigma^2)));
octave:10> plot(x,fx)

Now that the data points have been increased the graph is much more smooth and looks like a bell shaped curve and the probability is now really maximum at point 3.5 as should be since mu (mean)=3.5.

Multivariate Probability Distribution

In order to generate further interest now lets look at multivariate normal distribution. The following equation gives us the multivariate normal distribution here the x and mu are d-dimensional vectors defining the multidimensional event and means while sigma is the co-variance matrix.

p(x)=\frac{1}{(2\pi)^{k/2}|\Sigma|^{1/2}}\, e^{ -\frac{1}{2}(x-\mu)'\Sigma^{-1}(x-\mu) }
The above equation requires further constructs like for-loop to be implemented in Octave lets use the example given at wiki to learn.
octave:10> mu=[40, 60]; sigma=[100, 30; 30, 140]; octave:39> isigma = inv(sigma);
octave:11> detsigma = det(sigma);
octave:12> coeff = 1/(2*pi*sqrt(detsigma));
octave:13> for i=1:100
>    for j=1:100
>        x = [i;j];
>        xm = x - mu;
>        p(i,j) = exp(-0.5*xm'*isigma*xm);
>    end
> end
octave:14> p=p*coeff;
octave:15> [X,Y]=meshgrid(1:100,1:100);
octave:16> surf(X,Y,p);

The plot above is a 3-D graph of the multivariate normal probability distribution of p(x,y) depending on two variables x and y. The above methodology helps us learn probability in a fun manner as well as get familiar with octave's computational and graphical features.