I made a change in the blogger configuration to ease the later work when blogging. It is possible that older entries are not correctly formatted.

Saturday, 30 June 2012

Useful to open firefox files under cygwin

I use cygwin extensively under windows. So I often need to open urls in firefox or in some other client. I finally found a was to implement this with simple alias and a bash function. It took me sometimes, but I guess or hope I learnt some thing.

You only need to put this in the .bashrc file or equivalent.

alias firefox='defCommand "/cygdrive/c/Program\ Files\ \(x86\)/Mozilla\
Firefox/firefox.exe"'

function defCommand(){
  PARAM=`cygpath -m $2`
  NEW_COMMAND="$1 file:$PARAM";
  eval $NEW_COMMAND
}

Wednesday, 27 June 2012

sed HERE documents and bash

I tried to create a small template and replace the value of the variable using sed. Here is the following code:

#! /usr/bin/bash


TEXT= cat << 'TEXTEND' #! /usr/bin/bash



CLASSPATH=



for a in #{LIBRARY}/*.jar ;
do
CLASSPATH="${CLASSPATH};$a"
done
echo $CLASSPATH
java -cp $CLASSPATH

TEXTEND

TEXT=`cat $TEXT |sed -e 's/#{LIBRARY}/lib/'|cat `

echo $TEXT



This code does not work correctly yet!

Mocking

Since I keep being annoyed at my inability to test classes quickly, I have to see if I can improve the speed of the testing using mocks. Mocks can be used in different ways. In particular they can be used in behavioral testing.

The idea us that instead of injecting existing classes in a code, one puts mocks which expect actions from the caller.

To illustrate the point, it is good to use an interface for the class called (and therefore to be mocked) and a class calling this interface. We first define the interface: Algorithm.

public interface Algorithm {
   void perform();
}

Then we define the AlgorithmUser class which calls the algorithm. We give it an algorithm.

public class AlgorithmUser {
  void performAlgorithm(Algorithm algorithm){
    algortihm.perform();
  }
}

After that we define a test and create a mock instance and define the expectations. To do this we use the JMock library.


@RunWith(JMock.class)
public class PublisherTest {

  private Mockery context = new JUnit4Mockery();

  @Test
  public void testPerformAlgorithm(Algorithm algorithm){
    // create the mock
    final Algorithm algorithm = context.mock(Algorithm.class);
    // create the expectations
    context.checking(new Expectations() {
      {
        oneOf(algorithm).perform();
      }
    });
    // perform
    new AlgorthmUser().performAlgorthm(algorithm);

  }
}

The power of mocks reside in the language which can be used for this checking.
To user jMock, there is a cheat sheet.


The different frameworks I know of:

Sunday, 24 June 2012

HTML PDF Rendering with itext and flyingsaucer

I want to perform automatic pdf rendering from xml for helping a project I am working on. But I have not completely found out how to do this. It seems that combining flying saucer (which is a HTML renderer for java and iText should do the trick. However, I am not sure how good this will work for new html versions.

I will try to keep this up to date with new development of my experiments.


The first experiment did not work correctly with the following code:

#! /usr/bin/bash

CLASSPATH=

for a in flyingsaucer-R8/*.jar ;
do
CLASSPATH="${CLASSPATH};$a"
done
echo $CLASSPATH
java -cp $CLASSPATH org.xhtmlrenderer.simple.PDFRenderer $@

The code being called in the following way:

./render.sh http://www.google.de pdf

Cygwin Packages setup.exe and command line

It seems that there is the possibility to use setup.exe to perform some action for the management of cygwin packages. The link: http://cygwin.com/faq/faq.setup.html#faq.setup.cli shows the diverse options.

I will take a look at it and try to improve my pakage management.

xmllint tutorial

http://linux.byexamples.com/archives/565/your-xml-friend-xpath-command-line-xmllint/ is a very small tutorial on how to use xmllint. I think I should try it a little bit further. Currently it did not do what I wanted it to do.


while trying xmllint on a settings.xml file from maven, I was having trouble getting the content out. After looking for the way to do it in internet, I found out that you need to set the namespace you need to look for even if it is the default namespace. I am not completely sure about the reason why. Anyway, that is how I did it:

> setns r=http://maven.apache.org/xsd/settings-1.0.0.xsd
/ > cat //r:settings
/ > cat //r:id
/ > setns r=http://maven.apache.org/SETTINGS/1.0.0
/ > cat //r:id
-------
<id >jsf-app-profile </id >
-------
<id >snapshots.jboss.org </id >
-------
<id >repository.jboss.org </id >
-------
<id >sonar</id >

Script and scriptreplay for recording and replaying a bash session

http://linux.byexamples.com/archives/279/record-the-terminal-session-and-replay-later/ is a page explaining the use of script and scriptreplay in order to record a bash session and play it again. I really find this very useful, though I do not really use it very often. But perhaps using this tutorial, I will manage to use it.

Python and Templating

For many purposes, it is useful to use templating engines. Looking for emgines I found the following site: http://wiki.python.de/Template-Engines.

That said it is a good question for me to know the aspects a template engine should have. Here are a few features I should look forward to:

  • expression's language
  • method chaining
  • macros
  • includes

Of course the more a language has features, the more complex can be the design or templating languages for developers. Moreover, the features may allow unwanted actions, therefore, it is important to make sure that these unwanted actions are limited.

Cygwin and Home directory

I was getting annoyed that my cygwin home directory was not easily accessible from my normal directory and vice versa. So I found out how to do this (I should have thought how this is done as an exercise first) by googling it. It is really easy. Just set the correct directory in the /etc/passwd file and the trick is done.

Tuesday, 19 June 2012

Law of Demeter and the Demeter project

I wanted to take a look again at the law of Demeter. In order to see whether there is a good way at looking at this to code more efficiently and more cleanly. I stumbled upon the following project: DemeterF. I will have to take a look.

Sunday, 17 June 2012

gitolite

An alternative to gitosis: gitolite. I have not tried it yet. But it is perhaps easier to install than gitosis.

Requirements for a Server

Here I want to sum up the different requirements which a server may/must provide.

  • Access
  • Upload access
  • Languages
  • Space and Bandwidth
  • Machine
  • Domains
  • Email
  • Statistics
  • Types of use
  • Support

Some cases are only supported if the server is dedicated, i.e. if the server is taken completely for the applications of the client.

Access

If the server is a dedicated server you need to be able to control a number of programs you set on it. For instance, you may need access to the web server, or the mail files. Usually, the access is performed per SSH. If the user can only control the content of the pages of the web server, then an FTP access is usually enough. This access may also contain the access to the logs of the system. However, using FTP the user cannot start or stop any program. This might be done however using an Web client offering different standard actions, such as starting the web servers again, or even restarting the machine.

Upload access

For Web hosting possibilities, it is possible to offer different means of uploading the necessary data to the server. For this, FTP is generally used. But some server also provide PHP or JSP uploads.

Programming Languages

HTML + Javascript is the language which browser typically understand. But, for most complex pages, it is necessary to choose an appropriate language to generate the HTML as well as to perform the necessary actions on the server. For this, different kinds of frameworks and languages exist. In particular, script languages like PHP, Perl, Python and Ruby or interpreted but compiled languages such as Java. While PHP is mostly more suitable for small dynamical web pages, Java simplifies the construction of complex multi-tiered applications, i.e applications which can be distributed on a certain number of different computers.

Space and Bandwidth

Well I am not yet sure which requirements I have for this. I will have to try to find the answer for this question myself.

Machine

This is also not clear what requirements I have to the machine. It should be a linux box. But concerning the actual hardware, I do not really know.

Domains

I should set a domain. I have not done it yet. But it should be easily done.

Email

There should be the possibility to have a mail server in order to perform mail tests.
But I should take a close look at the configuration of mail servers.

Statistics

Types of use

I have planned a number of uses for a server:

  • mail server
  • Http server
  • FTP server
  • Tooling server
  • vnc server if possible
  • as application server for X
  • test server

Support

Well this is a topic I have to see what is needed.

Useful tools

As I was looking for a tutorial to set up a git repository for my server, I found the following list of tools. I have taken only a brief look at the list. But I thought I might as well reference it here. In order to come back to it later on.

Sunday, 10 June 2012

Open Graph Protocol

I had a short look at: Open Graph Protocol. This is interesting. I have to see what are the implications that this protocol has.

Ruby Tutorial

Just performed again the ruby tutorial in 20 minutes.
It was kind of cool. I noticed a few nice things about ruby, especially, I must say that appreciate Duck Typing.
It might not be very secure, but it really sounds useful.

Google and Tasks

I finally got to take a look at tasks in Gmail. And I must say this is pretty cool.

Go and take a look for yourself at this place.

packages to install on the server

## java java 6 is installed

## perl are installed
## ruby
## python

## CURL
curl
get was installed

## tomcat
tomcat6 is installed
tomcat7 should get installed
tomee should get installed

## Editor
emacs-nox got installed
vim

## Databases
mysql
postgres

## maven
maven only maven2 was there ... installed maven 3

## ant
ant installed the latest

## nagios



## git + git-daemon +gitosis

## VNC

## svn

## jenkins

## sonar

## XServer ?


##FTP
pure-ftp

Simple script to install some packages for my server

#! /bin/bash

#CMD='apt-get -y install %s';
CMD='echo %s';
REGEXP='(#.*|^\s*$)'



function installPackage(){
PERFORM_CMD=`printf "${CMD}" $1`;
echo ${PERFORM_CMD};
${PERFORM_CMD};
}


function installPackages(){
while read line
do
if [[ $line =~ $REGEXP ]]; then
continue;
fi
installPackage $line;
done <$1 } # for PACKAGE_LIST in installfiles.txt; do installPackages ${PACKAGE_LIST}; done



Saturday, 9 June 2012

Gnome 3.0 ARRRH!#"§$#!!!

Rant and perhaps solution

I finallly reinstalled fedora. So now I have a completely new Fedora version and I am not amused. Really not amused. First I had trouble with Grub, then I had trouble with the DNS and finally I had to curse against gnome 3.0. Or is it only unity... I am not sure. I do not rant. But this time, I am more than annoyed. I would not say I am pissed off. But nearly. I keep asking myself: why? Why? Why?


First of all Grub... Actually I did not want to reinstall the boot directory from Grub. I wanted to be able to use my old fedora if I needed it. But that did not really work. So I let the new fedora (or I should say anaconda, overwrite the boot loader).


Then, for some reason the DNS was not configured and I had to reconfigure it per hand. Why ?


Finally, how is gnome 3.0 supposed to be used. Why can't I create my desktop icons ? Why can't I add launchers to the panel or the desktop. My computer is supposed to be used. I do not care really how it looks.


I just found the solution in this post for at least some of my problems

Tuesday, 5 June 2012

Sonar - explore and improve your code

For a while now I have been using extensively the features of sonar.
For those who have never heard of sonar, it is a tool used to gather and present the results of different software quality tools, such as pmd,
cobertura.


Sonar provides for each project the following information:

  • lines of code
  • complexity
  • number of unit tests
  • ...

Saturday, 2 June 2012

Certifications

Currently I am quite interested in doing a few certifications in order to round my professional profile a little bit. It seems to me that for this certifications are quite appropriate. Therefore I intend to do the three following certifications:

  • IREB's CPRE for requirement engineering
  • ISTQB for software testing
  • iSAQB for software architecture

Of course, I still have a lot to learn in these domains. But still this will provide me enough background. Parallel to this I hope that I am going to be able to gather supplementary experience. For example, I believe I need to learn more on the soft skills needed to be a good requirements engineer. We'll see.

Spring Testing

This entry contains necessary information about Testing with Spring. One of the most interesting feature of the Spring Framework is the use of lightweight containers which simplify the testing of an application, whether the usual J2EE container can be more cumbersome to test.

Since there are so many aspects in Spring, I should first present a given overview of the different topics.

Dao Testing

Spring provides different mechanism to simplify testing. In particular there is a class to perform Dao testing by including the transactional aspects. You can easily load your daos using a xml file to initialize the configurations of the database and daos.

NOTE to myself: I hsould give here a code example.

Controller Testing

Here again Spring controller are quite easy to test. They require very little overhead. And the dependency injection provide a very simple setup.

NetBean

After I had some discussions with some friends about their works as developers. They mentioned that they were using NetBeans as IDE. Curious about it. I downloaded it. I tried some JSF example after trying to create a Rails project failed because the grails website was not available.

My first impressions are not bad. It seems to be a quite nice and quick interface. But I am a little bit lost.

So what should I do and look at to study this new (to me) IDE.

The following points seem important to me:

  • editor issues, error, warnings as well as suggestions
  • Maven integration
  • SCM integration, i.e svn, git
  • debugger integration
  • servers creation and use

These are the points that seem important to me.
But I have the feeling that the list is not yet complete enough... Not even in the pareto sense.