First steps with Git

To set some important configuration properties for Git use the following commands:


$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
$ git config --global merge.tool meld

The properties are set for all repositories on the current machine.

Fail2Ban

A tutorial (in German):
http://blog.256bit.org/archives/383-fail2ban-und-der-Kampf-gegen-Trackback-Spam.html

http://www.fail2ban.org/wiki/index.php/HOWTOs
http://www.fail2ban.org/wiki/index.php/MANUAL_0_8

PHP_CodeSniffer standards

Look into /usr/share/php5/PEAR/PHP/CodeSniffer/Standards

All sub-folders there can be used as standard name:


phpcs --standard=PEAR test.php
phpcs --standard=Zend test.php

Use keywords with SVN

You can use keyword replacement with Subversion. A good tutorial is available on http://www.startupcto.com.

Eclipse, Windows and Subversion

Yesterday I had to use Windows with Eclipse and I needed access to our Subversion repository. But we use SSH with certificates and I had a lot of trouble to get a working system. At the end I have installed TortoiseSVN and PLink to test the access.

First use PLink and check the access to your Subversion server. The certificate can reside within a running PageAnt or you can set the local path to your private key direct in the command-line.


"c:\program files\plink.exe" -2 -P <port> -noagent -i "H:\\keys\\subversion.ppk" user@server

This should create a connection to the user account on the Subversion server. You have to set double backslashes within the key parameter, because PLink is a Unix program, which uses backslash as escape character for the following character.

An alternative will be:

"c:\program files\plink.exe" -2 -P <port> user@server

if you use PageAnt and your certificate is imported there (you should look twice!). If you have a working connection, you can close it and now open TortoiseSVN->Settings. You will find a button, which lets you open the configuration file for Subversion.

TortoiseSVN settings

TortoiseSVN settings

In the configuration file define your own [tunnel] entry, which you can use as protocol extension. In example, you define a [tunnel] named as “work”, you can access the repository with:


svn+work://user@server/repository-path

Open the configuration file and scroll down to the [tunnels] sections. Now you can define:


work = "C:\\Program Files\\PLink.exe" -v -2 -P <port> -i "H:\\keys\\subversion.ppk" -noagent

You have to use double backslashes also for the program path to PLink, because TortoiseSVN uses also the UNIX notation. Now You can test the [tunnel] with your TortoiseSVN installation. Open your repository browser and enter the Subversion Uri as described above. Some command windows will be open, this is a side effect of PLink. If you can see the repository tree, we should test it without the explicit key notation and work with PageAnt.


work = "C:\\Program Files\\PLink.exe" -v -2 -P <port>

If the [tunnel] works again (PageAnt should run and the key should be imported), we replace the PLink with the TortoiseSVN internal variant, which is called TortoisePLink. This program doesn’t open a command window.


work = "C:\\Program Files\\TortoiseSVN\\bin\\TortoisePLink.exe" -v -2 -P <port>

Test it again with the repository browser. If all works fine, we can now open Eclipse to configure a repository there. I have installed Subclipse and JavaHL as connector. Go to Window->Preferences->Team->SVN and you can see the client “JavaHL (JNI)” with a specific version number. I’m not sure, whether or not Eclipse loads the Subversion config file from the Tortoise installation as default. So I have changed the location to the config file, which we have modified above. Normally you can find it within “C:\Documents and Settings\\Application Data\Subversion”. Check the content of the config file there, it should contain your [tunnel] definition.

Back to Eclipse, save the settings and open the Subversion perspective. Add a new repository and use the Uri:


svn+work://user@server/repository-path

That’s all.

Code Formatter Eclipse PDT

You can download a cool extension from http://sourceforge.jp/users/atlanto/pf/eclipse/files/ which allows you to define the code format for your PHP code. Install the .zip-file as archive with Eclipse’s “Install New Software…” feature.

Find all used IP adresses within a subnet

If your local computers allow a ping, you can simply execute:


nmap -sP 192.168.x.*

where x is the subnet number (1 <= x <= 254). You will get a list of all hosts, their IP addresses and their MAC addresses. That is really cool for DHCP networks, where you don't know, which IP addresses are already been used.

Log file of the Eclipse workspace

All errors are logged within


${WORKSPACE}/.metadata/.log

Here you can see ClassNotFoundExceptions and timeouts of I/O operations (like Maven index download).

Set the localtime on a Linux system

cd /etc

Set the timezone of your server location:

ln -sf /usr/share/zoneinfo/Europe/Berlin localtime

Check the new settings with:

date

If you have set the hardware clock with an UTC timestamp, the date command will calculate the correct time offset using the localtime settings (including daylight save time switch).

Access private fields per Reflections within Glassfish

You can not access a private field per Reflections, if your application runs on Glassfish. You have to set a policy entry on the server to permit it:

1. open the security policy file: glassfishv3/glassfish/domains/domain1/config/server.policy
2. include the following entry:

        grant codeBase "file:${com.sun.aas.installRoot}/domains/domain1/applications/arena-dwr/-" {
            permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
        };

Don’t forget to replace the arena-dwr by the name of your application, and also to check project path if you are not using the default container instance domain1.

Then you can call:

   Entity.class.getDeclaredFields()

without a SecurityException.