Tuesday, December 25, 2012

Linux: The power of Open Source

Everyone that had a go with Linux, has an idea of what Open Source Software means. For those who don't, open source means that the code of the programming language that the software is written and in general the pre-compiled units of it are available to the public.
This gives a lot of advantages. Many programmers can contribute to the code or users that know a couple of things in programming can modify a piece of code and re-compile it to cover their needs and then maybe share it with others that have the same needs. That's how every open source community has been working so far.
We've all heard about it, but few of us have seen it. How do we modify the code? How do we find it? There are a lot of possibilities and options here. For example, most recent programs for Ubuntu are written in Python (e.g. Gwibber). In those programs it won't be difficult to find the code, since Python is not compiled but it's an interpreter based environment. In other words, you can see the code if you open the program with a text editor.

Let's see the real stuff now with an example. We came along the program "fortune" recently and tried to run fortune -f in Fedora, which displays the files that fortune looks at to generate a fortune cookie. We wanted to pass the output data through pipe but it didn't work:
fortune -f | grep humour
After a couple of failures, we assumed that the output was redirected to STDERR instead of STDOUT. But, this is unacceptable code practice. Why send data that are normal output to the error stream? So we downloaded the fortune source rpm package. Here is the process that followed:

  • Find the repository of the fedora-mod.rpm, google is your friend.
  • Find the source code which is in form fortune-mod.src.rpm
    Create a folder in your home directory (/home/username/) named rpmbuild and inside it a directory named SOURCES 
  • Install developer tools and recode-devel: sudo yum install @development-tools recode-devel
  • Extract the rpm in the /home/username/SOURCE/ directory.
  • Modify the code, in that case we found fortune.c and changed in the function print_list() every fprintf(stderr... to fprintf(stdout... (yes it was that simple)
  • To compile it and pack it run rpmbuild -ba fortune-mod.spec.
You can find the rpm now in the rpmbuild/RPMS directory from where you can install it but first run yum remove fortune-mod if you already have it install in your machine.

We've found the source from here

Thursday, October 11, 2012

Android presentation

Download the android presentation (08/10/2012- Man-UP) from here.

Sunday, January 8, 2012

jlab : Your own Java Testing Lab by VasLabs for you!

What is the way of programming big programs? You create object classes and test them individually. You configure them to work as you want and then you put them together to form a nice new shiny program.
Most of the programmers use IDE's to do that. However, if you are a hardcore of the kind, you may wish to create your own environment just as how you like it to be.
VasLabs has created a small script to give you ideas and/or help you start building your own lab environment to do what everyone does in labs; tests!
The philosophy behind it is that for every object class you get a test class. And for every test you do, you can view a log file containing the results. Then you can compare it with the expected results by reading it or using cmp, or even better, you could initially create a file that contains the expected results and then use jlab to run the test by comparing for you both results.
The program works on your current directory. I.e. you should change directory to the directory you want to build your lab and then run jlab.
Here is the manual of the program (you can also view it by running jlab without arguments):

To use this program use the format jlab --argument [file]
The list of available arguments are:
Initialises your lab environment in your current directory creating the appropriate folders

--create [file1 ... fileN]
Creates the given class names and puts them in the src directory. It also opens them using gedit

Creates a test class for each class in the src directory. It then opens them with gedit

Compiles every src file in all directories and puts the .class files in the bin directory

Runs all tests and puts the results in log files. Then it opens the log files with gedit

--test file expectedResults
Runs the given test file and compares its results with the given expectedResults file. If there is a difference it opens the results with gedit

Requires: gedit text editor

Author: Vasilis Nicolaou
Distributed by: vaslabs
User Agreement:

This script shall be used with care by people who know what they are doing. This program intends to help building a java lab. By java lab
we mean a virtual environment that behaves like IDE with the difference that offers simple functionalities for testing java object classes.
The author has no responsibility for any loss of data or damage caused by using this script.
You can edit and re-distribute this script as you wish. If you do not agree delete this script file from you computer.

Tip: You can create aliases for every different functionality and put it in .my_bashrc

Using this idea you can build a similar lab for every language or facility you want.
Download it from here.
This is written in bash, and therefore can be run only on Unix based OS which have bash installed.
By VasLabs