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:
--initialise
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

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

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

--run_tests
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
08/01/2012



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


Tuesday, December 13, 2011

The great convert tool of ImageMagick


It's of those days where you are just wondering why you are failing to program as usual. Your mind is sleepy, your thinking slow. While drinking a cup of coffee in order to awake your brain (even if you know that in such situations coffee just fails) you listen something not so important (as most things sound at the beginning). "I have a large pdf file how do I reduce its size?".
(I want to inform you now that this article is not about pdf resizing).
Then, as the coffee sinks in, along with this words, there is another question on the horizon. Can you reduce anything without losing something? Of course not. Anyway, that's not my point.

I decided to try and find how to do that, with linux, using scripts. After a couple of google searches I found ghostscript. It was quite a fail, since the pdf was at its minimum size that ghostscript could convert, so it made it bigger.

Then, I looked at my pictures. I always do this when I fail to find a solution for something. Great images, with high resolution. Hang on! What about making every pdf page as a jpg file and then reducing the resolution of those images, and after that putting all these images back as pdf pages?

If you have the knowledge of a normal user this could mean hours of work, especially if pdf has 100 pages. Imagine having at the end another bigger pdf file.

So, I realised that it was a lot of work. What about using a script to do that? Here it comes the convert of ImageMagick!

I might failed to find an optimised solution for the pdf problem, but I've found a great tool! Convert is a terminal program created by ImageMagick that can convert any image file into another by user's will. In addition, it is open source, written in C.

You can reduce your size of your images, transform them, skew them, flip them, change colours with mapping and more more advance image things! It's like having photoshop in a small program, without the heavy brashes and tools. Type the commands, you have your image converted. Just visit man pages on your linux. Or visit  http://www.imagemagick.org/script/convert.php to download a version with GUI or for a different operating system.

For the story, I used this to convert my pdf:
convert input.pdf -scale 500 output.pdf
And got a smaller file with a terrible resolution.
Anyone knows anything about it?

That's a story about how something irrelevant results to an exploration of another irrelevant thing (but useful).


So, even if you are going to fail, never mind, explore! Even if it's pangolins! :)

Monday, November 14, 2011

Computer Synesthesia

Synesthesia (also spelled synæsthesia or synaesthesia, plural synesthesiae or synaesthesiae), from the ancient Greek σύν (syn), "together," and αἴσθησις (aisthēsis), "sensation," is a neurologically based condition in which stimulation of one sensory or cognitive pathway leads to automatic, involuntary experiences in a second sensory or cognitive pathway. People who report such experiences are known as synesthetes. (http://en.wikipedia.org/wiki/Synesthesia)

Here, we are going to illustrate Synesthesia as a situation where a person (in this case the computer) hears images. I.e. instead of seeing them, the pathway goes from the eyes to the part of the brain that understands sounds (or something like that :))

How is it like to hear images? Let's hear one.

You have to have this tools:
A linux distribution
The pacat program (check if you have it, otherwise install it)
A little C (so we need gcc compiler)

Here is the code for reading a file. We are going to use it to read image files:

#include
int main(int argc, char *argv[])
{
int t = 0;
FILE *input;
input = fopen(argv[1], "r");
while (t != -1)
{t = getc(input); putchar(t);}
fclose(input);
}

Save it as sounds.c and compile it using gcc sounds.c -o sounds
Then use
sounds mypicture.png | pacat --format u8 --rate 8000

And you can hear your pictures and images :P Don't expect the sweetest melody :P