Wednesday 20 March 2013

Cool tool tip of the day: Rant and Rave

Gathering customer feed back can assist and drive sales.
According to Rapide Communications who produce the "RantandRave" product:

"The most important aspect of capturing feedback is timing. Response rates increase 10% to 12% and accuracy increases by 40% simply by requesting feedback straight after service delivery."


I interviewed with these guys and from the research I did their product sounds very useful.

http://rantandrave.com/feedback/capturing-customer-feedback/

Tuesday 19 March 2013

Cool tip of the day: Don't trust SSL

How good is SSL?

Not so great according to HAK5.org.
http://www.youtube.com/watch?v=PmtkJKHFX5Q

The key point on this video is don't be a n00b!
Check for real https and use SSH tunneling!

Friday 15 March 2013

Cool tip of the day: Ebuild

EBuild is an ant based generic build system for Java projects developed in Eclipse.

it can build almost any Eclipse java project with very minimal configuration.
it automatically figures out dependencies and build order based on the .classpath Eclipse files.

http://ebuild.firefang.net/

The project is about 5 years old and hasn't been under development for some time (not that it needs it).
I am currently working on this project with its creator to add a couple of new features. (watch this space) 

Project on Sourceforge: A generic ANT build script. http://sourceforge.net/projects/antbuildscript/


All you java developers ... do you find your self looking to create a build script to package up your beautiful code?
No?
Are you sure you are a developer?
I was packing up my other project (Beanmapper) and I though this might be handy to other people.

project on source forge: http://sourceforge.net/projects/antbuildscript/

However you really can't use this project with out using : ebuild a cute ant tool.

Cool tip of the day - Bitnami Stacks

When you need a LAMP stack or a Tomcat Stack for development ... what do you do?

Yes you go trawling around the net looking for all the bits and how to glue them together.
Well don't just go to http://bitnami.org/stacks and download their all in one stack.

My favorite is the tomcat stack!

Cool tip of the day - Newrelic server and app monitoring

 This looks worth an invertigate if you have some servers to watch: https://newrelic.com/

They say on their web site that they do the following:
New Relic is the all-in-one web application performance tool that lets you see performance from the end user experience, through servers, and down to the line of application code.

They seem to have the free try before you buy option while their full price offering is $24 per month. This could be considered expensive for some uses especially as it seems to be offering much that Google analytics also offers.

But one to think about nether the less.

Tuesday 12 March 2013

Quick Guide to setting up Tomcat on Linux

Tomcat's default website

Before starting

Check for the process:


# ps ax | grep tomcat

If it is installed it will show up in the response (don't be fooled by just grep tomcat).

And check the OS (see):
$ cat /etc/*-release
$ uname -m

This will tell you the release and whether it is 64 or 32 bit.

Install the Java JDK

Versions of Java can be installed using the “yum” tool (this will require super user rights). 
See: http://wiki.centos.org/HowTos/JavaOnCentOS


When installed I find that a convenience symbolic link "/java" is helpful.
Often the Yum tool places the files here /usr/lib/jvm/java-6-oracle
NB.
ln -s [TARGET DIRECTORY OR FILE] ./[SHORTCUT]

You can download the latest JDK here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
The problem with this site is that it asks for you to accept the license conditions before you can down load the file.
This can be done by checking the url you get after browsing the appropriate links (see but best done using firefox not IE).

We'll install the latest JDK, which is JDK 7, Update 17. The JDK is specific to 32 and 64 bit versions.

My CentOS box is 64 bit, so I'll need: jdk-7u17-linux-x64.tar.gz.

If you are on 32 bit, you'll need: jdk-7u17-linux-i586.tar.gz
ie.

wget http://download.oracle.com/otn-pub/java/jdk/7u17-b02/jdk-7u17-linux-i586.tar.gz

NB. I'm not sure this works at all so I used WinSCP and transferred the file.

Start by creating a new directory /usr/java: (# mkdir /usr/java).
Download the appropriate JDK and save it to /usr/java directory we created above.

Unpack jdk-7u17-linux-x64.tar.gz in the /usr/java directory using tar -xzf:
tar -xzf jdk-7u17-linux-x64.tar.gz  

DON'T FORGET!!! 
... Set JAVA_HOME and put Java into the path of our user!

JAVA_HOME=/usr/java/jdk1.7.0_17
export JAVA_HOME 
PATH=$JAVA_HOME/bin:$PATH 
export PATH 
   
NB. The export command will marks each VAR for automatic export to the environment of subsequently executed commands i.e. make the local shell variable VAR global. (see)

Check you did it correctly:

#echo $JAVA_HOME 
#java -version

One GOTCHA at this point can be the error "-bash: /usr/java/jdk1.7.0_17/bin/java: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory"

This is easy to fix (see here) by issuing this command:
yum -y install glibc.i686
 

Download & Install Tomcat

If necessary versions of Tomcat can be installed by hand or using “yum”.

Details on Tomcat can be found here: http://tomcat.apache.org/ or more specifically: http://tomcat.apache.org/tomcat-7.0-doc/index.html.

We can manually do this as follows (installing Tomcat 7 under /usr/share.).
Download and unzip.

# wget http://mirror.ox.ac.uk/sites/rsync.apache.org/tomcat/tomcat-7/v7.0.37/bin/apache-tomcat-7.0.37.tar.gz
# tar -xzf apache-tomcat-7.0.29.tar.gz

 From this point you should be able to start the process by jumping to /user/share/apache-tomcat-7.0.37/bin and running the start.sh

For more information on starting as a service : see http://www.davidghedini.com/pg/entry/install_tomcat_7_on_centos

NB. I haven't gone into the details of tidying up the service with symbolic links (an exercise for the reader and me to tidy up in future.) 

To check the process is working then the following operation will work:

#curl -I http://localhost:8080

 

 

 







Friday 8 March 2013

Virgin Media and Stackoverflow

I don't usually complain about my ISP Virgin media but recently I have found their tech support is shockingly bad.
While I will not dwell on one of their IT support guys doing a remote connection to my PC and resetting my network drivers ... blue screen of death!
It looks as if they would not know a network fault if it had a big sign hanging around its neck!
At this time it is impossible for me to access stackoverflow.com and as I am at home doing technical research this is a pain in the arse.
So after the support muppets have told me to restart my PC, change my network settings and reboot my modem ... even when I tell them the iPad can not connect they then tell me I need to contact stackoverflow directly and advise them that that they have blocked the IP range my requests are coming from. That is an interesting idea ... but I can't contact them because I can't get to their web site & emails are blocked!

But it isn't just me ... read on ...

One post suggested using a VPN, which I have now set up.
The free VPN I used was justfreevpn.com which did not at first work.
Why?
Because the Virgin Super hub blocks all PPTP traffic. (Go to your router-->Advanced Settings-->Security-->Firewall and select PPTP Pass through to be on.)





But now I have a VPN to enable when I need to access the blocked sites.

Struth!

Wednesday 6 March 2013

Cool explaination: A Visual Explanation of SQL Joins

I stumbled on this web page while doing a little revision. and when I read the comment "If you have tried to understand how joins work and constantly get confused about what join to use, you just need to keep a simple picture in mind (I like pictures). " ... as I like pictures I have borrowed them.

The joins are drawn in the form of  VENN diagrams.

The full article can be found here: http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html

We will start with just an empty diagram:



INNER JOIN
An inner join only returns those records that have “matches” in both tables.
 
In programming logic – think in terms of AND.
The SQL: SELECT * FROM T1 INNER JOIN T2 ON T1.name = T2.name

OUTER JOIN
An outer join is the inverse of the inner join. It only returns those records not in T1 and T2.

In programming logic – think in terms of NOT AND.


FULL OUTER JOIN
Produces the set of all records in Table A and Table B:

  
The SQL:  SELECT * FROM TableA FULL OUTER JOIN TableB ON TableA.name = TableB.name

LEFT JOIN
A left join returns all the records in the “left” table (T1) whether they have a match in the right table or not.
If, however, they do have a match in the right table – give me the “matching” data from the right table as well. If not – fill in the holes with null.

LEFT OUTER JOIN
A left outer join combines the ideas behind a left join and an outer join.

Again it is noted that the same thing is possible with a right outer join – most people just use a left one.

Basically – if you use a left outer join you will get the records in the left table that DO NOT have a match in the right table.



Tuesday 5 March 2013

Tool tip of the day - Netsparker!

Have you heard of a tool called Netsparker ?  It will scan your site for XSS exploits, useful for testing you haven't left something wide open !

What is Netsparker?

Netsparker is the only False-positive-free web application security scanner. Simply point it at your website and it will automatically discover the flaws that could leave you dangerously exposed.

http://www.mavitunasecurity.com/netsparker/

Thanks for the tip Neil.

Saturday 2 March 2013

Project on Sourceforge: Pojo/Bean mapper

This is a work in progress but I am creating an ANT task to generate the conversion classes to allow you to create the code that transfers data from one POJO to an other..
While at first sight this may seem similar to dozer the primary difference is that this is code generation and does not have the overhead of using introspection at run time.


Project on Sourceforge: https://sourceforge.net/projects/pojobeanmapper/


The original use for this was to take data out of a set of Hibernate DAO objects and create a variety of XML DOM objects from them. In the project that instigated this work the mapping between the DAOs and the XML DOM was not one for one and encoding the conversion into the DOAs was not a good idea.

Use

To create the task ensure the ant-pojomapper-x.x.xx.jar is on your ANT path (I suggest in ANT_HOME/lib).
Create the task with this task def command:

<property name="ant.pojomapper.dir" value="./libs/pojomapper"/>
<path id="pojomapper.lib.classpath">
<fileset dir="${ant.pojomapper.dir}" includes="*.jar" />
</path>
<taskdef resource="pojomapper_ant.properties" classpathref="pojomapper.lib.classpath" />


Once declared this will allow you to call the pojomapper task.
This will look something like this:

<beanmapper
classPath="${build.classpath}"
settingsFolder="./src/templates"
srcPackage ="myproj.dom1"
dstPackage ="myproj.api"
dstDir ="${gensrc.java.dir}/pojomapping"
outputPackageName ="myproj.dom1.converters"
/>

To work correctly there needs to be at least the following file present in the settings folder:
This file is a "property" file which contains the classes that equate to each other.

beanmapper-classpairs.properties

This file is of the form:

srcClass1=destClass1
srcClass2=destClass2

In this example two classes will be created in the package myproj.dom1.converters:

SrcClass1ToDestClass1Copier.java
SrcClass2ToDestClass2Copier.java


The generator will create these files under the folder   ${gensrc.java.dir}/pojomapping/src
along with a copy of the beanmapper-classpairs.properties file.


Additionally two other files are auto-generated.
These files can be reused if the build process failed.

beanmapper-knownmethodmappings.properties

While the this pojo mapper will match beans of the same name.
There are some that it will not beable to convert.

destClass.setter=srcClass.getter

The file defines the mappings that are already known.

PojoB.pennies=PojoA.cash
PojoB.extra=PojoA.more

At the end of the generated file are a series of mappings the pojo mapper could not determine what should be done with them.
These will appear as follows:

## Missing mappings
# destClass.???=PojoA.getter1
# destClass.???=PojoA.getter2

This allows the developer to determine quickly which methods need some attention.

beanmapper-classconverters.properties

There are conversions that the pojomapper knows implicitly but some are not known.

These need to be defined for it as follows:

SrcType:DstType=ConverterClass.convertermethod

This will create a call in any of the generated code where a SrcType class needs to be converted into a dstType.

The call will be approximatly as follows:

SrcType a ;
DstType b ;
b = ConverterClass.convertermethod(a);


If the pojomapper will detect the need for converters that it is self will be creating.

MAVEN USE

It is possible to use this ant task as a plugin.
Add the following:

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>download-files</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo>+++++++++++++++++ DOWNLOAD POJO BEAN MAPPER ++++++++++++++</echo>
                                <echo>Download pojobeanmapper to ${project.build.pojobeanmapper.jar}</echo>
                                <mkdir dir="${project.build.download.folder}" />
                                <get src="${project.build.pojobeanmapper.url}" 
                                        dest="${project.build.pojobeanmapper.jar}"
                                        verbose="false" 
                                        usetimestamp="true" />
                                <echo>Get commons-io 2.1</echo>
                                <get src="http://repo1.maven.org/maven2/commons-io/commons-io/2.1/commons-io-2.1.jar" 
                                        dest="${project.build.download.folder}"
                                        verbose="false" 
                                        usetimestamp="true" />
                                <echo>Get commons-lang 2.6</echo>
                                <get src="http://repo1.maven.org/maven2/commons-lang/commons-lang/2.6/commons-lang-2.6.jar" 
                                        dest="${project.build.download.folder}"
                                        verbose="false" 
                                        usetimestamp="true" />                                
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <phase>generate-sources</phase>
                        <configuration>
                            <target>
                                <echo>+++++++++++++++++ INVOKE POJO BEAN MAPPER ++++++++++++++</echo>
                            
                                <!-- sEE: http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html -->
                                <property name="compile_classpath" refid="maven.compile.classpath"/>
                                <property name="runtime_classpath" refid="maven.runtime.classpath"/>
                                <property name="test_classpath"    refid="maven.test.classpath"/>
                                <property name="plugin_classpath"  refid="maven.plugin.classpath"/>
                                <path id="pojomapper.lib.classpath">
                                     <fileset dir="${project.build.download.folder}" includes="*.jar" />
                                </path> 
                                <taskdef resource="pojomapper_ant.properties" 
                                         classpathref="pojomapper.lib.classpath" />

                                <beanmapper 
                                    classPath="${compile_classpath}"
                                    settingsFolder="./src/templates"
                                    srcPackage ="com.proj.src"
                                    dstPackage ="com.proj.dst"
                                    dstDir ="${project.build.directory}/pojomapping"
                                    outputPackageName ="com.proj.converters"
                                    />

                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


and add the following properties:

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.build.pojobeanmapper.url>http://sourceforge.net/projects/pojobeanmapper/files/latest/download?source=files</project.build.pojobeanmapper.url>
        <project.build.download.folder>${project.build.directory}/downloads</project.build.download.folder>
        <project.build.pojobeanmapper.jar>${project.build.download.folder}/pojobeanmapper.jar</project.build.pojobeanmapper.jar>
    </properties>


------------------------------------------------------------------------------
Please return to the is blog entry for full information at a later date.
It will be updated over the month of decemper 2013.